mirror of
https://github.com/Ukendio/jecs.git
synced 2025-08-05 11:49:16 +00:00
Compare commits
No commits in common. "d0af80577b2eff0cb5423d0fe92e54e5d0e5b5d3" and "fd2c57fe1744fdf7f860236a2b20eeeb03b0c326" have entirely different histories.
d0af80577b
...
fd2c57fe17
1 changed files with 15 additions and 22 deletions
37
jecs.luau
37
jecs.luau
|
@ -1437,24 +1437,19 @@ local function world_delete(world: ecs_world_t, entity: i53)
|
||||||
end
|
end
|
||||||
|
|
||||||
local dense_array = entity_index.dense_array
|
local dense_array = entity_index.dense_array
|
||||||
local dense = record.dense
|
local index_of_deleted_entity = record.dense
|
||||||
local i_swap = entity_index.alive_count
|
local index_of_last_alive_entity = entity_index.alive_count
|
||||||
entity_index.alive_count = i_swap - 1
|
entity_index.alive_count = index_of_last_alive_entity - 1
|
||||||
|
|
||||||
local e_swap = dense_array[i_swap]
|
local last_alive_entity = dense_array[index_of_last_alive_entity]
|
||||||
local r_swap = entity_index_try_get_any(entity_index, e_swap) :: ecs_record_t
|
local r_swap = entity_index_try_get_any(entity_index, last_alive_entity) :: ecs_record_t
|
||||||
|
r_swap.dense = index_of_deleted_entity
|
||||||
r_swap.dense = dense
|
|
||||||
record.archetype = nil :: any
|
record.archetype = nil :: any
|
||||||
record.row = nil :: any
|
record.row = nil :: any
|
||||||
record.dense = i_swap
|
record.dense = index_of_last_alive_entity
|
||||||
|
|
||||||
dense_array[dense] = e_swap
|
dense_array[index_of_deleted_entity] = last_alive_entity
|
||||||
dense_array[i_swap] = ECS_GENERATION_INC(entity)
|
dense_array[index_of_last_alive_entity] = ECS_GENERATION_INC(entity)
|
||||||
end
|
|
||||||
|
|
||||||
local function world_exists(world: ecs_world_t, entity): boolean
|
|
||||||
return entity_index_try_get_any(world.entity_index, entity) ~= nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function world_contains(world: ecs_world_t, entity): boolean
|
local function world_contains(world: ecs_world_t, entity): boolean
|
||||||
|
@ -2448,7 +2443,6 @@ World.has = world_has
|
||||||
World.target = world_target
|
World.target = world_target
|
||||||
World.parent = world_parent
|
World.parent = world_parent
|
||||||
World.contains = world_contains
|
World.contains = world_contains
|
||||||
World.exists = world_exists
|
|
||||||
World.cleanup = world_cleanup
|
World.cleanup = world_cleanup
|
||||||
World.each = world_each
|
World.each = world_each
|
||||||
World.children = world_children
|
World.children = world_children
|
||||||
|
@ -2488,6 +2482,12 @@ local function world_new()
|
||||||
entity_index_new_id(entity_index)
|
entity_index_new_id(entity_index)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for i = EcsRest + 1, ecs_max_tag_id do
|
||||||
|
-- Initialize built-in components
|
||||||
|
entity_index_new_id(entity_index)
|
||||||
|
print("hm...", i)
|
||||||
|
end
|
||||||
|
|
||||||
world_add(self, EcsName, EcsComponent)
|
world_add(self, EcsName, EcsComponent)
|
||||||
world_add(self, EcsOnChange, EcsComponent)
|
world_add(self, EcsOnChange, EcsComponent)
|
||||||
world_add(self, EcsOnAdd, EcsComponent)
|
world_add(self, EcsOnAdd, EcsComponent)
|
||||||
|
@ -2510,10 +2510,6 @@ local function world_new()
|
||||||
|
|
||||||
world_add(self, EcsChildOf, ECS_PAIR(EcsOnDeleteTarget, EcsDelete))
|
world_add(self, EcsChildOf, ECS_PAIR(EcsOnDeleteTarget, EcsDelete))
|
||||||
|
|
||||||
for i = EcsRest + 1, ecs_max_tag_id do
|
|
||||||
entity_index_new_id(entity_index)
|
|
||||||
end
|
|
||||||
|
|
||||||
for i, bundle in ecs_metadata do
|
for i, bundle in ecs_metadata do
|
||||||
for ty, value in bundle do
|
for ty, value in bundle do
|
||||||
if value == NULL then
|
if value == NULL then
|
||||||
|
@ -2616,9 +2612,6 @@ export type World = {
|
||||||
--- Checks if the world contains the given entity
|
--- Checks if the world contains the given entity
|
||||||
contains:(self: World, entity: Entity) -> boolean,
|
contains:(self: World, entity: Entity) -> boolean,
|
||||||
|
|
||||||
--- Checks if the entity exists
|
|
||||||
exists: (self: World, entity: Entity) -> boolean,
|
|
||||||
|
|
||||||
each: <T>(self: World, id: Id<T>) -> () -> Entity,
|
each: <T>(self: World, id: Id<T>) -> () -> Entity,
|
||||||
|
|
||||||
children: <T>(self: World, id: Id<T>) -> () -> Entity,
|
children: <T>(self: World, id: Id<T>) -> () -> Entity,
|
||||||
|
|
Loading…
Reference in a new issue