insert should not work as assign!

This commit is contained in:
BlackMATov
2024-11-24 13:01:41 +07:00
parent b5d535a693
commit dbdf20d1d4
2 changed files with 11 additions and 7 deletions

View File

@@ -78,23 +78,29 @@ do
local e = evo.registry.entity()
assert(not e:assign(f, 42))
assert(not e:has(f))
assert(e:get(f) == nil)
assert(e:get(f, 42) == 42)
assert(e:insert(f, 84))
assert(e:has(f))
assert(e:get(f) == 84)
assert(e:get(f, 42) == 84)
assert(not e:insert(f, 42))
assert(e:get(f) == 42)
assert(not e:insert(f, 21))
assert(e:has(f))
assert(e:get(f) == 84)
assert(e:get(f, 42) == 84)
assert(e:assign(f))
assert(e:has(f))
assert(e:get(f) == true)
assert(e:get(f, 42) == true)
e:assign(f, 21)
assert(e:assign(f, 21))
assert(e:has(f))
assert(e:get(f) == 21)
assert(e:get(f, 42) == 21)
end
do

View File

@@ -380,8 +380,6 @@ function registry.insert(entity, fragment, component)
local new_chunk = __chunk_with_fragment(old_chunk, fragment)
if old_chunk == new_chunk then
local chunk_components = new_chunk.__components[fragment]
chunk_components[entity.__index_in_chunk] = component
return false
end