has/get function set for pairs

This commit is contained in:
BlackMATov
2025-06-16 21:36:20 +07:00
parent 9a2a62ec89
commit 697a041832
2 changed files with 32 additions and 0 deletions

View File

@@ -87,3 +87,15 @@ do
assert(evo.empty_all(evo.pair(p1, s1), evo.pair(p2, s2), s2))
assert(evo.empty_any(evo.pair(p1, s1), evo.pair(p2, s2), s2))
end
do
local p1, s1 = evo.id(2)
evo.set(p1, s1)
evo.set(s1, p1)
assert(not evo.has(evo.pair(p1, s1), p1))
assert(not evo.has(evo.pair(p1, s1), s1))
assert(not evo.has_all(evo.pair(p1, s1), p1, s1))
assert(not evo.has_any(evo.pair(p1, s1), p1, s1))
assert(evo.get(evo.pair(p1, s1), p1) == nil)
assert(evo.get(evo.pair(p1, s1), s1) == nil)
end

View File

@@ -4284,6 +4284,11 @@ end
---@return boolean
---@nodiscard
function __evolved_has(entity, fragment)
if entity < 0 then
-- pairs are always empty
return false
end
local entity_index = entity % 0x100000
if __freelist_ids[entity_index] ~= entity then
@@ -4304,6 +4309,11 @@ end
---@return boolean
---@nodiscard
function __evolved_has_all(entity, ...)
if entity < 0 then
-- pairs are always empty
return __lua_select('#', ...) == 0
end
local entity_index = entity % 0x100000
if __freelist_ids[entity_index] ~= entity then
@@ -4324,6 +4334,11 @@ end
---@return boolean
---@nodiscard
function __evolved_has_any(entity, ...)
if entity < 0 then
-- pairs are always empty
return false
end
local entity_index = entity % 0x100000
if __freelist_ids[entity_index] ~= entity then
@@ -4344,6 +4359,11 @@ end
---@return evolved.component ... components
---@nodiscard
function __evolved_get(entity, ...)
if entity < 0 then
-- pairs are always empty
return
end
local entity_index = entity % 0x100000
if __freelist_ids[entity_index] ~= entity then