mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Return existing entity
This commit is contained in:
parent
b89cd10b7b
commit
9fad8311c4
1 changed files with 9 additions and 2 deletions
11
lib/init.lua
11
lib/init.lua
|
@ -300,9 +300,16 @@ local function nextEntityId(world: World, index: i24, name: string?)
|
|||
dense = index
|
||||
} :: Record
|
||||
entityIndex.dense[index] = id
|
||||
local entityLookup = world.entityLookup
|
||||
if name then
|
||||
world.entityLookup.id[id] = name
|
||||
world.entityLookup.name[name] = id
|
||||
local entityLookupName = entityLookup.name
|
||||
local entity = entityLookupName[name]
|
||||
if entity then
|
||||
return entity
|
||||
end
|
||||
|
||||
entityLookup.id[id] = name
|
||||
entityLookupName[name] = id
|
||||
end
|
||||
|
||||
return id
|
||||
|
|
Loading…
Reference in a new issue