mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-14 12:10:23 +07:00
has/get function set for pairs
This commit is contained in:
@@ -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
|
||||
|
||||
20
evolved.lua
20
evolved.lua
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user