mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-15 04:15:28 +07:00
defer all hooks (without optimizations yet)
This commit is contained in:
@@ -699,7 +699,7 @@ do
|
||||
---@param component evolved.component
|
||||
evo.set(f1, evo.ON_REMOVE, function(entity, fragment, component)
|
||||
assert(fragment == f1)
|
||||
assert(evo.get(entity, f2) == component * 2)
|
||||
assert(component == 21)
|
||||
evo.remove(entity, f2)
|
||||
end)
|
||||
|
||||
@@ -754,7 +754,7 @@ do
|
||||
---@param component evolved.component
|
||||
evo.set(f1, evo.ON_REMOVE, function(entity, fragment, component)
|
||||
assert(fragment == f1)
|
||||
assert(evo.get(entity, f2) == component * 2)
|
||||
assert(component == 21)
|
||||
evo.remove(entity, f2)
|
||||
end)
|
||||
|
||||
@@ -5652,3 +5652,479 @@ do
|
||||
assert(evo.get(e2, f4) == nil)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local f1, f2 = evo.id(2)
|
||||
|
||||
local assign_count = 0
|
||||
local insert_count = 0
|
||||
local remove_count = 0
|
||||
|
||||
do
|
||||
evo.set(f1, evo.ON_ASSIGN, function(e, f, c)
|
||||
assign_count = assign_count + 1
|
||||
assert(f == f1)
|
||||
assert(evo.get(e, f1) == c)
|
||||
|
||||
do
|
||||
local s, d = evo.assign(e, f2, c)
|
||||
assert(s and not d)
|
||||
end
|
||||
end)
|
||||
|
||||
evo.set(f1, evo.ON_INSERT, function(e, f, c)
|
||||
insert_count = insert_count + 1
|
||||
assert(f == f1)
|
||||
assert(evo.get(e, f1) == c)
|
||||
|
||||
do
|
||||
local s, d = evo.insert(e, f2, c)
|
||||
assert(s and not d)
|
||||
end
|
||||
end)
|
||||
|
||||
evo.set(f1, evo.ON_REMOVE, function(e, f, c)
|
||||
remove_count = remove_count + 1
|
||||
assert(f == f1)
|
||||
assert(c == 51)
|
||||
assert(evo.get(e, f1) == nil)
|
||||
|
||||
do
|
||||
local s, d = evo.remove(e, f2)
|
||||
assert(s and not d)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
do
|
||||
evo.set(f2, evo.ON_ASSIGN, function(e, f, c)
|
||||
assign_count = assign_count + 1
|
||||
assert(f == f2)
|
||||
assert(evo.get(e, f1) == c)
|
||||
assert(evo.get(e, f2) == c)
|
||||
end)
|
||||
|
||||
evo.set(f2, evo.ON_INSERT, function(e, f, c)
|
||||
insert_count = insert_count + 1
|
||||
assert(f == f2)
|
||||
assert(evo.get(e, f1) == c)
|
||||
assert(evo.get(e, f2) == c)
|
||||
end)
|
||||
|
||||
evo.set(f2, evo.ON_REMOVE, function(e, f, c)
|
||||
remove_count = remove_count + 1
|
||||
assert(f == f2)
|
||||
assert(c == 51)
|
||||
assert(evo.get(e, f2) == nil)
|
||||
end)
|
||||
end
|
||||
|
||||
do
|
||||
assign_count = 0
|
||||
insert_count = 0
|
||||
remove_count = 0
|
||||
|
||||
local e = evo.id()
|
||||
|
||||
assert(evo.set(e, f1, 41))
|
||||
assert(evo.get(e, f1) == 41)
|
||||
assert(evo.get(e, f2) == 41)
|
||||
assert(assign_count == 0 and insert_count == 2 and remove_count == 0)
|
||||
|
||||
assert(evo.set(e, f1, 51))
|
||||
assert(evo.get(e, f1) == 51)
|
||||
assert(evo.get(e, f2) == 51)
|
||||
assert(assign_count == 2 and insert_count == 2 and remove_count == 0)
|
||||
|
||||
assert(evo.remove(e, f1))
|
||||
assert(evo.get(e, f1) == nil)
|
||||
assert(evo.get(e, f2) == nil)
|
||||
assert(assign_count == 2 and insert_count == 2 and remove_count == 2)
|
||||
end
|
||||
|
||||
do
|
||||
assign_count = 0
|
||||
insert_count = 0
|
||||
remove_count = 0
|
||||
|
||||
local e = evo.id()
|
||||
|
||||
assert(evo.multi_set(e, { f1 }, { 41 }))
|
||||
assert(evo.get(e, f1) == 41)
|
||||
assert(evo.get(e, f2) == 41)
|
||||
assert(assign_count == 0 and insert_count == 2 and remove_count == 0)
|
||||
|
||||
assert(evo.multi_set(e, { f1 }, { 51 }))
|
||||
assert(evo.get(e, f1) == 51)
|
||||
assert(evo.get(e, f2) == 51)
|
||||
assert(assign_count == 2 and insert_count == 2 and remove_count == 0)
|
||||
|
||||
assert(evo.multi_remove(e, { f1 }))
|
||||
assert(evo.get(e, f1) == nil)
|
||||
assert(evo.get(e, f2) == nil)
|
||||
assert(assign_count == 2 and insert_count == 2 and remove_count == 2)
|
||||
end
|
||||
|
||||
do
|
||||
assign_count = 0
|
||||
insert_count = 0
|
||||
remove_count = 0
|
||||
|
||||
local e = evo.id()
|
||||
|
||||
assert(evo.insert(e, f1, 41))
|
||||
assert(evo.get(e, f1) == 41)
|
||||
assert(evo.get(e, f2) == 41)
|
||||
assert(assign_count == 0 and insert_count == 2 and remove_count == 0)
|
||||
|
||||
assert(evo.assign(e, f1, 51))
|
||||
assert(evo.get(e, f1) == 51)
|
||||
assert(evo.get(e, f2) == 51)
|
||||
assert(assign_count == 2 and insert_count == 2 and remove_count == 0)
|
||||
|
||||
assert(evo.remove(e, f1))
|
||||
assert(evo.get(e, f1) == nil)
|
||||
assert(evo.get(e, f2) == nil)
|
||||
assert(assign_count == 2 and insert_count == 2 and remove_count == 2)
|
||||
end
|
||||
|
||||
do
|
||||
assign_count = 0
|
||||
insert_count = 0
|
||||
remove_count = 0
|
||||
|
||||
local e = evo.id()
|
||||
|
||||
assert(evo.multi_insert(e, { f1 }, { 41 }))
|
||||
assert(evo.get(e, f1) == 41)
|
||||
assert(evo.get(e, f2) == 41)
|
||||
assert(assign_count == 0 and insert_count == 2 and remove_count == 0)
|
||||
|
||||
assert(evo.multi_assign(e, { f1 }, { 51 }))
|
||||
assert(evo.get(e, f1) == 51)
|
||||
assert(evo.get(e, f2) == 51)
|
||||
assert(assign_count == 2 and insert_count == 2 and remove_count == 0)
|
||||
|
||||
assert(evo.multi_remove(e, { f1 }))
|
||||
assert(evo.get(e, f1) == nil)
|
||||
assert(evo.get(e, f2) == nil)
|
||||
assert(assign_count == 2 and insert_count == 2 and remove_count == 2)
|
||||
end
|
||||
|
||||
do
|
||||
assign_count = 0
|
||||
insert_count = 0
|
||||
remove_count = 0
|
||||
|
||||
local e = evo.id()
|
||||
|
||||
assert(evo.insert(e, f1, 51))
|
||||
assert(evo.get(e, f1) == 51)
|
||||
assert(evo.get(e, f2) == 51)
|
||||
assert(assign_count == 0 and insert_count == 2 and remove_count == 0)
|
||||
|
||||
assert(evo.clear(e))
|
||||
assert(assign_count == 0 and insert_count == 2 and remove_count == 2)
|
||||
end
|
||||
|
||||
do
|
||||
assign_count = 0
|
||||
insert_count = 0
|
||||
remove_count = 0
|
||||
|
||||
local e = evo.id()
|
||||
|
||||
assert(evo.insert(e, f1, 51))
|
||||
assert(evo.get(e, f1) == 51)
|
||||
assert(evo.get(e, f2) == 51)
|
||||
assert(assign_count == 0 and insert_count == 2 and remove_count == 0)
|
||||
|
||||
assert(evo.destroy(e))
|
||||
assert(assign_count == 0 and insert_count == 2 and remove_count == 2)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local f1, f2 = evo.id(2)
|
||||
|
||||
local assign_count = 0
|
||||
local insert_count = 0
|
||||
local remove_count = 0
|
||||
|
||||
evo.set(f1, evo.ON_ASSIGN, function(e, f, c)
|
||||
assign_count = assign_count + 1
|
||||
assert(f == f1)
|
||||
assert(c == 51)
|
||||
assert(evo.get(e, f1) == 51)
|
||||
assert(evo.get(e, f2) == 52)
|
||||
end)
|
||||
|
||||
evo.set(f2, evo.ON_ASSIGN, function(e, f, c)
|
||||
assign_count = assign_count + 1
|
||||
assert(f == f2)
|
||||
assert(c == 52)
|
||||
assert(evo.get(e, f1) == 51)
|
||||
assert(evo.get(e, f2) == 52)
|
||||
end)
|
||||
|
||||
evo.set(f1, evo.ON_INSERT, function(e, f, c)
|
||||
insert_count = insert_count + 1
|
||||
assert(f == f1)
|
||||
assert(c == 41)
|
||||
assert(evo.get(e, f1) == 41)
|
||||
assert(evo.get(e, f2) == 42)
|
||||
end)
|
||||
|
||||
evo.set(f2, evo.ON_INSERT, function(e, f, c)
|
||||
insert_count = insert_count + 1
|
||||
assert(f == f2)
|
||||
assert(c == 42)
|
||||
assert(evo.get(e, f1) == 41)
|
||||
assert(evo.get(e, f2) == 42)
|
||||
end)
|
||||
|
||||
evo.set(f1, evo.ON_REMOVE, function(e, f, c)
|
||||
remove_count = remove_count + 1
|
||||
assert(f == f1)
|
||||
assert(c == 51)
|
||||
assert(evo.get(e, f1) == nil)
|
||||
assert(evo.get(e, f2) == nil)
|
||||
end)
|
||||
|
||||
evo.set(f2, evo.ON_REMOVE, function(e, f, c)
|
||||
remove_count = remove_count + 1
|
||||
assert(f == f2)
|
||||
assert(c == 52)
|
||||
assert(evo.get(e, f1) == nil)
|
||||
assert(evo.get(e, f2) == nil)
|
||||
end)
|
||||
|
||||
do
|
||||
assign_count = 0
|
||||
insert_count = 0
|
||||
remove_count = 0
|
||||
|
||||
local e = evo.id()
|
||||
assert(evo.multi_set(e, { f1, f2 }, { 41, 42 }))
|
||||
|
||||
assert(assign_count == 0 and insert_count == 2 and remove_count == 0)
|
||||
end
|
||||
|
||||
do
|
||||
assign_count = 0
|
||||
insert_count = 0
|
||||
remove_count = 0
|
||||
|
||||
local e = evo.id()
|
||||
assert(evo.multi_insert(e, { f1, f2 }, { 41, 42 }))
|
||||
|
||||
assert(assign_count == 0 and insert_count == 2 and remove_count == 0)
|
||||
end
|
||||
|
||||
do
|
||||
assign_count = 0
|
||||
insert_count = 0
|
||||
remove_count = 0
|
||||
|
||||
local e = evo.id()
|
||||
assert(evo.multi_insert(e, { f1, f2 }, { 41, 42 }))
|
||||
assert(evo.multi_assign(e, { f1, f2 }, { 51, 52 }))
|
||||
assert(evo.multi_remove(e, { f1, f2 }))
|
||||
|
||||
assert(assign_count == 2 and insert_count == 2 and remove_count == 2)
|
||||
end
|
||||
|
||||
do
|
||||
assign_count = 0
|
||||
insert_count = 0
|
||||
remove_count = 0
|
||||
|
||||
local e = evo.id()
|
||||
assert(evo.multi_insert(e, { f1, f2 }, { 41, 42 }))
|
||||
assert(evo.multi_assign(e, { f1, f2 }, { 51, 52 }))
|
||||
assert(evo.clear(e))
|
||||
|
||||
assert(assign_count == 2 and insert_count == 2 and remove_count == 2)
|
||||
end
|
||||
|
||||
do
|
||||
assign_count = 0
|
||||
insert_count = 0
|
||||
remove_count = 0
|
||||
|
||||
local e = evo.id()
|
||||
assert(evo.multi_insert(e, { f1, f2 }, { 41, 42 }))
|
||||
assert(evo.multi_assign(e, { f1, f2 }, { 51, 52 }))
|
||||
assert(evo.destroy(e))
|
||||
|
||||
assert(assign_count == 2 and insert_count == 2 and remove_count == 2)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local f0, f1 = evo.id(2)
|
||||
local q0 = evo.query():include(f0):build()
|
||||
|
||||
local assign_count = 0
|
||||
local insert_count = 0
|
||||
local remove_count = 0
|
||||
|
||||
local e1, e2 = evo.id(2)
|
||||
|
||||
evo.set(f1, evo.ON_ASSIGN, function(e, f, c)
|
||||
assign_count = assign_count + 1
|
||||
assert(e == e1 or e == e2)
|
||||
assert(f == f1)
|
||||
assert(evo.get(e1, f1) == c)
|
||||
assert(evo.get(e2, f1) == c)
|
||||
end)
|
||||
|
||||
evo.set(f1, evo.ON_INSERT, function(e, f, c)
|
||||
insert_count = insert_count + 1
|
||||
assert(e == e1 or e == e2)
|
||||
assert(f == f1)
|
||||
assert(evo.get(e1, f1) == c)
|
||||
assert(evo.get(e2, f1) == c)
|
||||
end)
|
||||
|
||||
evo.set(f1, evo.ON_REMOVE, function(e, f, c)
|
||||
remove_count = remove_count + 1
|
||||
assert(e == e1 or e == e2)
|
||||
assert(f == f1)
|
||||
assert(evo.get(e1, f1) == nil)
|
||||
assert(evo.get(e2, f1) == nil)
|
||||
end)
|
||||
|
||||
do
|
||||
assign_count = 0
|
||||
insert_count = 0
|
||||
remove_count = 0
|
||||
|
||||
assert(evo.insert(e1, f0) and evo.insert(e2, f0))
|
||||
|
||||
assert(evo.batch_insert(q0, f1, 41))
|
||||
assert(assign_count == 0 and insert_count == 2 and remove_count == 0)
|
||||
|
||||
assert(evo.batch_assign(q0, f1, 51))
|
||||
assert(assign_count == 2 and insert_count == 2 and remove_count == 0)
|
||||
|
||||
assert(evo.batch_remove(q0, f1))
|
||||
assert(assign_count == 2 and insert_count == 2 and remove_count == 2)
|
||||
|
||||
assert(evo.batch_insert(q0, f1, 41))
|
||||
assert(assign_count == 2 and insert_count == 4 and remove_count == 2)
|
||||
|
||||
assert(evo.batch_clear(q0))
|
||||
assert(assign_count == 2 and insert_count == 4 and remove_count == 4)
|
||||
|
||||
assert(evo.insert(e1, f0) and evo.insert(e2, f0))
|
||||
assert(evo.batch_insert(q0, f1, 41))
|
||||
assert(assign_count == 2 and insert_count == 6 and remove_count == 4)
|
||||
|
||||
assert(evo.batch_destroy(q0))
|
||||
assert(assign_count == 2 and insert_count == 6 and remove_count == 6)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local f0, f1, f2 = evo.id(3)
|
||||
local q0 = evo.query():include(f0):build()
|
||||
|
||||
local assign_count = 0
|
||||
local insert_count = 0
|
||||
local remove_count = 0
|
||||
|
||||
local e1, e2 = evo.id(2)
|
||||
|
||||
evo.set(f1, evo.ON_ASSIGN, function(e, f, c)
|
||||
assign_count = assign_count + 1
|
||||
assert(e == e1 or e == e2)
|
||||
assert(f == f1)
|
||||
assert(c == 51)
|
||||
assert(evo.get(e1, f1) == 51)
|
||||
assert(evo.get(e2, f1) == 51)
|
||||
assert(evo.get(e1, f2) == 52)
|
||||
assert(evo.get(e2, f2) == 52)
|
||||
end)
|
||||
|
||||
evo.set(f2, evo.ON_ASSIGN, function(e, f, c)
|
||||
assign_count = assign_count + 1
|
||||
assert(e == e1 or e == e2)
|
||||
assert(f == f2)
|
||||
assert(c == 52)
|
||||
assert(evo.get(e1, f1) == 51)
|
||||
assert(evo.get(e2, f1) == 51)
|
||||
assert(evo.get(e1, f2) == 52)
|
||||
assert(evo.get(e2, f2) == 52)
|
||||
end)
|
||||
|
||||
evo.set(f1, evo.ON_INSERT, function(e, f, c)
|
||||
insert_count = insert_count + 1
|
||||
assert(e == e1 or e == e2)
|
||||
assert(f == f1)
|
||||
assert(c == 41)
|
||||
assert(evo.get(e1, f1) == 41)
|
||||
assert(evo.get(e2, f1) == 41)
|
||||
assert(evo.get(e1, f2) == 42)
|
||||
assert(evo.get(e2, f2) == 42)
|
||||
end)
|
||||
|
||||
evo.set(f2, evo.ON_INSERT, function(e, f, c)
|
||||
insert_count = insert_count + 1
|
||||
assert(e == e1 or e == e2)
|
||||
assert(f == f2)
|
||||
assert(c == 42)
|
||||
assert(evo.get(e1, f1) == 41)
|
||||
assert(evo.get(e2, f1) == 41)
|
||||
assert(evo.get(e1, f2) == 42)
|
||||
assert(evo.get(e2, f2) == 42)
|
||||
end)
|
||||
|
||||
evo.set(f1, evo.ON_REMOVE, function(e, f, c)
|
||||
remove_count = remove_count + 1
|
||||
assert(e == e1 or e == e2)
|
||||
assert(f == f1)
|
||||
assert(c == 51)
|
||||
assert(evo.get(e1, f1) == nil)
|
||||
assert(evo.get(e2, f1) == nil)
|
||||
assert(evo.get(e1, f2) == nil)
|
||||
assert(evo.get(e2, f2) == nil)
|
||||
end)
|
||||
|
||||
evo.set(f2, evo.ON_REMOVE, function(e, f, c)
|
||||
remove_count = remove_count + 1
|
||||
assert(e == e1 or e == e2)
|
||||
assert(f == f2)
|
||||
assert(c == 52)
|
||||
assert(evo.get(e1, f2) == nil)
|
||||
assert(evo.get(e2, f2) == nil)
|
||||
assert(evo.get(e1, f1) == nil)
|
||||
assert(evo.get(e2, f1) == nil)
|
||||
end)
|
||||
|
||||
do
|
||||
assign_count = 0
|
||||
insert_count = 0
|
||||
remove_count = 0
|
||||
|
||||
assert(evo.insert(e1, f0) and evo.insert(e2, f0))
|
||||
|
||||
assert(evo.batch_multi_insert(q0, { f1, f2 }, { 41, 42 }))
|
||||
assert(assign_count == 0 and insert_count == 4 and remove_count == 0)
|
||||
|
||||
assert(evo.batch_multi_assign(q0, { f1, f2 }, { 51, 52 }))
|
||||
assert(assign_count == 4 and insert_count == 4 and remove_count == 0)
|
||||
|
||||
assert(evo.batch_multi_remove(q0, { f1, f2 }))
|
||||
assert(assign_count == 4 and insert_count == 4 and remove_count == 4)
|
||||
|
||||
assert(evo.batch_multi_set(q0, { f1, f2 }, { 41, 42 }))
|
||||
assert(assign_count == 4 and insert_count == 8 and remove_count == 4)
|
||||
|
||||
assert(evo.batch_multi_set(q0, { f1, f2 }, { 51, 52 }))
|
||||
assert(assign_count == 8 and insert_count == 8 and remove_count == 4)
|
||||
|
||||
assert(evo.batch_multi_remove(q0, { f1, f2 }))
|
||||
assert(assign_count == 8 and insert_count == 8 and remove_count == 8)
|
||||
end
|
||||
end
|
||||
|
||||
223
evolved.lua
223
evolved.lua
@@ -1133,9 +1133,9 @@ local function __spawn_entity_at(entity, chunk, fragments, components)
|
||||
|
||||
local new_component = component_storage[place]
|
||||
|
||||
__call_fragment_set_and_insert_hooks(entity, fragment, new_component)
|
||||
__defer_insert_hook(entity, fragment, new_component)
|
||||
else
|
||||
__call_fragment_set_and_insert_hooks(entity, fragment)
|
||||
__defer_insert_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1223,9 +1223,9 @@ local function __spawn_entity_with(entity, chunk, fragments, components)
|
||||
|
||||
local new_component = component_storage[place]
|
||||
|
||||
__call_fragment_set_and_insert_hooks(entity, fragment, new_component)
|
||||
__defer_insert_hook(entity, fragment, new_component)
|
||||
else
|
||||
__call_fragment_set_and_insert_hooks(entity, fragment)
|
||||
__defer_insert_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1298,13 +1298,7 @@ local function __chunk_assign(chunk, fragment, ...)
|
||||
|
||||
component_storage[place] = new_component
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment, new_component, old_component)
|
||||
end
|
||||
|
||||
if fragment_on_assign then
|
||||
fragment_on_assign(entity, fragment, new_component, old_component)
|
||||
end
|
||||
__defer_assign_hook(entity, fragment, new_component, old_component)
|
||||
end
|
||||
else
|
||||
local new_component = ...
|
||||
@@ -1316,26 +1310,13 @@ local function __chunk_assign(chunk, fragment, ...)
|
||||
|
||||
component_storage[place] = new_component
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment, new_component, old_component)
|
||||
end
|
||||
|
||||
if fragment_on_assign then
|
||||
fragment_on_assign(entity, fragment, new_component, old_component)
|
||||
end
|
||||
__defer_assign_hook(entity, fragment, new_component, old_component)
|
||||
end
|
||||
end
|
||||
else
|
||||
for place = 1, chunk_entity_count do
|
||||
local entity = chunk_entities[place]
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment)
|
||||
end
|
||||
|
||||
if fragment_on_assign then
|
||||
fragment_on_assign(entity, fragment)
|
||||
end
|
||||
__defer_assign_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -1448,13 +1429,7 @@ local function __chunk_insert(old_chunk, fragment, ...)
|
||||
|
||||
new_component_storage[new_place] = new_component
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment, new_component)
|
||||
end
|
||||
|
||||
if fragment_on_insert then
|
||||
fragment_on_insert(entity, fragment, new_component)
|
||||
end
|
||||
__defer_insert_hook(entity, fragment, new_component)
|
||||
end
|
||||
else
|
||||
local new_component = ...
|
||||
@@ -1465,26 +1440,13 @@ local function __chunk_insert(old_chunk, fragment, ...)
|
||||
|
||||
new_component_storage[new_place] = new_component
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment, new_component)
|
||||
end
|
||||
|
||||
if fragment_on_insert then
|
||||
fragment_on_insert(entity, fragment, new_component)
|
||||
end
|
||||
__defer_insert_hook(entity, fragment, new_component)
|
||||
end
|
||||
end
|
||||
else
|
||||
for new_place = new_entity_count + 1, new_entity_count + old_entity_count do
|
||||
local entity = new_entities[new_place]
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment)
|
||||
end
|
||||
|
||||
if fragment_on_insert then
|
||||
fragment_on_insert(entity, fragment)
|
||||
end
|
||||
__defer_insert_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -1579,12 +1541,12 @@ local function __chunk_remove(old_chunk, ...)
|
||||
for old_place = 1, old_entity_count do
|
||||
local entity = old_entities[old_place]
|
||||
local old_component = old_component_storage[old_place]
|
||||
fragment_on_remove(entity, fragment, old_component)
|
||||
__defer_remove_hook(entity, fragment, old_component)
|
||||
end
|
||||
else
|
||||
for old_place = 1, old_entity_count do
|
||||
local entity = old_entities[old_place]
|
||||
fragment_on_remove(entity, fragment)
|
||||
__defer_remove_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1675,12 +1637,12 @@ local function __chunk_clear(chunk)
|
||||
for place = 1, chunk_entity_count do
|
||||
local entity = chunk_entities[place]
|
||||
local old_component = component_storage[place]
|
||||
fragment_on_remove(entity, fragment, old_component)
|
||||
__defer_remove_hook(entity, fragment, old_component)
|
||||
end
|
||||
else
|
||||
for place = 1, chunk_entity_count do
|
||||
local entity = chunk_entities[place]
|
||||
fragment_on_remove(entity, fragment)
|
||||
__defer_remove_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1736,12 +1698,12 @@ local function __chunk_destroy(chunk)
|
||||
for place = 1, chunk_entity_count do
|
||||
local entity = chunk_entities[place]
|
||||
local old_component = component_storage[place]
|
||||
fragment_on_remove(entity, fragment, old_component)
|
||||
__defer_remove_hook(entity, fragment, old_component)
|
||||
end
|
||||
else
|
||||
for place = 1, chunk_entity_count do
|
||||
local entity = chunk_entities[place]
|
||||
fragment_on_remove(entity, fragment)
|
||||
__defer_remove_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1834,25 +1796,12 @@ local function __chunk_multi_set(old_chunk, fragments, components)
|
||||
|
||||
old_component_storage[place] = new_component
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment, new_component, old_component)
|
||||
end
|
||||
|
||||
if fragment_on_assign then
|
||||
fragment_on_assign(entity, fragment, new_component, old_component)
|
||||
end
|
||||
__defer_assign_hook(entity, fragment, new_component, old_component)
|
||||
end
|
||||
else
|
||||
for place = 1, old_entity_count do
|
||||
local entity = old_entities[place]
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment)
|
||||
end
|
||||
|
||||
if fragment_on_assign then
|
||||
fragment_on_assign(entity, fragment)
|
||||
end
|
||||
__defer_assign_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -1939,25 +1888,12 @@ local function __chunk_multi_set(old_chunk, fragments, components)
|
||||
|
||||
new_component_storage[new_place] = new_component
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment, new_component, old_component)
|
||||
end
|
||||
|
||||
if fragment_on_assign then
|
||||
fragment_on_assign(entity, fragment, new_component, old_component)
|
||||
end
|
||||
__defer_assign_hook(entity, fragment, new_component, old_component)
|
||||
end
|
||||
else
|
||||
for new_place = new_entity_count + 1, new_entity_count + old_entity_count do
|
||||
local entity = new_entities[new_place]
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment)
|
||||
end
|
||||
|
||||
if fragment_on_assign then
|
||||
fragment_on_assign(entity, fragment)
|
||||
end
|
||||
__defer_assign_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -2011,25 +1947,12 @@ local function __chunk_multi_set(old_chunk, fragments, components)
|
||||
|
||||
new_component_storage[new_place] = new_component
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment, new_component)
|
||||
end
|
||||
|
||||
if fragment_on_insert then
|
||||
fragment_on_insert(entity, fragment, new_component)
|
||||
end
|
||||
__defer_insert_hook(entity, fragment, new_component)
|
||||
end
|
||||
else
|
||||
for new_place = new_entity_count + 1, new_entity_count + old_entity_count do
|
||||
local entity = new_entities[new_place]
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment)
|
||||
end
|
||||
|
||||
if fragment_on_insert then
|
||||
fragment_on_insert(entity, fragment)
|
||||
end
|
||||
__defer_insert_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -2136,25 +2059,12 @@ local function __chunk_multi_assign(chunk, fragments, components)
|
||||
|
||||
component_storage[place] = new_component
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment, new_component, old_component)
|
||||
end
|
||||
|
||||
if fragment_on_assign then
|
||||
fragment_on_assign(entity, fragment, new_component, old_component)
|
||||
end
|
||||
__defer_assign_hook(entity, fragment, new_component, old_component)
|
||||
end
|
||||
else
|
||||
for place = 1, chunk_entity_count do
|
||||
local entity = chunk_entities[place]
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment)
|
||||
end
|
||||
|
||||
if fragment_on_assign then
|
||||
fragment_on_assign(entity, fragment)
|
||||
end
|
||||
__defer_assign_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -2274,25 +2184,12 @@ local function __chunk_multi_insert(old_chunk, fragments, components)
|
||||
|
||||
new_component_storage[new_place] = new_component
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment, new_component)
|
||||
end
|
||||
|
||||
if fragment_on_insert then
|
||||
fragment_on_insert(entity, fragment, new_component)
|
||||
end
|
||||
__defer_insert_hook(entity, fragment, new_component)
|
||||
end
|
||||
else
|
||||
for new_place = new_entity_count + 1, new_entity_count + old_entity_count do
|
||||
local entity = new_entities[new_place]
|
||||
|
||||
if fragment_on_set then
|
||||
fragment_on_set(entity, fragment)
|
||||
end
|
||||
|
||||
if fragment_on_insert then
|
||||
fragment_on_insert(entity, fragment)
|
||||
end
|
||||
__defer_insert_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -2381,12 +2278,12 @@ local function __chunk_multi_remove(old_chunk, fragments)
|
||||
for old_place = 1, old_entity_count do
|
||||
local entity = old_entities[old_place]
|
||||
local old_component = old_component_storage[old_place]
|
||||
fragment_on_remove(entity, fragment, old_component)
|
||||
__defer_remove_hook(entity, fragment, old_component)
|
||||
end
|
||||
else
|
||||
for place = 1, old_entity_count do
|
||||
local entity = old_entities[place]
|
||||
fragment_on_remove(entity, fragment)
|
||||
__defer_remove_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3731,7 +3628,7 @@ function evolved.set(entity, fragment, ...)
|
||||
if old_chunk.__has_set_or_assign_hooks then
|
||||
local old_component = old_component_storage[old_place]
|
||||
old_component_storage[old_place] = new_component
|
||||
__call_fragment_set_and_assign_hooks(entity, fragment, new_component, old_component)
|
||||
__defer_assign_hook(entity, fragment, new_component, old_component)
|
||||
else
|
||||
old_component_storage[old_place] = new_component
|
||||
end
|
||||
@@ -3745,14 +3642,14 @@ function evolved.set(entity, fragment, ...)
|
||||
if old_chunk.__has_set_or_assign_hooks then
|
||||
local old_component = old_component_storage[old_place]
|
||||
old_component_storage[old_place] = new_component
|
||||
__call_fragment_set_and_assign_hooks(entity, fragment, new_component, old_component)
|
||||
__defer_assign_hook(entity, fragment, new_component, old_component)
|
||||
else
|
||||
old_component_storage[old_place] = new_component
|
||||
end
|
||||
end
|
||||
else
|
||||
if old_chunk.__has_set_or_assign_hooks then
|
||||
__call_fragment_set_and_assign_hooks(entity, fragment)
|
||||
__defer_assign_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -3797,7 +3694,7 @@ function evolved.set(entity, fragment, ...)
|
||||
new_component_storage[new_place] = new_component
|
||||
|
||||
if new_chunk.__has_set_or_insert_hooks then
|
||||
__call_fragment_set_and_insert_hooks(entity, fragment, new_component)
|
||||
__defer_insert_hook(entity, fragment, new_component)
|
||||
end
|
||||
else
|
||||
local new_component = ...
|
||||
@@ -3809,12 +3706,12 @@ function evolved.set(entity, fragment, ...)
|
||||
new_component_storage[new_place] = new_component
|
||||
|
||||
if new_chunk.__has_set_or_insert_hooks then
|
||||
__call_fragment_set_and_insert_hooks(entity, fragment, new_component)
|
||||
__defer_insert_hook(entity, fragment, new_component)
|
||||
end
|
||||
end
|
||||
else
|
||||
if new_chunk.__has_set_or_insert_hooks then
|
||||
__call_fragment_set_and_insert_hooks(entity, fragment)
|
||||
__defer_insert_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3873,7 +3770,7 @@ function evolved.assign(entity, fragment, ...)
|
||||
if chunk.__has_set_or_assign_hooks then
|
||||
local old_component = component_storage[place]
|
||||
component_storage[place] = new_component
|
||||
__call_fragment_set_and_assign_hooks(entity, fragment, new_component, old_component)
|
||||
__defer_assign_hook(entity, fragment, new_component, old_component)
|
||||
else
|
||||
component_storage[place] = new_component
|
||||
end
|
||||
@@ -3887,14 +3784,14 @@ function evolved.assign(entity, fragment, ...)
|
||||
if chunk.__has_set_or_assign_hooks then
|
||||
local old_component = component_storage[place]
|
||||
component_storage[place] = new_component
|
||||
__call_fragment_set_and_assign_hooks(entity, fragment, new_component, old_component)
|
||||
__defer_assign_hook(entity, fragment, new_component, old_component)
|
||||
else
|
||||
component_storage[place] = new_component
|
||||
end
|
||||
end
|
||||
else
|
||||
if chunk.__has_set_or_assign_hooks then
|
||||
__call_fragment_set_and_assign_hooks(entity, fragment)
|
||||
__defer_assign_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -3976,7 +3873,7 @@ function evolved.insert(entity, fragment, ...)
|
||||
new_component_storage[new_place] = new_component
|
||||
|
||||
if new_chunk.__has_set_or_insert_hooks then
|
||||
__call_fragment_set_and_insert_hooks(entity, fragment, new_component)
|
||||
__defer_insert_hook(entity, fragment, new_component)
|
||||
end
|
||||
else
|
||||
local new_component = ...
|
||||
@@ -3988,12 +3885,12 @@ function evolved.insert(entity, fragment, ...)
|
||||
new_component_storage[new_place] = new_component
|
||||
|
||||
if new_chunk.__has_set_or_insert_hooks then
|
||||
__call_fragment_set_and_insert_hooks(entity, fragment, new_component)
|
||||
__defer_insert_hook(entity, fragment, new_component)
|
||||
end
|
||||
end
|
||||
else
|
||||
if new_chunk.__has_set_or_insert_hooks then
|
||||
__call_fragment_set_and_insert_hooks(entity, fragment)
|
||||
__defer_insert_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -4057,9 +3954,9 @@ function evolved.remove(entity, ...)
|
||||
if old_component_index then
|
||||
local old_component_storage = old_component_storages[old_component_index]
|
||||
local old_component = old_component_storage[old_place]
|
||||
__call_fragment_remove_hook(entity, fragment, old_component)
|
||||
__defer_remove_hook(entity, fragment, old_component)
|
||||
else
|
||||
__call_fragment_remove_hook(entity, fragment)
|
||||
__defer_remove_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -4141,15 +4038,17 @@ function evolved.clear(entity)
|
||||
local chunk_fragment_count = chunk.__fragment_count
|
||||
local chunk_component_indices = chunk.__component_indices
|
||||
local chunk_component_storages = chunk.__component_storages
|
||||
|
||||
for i = 1, chunk_fragment_count do
|
||||
local fragment = chunk_fragment_list[i]
|
||||
local component_index = chunk_component_indices[fragment]
|
||||
|
||||
if component_index then
|
||||
local component_storage = chunk_component_storages[component_index]
|
||||
local old_component = component_storage[place]
|
||||
__call_fragment_remove_hook(entity, fragment, old_component)
|
||||
__defer_remove_hook(entity, fragment, old_component)
|
||||
else
|
||||
__call_fragment_remove_hook(entity, fragment)
|
||||
__defer_remove_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -4200,15 +4099,17 @@ function evolved.destroy(entity)
|
||||
local chunk_fragment_count = chunk.__fragment_count
|
||||
local chunk_component_indices = chunk.__component_indices
|
||||
local chunk_component_storages = chunk.__component_storages
|
||||
|
||||
for i = 1, chunk_fragment_count do
|
||||
local fragment = chunk_fragment_list[i]
|
||||
local component_index = chunk_component_indices[fragment]
|
||||
|
||||
if component_index then
|
||||
local component_storage = chunk_component_storages[component_index]
|
||||
local old_component = component_storage[place]
|
||||
__call_fragment_remove_hook(entity, fragment, old_component)
|
||||
__defer_remove_hook(entity, fragment, old_component)
|
||||
else
|
||||
__call_fragment_remove_hook(entity, fragment)
|
||||
__defer_remove_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -4295,13 +4196,13 @@ function evolved.multi_set(entity, fragments, components)
|
||||
if old_chunk_has_set_or_assign_hooks then
|
||||
local old_component = old_component_storage[old_place]
|
||||
old_component_storage[old_place] = new_component
|
||||
__call_fragment_set_and_assign_hooks(entity, fragment, new_component, old_component)
|
||||
__defer_assign_hook(entity, fragment, new_component, old_component)
|
||||
else
|
||||
old_component_storage[old_place] = new_component
|
||||
end
|
||||
else
|
||||
if old_chunk_has_set_or_assign_hooks then
|
||||
__call_fragment_set_and_assign_hooks(entity, fragment)
|
||||
__defer_assign_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -4365,13 +4266,13 @@ function evolved.multi_set(entity, fragments, components)
|
||||
if new_chunk_has_set_or_assign_hooks then
|
||||
local old_component = new_component_storage[new_place]
|
||||
new_component_storage[new_place] = new_component
|
||||
__call_fragment_set_and_assign_hooks(entity, fragment, new_component, old_component)
|
||||
__defer_assign_hook(entity, fragment, new_component, old_component)
|
||||
else
|
||||
new_component_storage[new_place] = new_component
|
||||
end
|
||||
else
|
||||
if new_chunk_has_set_or_assign_hooks then
|
||||
__call_fragment_set_and_assign_hooks(entity, fragment)
|
||||
__defer_assign_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -4395,11 +4296,11 @@ function evolved.multi_set(entity, fragments, components)
|
||||
new_component_storage[new_place] = new_component
|
||||
|
||||
if new_chunk_has_set_or_insert_hooks then
|
||||
__call_fragment_set_and_insert_hooks(entity, fragment, new_component)
|
||||
__defer_insert_hook(entity, fragment, new_component)
|
||||
end
|
||||
else
|
||||
if new_chunk_has_set_or_insert_hooks then
|
||||
__call_fragment_set_and_insert_hooks(entity, fragment)
|
||||
__defer_insert_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -4486,13 +4387,13 @@ function evolved.multi_assign(entity, fragments, components)
|
||||
if chunk_has_set_or_assign_hooks then
|
||||
local old_component = component_storage[place]
|
||||
component_storage[place] = new_component
|
||||
__call_fragment_set_and_assign_hooks(entity, fragment, new_component, old_component)
|
||||
__defer_assign_hook(entity, fragment, new_component, old_component)
|
||||
else
|
||||
component_storage[place] = new_component
|
||||
end
|
||||
else
|
||||
if chunk_has_set_or_assign_hooks then
|
||||
__call_fragment_set_and_assign_hooks(entity, fragment)
|
||||
__defer_assign_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -4605,11 +4506,11 @@ function evolved.multi_insert(entity, fragments, components)
|
||||
new_component_storage[new_place] = new_component
|
||||
|
||||
if new_chunk_has_set_or_insert_hooks then
|
||||
__call_fragment_set_and_insert_hooks(entity, fragment, new_component)
|
||||
__defer_insert_hook(entity, fragment, new_component)
|
||||
end
|
||||
else
|
||||
if new_chunk_has_set_or_insert_hooks then
|
||||
__call_fragment_set_and_insert_hooks(entity, fragment)
|
||||
__defer_insert_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -4682,9 +4583,9 @@ function evolved.multi_remove(entity, fragments)
|
||||
if old_component_index then
|
||||
local old_component_storage = old_component_storages[old_component_index]
|
||||
local old_component = old_component_storage[old_place]
|
||||
__call_fragment_remove_hook(entity, fragment, old_component)
|
||||
__defer_remove_hook(entity, fragment, old_component)
|
||||
else
|
||||
__call_fragment_remove_hook(entity, fragment)
|
||||
__defer_remove_hook(entity, fragment)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user