mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Reallocate tables
This commit is contained in:
parent
eedad66517
commit
95b166eca3
1 changed files with 18 additions and 3 deletions
|
@ -912,8 +912,10 @@ local function archetype_destroy(world: World, archetype: Archetype)
|
|||
local component_index = world.componentIndex
|
||||
archetype_clear_edges(archetype)
|
||||
local archetype_id = archetype.id
|
||||
if archetype ~= world.ROOT_ARCHETYPE then
|
||||
world.archetypes[archetype_id] = nil
|
||||
world.archetypeIndex[archetype.type] = nil
|
||||
end
|
||||
local records = archetype.records
|
||||
|
||||
for id in records do
|
||||
|
@ -928,11 +930,24 @@ local function archetype_destroy(world: World, archetype: Archetype)
|
|||
end
|
||||
|
||||
local function world_cleanup(world)
|
||||
for _, archetype in world.archetypes do
|
||||
local archetypes = world.archetypes
|
||||
|
||||
for _, archetype in archetypes do
|
||||
if #archetype.entities == 0 then
|
||||
archetype_destroy(world, archetype)
|
||||
end
|
||||
end
|
||||
|
||||
local new_archetypes = {}
|
||||
local new_archetype_map = {}
|
||||
|
||||
for index, archetype in archetypes do
|
||||
new_archetypes[index] = archetype
|
||||
new_archetype_map[archetype.type] = archetype
|
||||
end
|
||||
|
||||
world.archetypes = new_archetypes
|
||||
world.archetypeIndex = new_archetype_map
|
||||
end
|
||||
|
||||
local world_delete: (world: World, entity: i53, destruct: boolean?) -> ()
|
||||
|
|
Loading…
Reference in a new issue