mirror of
https://github.com/Ukendio/jecs.git
synced 2025-09-23 08:39:16 +00:00
Compare commits
No commits in common. "1eecaac96f1f41b2fe22f75a6f4b2d02a5c08c46" and "af093713b4d82f0b2be926a6dd51083d8b736242" have entirely different histories.
1eecaac96f
...
af093713b4
2 changed files with 13 additions and 21 deletions
20
jecs.luau
20
jecs.luau
|
@ -41,8 +41,16 @@ export type Iter<T...> = (query: Query<T...>) -> () -> (Entity, T...)
|
|||
export type Query<T...> = typeof(setmetatable(
|
||||
{} :: {
|
||||
iter: Iter<T...>,
|
||||
with: ((Query<T...>, ...Id) -> Query<T...>),
|
||||
without: ((Query<T...>, ...Id) -> Query<T...>),
|
||||
with: (<a>(Query<T...>, Id<a>) -> Query<T...>)
|
||||
& (<a, b>(Query<T...>, Id<a>, Id<b>) -> Query<T...>)
|
||||
& (<a, b, c>(Query<T...>, Id<a>, Id<b>, Id<c>) -> Query<T...>)
|
||||
& (<a, b, c>(Query<T...>, Id<a>, Id<b>, Id<c>) -> Query<T...>)
|
||||
& (<a, b, c, d>(Query<T...>, Id<a>, Id<b>, Id<c>, Id) -> Query<T...>),
|
||||
without: (<a>(Query<T...>, Id<a>) -> Query<T...>)
|
||||
& (<a, b>(Query<T...>, Id<a>, Id<b>) -> Query<T...>)
|
||||
& (<a, b, c>(Query<T...>, Id<a>, Id<b>, Id<c>) -> Query<T...>)
|
||||
& (<a, b, c>(Query<T...>, Id<a>, Id<b>, Id<c>) -> Query<T...>)
|
||||
& (<a, b, c, d>(Query<T...>, Id<a>, Id<b>, Id<c>, Id) -> Query<T...>),
|
||||
archetypes: (self: Query<T...>) -> { Archetype },
|
||||
cached: (self: Query<T...>) -> Query<T...>,
|
||||
ids: { Id<any> },
|
||||
|
@ -161,9 +169,9 @@ export type World = {
|
|||
|
||||
observable: Map<Id, Map<Id, { Observer }>>,
|
||||
|
||||
added: <T>(World, Entity<T>, (e: Entity, id: Id<T>, value: T, oldarchetype: Archetype) -> ()) -> () -> (),
|
||||
added: <T>(World, Entity<T>, <e>(e: Entity<e>, id: Id<T>, value: T, oldarchetype: Archetype) -> ()) -> () -> (),
|
||||
removed: <T>(World, Entity<T>, (e: Entity, id: Id<T>) -> ()) -> () -> (),
|
||||
changed: <T>(World, Entity<T>, (e: Entity, id: Id<T>, value: T, oldarchetype: Archetype) -> ()) -> () -> (),
|
||||
changed: <T>(World, Entity<T>, <e>(e: Entity<e>, id: Id<T>, value: T, oldarchetype: Archetype) -> ()) -> () -> (),
|
||||
|
||||
--- Enforce a check on entities to be created within desired range
|
||||
range: (self: World, range_begin: number, range_end: number?) -> (),
|
||||
|
@ -2042,9 +2050,7 @@ local function ecs_bulk_insert(world: world, entity: i53, ids: { i53 }, values:
|
|||
local from = r.archetype
|
||||
local component_index = world.component_index
|
||||
if not from then
|
||||
local dst_types = table.clone(ids)
|
||||
table.sort(dst_types)
|
||||
|
||||
local dst_types = ids
|
||||
local to = archetype_ensure(world, dst_types)
|
||||
new_entity(entity, r, to)
|
||||
local ROOT_ARCHETYPE = world.ROOT_ARCHETYPE
|
||||
|
|
|
@ -330,20 +330,6 @@ TEST("bulk", function()
|
|||
CHECK(world:get(e, c2) == 123)
|
||||
CHECK(world:get(e, c3) == "hello")
|
||||
end
|
||||
|
||||
do CASE "Should ensure archetype ids are sorted"
|
||||
local world = jecs.world()
|
||||
local c1, c2, c3 = world:component(), world:component(), world:component()
|
||||
|
||||
local e = world:entity()
|
||||
jecs.bulk_insert(world, e, { c2, c1 }, { 2, 1 })
|
||||
jecs.bulk_insert(world, e, { c1 }, { 1 })
|
||||
world:set(e, c3, 3)
|
||||
|
||||
CHECK(world:get(e, c1) == 1)
|
||||
CHECK(world:get(e, c2) == 2)
|
||||
CHECK(world:get(e, c3) == 3)
|
||||
end
|
||||
end)
|
||||
|
||||
TEST("repro", function()
|
||||
|
|
Loading…
Reference in a new issue