mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-16 14:11:16 +07:00
fix: batch_insert with defaults
This commit is contained in:
@@ -1262,6 +1262,22 @@ do
|
||||
end
|
||||
|
||||
do
|
||||
do
|
||||
local f1, f2 = evo.id(2)
|
||||
evo.set(f2, evo.DEFAULT, 42)
|
||||
|
||||
local e1 = evo.entity():set(f1, 11):build()
|
||||
local e2 = evo.entity():set(f1, 21):set(f2, 22):build()
|
||||
|
||||
assert(evo.get(e1, f1) == 11 and evo.get(e1, f2) == nil)
|
||||
assert(evo.get(e2, f1) == 21 and evo.get(e2, f2) == 22)
|
||||
|
||||
local q = evo.query():include(f1):build()
|
||||
assert(evo.batch_insert(q, f2) == 1)
|
||||
|
||||
assert(evo.get(e1, f1) == 11 and evo.get(e1, f2) == 42)
|
||||
assert(evo.get(e2, f1) == 21 and evo.get(e2, f2) == 22)
|
||||
end
|
||||
do
|
||||
local f1, f2, f3, f4 = evo.id(4)
|
||||
|
||||
|
||||
@@ -1064,7 +1064,7 @@ local function __chunk_insert(chunk, fragment, ...)
|
||||
local new_component_index = new_component_indices[fragment]
|
||||
if new_component_index then
|
||||
local new_component_storage = new_component_storages[new_component_index]
|
||||
if chunk.__has_defaults_or_constructs and __fragment_has_default_or_construct(fragment) then
|
||||
if new_chunk.__has_defaults_or_constructs and __fragment_has_default_or_construct(fragment) then
|
||||
for new_place = new_size + 1, new_size + old_size do
|
||||
local entity = new_entities[new_place]
|
||||
local new_component = __component_construct(fragment, ...)
|
||||
@@ -1094,7 +1094,7 @@ local function __chunk_insert(chunk, fragment, ...)
|
||||
local new_component_index = new_component_indices[fragment]
|
||||
if new_component_index then
|
||||
local new_component_storage = new_component_storages[new_component_index]
|
||||
if chunk.__has_defaults_or_constructs and __fragment_has_default_or_construct(fragment) then
|
||||
if new_chunk.__has_defaults_or_constructs and __fragment_has_default_or_construct(fragment) then
|
||||
for new_place = new_size + 1, new_size + old_size do
|
||||
local new_component = __component_construct(fragment, ...)
|
||||
new_component_storage[new_place] = new_component
|
||||
|
||||
Reference in New Issue
Block a user