mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
Assert that the entity is alive
This commit is contained in:
parent
88457efd1d
commit
35f92a79d0
1 changed files with 6 additions and 6 deletions
12
lib/init.lua
12
lib/init.lua
|
@ -278,15 +278,15 @@ local function ECS_PAIR(source: number, target: number)
|
||||||
return id
|
return id
|
||||||
end
|
end
|
||||||
|
|
||||||
local function getAlive(entityIndex, id)
|
local function getAlive(entityIndex: EntityIndex, id: i53)
|
||||||
return entityIndex.dense[id]
|
return assert(entityIndex.dense[id], id .. "is not alive")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function ecs_pair_first(entityIndex, e)
|
local function ecs_get_source(entityIndex, e)
|
||||||
assert(isPair(e))
|
assert(isPair(e))
|
||||||
return getAlive(entityIndex, ECS_PAIR_FIRST(e))
|
return getAlive(entityIndex, ECS_PAIR_FIRST(e))
|
||||||
end
|
end
|
||||||
local function ecs_pair_second(entityIndex, e)
|
local function ecs_get_target(entityIndex, e)
|
||||||
assert(isPair(e))
|
assert(isPair(e))
|
||||||
return getAlive(entityIndex, ECS_PAIR_SECOND(e))
|
return getAlive(entityIndex, ECS_PAIR_SECOND(e))
|
||||||
end
|
end
|
||||||
|
@ -771,6 +771,6 @@ return table.freeze({
|
||||||
ECS_GENERATION = ECS_GENERATION,
|
ECS_GENERATION = ECS_GENERATION,
|
||||||
ECS_GENERATION_INC = ECS_GENERATION_INC,
|
ECS_GENERATION_INC = ECS_GENERATION_INC,
|
||||||
getAlive = getAlive,
|
getAlive = getAlive,
|
||||||
ecs_pair_first = ecs_pair_first,
|
ecs_get_target = ecs_get_target,
|
||||||
ecs_pair_second = ecs_pair_second
|
ecs_get_source = ecs_get_source
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue