Merge pull request #8 from BlackMATov/dev

Dev
This commit is contained in:
2025-05-21 02:11:39 +07:00
committed by GitHub
3 changed files with 1485 additions and 69 deletions

1498
README.md

File diff suppressed because it is too large Load Diff

View File

@@ -56,6 +56,10 @@ do
end
do
do
local i0 = evo.id(-1)
assert(type(i0) == 'nil')
end
do
local i0 = evo.id(0)
assert(type(i0) == 'nil')
@@ -498,42 +502,44 @@ do
local e = evo.id()
local remove_count = 0
local last_removed_component = nil
local removed_sum = 0
evo.set(f1, evo.ON_REMOVE, function(entity, fragment, component)
assert(entity == e)
assert(fragment == f1)
remove_count = remove_count + 1
last_removed_component = component
removed_sum = removed_sum + component
end)
evo.set(f2, evo.ON_REMOVE, function(entity, fragment, component)
assert(entity == e)
assert(fragment == f2)
remove_count = remove_count + 1
last_removed_component = component
removed_sum = removed_sum + component
end)
evo.set(e, f1, 42)
evo.remove(e, f1, f2)
assert(remove_count == 1)
assert(last_removed_component == 42)
assert(removed_sum == 42)
evo.set(e, f1, 42)
evo.set(e, f2, 43)
evo.remove(e, f1, f2, f2)
assert(remove_count == 3)
assert(last_removed_component == 43)
assert(removed_sum == 42 + 42 + 43)
evo.set(e, f1, 44)
evo.set(e, f2, 45)
evo.clear(e)
assert(remove_count == 5)
assert(removed_sum == 42 + 42 + 43 + 44 + 45)
evo.set(e, f1, 46)
evo.set(e, f2, 47)
evo.destroy(e)
assert(remove_count == 7)
assert(removed_sum == 42 + 42 + 43 + 44 + 45 + 46 + 47)
end
do

View File

@@ -2544,21 +2544,20 @@ function __chunk_remove(old_chunk, ...)
return
end
local old_fragment_set = old_chunk.__fragment_set
local old_fragment_list = old_chunk.__fragment_list
local old_fragment_count = old_chunk.__fragment_count
local old_component_indices = old_chunk.__component_indices
local old_component_storages = old_chunk.__component_storages
if old_chunk.__has_remove_hooks then
---@type table<evolved.fragment, boolean>
local removed_set = __acquire_table(__table_pool_tag.fragment_set)
---@type table<evolved.fragment, integer>
local new_fragment_set = new_chunk and new_chunk.__fragment_set
or __safe_tbls.__EMPTY_FRAGMENT_SET
for i = 1, fragment_count do
---@type evolved.fragment
local fragment = __lua_select(i, ...)
if not removed_set[fragment] and old_fragment_set[fragment] then
removed_set[fragment] = true
for i = 1, old_fragment_count do
local fragment = old_fragment_list[i]
if not new_fragment_set[fragment] then
---@type evolved.remove_hook?
local fragment_on_remove = __evolved_get(fragment, __ON_REMOVE)
@@ -2582,8 +2581,6 @@ function __chunk_remove(old_chunk, ...)
end
end
end
__release_table(__table_pool_tag.fragment_set, removed_set)
end
if new_chunk then
@@ -3461,7 +3458,7 @@ end
function __evolved_id(count)
count = count or 1
if count == 0 then
if count <= 0 then
return
end
@@ -3990,21 +3987,20 @@ function __evolved_remove(entity, ...)
__evolved_defer()
do
local old_fragment_set = old_chunk.__fragment_set
local old_fragment_list = old_chunk.__fragment_list
local old_fragment_count = old_chunk.__fragment_count
local old_component_indices = old_chunk.__component_indices
local old_component_storages = old_chunk.__component_storages
if old_chunk.__has_remove_hooks then
---@type table<evolved.fragment, boolean>
local removed_set = __acquire_table(__table_pool_tag.fragment_set)
---@type table<evolved.fragment, integer>
local new_fragment_set = new_chunk and new_chunk.__fragment_set
or __safe_tbls.__EMPTY_FRAGMENT_SET
for i = 1, fragment_count do
---@type evolved.fragment
local fragment = __lua_select(i, ...)
if not removed_set[fragment] and old_fragment_set[fragment] then
removed_set[fragment] = true
for i = 1, old_fragment_count do
local fragment = old_fragment_list[i]
if not new_fragment_set[fragment] then
---@type evolved.remove_hook?
local fragment_on_remove = __evolved_get(fragment, __ON_REMOVE)
@@ -4021,8 +4017,6 @@ function __evolved_remove(entity, ...)
end
end
end
__release_table(__table_pool_tag.fragment_set, removed_set)
end
if new_chunk then