mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-24 17:10:03 +00:00
Add parent method
This commit is contained in:
parent
b8f35ccb85
commit
ec833464a5
1 changed files with 10 additions and 2 deletions
|
@ -361,9 +361,10 @@ function World.entity(world: World): i53
|
|||
end
|
||||
|
||||
-- TODO:
|
||||
-- should have an additional `index` parameter which selects the nth target
|
||||
-- TODO:
|
||||
-- should have an additional `nth` parameter which selects the nth target
|
||||
-- this is important when an entity can have multiple relationships with the same target
|
||||
function World.target(world: World, entity: i53, relation: i24): i24?
|
||||
local function target(world: World, entity: i53, relation: i24--[[, nth: number]]): i24?
|
||||
local entityIndex = world.entityIndex
|
||||
local record = entityIndex.sparse[entity]
|
||||
local archetype = record.archetype
|
||||
|
@ -384,6 +385,13 @@ function World.target(world: World, entity: i53, relation: i24): i24?
|
|||
return ECS_PAIR_OBJECT(entityIndex, archetype.types[archetypeRecord])
|
||||
end
|
||||
|
||||
local function parent(world: World, entity: i53)
|
||||
return target(world, entity, EcsChildOf)
|
||||
end
|
||||
|
||||
World.target = target
|
||||
World.parent = parent
|
||||
|
||||
-- should reuse this logic in World.set instead of swap removing in transition archetype
|
||||
local function destructColumns(columns: { Column }, count: number, row: number)
|
||||
if row == count then
|
||||
|
|
Loading…
Reference in a new issue