mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
Initial commit
This commit is contained in:
parent
0292574b5f
commit
6f984b042c
3 changed files with 34 additions and 2 deletions
|
@ -40,6 +40,11 @@ do
|
||||||
end
|
end
|
||||||
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()
|
local e = world:entity()
|
||||||
world:set(e, A, true)
|
world:set(e, A, true)
|
||||||
world:set(e, B, true)
|
world:set(e, B, true)
|
||||||
|
|
|
@ -855,6 +855,32 @@ do
|
||||||
end
|
end
|
||||||
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, ...: number): Query
|
function world_query(world: World, ...: number): Query
|
||||||
-- breaking?
|
-- breaking?
|
||||||
if (...) == nil then
|
if (...) == nil then
|
||||||
|
@ -924,7 +950,8 @@ do
|
||||||
__iter = world_query_iter,
|
__iter = world_query_iter,
|
||||||
next = world_query_next,
|
next = world_query_next,
|
||||||
without = world_query_without,
|
without = world_query_without,
|
||||||
replace = world_query_replace
|
with = world_query_with,
|
||||||
|
replace = world_query_replace,
|
||||||
}
|
}
|
||||||
|
|
||||||
return setmetatable(it, it) :: any
|
return setmetatable(it, it) :: any
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "ukendio/jecs"
|
name = "ukendio/jecs"
|
||||||
version = "0.2.3"
|
version = "0.2.5"
|
||||||
registry = "https://github.com/UpliftGames/wally-index"
|
registry = "https://github.com/UpliftGames/wally-index"
|
||||||
realm = "shared"
|
realm = "shared"
|
||||||
include = [
|
include = [
|
||||||
|
|
Loading…
Reference in a new issue