Initial commit (#86)

This commit is contained in:
Marcus 2024-07-26 16:21:13 +02:00 committed by GitHub
parent 2f0f817b08
commit d46df8c0a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 2 deletions

View file

@ -40,6 +40,11 @@ do
end
end)
BENCH("1 component, 7 tags", function()
for _ in world:query(H):with(G, F, E, D, C, B, A) do
end
end)
local e = world:entity()
world:set(e, A, true)
world:set(e, B, true)

View file

@ -895,6 +895,31 @@ do
end
end
local function world_query_with(query, ...)
local ids = { ... }
for i = #compatibleArchetypes, 1, -1 do
local archetype = compatibleArchetypes[i]
local records = archetype.records
local shouldRemove = false
for _, id in ids do
if not records[id] then
shouldRemove = true
break
end
end
if shouldRemove then
table.remove(compatibleArchetypes, i)
end
end
if #compatibleArchetypes == 0 then
return EmptyQuery
end
return query
end
function world_query(world: World, ...: any): Query
-- breaking?
@ -969,8 +994,9 @@ do
local it = {
__iter = world_query_iter,
next = world_query_next,
with = world_query_with,
without = world_query_without,
replace = world_query_replace
replace = world_query_replace,
} :: any
setmetatable(it, it)

View file

@ -1,6 +1,6 @@
[package]
name = "ukendio/jecs"
version = "0.2.3"
version = "0.2.5"
registry = "https://github.com/UpliftGames/wally-index"
realm = "shared"
include = [