mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 01:20:04 +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
|
dense = index
|
||||||
} :: Record
|
} :: Record
|
||||||
entityIndex.dense[index] = id
|
entityIndex.dense[index] = id
|
||||||
|
local entityLookup = world.entityLookup
|
||||||
if name then
|
if name then
|
||||||
world.entityLookup.id[id] = name
|
local entityLookupName = entityLookup.name
|
||||||
world.entityLookup.name[name] = id
|
local entity = entityLookupName[name]
|
||||||
|
if entity then
|
||||||
|
return entity
|
||||||
|
end
|
||||||
|
|
||||||
|
entityLookup.id[id] = name
|
||||||
|
entityLookupName[name] = id
|
||||||
end
|
end
|
||||||
|
|
||||||
return id
|
return id
|
||||||
|
|
Loading…
Reference in a new issue