set/remove/clear/destroy for pairs

This commit is contained in:
BlackMATov
2025-06-16 21:53:45 +07:00
parent 697a041832
commit 14055fbadf

View File

@@ -4389,6 +4389,11 @@ function __evolved_set(entity, fragment, component)
__debug_fns.validate_fragment(fragment) __debug_fns.validate_fragment(fragment)
end end
if entity < 0 then
__error_fmt('the pair (%s) cannot have any fragments',
__id_name(entity))
end
if __defer_depth > 0 then if __defer_depth > 0 then
__defer_set(entity, fragment, component) __defer_set(entity, fragment, component)
return return
@@ -4625,6 +4630,11 @@ function __evolved_remove(entity, ...)
return return
end end
if entity < 0 then
-- pairs cannot have fragments, nothing to remove
return
end
local entity_index = entity % 0x100000 local entity_index = entity % 0x100000
if __freelist_ids[entity_index] ~= entity then if __freelist_ids[entity_index] ~= entity then
@@ -4743,7 +4753,9 @@ function __evolved_clear(...)
local entity = __lua_select(argument_index, ...) local entity = __lua_select(argument_index, ...)
local entity_index = entity % 0x100000 local entity_index = entity % 0x100000
if __freelist_ids[entity_index] ~= entity then if entity < 0 then
-- pairs cannot have fragments, nothing to clear
elseif __freelist_ids[entity_index] ~= entity then
-- this entity is not alive, nothing to clear -- this entity is not alive, nothing to clear
else else
local chunk = entity_chunks[entity_index] local chunk = entity_chunks[entity_index]
@@ -4817,7 +4829,9 @@ function __evolved_destroy(...)
local entity = __lua_select(argument_index, ...) local entity = __lua_select(argument_index, ...)
local entity_index = entity % 0x100000 local entity_index = entity % 0x100000
if __freelist_ids[entity_index] ~= entity then if entity < 0 then
-- pairs cannot be destroyed, nothing to do
elseif __freelist_ids[entity_index] ~= entity then
-- this entity is not alive, nothing to destroy -- this entity is not alive, nothing to destroy
else else
if not __minor_chunks[entity] then if not __minor_chunks[entity] then