diff --git a/README.md b/README.md index ecb9480..1f9fd8c 100644 --- a/README.md +++ b/README.md @@ -78,27 +78,19 @@ has_any :: chunk | entity, fragment... -> boolean get :: entity, fragment... -> component... set :: entity, fragment, any... -> boolean, boolean -assign :: entity, fragment, any... -> boolean, boolean -insert :: entity, fragment, any... -> boolean, boolean remove :: entity, fragment... -> boolean, boolean clear :: entity... -> boolean, boolean destroy :: entity... -> boolean, boolean multi_set :: entity, fragment[], component[]? -> boolean, boolean -multi_assign :: entity, fragment[], component[]? -> boolean, boolean -multi_insert :: entity, fragment[], component[]? -> boolean, boolean multi_remove :: entity, fragment[] -> boolean, boolean batch_set :: chunk | query, fragment, any... -> integer, boolean -batch_assign :: chunk | query, fragment, any... -> integer, boolean -batch_insert :: chunk | query, fragment, any... -> integer, boolean batch_remove :: chunk | query, fragment... -> integer, boolean batch_clear :: chunk | query... -> integer, boolean batch_destroy :: chunk | query... -> integer, boolean batch_multi_set :: chunk | query, fragment[], component[]? -> integer, boolean -batch_multi_assign :: chunk | query, fragment[], component[]? -> integer, boolean -batch_multi_insert :: chunk | query, fragment[], component[]? -> integer, boolean batch_multi_remove :: chunk | query, fragment[] -> integer, boolean chunk :: fragment, fragment... -> chunk, entity[], integer diff --git a/ROADMAP.md b/ROADMAP.md index c3b68d7..b70e6c1 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -4,6 +4,7 @@ - validate operation sources in the debug mode - should set/assign/insert return a constructed component? +- can we pass systems and groups to the process function? ## After first release diff --git a/develop/all.lua b/develop/all.lua index 7d7536f..49a0913 100644 --- a/develop/all.lua +++ b/develop/all.lua @@ -1,4 +1,4 @@ require 'develop.example' --- require 'develop.unbench' +require 'develop.unbench' require 'develop.untests' --- require 'develop.usbench' +require 'develop.usbench' diff --git a/develop/unbench.lua b/develop/unbench.lua index 8266781..1a97149 100644 --- a/develop/unbench.lua +++ b/develop/unbench.lua @@ -236,11 +236,11 @@ basics.describe_bench(string.format('create and destroy %d entities with 1 compo ---@param entities evolved.id[] function(entities) local id = evo.id - local insert = evo.insert + local set = evo.set for i = 1, N do local e = id() - insert(e, F1) + set(e, F1) entities[i] = e end @@ -253,12 +253,12 @@ basics.describe_bench(string.format('create and destroy %d entities with 2 compo ---@param entities evolved.id[] function(entities) local id = evo.id - local insert = evo.insert + local set = evo.set for i = 1, N do local e = id() - insert(e, F1) - insert(e, F2) + set(e, F1) + set(e, F2) entities[i] = e end @@ -271,13 +271,13 @@ basics.describe_bench(string.format('create and destroy %d entities with 3 compo ---@param entities evolved.id[] function(entities) local id = evo.id - local insert = evo.insert + local set = evo.set for i = 1, N do local e = id() - insert(e, F1) - insert(e, F2) - insert(e, F3) + set(e, F1) + set(e, F2) + set(e, F3) entities[i] = e end @@ -290,14 +290,14 @@ basics.describe_bench(string.format('create and destroy %d entities with 4 compo ---@param entities evolved.id[] function(entities) local id = evo.id - local insert = evo.insert + local set = evo.set for i = 1, N do local e = id() - insert(e, F1) - insert(e, F2) - insert(e, F3) - insert(e, F4) + set(e, F1) + set(e, F2) + set(e, F3) + set(e, F4) entities[i] = e end @@ -310,15 +310,15 @@ basics.describe_bench(string.format('create and destroy %d entities with 5 compo ---@param entities evolved.id[] function(entities) local id = evo.id - local insert = evo.insert + local set = evo.set for i = 1, N do local e = id() - insert(e, F1) - insert(e, F2) - insert(e, F3) - insert(e, F4) - insert(e, F5) + set(e, F1) + set(e, F2) + set(e, F3) + set(e, F4) + set(e, F5) entities[i] = e end @@ -333,12 +333,12 @@ basics.describe_bench(string.format('create and destroy %d entities with 1 compo ---@param entities evolved.id[] function(entities) local id = evo.id - local insert = evo.insert + local set = evo.set evo.defer() for i = 1, N do local e = id() - insert(e, F1) + set(e, F1) entities[i] = e end evo.commit() @@ -352,13 +352,13 @@ basics.describe_bench(string.format('create and destroy %d entities with 2 compo ---@param entities evolved.id[] function(entities) local id = evo.id - local insert = evo.insert + local set = evo.set evo.defer() for i = 1, N do local e = id() - insert(e, F1) - insert(e, F2) + set(e, F1) + set(e, F2) entities[i] = e end evo.commit() @@ -372,14 +372,14 @@ basics.describe_bench(string.format('create and destroy %d entities with 3 compo ---@param entities evolved.id[] function(entities) local id = evo.id - local insert = evo.insert + local set = evo.set evo.defer() for i = 1, N do local e = id() - insert(e, F1) - insert(e, F2) - insert(e, F3) + set(e, F1) + set(e, F2) + set(e, F3) entities[i] = e end evo.commit() @@ -393,15 +393,15 @@ basics.describe_bench(string.format('create and destroy %d entities with 4 compo ---@param entities evolved.id[] function(entities) local id = evo.id - local insert = evo.insert + local set = evo.set evo.defer() for i = 1, N do local e = id() - insert(e, F1) - insert(e, F2) - insert(e, F3) - insert(e, F4) + set(e, F1) + set(e, F2) + set(e, F3) + set(e, F4) entities[i] = e end evo.commit() @@ -415,16 +415,16 @@ basics.describe_bench(string.format('create and destroy %d entities with 5 compo ---@param entities evolved.id[] function(entities) local id = evo.id - local insert = evo.insert + local set = evo.set evo.defer() for i = 1, N do local e = id() - insert(e, F1) - insert(e, F2) - insert(e, F3) - insert(e, F4) - insert(e, F5) + set(e, F1) + set(e, F2) + set(e, F3) + set(e, F4) + set(e, F5) entities[i] = e end evo.commit() diff --git a/develop/untests.lua b/develop/untests.lua index 0d57966..a293987 100644 --- a/develop/untests.lua +++ b/develop/untests.lua @@ -120,7 +120,7 @@ do assert(c1 == nil and c2 == nil) end - assert(evo.insert(e, f1, 41)) + assert(evo.set(e, f1, 41)) do assert(evo.has(e, f1)) @@ -137,7 +137,7 @@ do assert(c1 == 41 and c2 == nil) end - assert(evo.insert(e, f2, 42)) + assert(evo.set(e, f2, 42)) do assert(evo.has(e, f1)) @@ -159,12 +159,9 @@ do local f1, f2 = evo.id(2) local e = evo.id() - assert(evo.insert(e, f1, 41)) - assert(not evo.insert(e, f1, 42)) + assert(evo.set(e, f1, 41)) - assert(evo.insert(e, f2, 42)) - assert(not evo.insert(e, f1, 42)) - assert(not evo.insert(e, f2, 41)) + assert(evo.set(e, f2, 42)) do assert(evo.has_all(e, f1, f2)) @@ -178,8 +175,8 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 41)) - assert(evo.insert(e, f2, 42)) + assert(evo.set(e, f1, 41)) + assert(evo.set(e, f2, 42)) evo.remove(e, f1) @@ -192,8 +189,8 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 41)) - assert(evo.insert(e, f2, 42)) + assert(evo.set(e, f1, 41)) + assert(evo.set(e, f2, 42)) evo.remove(e, f2) @@ -206,8 +203,8 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 41)) - assert(evo.insert(e, f2, 42)) + assert(evo.set(e, f1, 41)) + assert(evo.set(e, f2, 42)) evo.remove(e, f1, f2) @@ -222,22 +219,22 @@ do local f1, f2 = evo.id(2) local e1, e2 = evo.id(2) - assert(evo.insert(e1, f1, 41)) - assert(evo.insert(e2, f2, 42)) + assert(evo.set(e1, f1, 41)) + assert(evo.set(e2, f2, 42)) do assert(evo.get(e1, f1) == 41 and evo.get(e1, f2) == nil) assert(evo.get(e2, f2) == 42 and evo.get(e2, f1) == nil) end - assert(evo.insert(e1, f2, 43)) + assert(evo.set(e1, f2, 43)) do assert(evo.get(e1, f1) == 41 and evo.get(e1, f2) == 43) assert(evo.get(e2, f2) == 42 and evo.get(e2, f1) == nil) end - assert(evo.insert(e2, f1, 44)) + assert(evo.set(e2, f1, 44)) do assert(evo.get(e1, f1) == 41 and evo.get(e1, f2) == 43) @@ -251,10 +248,10 @@ do do local e1, e2 = evo.id(2) - assert(evo.insert(e1, f1, 41)) - assert(evo.insert(e1, f2, 43)) - assert(evo.insert(e2, f1, 44)) - assert(evo.insert(e2, f2, 42)) + assert(evo.set(e1, f1, 41)) + assert(evo.set(e1, f2, 43)) + assert(evo.set(e2, f1, 44)) + assert(evo.set(e2, f2, 42)) do assert(evo.get(e1, f1) == 41 and evo.get(e1, f2) == 43) @@ -281,10 +278,10 @@ do local f1, f2 = evo.id(2) local e1, e2 = evo.id(2) - assert(evo.insert(e1, f1, 41)) - assert(evo.insert(e1, f2, 43)) - assert(evo.insert(e2, f1, 44)) - assert(evo.insert(e2, f2, 42)) + assert(evo.set(e1, f1, 41)) + assert(evo.set(e1, f2, 43)) + assert(evo.set(e2, f1, 44)) + assert(evo.set(e2, f2, 42)) evo.clear(e1) @@ -306,18 +303,16 @@ do local e = evo.id() - assert(not evo.assign(e, f1, 41)) assert(evo.get(e, f1) == nil) - assert(evo.insert(e, f1, 41)) - assert(evo.assign(e, f1, 42)) + assert(evo.set(e, f1, 41)) + assert(evo.set(e, f1, 42)) assert(evo.get(e, f1) == 42) - assert(not evo.assign(e, f2, 43)) assert(evo.get(e, f2) == nil) - assert(evo.insert(e, f2, 43)) - assert(evo.assign(e, f2, 44)) + assert(evo.set(e, f2, 43)) + assert(evo.set(e, f2, 44)) assert(evo.get(e, f2) == 44) end @@ -397,20 +392,20 @@ do local e = evo.id() - evo.insert(e, f1, 43, 1) - evo.insert(e, f2, false) - evo.insert(e, f3, 43) - evo.insert(e, f4, 43) + evo.set(e, f1, 43, 1) + evo.set(e, f2, false) + evo.set(e, f3, 43) + evo.set(e, f4, 43) assert(evo.get(e, f1) == 42) assert(evo.get(e, f2) == false) assert(evo.get(e, f3) == true) assert(evo.get(e, f4) == false) - evo.assign(e, f1, 42, 2) - evo.assign(e, f2, true) - evo.assign(e, f3, 43) - evo.assign(e, f4, 43) + evo.set(e, f1, 42, 2) + evo.set(e, f2, true) + evo.set(e, f3, 43) + evo.set(e, f4, 43) assert(evo.get(e, f1) == 40) assert(evo.get(e, f2) == true) @@ -486,7 +481,7 @@ do last_remove_old_component = old_component end) - assert(evo.insert(e, f, 21)) + assert(evo.set(e, f, 21)) assert(set_count == 1) assert(assign_count == 0) assert(insert_count == 1) @@ -495,7 +490,7 @@ do assert(last_set_new_component == 21) assert(last_insert_new_component == 21) - assert(evo.assign(e, f, 42)) + assert(evo.set(e, f, 42)) assert(set_count == 2) assert(assign_count == 1) assert(insert_count == 1) @@ -505,7 +500,7 @@ do assert(last_assign_new_component == 42) assert(last_assign_old_component == 21) - assert(evo.assign(e, f, 43)) + assert(evo.set(e, f, 43)) assert(set_count == 3) assert(assign_count == 2) assert(insert_count == 1) @@ -570,24 +565,24 @@ do last_removed_component = component end) - assert(evo.insert(e, f1, 42)) + assert(evo.set(e, f1, 42)) evo.remove(e, f1, f2) assert(remove_count == 1) assert(last_removed_component == 42) - assert(evo.insert(e, f1, 42)) - assert(evo.insert(e, f2, 43)) + assert(evo.set(e, f1, 42)) + assert(evo.set(e, f2, 43)) evo.remove(e, f1, f2, f2) assert(remove_count == 3) assert(last_removed_component == 43) - assert(evo.insert(e, f1, 44)) - assert(evo.insert(e, f2, 45)) + assert(evo.set(e, f1, 44)) + assert(evo.set(e, f2, 45)) evo.clear(e) assert(remove_count == 5) - assert(evo.insert(e, f1, 46)) - assert(evo.insert(e, f2, 47)) + assert(evo.set(e, f1, 46)) + assert(evo.set(e, f2, 47)) evo.destroy(e) assert(remove_count == 7) end @@ -596,7 +591,7 @@ do local f = evo.id() local e = evo.id() - assert(evo.insert(e, f, 42)) + assert(evo.set(e, f, 42)) assert(evo.has(e, f)) assert(evo.is_alive(e)) @@ -612,7 +607,7 @@ do local e = evo.id() assert(evo.is_empty(e)) - evo.insert(e, f, 42) + evo.set(e, f, 42) assert(not evo.is_empty(e)) evo.clear(e) @@ -623,7 +618,7 @@ do local e = evo.id() assert(evo.is_empty(e)) - evo.insert(e, f, 42) + evo.set(e, f, 42) assert(not evo.is_empty(e)) evo.destroy(e) @@ -637,15 +632,15 @@ do local _ = evo.id() local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 42)) - assert(evo.insert(e2, f2, 43)) + assert(evo.set(e2, f1, 42)) + assert(evo.set(e2, f2, 43)) local e2b = evo.id() - assert(evo.insert(e2b, f1, 44)) - assert(evo.insert(e2b, f2, 45)) + assert(evo.set(e2b, f1, 44)) + assert(evo.set(e2b, f2, 45)) do local chunk, entities = evo.chunk(f1) @@ -682,15 +677,15 @@ do local e1, e2, e3, e4 = evo.id(4) - assert(evo.insert(e1, f3, 44)) + assert(evo.set(e1, f3, 44)) - assert(evo.insert(e2, f1, 45)) - assert(evo.insert(e2, f2, 46)) - assert(evo.insert(e2, f3, 47)) + assert(evo.set(e2, f1, 45)) + assert(evo.set(e2, f2, 46)) + assert(evo.set(e2, f3, 47)) - assert(evo.insert(e3, f1, 45)) - assert(evo.insert(e3, f2, 46)) - assert(evo.insert(e3, f3, 47)) + assert(evo.set(e3, f1, 45)) + assert(evo.set(e3, f2, 46)) + assert(evo.set(e3, f3, 47)) assert(evo.defer()) assert(not evo.defer()) @@ -698,10 +693,9 @@ do evo.set(e1, f1) evo.set(e1, f2, 43) evo.remove(e2, f1, f2) - evo.assign(e2, f3, 48) + evo.set(e2, f3, 48) evo.clear(e3) - evo.insert(e3, f1, 48) - evo.insert(e3, f1, 49) + evo.set(e3, f1, 48) evo.destroy(e4) assert(evo.get(e1, f1) == nil) @@ -742,7 +736,7 @@ do ---@param component evolved.component evo.set(f1, evo.ON_SET, function(entity, fragment, component) assert(fragment == f1) - evo.insert(entity, f2, component * 2) + evo.set(entity, f2, component * 2) end) ---@param entity evolved.entity @@ -797,7 +791,7 @@ do ---@param component evolved.component evo.set(f1, evo.ON_INSERT, function(entity, fragment, component) assert(fragment == f1) - evo.insert(entity, f2, component * 2) + evo.set(entity, f2, component * 2) end) ---@param entity evolved.entity @@ -812,7 +806,7 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 21)) + assert(evo.set(e, f1, 21)) assert(evo.get(e, f1) == 21) assert(evo.get(e, f2) == 42) @@ -823,7 +817,7 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 21)) + assert(evo.set(e, f1, 21)) assert(evo.get(e, f1) == 21) assert(evo.get(e, f2) == 42) @@ -834,7 +828,7 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 21)) + assert(evo.set(e, f1, 21)) assert(evo.get(e, f1) == 21) assert(evo.get(e, f2) == 42) @@ -849,32 +843,32 @@ do local f1, f2, f3, f4 = evo.id(4) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 42)) - assert(evo.insert(e2, f2, 43)) + assert(evo.set(e2, f1, 42)) + assert(evo.set(e2, f2, 43)) local e3 = evo.id() - assert(evo.insert(e3, f1, 44)) - assert(evo.insert(e3, f2, 45)) - assert(evo.insert(e3, f3, 46)) + assert(evo.set(e3, f1, 44)) + assert(evo.set(e3, f2, 45)) + assert(evo.set(e3, f3, 46)) local e4 = evo.id() - assert(evo.insert(e4, f1, 47)) - assert(evo.insert(e4, f2, 48)) - assert(evo.insert(e4, f3, 49)) - assert(evo.insert(e4, f4, 50)) + assert(evo.set(e4, f1, 47)) + assert(evo.set(e4, f2, 48)) + assert(evo.set(e4, f3, 49)) + assert(evo.set(e4, f4, 50)) local e5 = evo.id() - assert(evo.insert(e5, f2, 51)) - assert(evo.insert(e5, f3, 52)) - assert(evo.insert(e5, f4, 53)) + assert(evo.set(e5, f2, 51)) + assert(evo.set(e5, f3, 52)) + assert(evo.set(e5, f4, 53)) local q = evo.id() - evo.insert(q, evo.INCLUDES, f1, f2) + evo.set(q, evo.INCLUDES, f1, f2) - assert(evo.batch_assign(q, f1, 60) == 3) + assert(evo.batch_set(q, f1, 60) == 3) assert(evo.get(e1, f1) == 41 and evo.get(e1, f3) == nil) assert(evo.get(e2, f1) == 60 and evo.get(e2, f3) == nil) @@ -882,7 +876,8 @@ do assert(evo.get(e4, f1) == 60 and evo.get(e4, f3) == 49) assert(evo.get(e5, f1) == nil and evo.get(e5, f3) == 52) - assert(evo.batch_assign(q, f3, 70) == 2) + evo.set(q, evo.INCLUDES, f1, f2, f3) + assert(evo.batch_set(q, f3, 70) == 2) assert(evo.get(e1, f1) == 41 and evo.get(e1, f3) == nil) assert(evo.get(e2, f1) == 60 and evo.get(e2, f3) == nil) @@ -909,32 +904,32 @@ do end) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 42)) - assert(evo.insert(e2, f2, 43)) + assert(evo.set(e2, f1, 42)) + assert(evo.set(e2, f2, 43)) local e3 = evo.id() - assert(evo.insert(e3, f1, 44)) - assert(evo.insert(e3, f2, 45)) - assert(evo.insert(e3, f3, 46)) + assert(evo.set(e3, f1, 44)) + assert(evo.set(e3, f2, 45)) + assert(evo.set(e3, f3, 46)) local e4 = evo.id() - assert(evo.insert(e4, f1, 47)) - assert(evo.insert(e4, f2, 48)) - assert(evo.insert(e4, f3, 49)) - assert(evo.insert(e4, f4, 50)) + assert(evo.set(e4, f1, 47)) + assert(evo.set(e4, f2, 48)) + assert(evo.set(e4, f3, 49)) + assert(evo.set(e4, f4, 50)) local e5 = evo.id() - assert(evo.insert(e5, f2, 51)) - assert(evo.insert(e5, f3, 52)) - assert(evo.insert(e5, f4, 53)) + assert(evo.set(e5, f2, 51)) + assert(evo.set(e5, f3, 52)) + assert(evo.set(e5, f4, 53)) local q = evo.id() - evo.insert(q, evo.INCLUDES, f1, f2) + evo.set(q, evo.INCLUDES, f1, f2) - assert(evo.batch_assign(q, f1, 60) == 3) + assert(evo.batch_set(q, f1, 60) == 3) assert(entity_sum == e2 + e3 + e4) assert(component_sum == 42 + 44 + 47 + 60 + 60 + 60) @@ -947,7 +942,8 @@ do assert(evo.get(e4, f1) == 60 and evo.get(e4, f3) == 49) assert(evo.get(e5, f1) == nil and evo.get(e5, f3) == 52) - assert(evo.batch_assign(q, f3, 70) == 2) + evo.set(q, evo.INCLUDES, f1, f2, f3) + assert(evo.batch_set(q, f3, 70) == 2) assert(entity_sum == e3 + e4) assert(component_sum == 46 + 49 + 70 + 70) @@ -967,30 +963,30 @@ do local f1, f2, f3, f4 = evo.id(4) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 42)) - assert(evo.insert(e2, f2, 43)) + assert(evo.set(e2, f1, 42)) + assert(evo.set(e2, f2, 43)) local e3 = evo.id() - assert(evo.insert(e3, f1, 44)) - assert(evo.insert(e3, f2, 45)) - assert(evo.insert(e3, f3, 46)) + assert(evo.set(e3, f1, 44)) + assert(evo.set(e3, f2, 45)) + assert(evo.set(e3, f3, 46)) local e4 = evo.id() - assert(evo.insert(e4, f1, 47)) - assert(evo.insert(e4, f2, 48)) - assert(evo.insert(e4, f3, 49)) - assert(evo.insert(e4, f4, 50)) + assert(evo.set(e4, f1, 47)) + assert(evo.set(e4, f2, 48)) + assert(evo.set(e4, f3, 49)) + assert(evo.set(e4, f4, 50)) local e5 = evo.id() - assert(evo.insert(e5, f2, 51)) - assert(evo.insert(e5, f3, 52)) - assert(evo.insert(e5, f4, 53)) + assert(evo.set(e5, f2, 51)) + assert(evo.set(e5, f3, 52)) + assert(evo.set(e5, f4, 53)) local q = evo.id() - evo.insert(q, evo.INCLUDES, f1, f2) + evo.set(q, evo.INCLUDES, f1, f2) assert(evo.batch_clear(q) == 3) @@ -1037,30 +1033,30 @@ do end) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 42)) - assert(evo.insert(e2, f2, 43)) + assert(evo.set(e2, f1, 42)) + assert(evo.set(e2, f2, 43)) local e3 = evo.id() - assert(evo.insert(e3, f1, 44)) - assert(evo.insert(e3, f2, 45)) - assert(evo.insert(e3, f3, 46)) + assert(evo.set(e3, f1, 44)) + assert(evo.set(e3, f2, 45)) + assert(evo.set(e3, f3, 46)) local e4 = evo.id() - assert(evo.insert(e4, f1, 47)) - assert(evo.insert(e4, f2, 48)) - assert(evo.insert(e4, f3, 49)) - assert(evo.insert(e4, f4, 50)) + assert(evo.set(e4, f1, 47)) + assert(evo.set(e4, f2, 48)) + assert(evo.set(e4, f3, 49)) + assert(evo.set(e4, f4, 50)) local e5 = evo.id() - assert(evo.insert(e5, f2, 51)) - assert(evo.insert(e5, f3, 52)) - assert(evo.insert(e5, f4, 53)) + assert(evo.set(e5, f2, 51)) + assert(evo.set(e5, f3, 52)) + assert(evo.set(e5, f4, 53)) local q = evo.id() - evo.insert(q, evo.INCLUDES, f1, f2) + evo.set(q, evo.INCLUDES, f1, f2) assert(evo.batch_clear(q) == 3) assert(entity_sum == e2 * 2 + e3 * 3 + e4 * 4) @@ -1085,30 +1081,30 @@ do local f1, f2, f3, f4 = evo.id(4) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 42)) - assert(evo.insert(e2, f2, 43)) + assert(evo.set(e2, f1, 42)) + assert(evo.set(e2, f2, 43)) local e3 = evo.id() - assert(evo.insert(e3, f1, 44)) - assert(evo.insert(e3, f2, 45)) - assert(evo.insert(e3, f3, 46)) + assert(evo.set(e3, f1, 44)) + assert(evo.set(e3, f2, 45)) + assert(evo.set(e3, f3, 46)) local e4 = evo.id() - assert(evo.insert(e4, f1, 47)) - assert(evo.insert(e4, f2, 48)) - assert(evo.insert(e4, f3, 49)) - assert(evo.insert(e4, f4, 50)) + assert(evo.set(e4, f1, 47)) + assert(evo.set(e4, f2, 48)) + assert(evo.set(e4, f3, 49)) + assert(evo.set(e4, f4, 50)) local e5 = evo.id() - assert(evo.insert(e5, f2, 51)) - assert(evo.insert(e5, f3, 52)) - assert(evo.insert(e5, f4, 53)) + assert(evo.set(e5, f2, 51)) + assert(evo.set(e5, f3, 52)) + assert(evo.set(e5, f4, 53)) local q = evo.id() - evo.insert(q, evo.INCLUDES, f1, f2) + evo.set(q, evo.INCLUDES, f1, f2) assert(evo.batch_destroy(q) == 3) @@ -1155,30 +1151,30 @@ do end) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 42)) - assert(evo.insert(e2, f2, 43)) + assert(evo.set(e2, f1, 42)) + assert(evo.set(e2, f2, 43)) local e3 = evo.id() - assert(evo.insert(e3, f1, 44)) - assert(evo.insert(e3, f2, 45)) - assert(evo.insert(e3, f3, 46)) + assert(evo.set(e3, f1, 44)) + assert(evo.set(e3, f2, 45)) + assert(evo.set(e3, f3, 46)) local e4 = evo.id() - assert(evo.insert(e4, f1, 47)) - assert(evo.insert(e4, f2, 48)) - assert(evo.insert(e4, f3, 49)) - assert(evo.insert(e4, f4, 50)) + assert(evo.set(e4, f1, 47)) + assert(evo.set(e4, f2, 48)) + assert(evo.set(e4, f3, 49)) + assert(evo.set(e4, f4, 50)) local e5 = evo.id() - assert(evo.insert(e5, f2, 51)) - assert(evo.insert(e5, f3, 52)) - assert(evo.insert(e5, f4, 53)) + assert(evo.set(e5, f2, 51)) + assert(evo.set(e5, f3, 52)) + assert(evo.set(e5, f4, 53)) local q = evo.id() - evo.insert(q, evo.INCLUDES, f1, f2) + evo.set(q, evo.INCLUDES, f1, f2) assert(evo.batch_destroy(q) == 3) assert(entity_sum == e2 * 2 + e3 * 3 + e4 * 4) @@ -1203,30 +1199,30 @@ do local f1, f2, f3, f4 = evo.id(4) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 42)) - assert(evo.insert(e2, f2, 43)) + assert(evo.set(e2, f1, 42)) + assert(evo.set(e2, f2, 43)) local e3 = evo.id() - assert(evo.insert(e3, f1, 44)) - assert(evo.insert(e3, f2, 45)) - assert(evo.insert(e3, f3, 46)) + assert(evo.set(e3, f1, 44)) + assert(evo.set(e3, f2, 45)) + assert(evo.set(e3, f3, 46)) local e4 = evo.id() - assert(evo.insert(e4, f1, 47)) - assert(evo.insert(e4, f2, 48)) - assert(evo.insert(e4, f3, 49)) - assert(evo.insert(e4, f4, 50)) + assert(evo.set(e4, f1, 47)) + assert(evo.set(e4, f2, 48)) + assert(evo.set(e4, f3, 49)) + assert(evo.set(e4, f4, 50)) local e5 = evo.id() - assert(evo.insert(e5, f2, 51)) - assert(evo.insert(e5, f3, 52)) - assert(evo.insert(e5, f4, 53)) + assert(evo.set(e5, f2, 51)) + assert(evo.set(e5, f3, 52)) + assert(evo.set(e5, f4, 53)) local q = evo.id() - evo.insert(q, evo.INCLUDES, f1, f2) + evo.set(q, evo.INCLUDES, f1, f2) assert(evo.batch_remove(q, f2, f3) == 3) @@ -1276,30 +1272,30 @@ do end) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 42)) - assert(evo.insert(e2, f2, 43)) + assert(evo.set(e2, f1, 42)) + assert(evo.set(e2, f2, 43)) local e3 = evo.id() - assert(evo.insert(e3, f1, 44)) - assert(evo.insert(e3, f2, 45)) - assert(evo.insert(e3, f3, 46)) + assert(evo.set(e3, f1, 44)) + assert(evo.set(e3, f2, 45)) + assert(evo.set(e3, f3, 46)) local e4 = evo.id() - assert(evo.insert(e4, f1, 47)) - assert(evo.insert(e4, f2, 48)) - assert(evo.insert(e4, f3, 49)) - assert(evo.insert(e4, f4, 50)) + assert(evo.set(e4, f1, 47)) + assert(evo.set(e4, f2, 48)) + assert(evo.set(e4, f3, 49)) + assert(evo.set(e4, f4, 50)) local e5 = evo.id() - assert(evo.insert(e5, f2, 51)) - assert(evo.insert(e5, f3, 52)) - assert(evo.insert(e5, f4, 53)) + assert(evo.set(e5, f2, 51)) + assert(evo.set(e5, f3, 52)) + assert(evo.set(e5, f4, 53)) local q = evo.id() - evo.insert(q, evo.INCLUDES, f1, f2) + evo.set(q, evo.INCLUDES, f1, f2) assert(evo.batch_remove(q, f2, f3, f3) == 3) assert(entity_sum == e2 + e3 * 2 + e4 * 2) @@ -1324,8 +1320,8 @@ do 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) + local q = evo.query():include(f1):exclude(f2):build() + assert(evo.batch_set(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) @@ -1334,26 +1330,27 @@ do local f1, f2, f3, f4 = evo.id(4) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 42)) - assert(evo.insert(e2, f2, 43)) + assert(evo.set(e2, f1, 42)) + assert(evo.set(e2, f2, 43)) local e3 = evo.id() - assert(evo.insert(e3, f1, 44)) - assert(evo.insert(e3, f2, 45)) - assert(evo.insert(e3, f3, 46)) + assert(evo.set(e3, f1, 44)) + assert(evo.set(e3, f2, 45)) + assert(evo.set(e3, f3, 46)) local e4 = evo.id() - assert(evo.insert(e4, f2, 48)) - assert(evo.insert(e4, f3, 49)) - assert(evo.insert(e4, f4, 50)) + assert(evo.set(e4, f2, 48)) + assert(evo.set(e4, f3, 49)) + assert(evo.set(e4, f4, 50)) local q = evo.id() - evo.insert(q, evo.INCLUDES, f2) + evo.set(q, evo.INCLUDES, f2) + evo.set(q, evo.EXCLUDES, f1) - assert(evo.batch_insert(q, f1, 60) == 1) + assert(evo.batch_set(q, f1, 60) == 1) assert(evo.get(e1, f1) == 41) assert(evo.get(e2, f1) == 42) @@ -1379,28 +1376,29 @@ do end) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 42)) - assert(evo.insert(e2, f2, 43)) + assert(evo.set(e2, f1, 42)) + assert(evo.set(e2, f2, 43)) local e3 = evo.id() - assert(evo.insert(e3, f1, 44)) - assert(evo.insert(e3, f2, 45)) - assert(evo.insert(e3, f3, 46)) + assert(evo.set(e3, f1, 44)) + assert(evo.set(e3, f2, 45)) + assert(evo.set(e3, f3, 46)) local e4 = evo.id() - assert(evo.insert(e4, f2, 48)) - assert(evo.insert(e4, f3, 49)) - assert(evo.insert(e4, f4, 50)) + assert(evo.set(e4, f2, 48)) + assert(evo.set(e4, f3, 49)) + assert(evo.set(e4, f4, 50)) local q = evo.id() - evo.insert(q, evo.INCLUDES, f2) + evo.set(q, evo.INCLUDES, f2) + evo.set(q, evo.EXCLUDES, f1) entity_sum = 0 component_sum = 0 - assert(evo.batch_insert(q, f1, 60) == 1) + assert(evo.batch_set(q, f1, 60) == 1) assert(entity_sum == e4) assert(component_sum == 60) @@ -1409,9 +1407,11 @@ do assert(evo.get(e3, f1) == 44) assert(evo.get(e4, f1) == 60) + evo.set(q, evo.EXCLUDES) + entity_sum = 0 component_sum = 0 - assert(evo.batch_insert(q, f5, 70) == 3) + assert(evo.batch_set(q, f5, 70) == 3) assert(entity_sum == e2 + e3 + e4) assert(component_sum == 70 * 3) end @@ -1422,24 +1422,24 @@ do local f1, f2, f3, f4 = evo.id(4) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 42)) - assert(evo.insert(e2, f2, 43)) + assert(evo.set(e2, f1, 42)) + assert(evo.set(e2, f2, 43)) local e3 = evo.id() - assert(evo.insert(e3, f1, 44)) - assert(evo.insert(e3, f2, 45)) - assert(evo.insert(e3, f3, 46)) + assert(evo.set(e3, f1, 44)) + assert(evo.set(e3, f2, 45)) + assert(evo.set(e3, f3, 46)) local e4 = evo.id() - assert(evo.insert(e4, f2, 48)) - assert(evo.insert(e4, f3, 49)) - assert(evo.insert(e4, f4, 50)) + assert(evo.set(e4, f2, 48)) + assert(evo.set(e4, f3, 49)) + assert(evo.set(e4, f4, 50)) local q = evo.id() - evo.insert(q, evo.INCLUDES, f2) + evo.set(q, evo.INCLUDES, f2) assert(evo.batch_set(q, f1, 60) == 3) @@ -1467,24 +1467,24 @@ do end) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 42)) - assert(evo.insert(e2, f2, 43)) + assert(evo.set(e2, f1, 42)) + assert(evo.set(e2, f2, 43)) local e3 = evo.id() - assert(evo.insert(e3, f1, 44)) - assert(evo.insert(e3, f2, 45)) - assert(evo.insert(e3, f3, 46)) + assert(evo.set(e3, f1, 44)) + assert(evo.set(e3, f2, 45)) + assert(evo.set(e3, f3, 46)) local e4 = evo.id() - assert(evo.insert(e4, f2, 48)) - assert(evo.insert(e4, f3, 49)) - assert(evo.insert(e4, f4, 50)) + assert(evo.set(e4, f2, 48)) + assert(evo.set(e4, f3, 49)) + assert(evo.set(e4, f4, 50)) local q = evo.id() - evo.insert(q, evo.INCLUDES, f2) + evo.set(q, evo.INCLUDES, f2) entity_sum = 0 component_sum = 0 @@ -1626,64 +1626,22 @@ do local e = evo.id() last_set_entity = 0 - assert(evo.insert(e, f1)) + assert(evo.set(e, f1)) assert(last_set_entity == e) assert(evo.has(e, f1) and not evo.has(e, f2)) assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil) - do - last_set_entity = 0 - assert(not evo.insert(e, f1)) - assert(last_set_entity == 0) - assert(evo.has(e, f1) and not evo.has(e, f2)) - assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil) - end - last_set_entity = 0 - assert(evo.insert(e, f2, 42)) + assert(evo.set(e, f2, 42)) assert(last_set_entity == e) assert(evo.has(e, f1) and evo.has(e, f2)) assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil) - do - last_set_entity = 0 - assert(not evo.insert(e, f1)) - assert(last_set_entity == 0) - assert(evo.has(e, f1) and evo.has(e, f2)) - assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil) - - last_set_entity = 0 - assert(not evo.insert(e, f2, 42)) - assert(last_set_entity == 0) - assert(evo.has(e, f1) and evo.has(e, f2)) - assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil) - end - last_set_entity = 0 - assert(evo.insert(e, f3, 43)) + assert(evo.set(e, f3, 43)) assert(last_set_entity == e) assert(evo.has(e, f1) and evo.has(e, f2) and evo.has(e, f3)) assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil and evo.get(e, f3) == 43) - - do - last_set_entity = 0 - assert(not evo.insert(e, f1)) - assert(last_set_entity == 0) - assert(evo.has(e, f1) and evo.has(e, f2) and evo.has(e, f3)) - assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil and evo.get(e, f3) == 43) - - last_set_entity = 0 - assert(not evo.insert(e, f2, 42)) - assert(last_set_entity == 0) - assert(evo.has(e, f1) and evo.has(e, f2)) - assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil and evo.get(e, f3) == 43) - - last_set_entity = 0 - assert(not evo.insert(e, f3, 44)) - assert(last_set_entity == 0) - assert(evo.has(e, f1) and evo.has(e, f2) and evo.has(e, f3)) - assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil and evo.get(e, f3) == 43) - end end do @@ -1691,17 +1649,12 @@ do do last_assign_entity = 0 - assert(not evo.assign(e, f1)) - assert(last_assign_entity == 0) - assert(not evo.has(e, f1) and not evo.has(e, f2)) - assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil) - - assert(evo.insert(e, f1)) + assert(evo.set(e, f1)) assert(evo.has(e, f1) and not evo.has(e, f2)) assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil) last_assign_entity = 0 - assert(evo.assign(e, f1)) + assert(evo.set(e, f1)) assert(last_assign_entity == e) assert(evo.has(e, f1) and not evo.has(e, f2)) assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil) @@ -1709,17 +1662,12 @@ do do last_assign_entity = 0 - assert(not evo.assign(e, f2, 43)) - assert(last_assign_entity == 0) - assert(evo.has(e, f1) and not evo.has(e, f2)) - assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil) - - assert(evo.insert(e, f2, 43)) + assert(evo.set(e, f2, 43)) assert(evo.has(e, f1) and evo.has(e, f2)) assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil) last_assign_entity = 0 - assert(evo.assign(e, f2, 44)) + assert(evo.set(e, f2, 44)) assert(last_assign_entity == e) assert(evo.has(e, f1) and evo.has(e, f2)) assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil) @@ -1727,17 +1675,12 @@ do do last_assign_entity = 0 - assert(not evo.assign(e, f3, 44)) - assert(last_assign_entity == 0) - assert(evo.has(e, f1) and evo.has(e, f2) and not evo.has(e, f3)) - assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil and evo.get(e, f3) == nil) - - assert(evo.insert(e, f3, 44)) + assert(evo.set(e, f3, 44)) assert(evo.has(e, f1) and evo.has(e, f2) and evo.has(e, f3)) assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil and evo.get(e, f3) == 44) last_assign_entity = 0 - assert(evo.assign(e, f3, 45)) + assert(evo.set(e, f3, 45)) assert(last_assign_entity == e) assert(evo.has(e, f1) and evo.has(e, f2) and evo.has(e, f3)) assert(evo.get(e, f1) == nil and evo.get(e, f2) == nil and evo.get(e, f3) == 45) @@ -1747,7 +1690,7 @@ do do do local e = evo.id() - assert(evo.insert(e, f1, 41)) + assert(evo.set(e, f1, 41)) last_remove_entity = 0 assert(evo.remove(e, f1)) @@ -1758,8 +1701,8 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 41)) - assert(evo.insert(e, f2, 42)) + assert(evo.set(e, f1, 41)) + assert(evo.set(e, f2, 42)) last_remove_entity = 0 assert(evo.remove(e, f1, f2)) @@ -1770,9 +1713,9 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 41)) - assert(evo.insert(e, f2, 42)) - assert(evo.insert(e, f3, 43)) + assert(evo.set(e, f1, 41)) + assert(evo.set(e, f2, 42)) + assert(evo.set(e, f3, 43)) last_remove_entity = 0 assert(evo.remove(e, f1, f2, f3)) @@ -1782,9 +1725,9 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 41)) - assert(evo.insert(e, f2, 42)) - assert(evo.insert(e, f3, 43)) + assert(evo.set(e, f1, 41)) + assert(evo.set(e, f2, 42)) + assert(evo.set(e, f3, 43)) last_remove_entity = 0 assert(evo.remove(e, f3)) @@ -1801,7 +1744,7 @@ do do do local e = evo.id() - assert(evo.insert(e, f1, 41)) + assert(evo.set(e, f1, 41)) last_remove_entity = 0 assert(evo.clear(e) and evo.is_alive(e)) @@ -1812,8 +1755,8 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 41)) - assert(evo.insert(e, f2, 42)) + assert(evo.set(e, f1, 41)) + assert(evo.set(e, f2, 42)) last_remove_entity = 0 assert(evo.clear(e) and evo.is_alive(e)) @@ -1824,9 +1767,9 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 41)) - assert(evo.insert(e, f2, 42)) - assert(evo.insert(e, f3, 43)) + assert(evo.set(e, f1, 41)) + assert(evo.set(e, f2, 42)) + assert(evo.set(e, f3, 43)) last_remove_entity = 0 assert(evo.clear(e) and evo.is_alive(e)) @@ -1839,7 +1782,7 @@ do do do local e = evo.id() - assert(evo.insert(e, f1, 41)) + assert(evo.set(e, f1, 41)) last_remove_entity = 0 assert(evo.destroy(e) and not evo.is_alive(e)) @@ -1850,8 +1793,8 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 41)) - assert(evo.insert(e, f2, 42)) + assert(evo.set(e, f1, 41)) + assert(evo.set(e, f2, 42)) last_remove_entity = 0 assert(evo.destroy(e) and not evo.is_alive(e)) @@ -1862,9 +1805,9 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 41)) - assert(evo.insert(e, f2, 42)) - assert(evo.insert(e, f3, 43)) + assert(evo.set(e, f1, 41)) + assert(evo.set(e, f2, 42)) + assert(evo.set(e, f3, 43)) last_remove_entity = 0 assert(evo.destroy(e) and not evo.is_alive(e)) @@ -1886,37 +1829,39 @@ do do local e = evo.id() - assert(evo.batch_assign(q, f1, 50) == 0) + assert(evo.batch_set(q, f1, 50) == 0) assert(not evo.has(e, f1)) assert(evo.get(e, f1) == nil) end do local e = evo.id() - assert(evo.insert(e, f1, 41)) + assert(evo.set(e, f1, 41)) - assert(evo.batch_assign(q, f1, 50) == 0) + assert(evo.batch_set(q, f1, 50) == 0) assert(evo.has(e, f1)) assert(evo.get(e, f1) == nil) end do local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) - assert(evo.insert(e1, f2, 42)) + assert(evo.set(e1, f1, 41)) + assert(evo.set(e1, f2, 42)) local e2 = evo.id() - assert(evo.insert(e2, f1, 41)) - assert(evo.insert(e2, f2, 42)) - assert(evo.insert(e2, f3, 43)) + assert(evo.set(e2, f1, 41)) + assert(evo.set(e2, f2, 42)) + assert(evo.set(e2, f3, 43)) - assert(evo.batch_assign(q, f1, 50) == 2) + assert(evo.batch_set(q, f1, 50) == 2) assert(evo.has(e1, f1) and evo.has(e1, f2) and not evo.has(e1, f3)) assert(evo.has(e2, f1) and evo.has(e2, f2) and evo.has(e2, f3)) assert(evo.get(e1, f1) == nil and evo.get(e1, f2) == nil) assert(evo.get(e2, f1) == nil and evo.get(e2, f2) == nil and evo.get(e2, f3) == 43) - assert(evo.batch_assign(q, f3, 51) == 1) + evo.set(q, evo.INCLUDES, f1, f2, f3) + assert(evo.batch_set(q, f3, 51) == 1) + assert(evo.has(e1, f1) and evo.has(e1, f2) and not evo.has(e1, f3)) assert(evo.has(e2, f1) and evo.has(e2, f2) and evo.has(e2, f3)) assert(evo.get(e1, f1) == nil and evo.get(e1, f2) == nil) @@ -1936,18 +1881,19 @@ do do local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) - assert(evo.insert(e1, f2, 42)) + assert(evo.set(e1, f1, 41)) + assert(evo.set(e1, f2, 42)) local e2 = evo.id() - assert(evo.insert(e2, f1, 41)) + assert(evo.set(e2, f1, 41)) local e3 = evo.id() - assert(evo.insert(e3, f1, 41)) - assert(evo.insert(e3, f2, 42)) - assert(evo.insert(e3, f3, 43)) + assert(evo.set(e3, f1, 41)) + assert(evo.set(e3, f2, 42)) + assert(evo.set(e3, f3, 43)) - assert(evo.batch_insert(q, f3, 50) == 1) + evo.set(q, evo.EXCLUDES, f3) + assert(evo.batch_set(q, f3, 50) == 1) assert(evo.has(e1, f1) and evo.has(e1, f2) and evo.has(e1, f3)) assert(evo.get(e1, f1) == nil and evo.get(e1, f2) == nil and evo.get(e1, f3) == 50) @@ -1983,16 +1929,16 @@ do do local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) - assert(evo.insert(e1, f2, 42)) + assert(evo.set(e1, f1, 41)) + assert(evo.set(e1, f2, 42)) local e2 = evo.id() - assert(evo.insert(e2, f1, 41)) + assert(evo.set(e2, f1, 41)) local e3 = evo.id() - assert(evo.insert(e3, f1, 41)) - assert(evo.insert(e3, f2, 42)) - assert(evo.insert(e3, f3, 43)) + assert(evo.set(e3, f1, 41)) + assert(evo.set(e3, f2, 42)) + assert(evo.set(e3, f3, 43)) assert(evo.batch_remove(q, f1) == 2) @@ -2034,16 +1980,16 @@ do do local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) - assert(evo.insert(e1, f2, 42)) + assert(evo.set(e1, f1, 41)) + assert(evo.set(e1, f2, 42)) local e2 = evo.id() - assert(evo.insert(e2, f1, 41)) + assert(evo.set(e2, f1, 41)) local e3 = evo.id() - assert(evo.insert(e3, f1, 41)) - assert(evo.insert(e3, f2, 42)) - assert(evo.insert(e3, f3, 43)) + assert(evo.set(e3, f1, 41)) + assert(evo.set(e3, f2, 42)) + assert(evo.set(e3, f3, 43)) assert(evo.batch_clear(q) == 2) @@ -2079,16 +2025,16 @@ do do local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) - assert(evo.insert(e1, f2, 42)) + assert(evo.set(e1, f1, 41)) + assert(evo.set(e1, f2, 42)) local e2 = evo.id() - assert(evo.insert(e2, f1, 41)) + assert(evo.set(e2, f1, 41)) local e3 = evo.id() - assert(evo.insert(e3, f1, 41)) - assert(evo.insert(e3, f2, 42)) - assert(evo.insert(e3, f3, 43)) + assert(evo.set(e3, f1, 41)) + assert(evo.set(e3, f2, 42)) + assert(evo.set(e3, f3, 43)) assert(evo.batch_destroy(q) == 2) @@ -2120,7 +2066,7 @@ do evo.set(q, evo.INCLUDES, f1) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) do assert(evo.defer()) @@ -2156,13 +2102,13 @@ do evo.set(q, evo.INCLUDES, f1) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) do assert(evo.defer()) do - local c, d = evo.batch_assign(q, f1, 42) + local c, d = evo.batch_set(q, f1, 42) assert(c == 0 and d == true) end assert(evo.get(e1, f1) == 41) @@ -2175,7 +2121,8 @@ do assert(evo.defer()) do - local c, d = evo.batch_assign(q, f2, 43) + evo.set(q, evo.INCLUDES, f1, f2) + local c, d = evo.batch_set(q, f2, 43) assert(c == 0 and d == true) end assert(evo.get(e1, f2) == nil) @@ -2192,13 +2139,14 @@ do evo.set(q, evo.INCLUDES, f1) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) do assert(evo.defer()) do - local c, d = evo.batch_insert(q, f1, 42) + evo.set(q, evo.EXCLUDES, f1) + local c, d = evo.batch_set(q, f1, 42) assert(c == 0 and d == true) end assert(evo.get(e1, f1) == 41) @@ -2211,7 +2159,8 @@ do assert(evo.defer()) do - local c, d = evo.batch_insert(q, f2, 43) + evo.set(q, evo.EXCLUDES) + local c, d = evo.batch_set(q, f2, 43) assert(c == 0 and d == true) end assert(evo.get(e1, f2) == nil) @@ -2228,7 +2177,7 @@ do evo.set(q, evo.INCLUDES, f1) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) do assert(evo.defer()) @@ -2251,7 +2200,7 @@ do evo.set(q, evo.INCLUDES, f1) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) do assert(evo.defer()) @@ -2276,7 +2225,7 @@ do evo.set(q, evo.INCLUDES, f1) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) do assert(evo.defer()) @@ -2302,10 +2251,10 @@ do evo.set(q, evo.INCLUDES, f2) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f2, 42)) + assert(evo.set(e2, f2, 42)) do local iter, state = evo.execute(q) @@ -2327,12 +2276,12 @@ do evo.set(q, evo.INCLUDES, f1) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) - assert(evo.insert(e1, f2, 42)) + assert(evo.set(e1, f1, 41)) + assert(evo.set(e1, f2, 42)) local e2 = evo.id() - assert(evo.insert(e2, f1, 43)) - assert(evo.insert(e2, f3, 44)) + assert(evo.set(e2, f1, 43)) + assert(evo.set(e2, f3, 44)) do local entity_sum = 0 @@ -2358,11 +2307,11 @@ do evo.set(q, evo.EXCLUDES, f2) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 43)) - assert(evo.insert(e2, f2, 44)) + assert(evo.set(e2, f1, 43)) + assert(evo.set(e2, f2, 44)) do local iter, state = evo.execute(q) @@ -2399,11 +2348,11 @@ do local q = evo.id() local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 43)) - assert(evo.insert(e2, f2, 44)) + assert(evo.set(e2, f1, 43)) + assert(evo.set(e2, f2, 44)) do local iter, state = evo.execute(q) @@ -2442,7 +2391,7 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 41)) + assert(evo.set(e, f1, 41)) local iter, state = evo.each(e) local fragment, component = iter(state) @@ -2454,8 +2403,8 @@ do do local e = evo.id() - assert(evo.insert(e, f1, 41)) - assert(evo.insert(e, f2, 42)) + assert(evo.set(e, f1, 41)) + assert(evo.set(e, f2, 42)) do local iter, state = evo.each(e) @@ -2488,8 +2437,8 @@ do evo.set(s, evo.TAG) local e = evo.id() - assert(evo.insert(e, f1)) - assert(evo.insert(e, s)) + assert(evo.set(e, f1)) + assert(evo.set(e, s)) do local iter, state = evo.each(e) @@ -2645,10 +2594,10 @@ do local e2 = evo.entity():set(f1, 42):set(f1, 41):build() assert(f1_assign_count == 0 and f1_insert_count == 2) - assert(evo.assign(e1, f1, 42)) + assert(evo.set(e1, f1, 42)) assert(f1_assign_count == 1 and f1_insert_count == 2) - assert(evo.assign(e2, f1, 42)) + assert(evo.set(e2, f1, 42)) assert(f1_assign_count == 2 and f1_insert_count == 2) assert(evo.get(e1, f1) == 42 and evo.get(e2, f1) == 42) @@ -2677,30 +2626,27 @@ do do local e = evo.id() - assert(not evo.multi_insert(e, {})) - assert(not evo.multi_insert(e, {}, {})) - assert(not evo.multi_insert(e, {}, { 41 })) + assert(not evo.multi_set(e, {})) + assert(not evo.multi_set(e, {}, {})) + assert(not evo.multi_set(e, {}, { 41 })) assert(evo.is_alive(e) and evo.is_empty(e)) - assert(evo.multi_insert(e, { f1 })) + assert(evo.multi_set(e, { f1 })) assert(evo.has(e, f1) and evo.get(e, f1) == true) - assert(not evo.multi_insert(e, { f1 })) - assert(evo.has(e, f1) and evo.get(e, f1) == true) - - assert(evo.multi_insert(e, { f2 }, { 42, 43 })) + assert(evo.multi_set(e, { f2 }, { 42, 43 })) assert(evo.has(e, f1) and evo.get(e, f1) == true) assert(evo.has(e, f2) and evo.get(e, f2) == 42) end do local e = evo.id() - assert(evo.multi_insert(e, { f1, f2 }, { 41 })) + assert(evo.multi_set(e, { f1, f2 }, { 41 })) assert(evo.has(e, f1) and evo.get(e, f1) == 41) assert(evo.has(e, f2) and evo.get(e, f2) == true) - assert(evo.multi_insert(e, { f1, f3 }, { 20, 43 })) - assert(evo.has(e, f1) and evo.get(e, f1) == 41) + assert(evo.multi_set(e, { f1, f3 }, { 20, 43 })) + assert(evo.has(e, f1) and evo.get(e, f1) == 20) assert(evo.has(e, f2) and evo.get(e, f2) == true) assert(evo.has(e, f3) and evo.get(e, f3) == 43) end @@ -2711,16 +2657,16 @@ do do local e1 = evo.id() - assert(evo.multi_insert(e1, { f1, f2 }, { 41, 42 })) + assert(evo.multi_set(e1, { f1, f2 }, { 41, 42 })) assert(evo.has(e1, f1) and evo.get(e1, f1) == 41) assert(evo.has(e1, f2) and evo.get(e1, f2) == 42) local e2 = evo.id() - assert(evo.multi_insert(e2, { f1, f2 }, { 43, 44 })) + assert(evo.multi_set(e2, { f1, f2 }, { 43, 44 })) assert(evo.has(e2, f1) and evo.get(e2, f1) == 43) assert(evo.has(e2, f2) and evo.get(e2, f2) == 44) - assert(evo.multi_insert(e1, { f3 })) + assert(evo.multi_set(e1, { f3 })) do local chunk, entities = evo.chunk(f1, f2) assert(entities and #entities == 1 and entities[1] == e2) @@ -2732,15 +2678,15 @@ do local e1, e2 = evo.id(2) evo.defer() do - evo.multi_insert(e1, { f1, f2 }, { 41, 42 }) - evo.multi_insert(e2, { f2, f2 }, { 43, 44 }) + evo.multi_set(e1, { f1, f2 }, { 41, 42 }) + evo.multi_set(e2, { f2, f2 }, { 43, 44 }) end assert(evo.is_alive(e1) and evo.is_empty(e1)) assert(evo.is_alive(e2) and evo.is_empty(e2)) assert(evo.commit()) assert(evo.has(e1, f1) and evo.get(e1, f1) == 41) assert(evo.has(e1, f2) and evo.get(e1, f2) == 42) - assert(evo.has(e2, f2) and evo.get(e2, f2) == 43) + assert(evo.has(e2, f2) and evo.get(e2, f2) == 44) end end @@ -2772,43 +2718,37 @@ do do local e = evo.id() - assert(evo.multi_insert(e, { f1, f2 }, { 41, 42 })) + assert(evo.multi_set(e, { f1, f2 }, { 41, 42 })) assert(last_set_entity == e and last_set_component == 42) end do local e = evo.id() - assert(evo.multi_insert(e, { f1, f2, f3 }, { 41, 42, 43 })) + assert(evo.multi_set(e, { f1, f2, f3 }, { 41, 42, 43 })) assert(last_set_entity == e and last_set_component == nil) end end do - local f1, f2, f3 = evo.id(3) + local f1, f2 = evo.id(2) do local e = evo.id() - assert(not evo.multi_assign(e, {})) - assert(not evo.multi_assign(e, {}, {})) - assert(not evo.multi_assign(e, {}, { 41 })) + assert(not evo.multi_set(e, {})) + assert(not evo.multi_set(e, {}, {})) + assert(not evo.multi_set(e, {}, { 41 })) assert(evo.is_alive(e) and evo.is_empty(e)) - assert(evo.multi_insert(e, { f1 }, { 21 })) - assert(evo.multi_assign(e, { f1, f2 }, { 41, 42 })) - assert(not evo.multi_assign(e, { f2 }, { 42 })) + assert(evo.multi_set(e, { f1 }, { 21 })) + assert(evo.multi_set(e, { f1 }, { 41 })) assert(evo.has(e, f1) and evo.get(e, f1) == 41) assert(not evo.has(e, f2) and evo.get(e, f2) == nil) - assert(not evo.multi_assign(e, { f3 }, { 43 })) - assert(evo.has(e, f1) and evo.get(e, f1) == 41) - assert(not evo.has(e, f2) and evo.get(e, f2) == nil) - assert(not evo.has(e, f3) and evo.get(e, f3) == nil) - - assert(evo.multi_insert(e, { f2 }, { 22 })) - assert(evo.multi_assign(e, { f2 })) + assert(evo.multi_set(e, { f2 }, { 22 })) + assert(evo.multi_set(e, { f2 })) assert(evo.has(e, f1) and evo.get(e, f1) == 41) assert(evo.has(e, f2) and evo.get(e, f2) == true) - assert(evo.multi_assign(e, { f2 }, { 42, 43 })) + assert(evo.multi_set(e, { f2 }, { 42, 43 })) assert(evo.has(e, f1) and evo.get(e, f1) == 41) assert(evo.has(e, f2) and evo.get(e, f2) == 42) end @@ -2817,11 +2757,11 @@ do local e1, e2 = evo.id(2) evo.defer() do - evo.multi_insert(e1, { f1, f2 }, { 21, 22 }) - evo.multi_assign(e1, { f1, f2 }, { 41, 42 }) + evo.multi_set(e1, { f1, f2 }, { 21, 22 }) + evo.multi_set(e1, { f1, f2 }, { 41, 42 }) - evo.multi_insert(e2, { f1, f2 }, { 31, 32 }) - evo.multi_assign(e2, { f1, f2 }, { 51, 52 }) + evo.multi_set(e2, { f1, f2 }, { 31, 32 }) + evo.multi_set(e2, { f1, f2 }, { 51, 52 }) end assert(evo.is_alive(e1) and evo.is_empty(e1)) assert(evo.is_alive(e2) and evo.is_empty(e2)) @@ -2861,23 +2801,20 @@ do do local e = evo.id() - assert(not evo.multi_assign(e, { f1, f2 }, { 41, 42 })) - assert(last_set_entity == 0 and last_set_component == 0) - - assert(evo.multi_insert(e, { f1, f2 }, { 21, 22 })) + assert(evo.multi_set(e, { f1, f2 }, { 21, 22 })) assert(last_set_entity == e and last_set_component == 22) - assert(evo.multi_assign(e, { f1, f2 }, { 41, 42 })) + assert(evo.multi_set(e, { f1, f2 }, { 41, 42 })) assert(last_set_entity == e and last_set_component == 42) end do local e = evo.id() - assert(evo.multi_insert(e, { f1, f2, f3 }, { 21, 22, 23 })) + assert(evo.multi_set(e, { f1, f2, f3 }, { 21, 22, 23 })) assert(last_set_entity == e and last_set_component == nil) last_set_entity, last_set_component = 0, 0 - assert(evo.multi_assign(e, { f1, f2, f3 }, { 41, 42, 43 })) + assert(evo.multi_set(e, { f1, f2, f3 }, { 41, 42, 43 })) assert(last_set_entity == e and last_set_component == nil) assert(evo.has(e, f1) and evo.get(e, f1) == 41) assert(evo.has(e, f2) and evo.get(e, f2) == 42) @@ -2892,7 +2829,7 @@ do do local e = evo.id() - assert(evo.multi_insert(e, { f1, f2, f3 }, { 41, 42, 43 })) + assert(evo.multi_set(e, { f1, f2, f3 }, { 41, 42, 43 })) assert(evo.has_all(e, f1, f2, f3)) assert(evo.multi_remove(e, {})) @@ -2910,7 +2847,7 @@ do do local e = evo.id() - assert(evo.multi_insert(e, { f1, f2, f3 }, { 41, 42, 43 })) + assert(evo.multi_set(e, { f1, f2, f3 }, { 41, 42, 43 })) assert(evo.has_all(e, f1, f2, f3)) evo.defer() evo.multi_remove(e, { f1, f2 }) @@ -2951,7 +2888,7 @@ do assert(evo.multi_remove(e, { f1, f2 })) assert(last_remove_entity == 0 and last_remove_component == 0) - assert(evo.multi_insert(e, { f1, f2, f3 }, { 41, 42 })) + assert(evo.multi_set(e, { f1, f2, f3 }, { 41, 42 })) assert(last_remove_entity == 0 and last_remove_component == 0) assert(evo.multi_remove(e, { f1, f2 })) assert(last_remove_entity == e and last_remove_component == 42) @@ -2965,8 +2902,8 @@ do do local e1, e2 = evo.id(2) - assert(evo.multi_insert(e1, { f1, f2, f3 }, { 41, 42, 43 })) - assert(evo.multi_insert(e2, { f1, f2, f3 }, { 44, 45, 46 })) + assert(evo.multi_set(e1, { f1, f2, f3 }, { 41, 42, 43 })) + assert(evo.multi_set(e2, { f1, f2, f3 }, { 44, 45, 46 })) assert(evo.multi_remove(e1, { f1, f2 })) @@ -3160,8 +3097,8 @@ do insert_entity_sum, insert_component_sum = 0, 0 local e = evo.id() - assert(evo.insert(e, f1, 41)) - assert(evo.multi_assign(e, { f1, f1 }, { 42, 43 })) + assert(evo.set(e, f1, 41)) + assert(evo.multi_set(e, { f1, f1 }, { 42, 43 })) assert(assign_entity_sum == e + e and assign_component_sum == 42 + 43) assert(insert_entity_sum == e and insert_component_sum == 41) @@ -3172,7 +3109,7 @@ do insert_entity_sum, insert_component_sum = 0, 0 local e = evo.id() - assert(evo.multi_insert(e, { f1, f1 }, { 41, 42 })) + assert(evo.multi_set(e, { f1, f1 }, { 41, 42 })) assert(insert_entity_sum == e and insert_component_sum == 41) end @@ -3181,7 +3118,7 @@ do remove_entity_sum, remove_component_sum = 0, 0 local e = evo.id() - assert(evo.insert(e, f1, 41)) + assert(evo.set(e, f1, 41)) assert(evo.multi_remove(e, { f1, f1 })) assert(remove_entity_sum == e and remove_component_sum == 41) @@ -4024,14 +3961,18 @@ do do local q = evo.query():include(f1):build() - assert(evo.batch_multi_assign(q, {}) == 0) - assert(evo.batch_multi_assign(q, { f5 }) == 0) + assert(evo.batch_multi_set(q, {}) == 0) end do - local q = evo.query():include(f3):build() + local q = evo.query():include(f1, f5):build() + assert(evo.batch_multi_set(q, { f5 }) == 0) + end - assert(evo.batch_multi_assign(q, { f4 }, { 54 }) == 1) + do + local q = evo.query():include(f3, f4):build() + + assert(evo.batch_multi_set(q, { f4 }, { 54 }) == 1) assert(evo.get(e3, f3) == 33 and evo.get(e3, f4) == nil) assert(evo.get(e4, f3) == 43 and evo.get(e4, f4) == 54) end @@ -4039,15 +3980,15 @@ do do local q = evo.query():include(f2):build() - assert(evo.batch_multi_assign(q, { f1 }, { 51, 52 }) == 3) + assert(evo.batch_multi_set(q, { f1 }, { 51, 52 }) == 3) assert(evo.get(e1, f1) == 11 and evo.get(e1, f2) == nil and evo.get(e1, f3) == nil) assert(evo.get(e2, f1) == 51 and evo.get(e2, f2) == 22 and evo.get(e2, f3) == nil) assert(evo.get(e3, f1) == 51 and evo.get(e3, f2) == 32 and evo.get(e3, f3) == 33) assert(evo.get(e4, f1) == 51 and evo.get(e4, f2) == 42 and evo.get(e4, f3) == 43 and evo.get(e4, f4) == 54) - assert(evo.batch_multi_assign(q, { f2, f3 }, { 52, 53 }) == 3) + assert(evo.batch_multi_set(q, { f2, f3 }, { 52, 53 }) == 4) assert(evo.get(e1, f1) == 11 and evo.get(e1, f2) == nil and evo.get(e1, f3) == nil) - assert(evo.get(e2, f1) == 51 and evo.get(e2, f2) == 52 and evo.get(e2, f3) == nil) + assert(evo.get(e2, f1) == 51 and evo.get(e2, f2) == 52 and evo.get(e2, f3) == 53) assert(evo.get(e3, f1) == 51 and evo.get(e3, f2) == 52 and evo.get(e3, f3) == 53) assert(evo.get(e4, f1) == 51 and evo.get(e4, f2) == 52 and evo.get(e4, f3) == 53 and evo.get(e4, f4) == 54) end @@ -4071,14 +4012,14 @@ do do local q = evo.query():include(f1):build() - assert(evo.batch_multi_assign(q, {}) == 0) - assert(evo.batch_multi_assign(q, { f5 }) == 0) + assert(evo.batch_multi_set(q, {}) == 0) + assert(evo.batch_multi_set(q, { f5 }) == 0) end do - local q = evo.query():include(f3):build() + local q = evo.query():include(f3, f4):build() - assert(evo.batch_multi_assign(q, { f4 }, { 54 }) == 1) + assert(evo.batch_multi_set(q, { f4 }, { 54 }) == 1) assert(evo.get(e1, f1) == 11 and evo.get(e1, f2) == nil and evo.get(e1, f3) == nil) assert(evo.get(e2, f1) == 21 and evo.get(e2, f2) == 22 and evo.get(e2, f3) == nil) assert(evo.get(e3, f1) == 31 and evo.get(e3, f2) == 32 and evo.get(e3, f3) == nil) @@ -4088,13 +4029,13 @@ do do local q = evo.query():include(f2):build() - assert(evo.batch_multi_assign(q, { f1 }, { 51, 52 }) == 3) + assert(evo.batch_multi_set(q, { f1 }, { 51, 52 }) == 3) assert(evo.get(e1, f1) == 11 and evo.get(e1, f2) == nil and evo.get(e1, f3) == nil) assert(evo.get(e2, f1) == 51 and evo.get(e2, f2) == 22 and evo.get(e2, f3) == nil) assert(evo.get(e3, f1) == 51 and evo.get(e3, f2) == 32 and evo.get(e3, f3) == nil) assert(evo.get(e4, f1) == 51 and evo.get(e4, f2) == 42 and evo.get(e4, f3) == nil and evo.get(e4, f4) == 54) - assert(evo.batch_multi_assign(q, { f2, f3 }, { 52, 53 }) == 3) + assert(evo.batch_multi_set(q, { f2, f3 }, { 52, 53 }) == 4) assert(evo.get(e1, f1) == 11 and evo.get(e1, f2) == nil and evo.get(e1, f3) == nil) assert(evo.get(e2, f1) == 51 and evo.get(e2, f2) == 52 and evo.get(e2, f3) == nil) assert(evo.get(e3, f1) == 51 and evo.get(e3, f2) == 52 and evo.get(e3, f3) == nil) @@ -4104,14 +4045,14 @@ do do local q = evo.query():include(f1):build() - assert(evo.batch_multi_assign(q, { f1 }) == 4) + assert(evo.batch_multi_set(q, { f1 }) == 4) assert(evo.get(e1, f1) == true and evo.get(e1, f2) == nil and evo.get(e1, f3) == nil) assert(evo.get(e2, f1) == true and evo.get(e2, f2) == 52 and evo.get(e2, f3) == nil) assert(evo.get(e3, f1) == true and evo.get(e3, f2) == 52 and evo.get(e3, f3) == nil) assert(evo.get(e4, f1) == true and evo.get(e4, f2) == 52 and evo.get(e4, f3) == nil and evo.get(e4, f4) == 54) - assert(evo.batch_multi_assign(q, { f2 }) == 3) - assert(evo.get(e1, f1) == true and evo.get(e1, f2) == nil and evo.get(e1, f3) == nil) + assert(evo.batch_multi_set(q, { f2 }) == 4) + assert(evo.get(e1, f1) == true and evo.get(e1, f2) == 41 and evo.get(e1, f3) == nil) assert(evo.get(e2, f1) == true and evo.get(e2, f2) == 41 and evo.get(e2, f3) == nil) assert(evo.get(e3, f1) == true and evo.get(e3, f2) == 41 and evo.get(e3, f3) == nil) assert(evo.get(e4, f1) == true and evo.get(e4, f2) == 41 and evo.get(e4, f3) == nil and evo.get(e4, f4) == 54) @@ -4165,7 +4106,7 @@ do last_assign_new_component = 0 last_assign_old_component = 0 - assert(evo.batch_multi_assign(q, { f2 }, {}) == 1) + assert(evo.batch_multi_set(q, { f2 }, {}) == 1) assert(sum_entity == e3) assert(last_assign_entity == e3) assert(last_assign_new_component == 42) @@ -4180,7 +4121,7 @@ do last_assign_new_component = 0 last_assign_old_component = 0 - assert(evo.batch_multi_assign(q, { f1 }, { 51 }) == 3) + assert(evo.batch_multi_set(q, { f1 }, { 51 }) == 3) assert(sum_entity == e1 + e2 + e3) assert(last_assign_entity == e3) assert(last_assign_new_component == 51) @@ -4195,7 +4136,7 @@ do last_assign_new_component = 0 last_assign_old_component = 0 - assert(evo.batch_multi_assign(q, { f1, f1 }, { 61, 61 }) == 3) + assert(evo.batch_multi_set(q, { f1, f1 }, { 61, 61 }) == 3) assert(sum_entity == e1 + e2 + e3 + e1 + e2 + e3) assert(last_assign_entity == e3) assert(last_assign_new_component == 61) @@ -4203,14 +4144,14 @@ do end do - local q = evo.query():include(f1):build() + local q = evo.query():include(f1, f3):build() sum_entity = 0 last_assign_entity = 0 last_assign_new_component = 0 last_assign_old_component = 0 - assert(evo.batch_multi_assign(q, { f3 }, { 63 }) == 1) + assert(evo.batch_multi_set(q, { f3 }, { 63 }) == 1) assert(sum_entity == e3) assert(last_assign_entity == e3) assert(last_assign_new_component == nil) @@ -4229,14 +4170,13 @@ do do local q = evo.query():include(f1):build() - assert(evo.batch_multi_insert(q, {}) == 0) - assert(evo.batch_multi_insert(q, { f1 }) == 0) + assert(evo.batch_multi_set(q, {}) == 0) end do - local q = evo.query():include(f3):build() + local q = evo.query():include(f3):exclude(f4):build() - assert(evo.batch_multi_insert(q, { f4 }) == 1) + assert(evo.batch_multi_set(q, { f4 }) == 1) assert(evo.get(e3, f1) == 31 and evo.get(e3, f2) == 32 and evo.get(e3, f3) == 33 and evo.get(e3, f4) == true) assert(evo.get(e4, f1) == 41 and evo.get(e4, f2) == 42 and evo.get(e4, f3) == 43 and evo.get(e4, f4) == 44) @@ -4257,9 +4197,9 @@ do end do - local q = evo.query():include(f1):build() + local q = evo.query():include(f1):exclude(f3, f4):build() - assert(evo.batch_multi_insert(q, { f3, f4 }, { 53, 54 }) == 2) + assert(evo.batch_multi_set(q, { f3, f4 }, { 53, 54 }) == 2) assert(evo.get(e1, f1) == 11 and evo.get(e1, f2) == nil and evo.get(e1, f3) == 53 and evo.get(e1, f4) == 54) assert(evo.get(e2, f1) == 21 and evo.get(e2, f2) == 22 and evo.get(e2, f3) == 53 and evo.get(e2, f4) == 54) assert(evo.get(e3, f1) == 31 and evo.get(e3, f2) == 32 and evo.get(e3, f3) == 33 and evo.get(e3, f4) == true) @@ -4315,12 +4255,12 @@ do do local q = evo.query():include(f1):build() - assert(evo.batch_multi_insert(q, {}) == 0) + assert(evo.batch_multi_set(q, {}) == 0) end do - local q = evo.query():include(f1):build() - assert(evo.batch_multi_insert(q, { f2 }) == 1) + local q = evo.query():include(f1):exclude(f2):build() + assert(evo.batch_multi_set(q, { f2 }) == 1) assert(evo.get(e1, f1) == 11 and evo.get(e1, f2) == 41 and evo.get(e1, f3) == nil) assert(evo.get(e2, f1) == 21 and evo.get(e2, f2) == 22 and evo.get(e2, f3) == nil) @@ -4379,13 +4319,13 @@ do local e3 = evo.entity():set(f1, 31):set(f2, 32):set(f3, 33):build() do - local q = evo.query():include(f1):build() + local q = evo.query():include(f1):exclude(f2):build() sum_entity = 0 last_insert_entity = 0 last_insert_component = 0 - assert(evo.batch_multi_insert(q, { f2 }) == 1) + assert(evo.batch_multi_set(q, { f2 }) == 1) assert(sum_entity == e1) assert(last_insert_entity == e1) assert(last_insert_component == 42) @@ -4398,13 +4338,13 @@ do end do - local q = evo.query():include(f2):build() + local q = evo.query():include(f2):exclude(f3):build() sum_entity = 0 last_insert_entity = 0 last_insert_component = 0 - assert(evo.batch_multi_insert(q, { f3 }) == 2) + assert(evo.batch_multi_set(q, { f3 }) == 2) assert(sum_entity == e1 + e2) assert(last_insert_entity == e1) assert(last_insert_component == nil) @@ -4423,7 +4363,7 @@ do last_insert_entity = 0 last_insert_component = 0 - assert(evo.batch_multi_insert(q, { f3, f4, f5, f5 }, { 53, 54, 55, 65 }) == 3) + assert(evo.batch_multi_set(q, { f3, f4, f5, f5 }, { 53, 54, 55, 65 }) == 3) assert(sum_entity == e1 + e2 + e3 + e1 + e2 + e3) assert(last_insert_entity == e1) assert(last_insert_component == 55) @@ -4433,9 +4373,9 @@ do assert(evo.get(e1, f1) == 11 and evo.get(e1, f2) == 42 and evo.get(e1, f3) == nil) assert(evo.get(e2, f1) == 21 and evo.get(e2, f2) == 22 and evo.get(e2, f3) == nil) assert(evo.get(e3, f1) == 31 and evo.get(e3, f2) == 32 and evo.get(e3, f3) == nil) - assert(evo.get(e1, f4) == 54 and evo.get(e1, f5) == 55) - assert(evo.get(e2, f4) == 54 and evo.get(e2, f5) == 55) - assert(evo.get(e3, f4) == 54 and evo.get(e3, f5) == 55) + assert(evo.get(e1, f4) == 54 and evo.get(e1, f5) == 65) + assert(evo.get(e2, f4) == 54 and evo.get(e2, f5) == 65) + assert(evo.get(e3, f4) == 54 and evo.get(e3, f5) == 65) end end @@ -4809,16 +4749,18 @@ do assert(evo.defer()) do - local q = evo.query():include(f1):build() do - local n, d = evo.batch_multi_insert(q, { f2 }, { 42 }) + local q = evo.query():include(f1):exclude(f2):build() + local n, d = evo.batch_multi_set(q, { f2 }, { 42 }) assert(n == 0 and d == true) end do - local n, d = evo.batch_multi_assign(q, { f3 }, { 43 }) + local q = evo.query():include(f1, f3):build() + local n, d = evo.batch_multi_set(q, { f3 }, { 43 }) assert(n == 0 and d == true) end do + local q = evo.query():include(f1):build() local n, d = evo.batch_multi_remove(q, { f1 }) assert(n == 0 and d == true) end @@ -4899,25 +4841,27 @@ do local q = evo.query():include(f1):build() - assert(evo.batch_insert(q, f2) == 2) + assert(evo.set(q, evo.EXCLUDES, f2)) + assert(evo.batch_set(q, f2) == 2) assert(evo.get(e1a, f1) == 11 and evo.get(e1a, f2) == 42) assert(evo.get(e1b, f1) == 11 and evo.get(e1b, f2) == 42) assert(evo.get(e2a, f1) == 11 and evo.get(e2a, f2) == 22) assert(evo.get(e2b, f1) == 11 and evo.get(e2b, f2) == 22) - assert(evo.batch_assign(q, f2) == 4) + assert(evo.set(q, evo.EXCLUDES)) + assert(evo.batch_set(q, f2) == 4) assert(evo.get(e1a, f1) == 11 and evo.get(e1a, f2) == 42) assert(evo.get(e1b, f1) == 11 and evo.get(e1b, f2) == 42) assert(evo.get(e2a, f1) == 11 and evo.get(e2a, f2) == 42) assert(evo.get(e2b, f1) == 11 and evo.get(e2b, f2) == 42) - assert(evo.batch_assign(q, f1) == 4) + assert(evo.batch_set(q, f1) == 4) assert(evo.get(e1a, f1) == true and evo.get(e1a, f2) == 42) assert(evo.get(e1b, f1) == true and evo.get(e1b, f2) == 42) assert(evo.get(e2a, f1) == true and evo.get(e2a, f2) == 42) assert(evo.get(e2b, f1) == true and evo.get(e2b, f2) == 42) - assert(evo.batch_insert(q, f3) == 4) + assert(evo.batch_set(q, f3) == 4) assert(evo.get(e1a, f1) == true and evo.get(e1a, f2) == 42 and evo.get(e1a, f3) == true) assert(evo.get(e1b, f1) == true and evo.get(e1b, f2) == 42 and evo.get(e1b, f3) == true) assert(evo.get(e2a, f1) == true and evo.get(e2a, f2) == 42 and evo.get(e2a, f3) == true) @@ -4944,13 +4888,13 @@ do do local q = evo.query():include(fc):build() - evo.batch_insert(q, evo.ON_ASSIGN, function(e, f, c) + evo.batch_set(q, evo.ON_ASSIGN, function(e, f, c) assert(f == f1 or f == f2 or f == f3 or f == f4) sum_entity = sum_entity + e last_assign_entity = e last_assign_component = c end) - evo.batch_insert(q, evo.ON_INSERT, function(e, f, c) + evo.batch_set(q, evo.ON_INSERT, function(e, f, c) assert(f == f1 or f == f2 or f == f3 or f == f4) sum_entity = sum_entity + e last_insert_entity = e @@ -4965,13 +4909,13 @@ do local e2b = evo.entity():set(f1, 11):set(f2, 22):build() do - local q = evo.query():include(f1):build() + local q = evo.query():include(f1):exclude(f2):build() sum_entity = 0 last_insert_entity = 0 last_insert_component = 0 - assert(evo.batch_insert(q, f2) == 2) + assert(evo.batch_set(q, f2) == 2) assert(evo.get(e1a, f1) == 11 and evo.get(e1a, f2) == 42) assert(evo.get(e1b, f1) == 11 and evo.get(e1b, f2) == 42) assert(evo.get(e2a, f1) == 11 and evo.get(e2a, f2) == 22) @@ -4989,7 +4933,7 @@ do last_insert_entity = 0 last_insert_component = 0 - assert(evo.batch_insert(q, f3) == 4) + assert(evo.batch_set(q, f3) == 4) assert(evo.has_all(e1a, f1, f2, f3) and evo.has_all(e1b, f1, f2, f3)) assert(evo.has_all(e2a, f1, f2, f3) and evo.has_all(e2b, f1, f2, f3)) assert(evo.get(e1a, f1) == 11 and evo.get(e1a, f2) == 42 and evo.get(e1a, f3) == nil) @@ -5005,7 +4949,7 @@ do last_insert_entity = 0 last_insert_component = 0 - assert(evo.batch_insert(q, f4) == 4) + assert(evo.batch_set(q, f4) == 4) assert(evo.has_all(e1a, f1, f2, f3, f4) and evo.has_all(e1b, f1, f2, f3, f4)) assert(evo.has_all(e2a, f1, f2, f3, f4) and evo.has_all(e2b, f1, f2, f3, f4)) assert(evo.get(e1a, f1) == 11 and evo.get(e1a, f2) == 42 and evo.get(e1a, f3) == nil and evo.get(e1a, f4) == true) @@ -5021,7 +4965,7 @@ do last_assign_entity = 0 last_assign_component = 0 - assert(evo.batch_assign(q, f2) == 4) + assert(evo.batch_set(q, f2) == 4) assert(sum_entity == e1a + e1b + e2a + e2b) assert(last_assign_entity == e1b) assert(last_assign_component == 42) @@ -5030,7 +4974,7 @@ do last_assign_entity = 0 last_assign_component = 0 - assert(evo.batch_assign(q, f1) == 4) + assert(evo.batch_set(q, f1) == 4) assert(sum_entity == e1a + e1b + e2a + e2b) assert(last_assign_entity == e1b) assert(last_assign_component == true) @@ -5111,7 +5055,7 @@ do assert(evo.set(e, f1)) assert(evo.set(e, f2, 22)) - assert(evo.assign(e, f2)) + assert(evo.set(e, f2)) assert(evo.get(e, f1) == true and evo.get(e, f2) == true) @@ -5120,14 +5064,13 @@ do assert(not evo.has_all(e, f1, f2) and not evo.has_any(e, f1, f2)) assert(not evo.set(e, f1, 11)) - assert(not evo.assign(e, f1, 11)) - assert(not evo.insert(e, f1, 11)) + assert(not evo.set(e, f1, 11)) assert(evo.remove(e, f1)) assert(evo.clear(e)) assert(not evo.multi_set(e, { f1 }, { 11 })) - assert(not evo.multi_assign(e, { f1 }, { 11 })) - assert(not evo.multi_insert(e, { f1 }, { 11 })) + assert(not evo.multi_set(e, { f1 }, { 11 })) + assert(not evo.multi_set(e, { f1 }, { 11 })) assert(evo.multi_remove(e, { f1 })) end @@ -5184,9 +5127,9 @@ do assert(last_assign_f2_new_component == 42 and last_assign_f2_old_component == 22) assert(last_insert_f3_new_component == nil) - assert(evo.multi_assign(e, { f1, f2, f3 }, { 11, 22, 33 })) + assert(evo.multi_set(e, { f1, f2, f3 }, { 11, 22, 33 })) assert(evo.get(e, f1) == 11 and evo.get(e, f2) == 22 and evo.get(e, f3) == nil) - assert(evo.multi_assign(e, { f1, f2, f3 }, {})) + assert(evo.multi_set(e, { f1, f2, f3 }, {})) assert(evo.get(e, f1) == true and evo.get(e, f2) == 42 and evo.get(e, f3) == nil) end @@ -5211,8 +5154,8 @@ do last_insert_f2_new_component = 0 - assert(evo.multi_insert(e, { f2, f2 }, { nil, 22 })) - assert(evo.get(e, f2) == 42) + assert(evo.multi_set(e, { f2, f2 }, { nil, 22 })) + assert(evo.get(e, f2) == 22) assert(last_insert_f2_new_component == 42) end end @@ -5225,11 +5168,11 @@ do do local e = evo.id() - assert(evo.multi_insert(e, { f1, f2 })) + assert(evo.multi_set(e, { f1, f2 })) assert(evo.get(e, f1) == 41 and evo.get(e, f2) == true) - assert(evo.multi_assign(e, { f1, f2 }, { 11, 22 })) + assert(evo.multi_set(e, { f1, f2 }, { 11, 22 })) assert(evo.get(e, f1) == 11 and evo.get(e, f2) == 22) - assert(evo.multi_assign(e, { f1, f2 })) + assert(evo.multi_set(e, { f1, f2 })) assert(evo.get(e, f1) == 41 and evo.get(e, f2) == true) end end @@ -5316,12 +5259,12 @@ do end do local e1 = evo.id() - evo.insert(e1, f0) - evo.insert(e1, f1, 1) - evo.insert(e1, f2, 1, 2) - evo.insert(e1, f3, 1, 2, 3) - evo.insert(e1, f4, 1, 2, 3, 4) - evo.insert(e1, f5, 1, 2, 3, 4, 5) + evo.set(e1, f0) + evo.set(e1, f1, 1) + evo.set(e1, f2, 1, 2) + evo.set(e1, f3, 1, 2, 3) + evo.set(e1, f4, 1, 2, 3, 4) + evo.set(e1, f5, 1, 2, 3, 4, 5) assert(evo.get(e1, f0) == 42) assert(evo.get(e1, f1) == 1) assert(evo.get(e1, f2) == 1 + 2) @@ -5331,13 +5274,13 @@ do end do local e1 = evo.id() - evo.multi_insert(e1, { f0, f1, f2, f3, f4, f5 }) - evo.assign(e1, f0) - evo.assign(e1, f1, 1) - evo.assign(e1, f2, 1, 2) - evo.assign(e1, f3, 1, 2, 3) - evo.assign(e1, f4, 1, 2, 3, 4) - evo.assign(e1, f5, 1, 2, 3, 4, 5) + evo.multi_set(e1, { f0, f1, f2, f3, f4, f5 }) + evo.set(e1, f0) + evo.set(e1, f1, 1) + evo.set(e1, f2, 1, 2) + evo.set(e1, f3, 1, 2, 3) + evo.set(e1, f4, 1, 2, 3, 4) + evo.set(e1, f5, 1, 2, 3, 4, 5) assert(evo.get(e1, f0) == 42) assert(evo.get(e1, f1) == 1) assert(evo.get(e1, f2) == 1 + 2) @@ -5347,11 +5290,11 @@ do end do local e1, e2, e3, e4, e5 = evo.id(5) - evo.multi_insert(e1, { f1, f2, f3, f4, f5 }) - evo.multi_insert(e2, { f1, f2, f3, f4, f5 }) - evo.multi_insert(e3, { f1, f2, f3, f4, f5 }) - evo.multi_insert(e4, { f1, f2, f3, f4, f5 }) - evo.multi_insert(e5, { f1, f2, f3, f4, f5 }) + evo.multi_set(e1, { f1, f2, f3, f4, f5 }) + evo.multi_set(e2, { f1, f2, f3, f4, f5 }) + evo.multi_set(e3, { f1, f2, f3, f4, f5 }) + evo.multi_set(e4, { f1, f2, f3, f4, f5 }) + evo.multi_set(e5, { f1, f2, f3, f4, f5 }) evo.remove(e1, f0, f1) evo.remove(e2, f0, f1, f2) evo.remove(e3, f0, f1, f2, f3) @@ -5414,18 +5357,18 @@ do do local e1, e2 = evo.id(2) assert(evo.defer()) - evo.insert(e1, f0) - evo.insert(e1, f1, 1) - evo.insert(e1, f2, 1, 2) - evo.insert(e1, f3, 1, 2, 3) - evo.insert(e1, f4, 1, 2, 3, 4) - evo.insert(e1, f5, 1, 2, 3, 4, 5) - evo.insert(e2, f0) - evo.insert(e2, f1, 1) - evo.insert(e2, f2, 1, 2) - evo.insert(e2, f3, 1, 2, 3) - evo.insert(e2, f4, 1, 2, 3, 4) - evo.insert(e2, f5, 1, 2, 3, 4, 5) + evo.set(e1, f0) + evo.set(e1, f1, 1) + evo.set(e1, f2, 1, 2) + evo.set(e1, f3, 1, 2, 3) + evo.set(e1, f4, 1, 2, 3, 4) + evo.set(e1, f5, 1, 2, 3, 4, 5) + evo.set(e2, f0) + evo.set(e2, f1, 1) + evo.set(e2, f2, 1, 2) + evo.set(e2, f3, 1, 2, 3) + evo.set(e2, f4, 1, 2, 3, 4) + evo.set(e2, f5, 1, 2, 3, 4, 5) assert(evo.commit()) assert(evo.get(e1, f0) == 42) assert(evo.get(e1, f1) == 1) @@ -5442,21 +5385,21 @@ do end do local e1, e2 = evo.id(2) - evo.multi_insert(e1, { f0, f1, f2, f3, f4, f5 }) - evo.multi_insert(e2, { f0, f1, f2, f3, f4, f5 }) + evo.multi_set(e1, { f0, f1, f2, f3, f4, f5 }) + evo.multi_set(e2, { f0, f1, f2, f3, f4, f5 }) assert(evo.defer()) - evo.assign(e1, f0) - evo.assign(e1, f1, 1) - evo.assign(e1, f2, 1, 2) - evo.assign(e1, f3, 1, 2, 3) - evo.assign(e1, f4, 1, 2, 3, 4) - evo.assign(e1, f5, 1, 2, 3, 4, 5) - evo.assign(e2, f0) - evo.assign(e2, f1, 1) - evo.assign(e2, f2, 1, 2) - evo.assign(e2, f3, 1, 2, 3) - evo.assign(e2, f4, 1, 2, 3, 4) - evo.assign(e2, f5, 1, 2, 3, 4, 5) + evo.set(e1, f0) + evo.set(e1, f1, 1) + evo.set(e1, f2, 1, 2) + evo.set(e1, f3, 1, 2, 3) + evo.set(e1, f4, 1, 2, 3, 4) + evo.set(e1, f5, 1, 2, 3, 4, 5) + evo.set(e2, f0) + evo.set(e2, f1, 1) + evo.set(e2, f2, 1, 2) + evo.set(e2, f3, 1, 2, 3) + evo.set(e2, f4, 1, 2, 3, 4) + evo.set(e2, f5, 1, 2, 3, 4, 5) assert(evo.commit()) assert(evo.get(e1, f0) == 42) assert(evo.get(e1, f1) == 1) @@ -5473,11 +5416,11 @@ do end do local e1, e2, e3, e4, e5 = evo.id(5) - evo.multi_insert(e1, { f1, f2, f3, f4, f5 }) - evo.multi_insert(e2, { f1, f2, f3, f4, f5 }) - evo.multi_insert(e3, { f1, f2, f3, f4, f5 }) - evo.multi_insert(e4, { f1, f2, f3, f4, f5 }) - evo.multi_insert(e5, { f1, f2, f3, f4, f5 }) + evo.multi_set(e1, { f1, f2, f3, f4, f5 }) + evo.multi_set(e2, { f1, f2, f3, f4, f5 }) + evo.multi_set(e3, { f1, f2, f3, f4, f5 }) + evo.multi_set(e4, { f1, f2, f3, f4, f5 }) + evo.multi_set(e5, { f1, f2, f3, f4, f5 }) assert(evo.defer()) evo.remove(e1, f1) evo.remove(e2, f1, f2) @@ -5601,24 +5544,24 @@ do local e1 = evo.entity():set(fa):build() local e2 = evo.entity():set(fa):build() assert(evo.defer()) - evo.batch_insert(q0, f0) + evo.batch_set(q0, f0) assert(evo.commit()) assert(evo.get(e1, f0) == 42) assert(evo.get(e2, f0) == 42) assert(evo.defer()) - evo.batch_insert(q0, f1, 1) + evo.batch_set(q0, f1, 1) assert(evo.commit()) assert(evo.get(e1, f1) == 1) assert(evo.get(e2, f1) == 1) assert(evo.defer()) - evo.batch_insert(q0, f2, 1, 2) + evo.batch_set(q0, f2, 1, 2) assert(evo.commit()) assert(evo.get(e1, f1) == 1) assert(evo.get(e1, f2) == 1 + 2) assert(evo.get(e2, f1) == 1) assert(evo.get(e2, f2) == 1 + 2) assert(evo.defer()) - evo.batch_insert(q0, f3, 1, 2, 3) + evo.batch_set(q0, f3, 1, 2, 3) assert(evo.commit()) assert(evo.get(e1, f1) == 1) assert(evo.get(e1, f2) == 1 + 2) @@ -5627,7 +5570,7 @@ do assert(evo.get(e2, f2) == 1 + 2) assert(evo.get(e2, f3) == 1 + 2 + 3) assert(evo.defer()) - evo.batch_insert(q0, f4, 1, 2, 3, 4) + evo.batch_set(q0, f4, 1, 2, 3, 4) assert(evo.commit()) assert(evo.get(e1, f1) == 1) assert(evo.get(e1, f2) == 1 + 2) @@ -5638,7 +5581,7 @@ do assert(evo.get(e2, f3) == 1 + 2 + 3) assert(evo.get(e2, f4) == 1 + 2 + 3 + 4) assert(evo.defer()) - evo.batch_insert(q0, f5, 1, 2, 3, 4, 5) + evo.batch_set(q0, f5, 1, 2, 3, 4, 5) assert(evo.commit()) assert(evo.get(e1, f1) == 1) assert(evo.get(e1, f2) == 1 + 2) @@ -5655,22 +5598,22 @@ do local e1 = evo.entity():set(fa):build() local e2 = evo.entity():set(fa):build() assert(evo.defer()) - evo.batch_insert(q0, f0, 0) - evo.batch_assign(q0, f0) + evo.batch_set(q0, f0, 0) + evo.batch_set(q0, f0) assert(evo.commit()) assert(evo.get(e1, f0) == 42) assert(evo.get(e2, f0) == 42) assert(evo.defer()) - evo.batch_insert(q0, f1, 0) - evo.batch_assign(q0, f1, 1) + evo.batch_set(q0, f1, 0) + evo.batch_set(q0, f1, 1) assert(evo.commit()) assert(evo.get(e1, f0) == 42) assert(evo.get(e2, f0) == 42) assert(evo.get(e1, f1) == 1) assert(evo.get(e2, f1) == 1) assert(evo.defer()) - evo.batch_insert(q0, f2, 0, 0) - evo.batch_assign(q0, f2, 1, 2) + evo.batch_set(q0, f2, 0, 0) + evo.batch_set(q0, f2, 1, 2) assert(evo.commit()) assert(evo.get(e1, f0) == 42) assert(evo.get(e2, f0) == 42) @@ -5679,8 +5622,8 @@ do assert(evo.get(e2, f1) == 1) assert(evo.get(e2, f2) == 1 + 2) assert(evo.defer()) - evo.batch_insert(q0, f3, 0, 0, 0) - evo.batch_assign(q0, f3, 1, 2, 3) + evo.batch_set(q0, f3, 0, 0, 0) + evo.batch_set(q0, f3, 1, 2, 3) assert(evo.commit()) assert(evo.get(e1, f0) == 42) assert(evo.get(e2, f0) == 42) @@ -5691,8 +5634,8 @@ do assert(evo.get(e2, f2) == 1 + 2) assert(evo.get(e2, f3) == 1 + 2 + 3) assert(evo.defer()) - evo.batch_insert(q0, f4, 0, 0, 0, 0) - evo.batch_assign(q0, f4, 1, 2, 3, 4) + evo.batch_set(q0, f4, 0, 0, 0, 0) + evo.batch_set(q0, f4, 1, 2, 3, 4) assert(evo.commit()) assert(evo.get(e1, f0) == 42) assert(evo.get(e2, f0) == 42) @@ -5818,7 +5761,7 @@ do assert(evo.get(e, f1) == c) do - local s, d = evo.assign(e, f2, c) + local s, d = evo.set(e, f2, c) assert(s and not d) end end) @@ -5829,7 +5772,7 @@ do assert(evo.get(e, f1) == c) do - local s, d = evo.insert(e, f2, c) + local s, d = evo.set(e, f2, c) assert(s and not d) end end) @@ -5923,12 +5866,12 @@ do local e = evo.id() - assert(evo.insert(e, f1, 41)) + 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.assign(e, f1, 51)) + 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) @@ -5946,12 +5889,12 @@ do local e = evo.id() - assert(evo.multi_insert(e, { f1 }, { 41 })) + 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_assign(e, { f1 }, { 51 })) + 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) @@ -5969,7 +5912,7 @@ do local e = evo.id() - assert(evo.insert(e, f1, 51)) + assert(evo.set(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) @@ -5985,7 +5928,7 @@ do local e = evo.id() - assert(evo.insert(e, f1, 51)) + assert(evo.set(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) @@ -6067,7 +6010,7 @@ do remove_count = 0 local e = evo.id() - assert(evo.multi_insert(e, { f1, f2 }, { 41, 42 })) + assert(evo.multi_set(e, { f1, f2 }, { 41, 42 })) assert(assign_count == 0 and insert_count == 2 and remove_count == 0) end @@ -6078,8 +6021,8 @@ do 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_set(e, { f1, f2 }, { 41, 42 })) + assert(evo.multi_set(e, { f1, f2 }, { 51, 52 })) assert(evo.multi_remove(e, { f1, f2 })) assert(assign_count == 2 and insert_count == 2 and remove_count == 2) @@ -6091,8 +6034,8 @@ do 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_set(e, { f1, f2 }, { 41, 42 })) + assert(evo.multi_set(e, { f1, f2 }, { 51, 52 })) assert(evo.clear(e)) assert(assign_count == 2 and insert_count == 2 and remove_count == 2) @@ -6104,8 +6047,8 @@ do 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_set(e, { f1, f2 }, { 41, 42 })) + assert(evo.multi_set(e, { f1, f2 }, { 51, 52 })) assert(evo.destroy(e)) assert(assign_count == 2 and insert_count == 2 and remove_count == 2) @@ -6152,25 +6095,25 @@ do insert_count = 0 remove_count = 0 - assert(evo.insert(e1, f0) and evo.insert(e2, f0)) + assert(evo.set(e1, f0) and evo.set(e2, f0)) - assert(evo.batch_insert(q0, f1, 41)) + assert(evo.batch_set(q0, f1, 41)) assert(assign_count == 0 and insert_count == 2 and remove_count == 0) - assert(evo.batch_assign(q0, f1, 51)) + assert(evo.batch_set(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, 51)) + assert(evo.batch_set(q0, f1, 51)) 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, 51)) + assert(evo.set(e1, f0) and evo.set(e2, f0)) + assert(evo.batch_set(q0, f1, 51)) assert(assign_count == 2 and insert_count == 6 and remove_count == 4) assert(evo.batch_destroy(q0)) @@ -6259,12 +6202,12 @@ do insert_count = 0 remove_count = 0 - assert(evo.insert(e1, f0) and evo.insert(e2, f0)) + assert(evo.set(e1, f0) and evo.set(e2, f0)) - assert(evo.batch_multi_insert(q0, { f1, f2 }, { 41, 42 })) + assert(evo.batch_multi_set(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(evo.batch_multi_set(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 })) @@ -6291,19 +6234,19 @@ do end) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e12 = evo.id() - assert(evo.insert(e12, f1, 41)) - assert(evo.insert(e12, f2, 42)) + assert(evo.set(e12, f1, 41)) + assert(evo.set(e12, f2, 42)) local e35 = evo.id() - assert(evo.insert(e35, f3, 43)) - assert(evo.insert(e35, f5, 45)) + assert(evo.set(e35, f3, 43)) + assert(evo.set(e35, f5, 45)) local e34 = evo.id() - assert(evo.insert(e34, f3, 43)) - assert(evo.insert(e34, f4, 44)) + assert(evo.set(e34, f3, 43)) + assert(evo.set(e34, f4, 44)) evo.set(f1, evo.ON_ASSIGN, function() assign_count = assign_count + 1 @@ -6315,16 +6258,16 @@ do assert(assign_count == 0) - assert(evo.assign(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) assert(assign_count == 1) - assert(evo.assign(e12, f1, 42)) + assert(evo.set(e12, f1, 42)) assert(assign_count == 2) - assert(evo.assign(e34, f3, 43)) + assert(evo.set(e34, f3, 43)) assert(assign_count == 3) - assert(evo.assign(e35, f3, 43)) + assert(evo.set(e35, f3, 43)) assert(assign_count == 4) end @@ -6344,7 +6287,7 @@ do assert(evo.set(e123, f1, 41) and evo.set(e123, f2, 42) and evo.set(e123, f3, 43)) assert(set_count == 5) - assert(evo.assign(e123, f1, 41) and evo.assign(e123, f2, 42) and evo.assign(e123, f3, 43)) + assert(evo.set(e123, f1, 41) and evo.set(e123, f2, 42) and evo.set(e123, f3, 43)) assert(set_count == 8) do @@ -6388,14 +6331,14 @@ do local f1, f2 = evo.id(2) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) - assert(evo.insert(e1, f2, 42)) + assert(evo.set(e1, f1, 41)) + assert(evo.set(e1, f2, 42)) evo.set(f1, evo.DEFAULT, 51) evo.set(f2, evo.CONSTRUCT, function() return 52 end) - assert(evo.assign(e1, f1)) - assert(evo.assign(e1, f2)) + assert(evo.set(e1, f1)) + assert(evo.set(e1, f2)) assert(evo.get(e1, f1) == 51) assert(evo.get(e1, f2) == 52) @@ -6405,17 +6348,17 @@ do local f1, f2 = evo.id(2) local e1 = evo.id() - assert(evo.insert(e1, f1, 41)) + assert(evo.set(e1, f1, 41)) local e2 = evo.id() - assert(evo.insert(e2, f1, 41)) - assert(evo.insert(e2, f2, 42)) + assert(evo.set(e2, f1, 41)) + assert(evo.set(e2, f2, 42)) assert(evo.get(e1, f1) == 41) assert(evo.get(e2, f1) == 41) assert(evo.get(e2, f2) == 42) - assert(evo.insert(f1, evo.TAG)) + assert(evo.set(f1, evo.TAG)) assert(evo.get(e1, f1) == nil) assert(evo.get(e2, f1) == nil) assert(evo.get(e2, f2) == 42) @@ -6425,12 +6368,12 @@ do assert(evo.get(e2, f1) == true) assert(evo.get(e2, f2) == 42) - assert(evo.insert(f2, evo.TAG)) + assert(evo.set(f2, evo.TAG)) assert(evo.get(e1, f1) == true) assert(evo.get(e2, f1) == true) assert(evo.get(e2, f2) == nil) - assert(evo.insert(f2, evo.DEFAULT, 42)) + assert(evo.set(f2, evo.DEFAULT, 42)) assert(evo.remove(f2, evo.TAG)) assert(evo.get(e1, f1) == true) assert(evo.get(e2, f1) == true) @@ -6458,7 +6401,7 @@ do assert(evo.components(c1, f1)[1] == 1 and evo.components(c1, f1)[2] == 11) end - assert(evo.batch_insert(q1, f2, 2) == 2) + assert(evo.batch_set(q1, f2, 2) == 2) do local c1, c1_es = evo.chunk(f1) @@ -6481,7 +6424,8 @@ do assert(evo.components(c1, f1)[1] == 111 and evo.components(c1, f1)[2] == 1111) end - assert(evo.batch_insert(q1, f2, 22) == 2) + assert(evo.set(q1, evo.EXCLUDES, f2)) + assert(evo.batch_set(q1, f2, 22) == 2) do local c1, c1_es = evo.chunk(f1) @@ -6701,7 +6645,7 @@ do end assert(evo.remove(e12a, f1) and evo.remove(e12b, f1)) - assert(evo.insert(e1a, f2, 7) and evo.insert(e1b, f2, 8)) + assert(evo.set(e1a, f2, 7) and evo.set(e1b, f2, 8)) do local c1_es, c1_ec = evo.entities(c1) @@ -7246,7 +7190,7 @@ do assert(matched_entity_count > 0) end - assert(evo.assign(qe12, evo.EXCLUDES)) + assert(evo.set(qe12, evo.EXCLUDES)) do local matched_chunk_count = 0 @@ -7263,7 +7207,7 @@ do assert(matched_entity_count > 0) end - assert(evo.insert(qe12, evo.INCLUDES, f1, f2)) + assert(evo.set(qe12, evo.INCLUDES, f1, f2)) do local iter, state = evo.execute(qe12) @@ -7278,8 +7222,8 @@ end do local f1, f2 = evo.id(2) - assert(evo.insert(f1, evo.NAME, 'f1')) - assert(evo.insert(f2, evo.NAME, 'f2')) + assert(evo.set(f1, evo.NAME, 'f1')) + assert(evo.set(f2, evo.NAME, 'f2')) local old_c1 = assert(evo.chunk(f1)) local old_c12 = assert(evo.chunk(f1, f2)) @@ -7352,8 +7296,8 @@ do local f1 = evo.id() local e1, e2 = evo.id(2) - assert(evo.insert(e1, f1, f1)) - assert(evo.insert(e2, f1, f1)) + assert(evo.set(e1, f1, f1)) + assert(evo.set(e2, f1, f1)) assert(evo.clear(e1, e2)) @@ -7365,11 +7309,11 @@ do local f1 = evo.id() local e1, e2, e3, e4, e5 = evo.id(5) - assert(evo.insert(e1, f1, f1)) - assert(evo.insert(e2, f1, f1)) - assert(evo.insert(e3, f1, f1)) - assert(evo.insert(e4, f1, f1)) - assert(evo.insert(e5, f1, f1)) + assert(evo.set(e1, f1, f1)) + assert(evo.set(e2, f1, f1)) + assert(evo.set(e3, f1, f1)) + assert(evo.set(e4, f1, f1)) + assert(evo.set(e5, f1, f1)) assert(evo.clear(e1, e2, e3, e4, e5)) @@ -7386,9 +7330,9 @@ do local f1 = evo.id() local e1, e2, e3 = evo.id(3) - assert(evo.insert(e1, f1, f1)) - assert(evo.insert(e2, f1, f1)) - assert(evo.insert(e3, f1, f1)) + assert(evo.set(e1, f1, f1)) + assert(evo.set(e2, f1, f1)) + assert(evo.set(e3, f1, f1)) assert(evo.defer()) do @@ -7408,11 +7352,11 @@ do local f1 = evo.id() local e1, e2, e3, e4, e5 = evo.id(5) - assert(evo.insert(e1, f1, f1)) - assert(evo.insert(e2, f1, f1)) - assert(evo.insert(e3, f1, f1)) - assert(evo.insert(e4, f1, f1)) - assert(evo.insert(e5, f1, f1)) + assert(evo.set(e1, f1, f1)) + assert(evo.set(e2, f1, f1)) + assert(evo.set(e3, f1, f1)) + assert(evo.set(e4, f1, f1)) + assert(evo.set(e5, f1, f1)) assert(evo.defer()) do @@ -7438,8 +7382,8 @@ do local f1 = evo.id() local e1, e2 = evo.id(2) - assert(evo.insert(e1, f1, f1)) - assert(evo.insert(e2, f1, f1)) + assert(evo.set(e1, f1, f1)) + assert(evo.set(e2, f1, f1)) assert(evo.destroy(e1, e2)) @@ -7451,11 +7395,11 @@ do local f1 = evo.id() local e1, e2, e3, e4, e5 = evo.id(5) - assert(evo.insert(e1, f1, f1)) - assert(evo.insert(e2, f1, f1)) - assert(evo.insert(e3, f1, f1)) - assert(evo.insert(e4, f1, f1)) - assert(evo.insert(e5, f1, f1)) + assert(evo.set(e1, f1, f1)) + assert(evo.set(e2, f1, f1)) + assert(evo.set(e3, f1, f1)) + assert(evo.set(e4, f1, f1)) + assert(evo.set(e5, f1, f1)) assert(evo.destroy(e1, e2, e3, e4, e5)) @@ -7472,9 +7416,9 @@ do local f1 = evo.id() local e1, e2, e3 = evo.id(3) - assert(evo.insert(e1, f1, f1)) - assert(evo.insert(e2, f1, f1)) - assert(evo.insert(e3, f1, f1)) + assert(evo.set(e1, f1, f1)) + assert(evo.set(e2, f1, f1)) + assert(evo.set(e3, f1, f1)) assert(evo.defer()) do @@ -7494,11 +7438,11 @@ do local f1 = evo.id() local e1, e2, e3, e4, e5 = evo.id(5) - assert(evo.insert(e1, f1, f1)) - assert(evo.insert(e2, f1, f1)) - assert(evo.insert(e3, f1, f1)) - assert(evo.insert(e4, f1, f1)) - assert(evo.insert(e5, f1, f1)) + assert(evo.set(e1, f1, f1)) + assert(evo.set(e2, f1, f1)) + assert(evo.set(e3, f1, f1)) + assert(evo.set(e4, f1, f1)) + assert(evo.set(e5, f1, f1)) assert(evo.defer()) do @@ -7522,8 +7466,8 @@ end do local f1 = evo.id() local e1, e2 = evo.id(2) - assert(evo.insert(e1, f1, f1)) - assert(evo.insert(e2, f1, f1)) + assert(evo.set(e1, f1, f1)) + assert(evo.set(e2, f1, f1)) assert(evo.clear(e1, e2, e1, e1)) assert(evo.is_alive(e1) and evo.is_empty(e1)) assert(evo.is_alive(e2) and evo.is_empty(e2)) @@ -7532,8 +7476,8 @@ end do local f1 = evo.id() local e1, e2 = evo.id(2) - assert(evo.insert(e1, f1, f1)) - assert(evo.insert(e2, f1, f1)) + assert(evo.set(e1, f1, f1)) + assert(evo.set(e2, f1, f1)) assert(evo.destroy(e1, e2, e1, e1)) assert(not evo.is_alive(e1) and evo.is_empty(e1)) assert(not evo.is_alive(e2) and evo.is_empty(e2)) @@ -7543,12 +7487,12 @@ do local f1, f2 = evo.id(2) local q1, q2 = evo.id(2) - assert(evo.insert(q1, evo.INCLUDES, f1)) - assert(evo.insert(q2, evo.INCLUDES, f2)) + assert(evo.set(q1, evo.INCLUDES, f1)) + assert(evo.set(q2, evo.INCLUDES, f2)) local e1, e2 = evo.id(2) - assert(evo.insert(e1, f1, f1)) - assert(evo.insert(e2, f2, f2)) + assert(evo.set(e1, f1, f1)) + assert(evo.set(e2, f2, f2)) assert(evo.batch_clear() == 0) @@ -7565,12 +7509,12 @@ do local f1, f2 = evo.id(2) local q1, q2 = evo.id(2) - assert(evo.insert(q1, evo.INCLUDES, f1)) - assert(evo.insert(q2, evo.INCLUDES, f2)) + assert(evo.set(q1, evo.INCLUDES, f1)) + assert(evo.set(q2, evo.INCLUDES, f2)) local e1, e2 = evo.id(2) - assert(evo.insert(e1, f1, f1)) - assert(evo.insert(e2, f2, f2)) + assert(evo.set(e1, f1, f1)) + assert(evo.set(e2, f2, f2)) assert(evo.defer()) do @@ -7588,12 +7532,12 @@ do local f1, f2 = evo.id(2) local q1, q2 = evo.id(2) - assert(evo.insert(q1, evo.INCLUDES, f1)) - assert(evo.insert(q2, evo.INCLUDES, f2)) + assert(evo.set(q1, evo.INCLUDES, f1)) + assert(evo.set(q2, evo.INCLUDES, f2)) local e1, e2 = evo.id(2) - assert(evo.insert(e1, f1, f1)) - assert(evo.insert(e2, f2, f2)) + assert(evo.set(e1, f1, f1)) + assert(evo.set(e2, f2, f2)) assert(evo.batch_destroy() == 0) @@ -7610,12 +7554,12 @@ do local f1, f2 = evo.id(2) local q1, q2 = evo.id(2) - assert(evo.insert(q1, evo.INCLUDES, f1)) - assert(evo.insert(q2, evo.INCLUDES, f2)) + assert(evo.set(q1, evo.INCLUDES, f1)) + assert(evo.set(q2, evo.INCLUDES, f2)) local e1, e2 = evo.id(2) - assert(evo.insert(e1, f1, f1)) - assert(evo.insert(e2, f2, f2)) + assert(evo.set(e1, f1, f1)) + assert(evo.set(e2, f2, f2)) assert(evo.defer()) do @@ -7711,7 +7655,7 @@ do assert(evo.is_empty_any(d1, e1, e2, d2, e3, d1)) local f1, f2 = evo.id(2) - assert(evo.insert(f1, f1) and evo.insert(f2, f2)) + assert(evo.set(f1, f1) and evo.set(f2, f2)) assert(not evo.is_empty(f1)) assert(not evo.is_empty_all(f1)) @@ -8018,7 +7962,7 @@ do assert(evo.get(e12a, f2) == 7 and evo.get(e12b, f2) == 7) end - assert(4 == evo.batch_assign(c12, f2, 8)) + assert(4 == evo.batch_set(c12, f2, 8)) do local c12_es, c12_ec = evo.entities(c12) @@ -8038,7 +7982,7 @@ do assert(evo.get(e12a, f1) == 3 and evo.get(e12b, f1) == 5) end - assert(4 == evo.batch_insert(c1, f2, 9)) + assert(4 == evo.batch_set(c1, f2, 9)) do local c12_es, c12_ec = evo.entities(c12) @@ -8055,8 +7999,8 @@ do assert(evo.is_empty_all(e1a, e1b, e12a, e12b)) end - assert(evo.insert(e1a, f1, 1) and evo.insert(e1b, f1, 2)) - assert(evo.multi_insert(e12a, { f1, f2 }, { 3, 4 }) and evo.multi_insert(e12b, { f1, f2 }, { 5, 6 })) + assert(evo.set(e1a, f1, 1) and evo.set(e1b, f1, 2)) + assert(evo.multi_set(e12a, { f1, f2 }, { 3, 4 }) and evo.multi_set(e12b, { f1, f2 }, { 5, 6 })) do assert(evo.is_alive_all(e1a, e1b, e12a, e12b)) @@ -8105,7 +8049,7 @@ do assert(evo.get(e12a, f2) == 4 and evo.get(e12b, f2) == 6) end - assert(4 == evo.batch_multi_assign(c12, { f1 }, { 7 })) + assert(4 == evo.batch_multi_set(c12, { f1 }, { 7 })) do local c12_es, c12_ec = evo.entities(c12) @@ -8127,7 +8071,7 @@ do assert(evo.get(e12a, f1) == 7 and evo.get(e12b, f1) == 7) end - assert(4 == evo.batch_multi_insert(c1, { f2 }, { 8 })) + assert(4 == evo.batch_multi_set(c1, { f2 }, { 8 })) do local c12_es, c12_ec = evo.entities(c12) diff --git a/evolved.lua b/evolved.lua index af60996..2e3c9b9 100644 --- a/evolved.lua +++ b/evolved.lua @@ -656,27 +656,19 @@ local __evolved_has_any local __evolved_get local __evolved_set -local __evolved_assign -local __evolved_insert local __evolved_remove local __evolved_clear local __evolved_destroy local __evolved_multi_set -local __evolved_multi_assign -local __evolved_multi_insert local __evolved_multi_remove local __evolved_batch_set -local __evolved_batch_assign -local __evolved_batch_insert local __evolved_batch_remove local __evolved_batch_clear local __evolved_batch_destroy local __evolved_batch_multi_set -local __evolved_batch_multi_assign -local __evolved_batch_multi_insert local __evolved_batch_multi_remove local __evolved_chunk @@ -1508,27 +1500,19 @@ end --- local __defer_set -local __defer_assign -local __defer_insert local __defer_remove local __defer_clear local __defer_destroy local __defer_multi_set -local __defer_multi_assign -local __defer_multi_insert local __defer_multi_remove local __defer_batch_set -local __defer_batch_assign -local __defer_batch_insert local __defer_batch_remove local __defer_batch_clear local __defer_batch_destroy local __defer_batch_multi_set -local __defer_batch_multi_assign -local __defer_batch_multi_insert local __defer_batch_multi_remove local __defer_spawn_entity_at @@ -1845,15 +1829,11 @@ end --- local __chunk_set -local __chunk_assign -local __chunk_insert local __chunk_remove local __chunk_clear local __chunk_destroy local __chunk_multi_set -local __chunk_multi_assign -local __chunk_multi_insert local __chunk_multi_remove --- @@ -1953,164 +1933,19 @@ end --- --- ----@param chunk evolved.chunk +---@param old_chunk evolved.chunk ---@param fragment evolved.fragment ---@param ... any component arguments ---@return integer set_count ---@nodiscard -__chunk_set = function(chunk, fragment, ...) - if __defer_depth <= 0 then - __error_fmt('batched chunk operations should be deferred') - end - - if chunk.__fragment_set[fragment] then - return __chunk_assign(chunk, fragment, ...) - else - return __chunk_insert(chunk, fragment, ...) - end -end - ----@param chunk evolved.chunk ----@param fragment evolved.fragment ----@param ... any component arguments ----@return integer assigned_count ----@nodiscard -__chunk_assign = function(chunk, fragment, ...) - if __defer_depth <= 0 then - __error_fmt('batched chunk operations should be deferred') - end - - if not chunk.__fragment_set[fragment] then - return 0 - end - - local chunk_entity_list = chunk.__entity_list - local chunk_entity_count = chunk.__entity_count - - if chunk_entity_count == 0 then - return 0 - end - - local chunk_component_indices = chunk.__component_indices - local chunk_component_storages = chunk.__component_storages - - ---@type evolved.default?, evolved.construct? - local fragment_default, fragment_construct - - ---@type evolved.set_hook?, evolved.assign_hook? - local fragment_on_set, fragment_on_assign - - do - if chunk.__has_defaults_or_constructs then - fragment_default, fragment_construct = __evolved_get(fragment, __DEFAULT, __CONSTRUCT) - end - - if chunk.__has_set_or_assign_hooks then - fragment_on_set, fragment_on_assign = __evolved_get(fragment, __ON_SET, __ON_ASSIGN) - end - end - - if fragment_on_set or fragment_on_assign then - local component_index = chunk_component_indices[fragment] - - if component_index then - local component_storage = chunk_component_storages[component_index] - - if fragment_default ~= nil or fragment_construct then - for place = 1, chunk_entity_count do - local entity = chunk_entity_list[place] - local old_component = component_storage[place] - - local new_component = ... - if fragment_construct then new_component = fragment_construct(...) end - if new_component == nil then new_component = fragment_default end - if new_component == nil then new_component = true end - - component_storage[place] = new_component - - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment, new_component, old_component) - end - - if fragment_on_assign then - __defer_call_hook(fragment_on_assign, entity, fragment, new_component, old_component) - end - end - else - local new_component = ... - if new_component == nil then new_component = true end - - for place = 1, chunk_entity_count do - local entity = chunk_entity_list[place] - local old_component = component_storage[place] - - component_storage[place] = new_component - - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment, new_component, old_component) - end - - if fragment_on_assign then - __defer_call_hook(fragment_on_assign, entity, fragment, new_component, old_component) - end - end - end - else - for place = 1, chunk_entity_count do - local entity = chunk_entity_list[place] - - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment) - end - - if fragment_on_assign then - __defer_call_hook(fragment_on_assign, entity, fragment) - end - end - end - else - local component_index = chunk_component_indices[fragment] - - if component_index then - local component_storage = chunk_component_storages[component_index] - - if fragment_default ~= nil or fragment_construct then - for place = 1, chunk_entity_count do - local new_component = ... - if fragment_construct then new_component = fragment_construct(...) end - if new_component == nil then new_component = fragment_default end - if new_component == nil then new_component = true end - component_storage[place] = new_component - end - else - local new_component = ... - if new_component == nil then new_component = true end - - for place = 1, chunk_entity_count do - component_storage[place] = new_component - end - end - else - -- nothing - end - end - - return chunk_entity_count -end - ----@param old_chunk evolved.chunk ----@param fragment evolved.fragment ----@param ... any component arguments ----@return integer inserted_count ----@nodiscard -__chunk_insert = function(old_chunk, fragment, ...) +__chunk_set = function(old_chunk, fragment, ...) if __defer_depth <= 0 then __error_fmt('batched chunk operations should be deferred') end local new_chunk = __chunk_with_fragment(old_chunk, fragment) - if not new_chunk or old_chunk == new_chunk then + if not new_chunk then return 0 end @@ -2122,160 +1957,255 @@ __chunk_insert = function(old_chunk, fragment, ...) end local old_component_count = old_chunk.__component_count + local old_component_indices = old_chunk.__component_indices local old_component_storages = old_chunk.__component_storages local old_component_fragments = old_chunk.__component_fragments - local new_entity_list = new_chunk.__entity_list - local new_entity_count = new_chunk.__entity_count + if old_chunk == new_chunk then + local old_chunk_has_defaults_or_constructs = old_chunk.__has_defaults_or_constructs + local old_chunk_has_set_or_assign_hooks = old_chunk.__has_set_or_assign_hooks - local new_component_indices = new_chunk.__component_indices - local new_component_storages = new_chunk.__component_storages + ---@type evolved.default?, evolved.construct?, evolved.set_hook?, evolved.assign_hook? + local fragment_default, fragment_construct, fragment_on_set, fragment_on_assign - ---@type evolved.default?, evolved.construct? - local fragment_default, fragment_construct - - ---@type evolved.set_hook?, evolved.insert_hook? - local fragment_on_set, fragment_on_insert - - do - if new_chunk.__has_defaults_or_constructs then - fragment_default, fragment_construct = __evolved_get(fragment, __DEFAULT, __CONSTRUCT) + if old_chunk_has_defaults_or_constructs or old_chunk_has_set_or_assign_hooks then + fragment_default, fragment_construct, fragment_on_set, fragment_on_assign = __evolved_get(fragment, + __DEFAULT, __CONSTRUCT, __ON_SET, __ON_ASSIGN) end - if new_chunk.__has_set_or_insert_hooks then - fragment_on_set, fragment_on_insert = __evolved_get(fragment, __ON_SET, __ON_INSERT) - end - end + if fragment_on_set or fragment_on_assign then + local old_component_index = old_component_indices[fragment] - if new_entity_count == 0 then - old_chunk.__entity_list, new_chunk.__entity_list = - new_entity_list, old_entity_list + if old_component_index then + local old_component_storage = old_component_storages[old_component_index] - old_entity_list, new_entity_list = - new_entity_list, old_entity_list + if fragment_default ~= nil or fragment_construct then + for place = 1, old_entity_count do + local entity = old_entity_list[place] + local old_component = old_component_storage[place] - for old_ci = 1, old_component_count do - local old_f = old_component_fragments[old_ci] - local new_ci = new_component_indices[old_f] - old_component_storages[old_ci], new_component_storages[new_ci] = - new_component_storages[new_ci], old_component_storages[old_ci] - end + local new_component = ... + if fragment_construct then new_component = fragment_construct(...) end + if new_component == nil then new_component = fragment_default end + if new_component == nil then new_component = true end - new_chunk.__entity_count = old_entity_count - else - __lua_table_move( - old_entity_list, 1, old_entity_count, - new_entity_count + 1, new_entity_list) + old_component_storage[place] = new_component - for old_ci = 1, old_component_count do - local old_f = old_component_fragments[old_ci] - local old_cs = old_component_storages[old_ci] - local new_ci = new_component_indices[old_f] - local new_cs = new_component_storages[new_ci] - __lua_table_move(old_cs, 1, old_entity_count, new_entity_count + 1, new_cs) - end - - new_chunk.__entity_count = new_entity_count + old_entity_count - end - - do - local entity_chunks = __entity_chunks - local entity_places = __entity_places - - for new_place = new_entity_count + 1, new_entity_count + old_entity_count do - local entity = new_entity_list[new_place] - local entity_index = entity % 0x100000 - entity_chunks[entity_index] = new_chunk - entity_places[entity_index] = new_place - end - - __detach_all_entities(old_chunk) - end - - if fragment_on_set or fragment_on_insert then - local new_component_index = new_component_indices[fragment] - - if new_component_index then - local new_component_storage = new_component_storages[new_component_index] - - if fragment_default ~= nil or fragment_construct then - for new_place = new_entity_count + 1, new_entity_count + old_entity_count do - local entity = new_entity_list[new_place] + if fragment_on_set then + __defer_call_hook(fragment_on_set, entity, fragment, new_component, old_component) + end + if fragment_on_assign then + __defer_call_hook(fragment_on_assign, entity, fragment, new_component, old_component) + end + end + else local new_component = ... - if fragment_construct then new_component = fragment_construct(...) end - if new_component == nil then new_component = fragment_default end if new_component == nil then new_component = true end - new_component_storage[new_place] = new_component + for place = 1, old_entity_count do + local entity = old_entity_list[place] + local old_component = old_component_storage[place] - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment, new_component) - end + old_component_storage[place] = new_component - if fragment_on_insert then - __defer_call_hook(fragment_on_insert, entity, fragment, new_component) + if fragment_on_set then + __defer_call_hook(fragment_on_set, entity, fragment, new_component, old_component) + end + + if fragment_on_assign then + __defer_call_hook(fragment_on_assign, entity, fragment, new_component, old_component) + end end end else - local new_component = ... - if new_component == nil then new_component = true end - - for new_place = new_entity_count + 1, new_entity_count + old_entity_count do - local entity = new_entity_list[new_place] - - new_component_storage[new_place] = new_component + for place = 1, old_entity_count do + local entity = old_entity_list[place] if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment, new_component) + __defer_call_hook(fragment_on_set, entity, fragment) end - if fragment_on_insert then - __defer_call_hook(fragment_on_insert, entity, fragment, new_component) + if fragment_on_assign then + __defer_call_hook(fragment_on_assign, entity, fragment) end end end else + local old_component_index = old_component_indices[fragment] + + if old_component_index then + local old_component_storage = old_component_storages[old_component_index] + + if fragment_default ~= nil or fragment_construct then + for place = 1, old_entity_count do + local new_component = ... + if fragment_construct then new_component = fragment_construct(...) end + if new_component == nil then new_component = fragment_default end + if new_component == nil then new_component = true end + old_component_storage[place] = new_component + end + else + local new_component = ... + if new_component == nil then new_component = true end + + for place = 1, old_entity_count do + old_component_storage[place] = new_component + end + end + else + -- nothing + end + end + else + local new_entity_list = new_chunk.__entity_list + local new_entity_count = new_chunk.__entity_count + + local new_component_indices = new_chunk.__component_indices + local new_component_storages = new_chunk.__component_storages + + local new_chunk_has_defaults_or_constructs = new_chunk.__has_defaults_or_constructs + local new_chunk_has_set_or_insert_hooks = new_chunk.__has_set_or_insert_hooks + + ---@type evolved.default?, evolved.construct?, evolved.set_hook?, evolved.insert_hook? + local fragment_default, fragment_construct, fragment_on_set, fragment_on_insert + + if new_chunk_has_defaults_or_constructs or new_chunk_has_set_or_insert_hooks then + fragment_default, fragment_construct, fragment_on_set, fragment_on_insert = __evolved_get(fragment, + __DEFAULT, __CONSTRUCT, __ON_SET, __ON_INSERT) + end + + if new_entity_count == 0 then + old_chunk.__entity_list, new_chunk.__entity_list = + new_entity_list, old_entity_list + + old_entity_list, new_entity_list = + new_entity_list, old_entity_list + + for old_ci = 1, old_component_count do + local old_f = old_component_fragments[old_ci] + local new_ci = new_component_indices[old_f] + old_component_storages[old_ci], new_component_storages[new_ci] = + new_component_storages[new_ci], old_component_storages[old_ci] + end + + new_chunk.__entity_count = old_entity_count + else + __lua_table_move( + old_entity_list, 1, old_entity_count, + new_entity_count + 1, new_entity_list) + + for old_ci = 1, old_component_count do + local old_f = old_component_fragments[old_ci] + local old_cs = old_component_storages[old_ci] + local new_ci = new_component_indices[old_f] + local new_cs = new_component_storages[new_ci] + __lua_table_move(old_cs, 1, old_entity_count, new_entity_count + 1, new_cs) + end + + new_chunk.__entity_count = new_entity_count + old_entity_count + end + + do + local entity_chunks = __entity_chunks + local entity_places = __entity_places + for new_place = new_entity_count + 1, new_entity_count + old_entity_count do local entity = new_entity_list[new_place] - - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment) - end - - if fragment_on_insert then - __defer_call_hook(fragment_on_insert, entity, fragment) - end + local entity_index = entity % 0x100000 + entity_chunks[entity_index] = new_chunk + entity_places[entity_index] = new_place end + + __detach_all_entities(old_chunk) end - else - local new_component_index = new_component_indices[fragment] - if new_component_index then - local new_component_storage = new_component_storages[new_component_index] + if fragment_on_set or fragment_on_insert then + local new_component_index = new_component_indices[fragment] - if fragment_default ~= nil or fragment_construct then - for new_place = new_entity_count + 1, new_entity_count + old_entity_count do + if new_component_index then + local new_component_storage = new_component_storages[new_component_index] + + if fragment_default ~= nil or fragment_construct then + for new_place = new_entity_count + 1, new_entity_count + old_entity_count do + local entity = new_entity_list[new_place] + + local new_component = ... + if fragment_construct then new_component = fragment_construct(...) end + if new_component == nil then new_component = fragment_default end + if new_component == nil then new_component = true end + + new_component_storage[new_place] = new_component + + if fragment_on_set then + __defer_call_hook(fragment_on_set, entity, fragment, new_component) + end + + if fragment_on_insert then + __defer_call_hook(fragment_on_insert, entity, fragment, new_component) + end + end + else local new_component = ... - if fragment_construct then new_component = fragment_construct(...) end - if new_component == nil then new_component = fragment_default end if new_component == nil then new_component = true end - new_component_storage[new_place] = new_component + + for new_place = new_entity_count + 1, new_entity_count + old_entity_count do + local entity = new_entity_list[new_place] + + new_component_storage[new_place] = new_component + + if fragment_on_set then + __defer_call_hook(fragment_on_set, entity, fragment, new_component) + end + + if fragment_on_insert then + __defer_call_hook(fragment_on_insert, entity, fragment, new_component) + end + end end else - local new_component = ... - if new_component == nil then new_component = true end - for new_place = new_entity_count + 1, new_entity_count + old_entity_count do - new_component_storage[new_place] = new_component + local entity = new_entity_list[new_place] + + if fragment_on_set then + __defer_call_hook(fragment_on_set, entity, fragment) + end + + if fragment_on_insert then + __defer_call_hook(fragment_on_insert, entity, fragment) + end end end else - -- nothing + local new_component_index = new_component_indices[fragment] + + if new_component_index then + local new_component_storage = new_component_storages[new_component_index] + + if fragment_default ~= nil or fragment_construct then + for new_place = new_entity_count + 1, new_entity_count + old_entity_count do + local new_component = ... + if fragment_construct then new_component = fragment_construct(...) end + if new_component == nil then new_component = fragment_default end + if new_component == nil then new_component = true end + new_component_storage[new_place] = new_component + end + else + local new_component = ... + if new_component == nil then new_component = true end + + for new_place = new_entity_count + 1, new_entity_count + old_entity_count do + new_component_storage[new_place] = new_component + end + end + else + -- nothing + end end + + __structural_changes = __structural_changes + 1 end - __structural_changes = __structural_changes + 1 return old_entity_count end @@ -2434,12 +2364,11 @@ __chunk_clear = function(chunk) return 0 end - local chunk_component_indices = chunk.__component_indices - local chunk_component_storages = chunk.__component_storages - if chunk.__has_remove_hooks then local chunk_fragment_list = chunk.__fragment_list local chunk_fragment_count = chunk.__fragment_count + local chunk_component_indices = chunk.__component_indices + local chunk_component_storages = chunk.__component_storages for chunk_fragment_index = 1, chunk_fragment_count do local fragment = chunk_fragment_list[chunk_fragment_index] @@ -2501,12 +2430,11 @@ __chunk_destroy = function(chunk) return 0 end - local chunk_component_indices = chunk.__component_indices - local chunk_component_storages = chunk.__component_storages - if chunk.__has_remove_hooks then local chunk_fragment_list = chunk.__fragment_list local chunk_fragment_count = chunk.__fragment_count + local chunk_component_indices = chunk.__component_indices + local chunk_component_storages = chunk.__component_storages for chunk_fragment_index = 1, chunk_fragment_count do local fragment = chunk_fragment_list[chunk_fragment_index] @@ -2614,27 +2542,19 @@ __chunk_multi_set = function(old_chunk, fragments, fragment_count, components) local old_component_storages = old_chunk.__component_storages local old_component_fragments = old_chunk.__component_fragments - local old_chunk_has_defaults_or_constructs = old_chunk.__has_defaults_or_constructs - local old_chunk_has_set_or_assign_hooks = old_chunk.__has_set_or_assign_hooks - if old_chunk == new_chunk then + local old_chunk_has_defaults_or_constructs = old_chunk.__has_defaults_or_constructs + local old_chunk_has_set_or_assign_hooks = old_chunk.__has_set_or_assign_hooks + for i = 1, fragment_count do local fragment = fragments[i] - ---@type evolved.default? - local fragment_default + ---@type evolved.default?, evolved.set_hook?, evolved.assign_hook? + local fragment_default, fragment_on_set, fragment_on_assign - ---@type evolved.set_hook?, evolved.assign_hook? - local fragment_on_set, fragment_on_assign - - do - if old_chunk_has_defaults_or_constructs then - fragment_default = __evolved_get(fragment, __DEFAULT) - end - - if old_chunk_has_set_or_assign_hooks then - fragment_on_set, fragment_on_assign = __evolved_get(fragment, __ON_SET, __ON_ASSIGN) - end + if old_chunk_has_defaults_or_constructs or old_chunk_has_set_or_assign_hooks then + fragment_default, fragment_on_set, fragment_on_assign = __evolved_get(fragment, + __DEFAULT, __ON_SET, __ON_ASSIGN) end if fragment_on_set or fragment_on_assign then @@ -2755,24 +2675,17 @@ __chunk_multi_set = function(old_chunk, fragments, fragment_count, components) local fragment = fragments[i] if inserted_set[fragment] or old_fragment_set[fragment] then - ---@type evolved.default? - local fragment_default + ---@type evolved.default?, evolved.set_hook?, evolved.assign_hook? + local fragment_default, fragment_on_set, fragment_on_assign - ---@type evolved.set_hook?, evolved.assign_hook? - local fragment_on_set, fragment_on_assign - - do - if new_chunk_has_defaults_or_constructs then - fragment_default = __evolved_get(fragment, __DEFAULT) - end - - if new_chunk_has_set_or_assign_hooks then - fragment_on_set, fragment_on_assign = __evolved_get(fragment, __ON_SET, __ON_ASSIGN) - end + if new_chunk_has_defaults_or_constructs or new_chunk_has_set_or_assign_hooks then + fragment_default, fragment_on_set, fragment_on_assign = __evolved_get(fragment, + __DEFAULT, __ON_SET, __ON_ASSIGN) end if fragment_on_set or fragment_on_assign then local new_component_index = new_component_indices[fragment] + if new_component_index then local new_component_storage = new_component_storages[new_component_index] @@ -2827,20 +2740,12 @@ __chunk_multi_set = function(old_chunk, fragments, fragment_count, components) else inserted_set[fragment] = true - ---@type evolved.default? - local fragment_default + ---@type evolved.default?, evolved.set_hook?, evolved.insert_hook? + local fragment_default, fragment_on_set, fragment_on_insert - ---@type evolved.set_hook?, evolved.insert_hook? - local fragment_on_set, fragment_on_insert - - do - if new_chunk_has_defaults_or_constructs then - fragment_default = __evolved_get(fragment, __DEFAULT) - end - - if new_chunk_has_set_or_insert_hooks then - fragment_on_set, fragment_on_insert = __evolved_get(fragment, __ON_SET, __ON_INSERT) - end + if new_chunk_has_defaults_or_constructs or new_chunk_has_set_or_insert_hooks then + fragment_default, fragment_on_set, fragment_on_insert = __evolved_get(fragment, + __DEFAULT, __ON_SET, __ON_INSERT) end if fragment_on_set or fragment_on_insert then @@ -2907,291 +2812,6 @@ __chunk_multi_set = function(old_chunk, fragments, fragment_count, components) return old_entity_count end ----@param chunk evolved.chunk ----@param fragments evolved.fragment[] ----@param fragment_count integer ----@param components evolved.component[] ----@return integer assigned_count -__chunk_multi_assign = function(chunk, fragments, fragment_count, components) - if __defer_depth <= 0 then - __error_fmt('batched chunk operations should be deferred') - end - - if fragment_count == 0 then - return 0 - end - - if not __chunk_has_any_fragment_list(chunk, fragments, fragment_count) then - return 0 - end - - local chunk_entity_list = chunk.__entity_list - local chunk_entity_count = chunk.__entity_count - - if chunk_entity_count == 0 then - return 0 - end - - local chunk_fragment_set = chunk.__fragment_set - local chunk_component_indices = chunk.__component_indices - local chunk_component_storages = chunk.__component_storages - - local chunk_has_defaults_or_constructs = chunk.__has_defaults_or_constructs - local chunk_has_set_or_assign_hooks = chunk.__has_set_or_assign_hooks - - for i = 1, fragment_count do - local fragment = fragments[i] - - if chunk_fragment_set[fragment] then - ---@type evolved.default? - local fragment_default - - ---@type evolved.set_hook?, evolved.assign_hook? - local fragment_on_set, fragment_on_assign - - do - if chunk_has_defaults_or_constructs then - fragment_default = __evolved_get(fragment, __DEFAULT) - end - - if chunk_has_set_or_assign_hooks then - fragment_on_set, fragment_on_assign = __evolved_get(fragment, __ON_SET, __ON_ASSIGN) - end - end - - if fragment_on_set or fragment_on_assign then - local component_index = chunk_component_indices[fragment] - - if component_index then - local component_storage = chunk_component_storages[component_index] - - local new_component = components[i] - if new_component == nil then new_component = fragment_default end - if new_component == nil then new_component = true end - - for place = 1, chunk_entity_count do - local entity = chunk_entity_list[place] - local old_component = component_storage[place] - - component_storage[place] = new_component - - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment, new_component, old_component) - end - - if fragment_on_assign then - __defer_call_hook(fragment_on_assign, entity, fragment, new_component, old_component) - end - end - else - for place = 1, chunk_entity_count do - local entity = chunk_entity_list[place] - - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment) - end - - if fragment_on_assign then - __defer_call_hook(fragment_on_assign, entity, fragment) - end - end - end - else - local component_index = chunk_component_indices[fragment] - - if component_index then - local component_storage = chunk_component_storages[component_index] - - local new_component = components[i] - if new_component == nil then new_component = fragment_default end - if new_component == nil then new_component = true end - - for place = 1, chunk_entity_count do - component_storage[place] = new_component - end - else - -- nothing - end - end - end - end - - return chunk_entity_count -end - ----@param old_chunk evolved.chunk ----@param fragments evolved.fragment[] ----@param fragment_count integer ----@param components evolved.component[] ----@return integer inserted_count -__chunk_multi_insert = function(old_chunk, fragments, fragment_count, components) - if __defer_depth <= 0 then - __error_fmt('batched chunk operations should be deferred') - end - - if fragment_count == 0 then - return 0 - end - - local new_chunk = __chunk_with_fragment_list(old_chunk, fragments, fragment_count) - - if not new_chunk or old_chunk == new_chunk then - return 0 - end - - local old_entity_list = old_chunk.__entity_list - local old_entity_count = old_chunk.__entity_count - - if old_entity_count == 0 then - return 0 - end - - local old_fragment_set = old_chunk.__fragment_set - local old_component_count = old_chunk.__component_count - local old_component_storages = old_chunk.__component_storages - local old_component_fragments = old_chunk.__component_fragments - - local new_entity_list = new_chunk.__entity_list - local new_entity_count = new_chunk.__entity_count - - local new_component_indices = new_chunk.__component_indices - local new_component_storages = new_chunk.__component_storages - - local new_chunk_has_defaults_or_constructs = new_chunk.__has_defaults_or_constructs - local new_chunk_has_set_or_insert_hooks = new_chunk.__has_set_or_insert_hooks - - if new_entity_count == 0 then - old_chunk.__entity_list, new_chunk.__entity_list = - new_entity_list, old_entity_list - - old_entity_list, new_entity_list = - new_entity_list, old_entity_list - - for old_ci = 1, old_component_count do - local old_f = old_component_fragments[old_ci] - local new_ci = new_component_indices[old_f] - old_component_storages[old_ci], new_component_storages[new_ci] = - new_component_storages[new_ci], old_component_storages[old_ci] - end - - new_chunk.__entity_count = old_entity_count - else - __lua_table_move( - old_entity_list, 1, old_entity_count, - new_entity_count + 1, new_entity_list) - - for old_ci = 1, old_component_count do - local old_f = old_component_fragments[old_ci] - local old_cs = old_component_storages[old_ci] - local new_ci = new_component_indices[old_f] - local new_cs = new_component_storages[new_ci] - __lua_table_move(old_cs, 1, old_entity_count, new_entity_count + 1, new_cs) - end - - new_chunk.__entity_count = new_entity_count + old_entity_count - end - - do - local entity_chunks = __entity_chunks - local entity_places = __entity_places - - for new_place = new_entity_count + 1, new_entity_count + old_entity_count do - local entity = new_entity_list[new_place] - local entity_index = entity % 0x100000 - entity_chunks[entity_index] = new_chunk - entity_places[entity_index] = new_place - end - - __detach_all_entities(old_chunk) - end - - ---@type table - local inserted_set = __acquire_table(__table_pool_tag.fragment_set) - - for i = 1, fragment_count do - local fragment = fragments[i] - - if not inserted_set[fragment] and not old_fragment_set[fragment] then - inserted_set[fragment] = true - - ---@type evolved.default? - local fragment_default - - ---@type evolved.set_hook?, evolved.insert_hook? - local fragment_on_set, fragment_on_insert - - do - if new_chunk_has_defaults_or_constructs then - fragment_default = __evolved_get(fragment, __DEFAULT) - end - - if new_chunk_has_set_or_insert_hooks then - fragment_on_set, fragment_on_insert = __evolved_get(fragment, __ON_SET, __ON_INSERT) - end - end - - if fragment_on_set or fragment_on_insert then - local new_component_index = new_component_indices[fragment] - - if new_component_index then - local new_component_storage = new_component_storages[new_component_index] - - local new_component = components[i] - if new_component == nil then new_component = fragment_default end - if new_component == nil then new_component = true end - - for new_place = new_entity_count + 1, new_entity_count + old_entity_count do - local entity = new_entity_list[new_place] - - new_component_storage[new_place] = new_component - - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment, new_component) - end - - if fragment_on_insert then - __defer_call_hook(fragment_on_insert, entity, fragment, new_component) - end - end - else - for new_place = new_entity_count + 1, new_entity_count + old_entity_count do - local entity = new_entity_list[new_place] - - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment) - end - - if fragment_on_insert then - __defer_call_hook(fragment_on_insert, entity, fragment) - end - end - end - else - local new_component_index = new_component_indices[fragment] - - if new_component_index then - local new_component_storage = new_component_storages[new_component_index] - - local new_component = components[i] - if new_component == nil then new_component = fragment_default end - if new_component == nil then new_component = true end - - for new_place = new_entity_count + 1, new_entity_count + old_entity_count do - new_component_storage[new_place] = new_component - end - else - -- nothing - end - end - end - end - - __release_table(__table_pool_tag.fragment_set, inserted_set) - - __structural_changes = __structural_changes + 1 - return old_entity_count -end - ---@param old_chunk evolved.chunk ---@param fragments evolved.fragment[] ---@param fragment_count integer @@ -3496,35 +3116,27 @@ end ---@enum evolved.defer_op local __defer_op = { set = 1, - assign = 2, - insert = 3, - remove = 4, - clear = 5, - destroy = 6, + remove = 2, + clear = 3, + destroy = 4, - multi_set = 7, - multi_assign = 8, - multi_insert = 9, - multi_remove = 10, + multi_set = 5, + multi_remove = 6, - batch_set = 11, - batch_assign = 12, - batch_insert = 13, - batch_remove = 14, - batch_clear = 15, - batch_destroy = 16, + batch_set = 7, + batch_remove = 8, + batch_clear = 9, + batch_destroy = 10, - batch_multi_set = 17, - batch_multi_assign = 18, - batch_multi_insert = 19, - batch_multi_remove = 20, + batch_multi_set = 11, + batch_multi_remove = 12, - spawn_entity_at = 21, - spawn_entity_with = 22, + spawn_entity_at = 13, + spawn_entity_with = 14, - call_hook = 23, + call_hook = 15, - __count = 23, + __count = 15, } ---@type table @@ -3606,158 +3218,6 @@ __defer_ops[__defer_op.set] = function(bytes, index) return 3 + argument_count end ----@param entity evolved.entity ----@param fragment evolved.fragment ----@param ... any component arguments -__defer_assign = function(entity, fragment, ...) - local length = __defer_length - local bytecode = __defer_bytecode - - local argument_count = __lua_select('#', ...) - - bytecode[length + 1] = __defer_op.assign - bytecode[length + 2] = entity - bytecode[length + 3] = fragment - bytecode[length + 4] = argument_count - - if argument_count == 0 then - -- nothing - elseif argument_count == 1 then - local a1 = ... - bytecode[length + 5] = a1 - elseif argument_count == 2 then - local a1, a2 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - elseif argument_count == 3 then - local a1, a2, a3 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - bytecode[length + 7] = a3 - elseif argument_count == 4 then - local a1, a2, a3, a4 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - bytecode[length + 7] = a3 - bytecode[length + 8] = a4 - else - local a1, a2, a3, a4 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - bytecode[length + 7] = a3 - bytecode[length + 8] = a4 - for i = 5, argument_count do - bytecode[length + 4 + i] = __lua_select(i, ...) - end - end - - __defer_length = length + 4 + argument_count -end - -__defer_ops[__defer_op.assign] = function(bytes, index) - local entity = bytes[index + 0] - local fragment = bytes[index + 1] - local argument_count = bytes[index + 2] - - if argument_count == 0 then - __evolved_assign(entity, fragment) - elseif argument_count == 1 then - local a1 = bytes[index + 3] - __evolved_assign(entity, fragment, a1) - elseif argument_count == 2 then - local a1, a2 = bytes[index + 3], bytes[index + 4] - __evolved_assign(entity, fragment, a1, a2) - elseif argument_count == 3 then - local a1, a2, a3 = bytes[index + 3], bytes[index + 4], bytes[index + 5] - __evolved_assign(entity, fragment, a1, a2, a3) - elseif argument_count == 4 then - local a1, a2, a3, a4 = bytes[index + 3], bytes[index + 4], bytes[index + 5], bytes[index + 6] - __evolved_assign(entity, fragment, a1, a2, a3, a4) - else - local a1, a2, a3, a4 = bytes[index + 3], bytes[index + 4], bytes[index + 5], bytes[index + 6] - __evolved_assign(entity, fragment, a1, a2, a3, a4, - __lua_table_unpack(bytes, index + 7, index + 2 + argument_count)) - end - - return 3 + argument_count -end - ----@param entity evolved.entity ----@param fragment evolved.fragment ----@param ... any component arguments -__defer_insert = function(entity, fragment, ...) - local length = __defer_length - local bytecode = __defer_bytecode - - local argument_count = __lua_select('#', ...) - - bytecode[length + 1] = __defer_op.insert - bytecode[length + 2] = entity - bytecode[length + 3] = fragment - bytecode[length + 4] = argument_count - - if argument_count == 0 then - -- nothing - elseif argument_count == 1 then - local a1 = ... - bytecode[length + 5] = a1 - elseif argument_count == 2 then - local a1, a2 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - elseif argument_count == 3 then - local a1, a2, a3 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - bytecode[length + 7] = a3 - elseif argument_count == 4 then - local a1, a2, a3, a4 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - bytecode[length + 7] = a3 - bytecode[length + 8] = a4 - else - local a1, a2, a3, a4 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - bytecode[length + 7] = a3 - bytecode[length + 8] = a4 - for i = 5, argument_count do - bytecode[length + 4 + i] = __lua_select(i, ...) - end - end - - __defer_length = length + 4 + argument_count -end - -__defer_ops[__defer_op.insert] = function(bytes, index) - local entity = bytes[index + 0] - local fragment = bytes[index + 1] - local argument_count = bytes[index + 2] - - if argument_count == 0 then - __evolved_insert(entity, fragment) - elseif argument_count == 1 then - local a1 = bytes[index + 3] - __evolved_insert(entity, fragment, a1) - elseif argument_count == 2 then - local a1, a2 = bytes[index + 3], bytes[index + 4] - __evolved_insert(entity, fragment, a1, a2) - elseif argument_count == 3 then - local a1, a2, a3 = bytes[index + 3], bytes[index + 4], bytes[index + 5] - __evolved_insert(entity, fragment, a1, a2, a3) - elseif argument_count == 4 then - local a1, a2, a3, a4 = bytes[index + 3], bytes[index + 4], bytes[index + 5], bytes[index + 6] - __evolved_insert(entity, fragment, a1, a2, a3, a4) - else - local a1, a2, a3, a4 = bytes[index + 3], bytes[index + 4], bytes[index + 5], bytes[index + 6] - __evolved_insert(entity, fragment, a1, a2, a3, a4, - __lua_table_unpack(bytes, index + 7, index + 2 + argument_count)) - end - - return 3 + argument_count -end - ---@param entity evolved.entity ---@param ... evolved.fragment fragments __defer_remove = function(entity, ...) @@ -4009,76 +3469,6 @@ __defer_ops[__defer_op.multi_set] = function(bytes, index) return 3 end ----@param entity evolved.entity ----@param fragments evolved.fragment[] ----@param fragment_count integer ----@param components evolved.component[] ----@param component_count integer -__defer_multi_assign = function(entity, fragments, fragment_count, components, component_count) - ---@type evolved.fragment[] - local fragment_list = __acquire_table(__table_pool_tag.fragment_list) - __lua_table_move(fragments, 1, fragment_count, 1, fragment_list) - - ---@type evolved.component[] - local component_list = __acquire_table(__table_pool_tag.component_list) - __lua_table_move(components, 1, component_count, 1, component_list) - - local length = __defer_length - local bytecode = __defer_bytecode - - bytecode[length + 1] = __defer_op.multi_assign - bytecode[length + 2] = entity - bytecode[length + 3] = fragment_list - bytecode[length + 4] = component_list - - __defer_length = length + 4 -end - -__defer_ops[__defer_op.multi_assign] = function(bytes, index) - local entity = bytes[index + 0] - local fragments = bytes[index + 1] - local components = bytes[index + 2] - __evolved_multi_assign(entity, fragments, components) - __release_table(__table_pool_tag.fragment_list, fragments) - __release_table(__table_pool_tag.component_list, components) - return 3 -end - ----@param entity evolved.entity ----@param fragments evolved.fragment[] ----@param fragment_count integer ----@param components evolved.component[] ----@param component_count integer -__defer_multi_insert = function(entity, fragments, fragment_count, components, component_count) - ---@type evolved.fragment[] - local fragment_list = __acquire_table(__table_pool_tag.fragment_list) - __lua_table_move(fragments, 1, fragment_count, 1, fragment_list) - - ---@type evolved.component[] - local component_list = __acquire_table(__table_pool_tag.component_list) - __lua_table_move(components, 1, component_count, 1, component_list) - - local length = __defer_length - local bytecode = __defer_bytecode - - bytecode[length + 1] = __defer_op.multi_insert - bytecode[length + 2] = entity - bytecode[length + 3] = fragment_list - bytecode[length + 4] = component_list - - __defer_length = length + 4 -end - -__defer_ops[__defer_op.multi_insert] = function(bytes, index) - local entity = bytes[index + 0] - local fragments = bytes[index + 1] - local components = bytes[index + 2] - __evolved_multi_insert(entity, fragments, components) - __release_table(__table_pool_tag.fragment_list, fragments) - __release_table(__table_pool_tag.component_list, components) - return 3 -end - ---@param entity evolved.entity ---@param fragments evolved.fragment[] ---@param fragment_count integer @@ -4181,158 +3571,6 @@ __defer_ops[__defer_op.batch_set] = function(bytes, index) return 3 + argument_count end ----@param chunk_or_query evolved.chunk | evolved.query ----@param fragment evolved.fragment ----@param ... any component arguments -__defer_batch_assign = function(chunk_or_query, fragment, ...) - local length = __defer_length - local bytecode = __defer_bytecode - - local argument_count = __lua_select('#', ...) - - bytecode[length + 1] = __defer_op.batch_assign - bytecode[length + 2] = chunk_or_query - bytecode[length + 3] = fragment - bytecode[length + 4] = argument_count - - if argument_count == 0 then - -- nothing - elseif argument_count == 1 then - local a1 = ... - bytecode[length + 5] = a1 - elseif argument_count == 2 then - local a1, a2 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - elseif argument_count == 3 then - local a1, a2, a3 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - bytecode[length + 7] = a3 - elseif argument_count == 4 then - local a1, a2, a3, a4 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - bytecode[length + 7] = a3 - bytecode[length + 8] = a4 - else - local a1, a2, a3, a4 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - bytecode[length + 7] = a3 - bytecode[length + 8] = a4 - for i = 5, argument_count do - bytecode[length + 4 + i] = __lua_select(i, ...) - end - end - - __defer_length = length + 4 + argument_count -end - -__defer_ops[__defer_op.batch_assign] = function(bytes, index) - local chunk_or_query = bytes[index + 0] - local fragment = bytes[index + 1] - local argument_count = bytes[index + 2] - - if argument_count == 0 then - __evolved_batch_assign(chunk_or_query, fragment) - elseif argument_count == 1 then - local a1 = bytes[index + 3] - __evolved_batch_assign(chunk_or_query, fragment, a1) - elseif argument_count == 2 then - local a1, a2 = bytes[index + 3], bytes[index + 4] - __evolved_batch_assign(chunk_or_query, fragment, a1, a2) - elseif argument_count == 3 then - local a1, a2, a3 = bytes[index + 3], bytes[index + 4], bytes[index + 5] - __evolved_batch_assign(chunk_or_query, fragment, a1, a2, a3) - elseif argument_count == 4 then - local a1, a2, a3, a4 = bytes[index + 3], bytes[index + 4], bytes[index + 5], bytes[index + 6] - __evolved_batch_assign(chunk_or_query, fragment, a1, a2, a3, a4) - else - local a1, a2, a3, a4 = bytes[index + 3], bytes[index + 4], bytes[index + 5], bytes[index + 6] - __evolved_batch_assign(chunk_or_query, fragment, a1, a2, a3, a4, - __lua_table_unpack(bytes, index + 7, index + 2 + argument_count)) - end - - return 3 + argument_count -end - ----@param chunk_or_query evolved.chunk | evolved.query ----@param fragment evolved.fragment ----@param ... any component arguments -__defer_batch_insert = function(chunk_or_query, fragment, ...) - local length = __defer_length - local bytecode = __defer_bytecode - - local argument_count = __lua_select('#', ...) - - bytecode[length + 1] = __defer_op.batch_insert - bytecode[length + 2] = chunk_or_query - bytecode[length + 3] = fragment - bytecode[length + 4] = argument_count - - if argument_count == 0 then - -- nothing - elseif argument_count == 1 then - local a1 = ... - bytecode[length + 5] = a1 - elseif argument_count == 2 then - local a1, a2 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - elseif argument_count == 3 then - local a1, a2, a3 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - bytecode[length + 7] = a3 - elseif argument_count == 4 then - local a1, a2, a3, a4 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - bytecode[length + 7] = a3 - bytecode[length + 8] = a4 - else - local a1, a2, a3, a4 = ... - bytecode[length + 5] = a1 - bytecode[length + 6] = a2 - bytecode[length + 7] = a3 - bytecode[length + 8] = a4 - for i = 5, argument_count do - bytecode[length + 4 + i] = __lua_select(i, ...) - end - end - - __defer_length = length + 4 + argument_count -end - -__defer_ops[__defer_op.batch_insert] = function(bytes, index) - local chunk_or_query = bytes[index + 0] - local fragment = bytes[index + 1] - local argument_count = bytes[index + 2] - - if argument_count == 0 then - __evolved_batch_insert(chunk_or_query, fragment) - elseif argument_count == 1 then - local a1 = bytes[index + 3] - __evolved_batch_insert(chunk_or_query, fragment, a1) - elseif argument_count == 2 then - local a1, a2 = bytes[index + 3], bytes[index + 4] - __evolved_batch_insert(chunk_or_query, fragment, a1, a2) - elseif argument_count == 3 then - local a1, a2, a3 = bytes[index + 3], bytes[index + 4], bytes[index + 5] - __evolved_batch_insert(chunk_or_query, fragment, a1, a2, a3) - elseif argument_count == 4 then - local a1, a2, a3, a4 = bytes[index + 3], bytes[index + 4], bytes[index + 5], bytes[index + 6] - __evolved_batch_insert(chunk_or_query, fragment, a1, a2, a3, a4) - else - local a1, a2, a3, a4 = bytes[index + 3], bytes[index + 4], bytes[index + 5], bytes[index + 6] - __evolved_batch_insert(chunk_or_query, fragment, a1, a2, a3, a4, - __lua_table_unpack(bytes, index + 7, index + 2 + argument_count)) - end - - return 3 + argument_count -end - ---@param chunk_or_query evolved.chunk | evolved.query ---@param ... evolved.fragment fragments __defer_batch_remove = function(chunk_or_query, ...) @@ -4583,76 +3821,6 @@ __defer_ops[__defer_op.batch_multi_set] = function(bytes, index) return 3 end ----@param chunk_or_query evolved.chunk | evolved.query ----@param fragments evolved.fragment[] ----@param fragment_count integer ----@param components evolved.component[] ----@param component_count integer -__defer_batch_multi_assign = function(chunk_or_query, fragments, fragment_count, components, component_count) - ---@type evolved.fragment[] - local fragment_list = __acquire_table(__table_pool_tag.fragment_list) - __lua_table_move(fragments, 1, fragment_count, 1, fragment_list) - - ---@type evolved.component[] - local component_list = __acquire_table(__table_pool_tag.component_list) - __lua_table_move(components, 1, component_count, 1, component_list) - - local length = __defer_length - local bytecode = __defer_bytecode - - bytecode[length + 1] = __defer_op.batch_multi_assign - bytecode[length + 2] = chunk_or_query - bytecode[length + 3] = fragment_list - bytecode[length + 4] = component_list - - __defer_length = length + 4 -end - -__defer_ops[__defer_op.batch_multi_assign] = function(bytes, index) - local chunk_or_query = bytes[index + 0] - local fragments = bytes[index + 1] - local components = bytes[index + 2] - __evolved_batch_multi_assign(chunk_or_query, fragments, components) - __release_table(__table_pool_tag.fragment_list, fragments) - __release_table(__table_pool_tag.component_list, components) - return 3 -end - ----@param chunk_or_query evolved.chunk | evolved.query ----@param fragments evolved.fragment[] ----@param fragment_count integer ----@param components evolved.component[] ----@param component_count integer -__defer_batch_multi_insert = function(chunk_or_query, fragments, fragment_count, components, component_count) - ---@type evolved.fragment[] - local fragment_list = __acquire_table(__table_pool_tag.fragment_list) - __lua_table_move(fragments, 1, fragment_count, 1, fragment_list) - - ---@type evolved.component[] - local component_list = __acquire_table(__table_pool_tag.component_list) - __lua_table_move(components, 1, component_count, 1, component_list) - - local length = __defer_length - local bytecode = __defer_bytecode - - bytecode[length + 1] = __defer_op.batch_multi_insert - bytecode[length + 2] = chunk_or_query - bytecode[length + 3] = fragment_list - bytecode[length + 4] = component_list - - __defer_length = length + 4 -end - -__defer_ops[__defer_op.batch_multi_insert] = function(bytes, index) - local chunk_or_query = bytes[index + 0] - local fragments = bytes[index + 1] - local components = bytes[index + 2] - __evolved_batch_multi_insert(chunk_or_query, fragments, components) - __release_table(__table_pool_tag.fragment_list, fragments) - __release_table(__table_pool_tag.component_list, components) - return 3 -end - ---@param chunk_or_query evolved.chunk | evolved.query ---@param fragments evolved.fragment[] ---@param fragment_count integer @@ -5281,17 +4449,17 @@ __evolved_set = function(entity, fragment, ...) local new_chunk = __chunk_with_fragment(old_chunk, fragment) - ---@type evolved.set_hook?, evolved.assign_hook?, evolved.insert_hook? - local fragment_on_set, fragment_on_assign, fragment_on_insert - - if new_chunk.__has_set_or_assign_hooks or new_chunk.__has_set_or_insert_hooks then - fragment_on_set, fragment_on_assign, fragment_on_insert = __evolved_get(fragment, - __ON_SET, __ON_ASSIGN, __ON_INSERT) - end - __evolved_defer() if old_chunk == new_chunk then + ---@type evolved.set_hook?, evolved.assign_hook? + local fragment_on_set, fragment_on_assign + + if old_chunk.__has_set_or_assign_hooks then + fragment_on_set, fragment_on_assign = __evolved_get(fragment, + __ON_SET, __ON_ASSIGN) + end + local old_component_indices = old_chunk.__component_indices local old_component_storages = old_chunk.__component_storages @@ -5351,241 +4519,14 @@ __evolved_set = function(entity, fragment, ...) end end else - local new_entity_list = new_chunk.__entity_list - local new_entity_count = new_chunk.__entity_count + ---@type evolved.set_hook?, evolved.insert_hook? + local fragment_on_set, fragment_on_insert - local new_component_indices = new_chunk.__component_indices - local new_component_storages = new_chunk.__component_storages - - local new_place = new_entity_count + 1 - new_chunk.__entity_count = new_place - - new_entity_list[new_place] = entity - - if old_chunk then - local old_component_count = old_chunk.__component_count - local old_component_storages = old_chunk.__component_storages - local old_component_fragments = old_chunk.__component_fragments - - for old_ci = 1, old_component_count do - local old_f = old_component_fragments[old_ci] - local old_cs = old_component_storages[old_ci] - local new_ci = new_component_indices[old_f] - local new_cs = new_component_storages[new_ci] - new_cs[new_place] = old_cs[old_place] - end - - __detach_entity(old_chunk, old_place) + if new_chunk.__has_set_or_insert_hooks then + fragment_on_set, fragment_on_insert = __evolved_get(fragment, + __ON_SET, __ON_INSERT) end - do - entity_chunks[entity_index] = new_chunk - entity_places[entity_index] = new_place - - __structural_changes = __structural_changes + 1 - end - - do - local new_component_index = new_component_indices[fragment] - - if new_component_index then - local new_component_storage = new_component_storages[new_component_index] - - if new_chunk.__has_defaults_or_constructs then - local new_component = __component_construct(fragment, ...) - - new_component_storage[new_place] = new_component - - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment, new_component) - end - - if fragment_on_insert then - __defer_call_hook(fragment_on_insert, entity, fragment, new_component) - end - else - local new_component = ... - - if new_component == nil then - new_component = true - end - - new_component_storage[new_place] = new_component - - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment, new_component) - end - - if fragment_on_insert then - __defer_call_hook(fragment_on_insert, entity, fragment, new_component) - end - end - else - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment) - end - - if fragment_on_insert then - __defer_call_hook(fragment_on_insert, entity, fragment) - end - end - end - end - - __evolved_commit() - return true, false -end - ----@param entity evolved.entity ----@param fragment evolved.fragment ----@param ... any component arguments ----@return boolean is_assigned ----@return boolean is_deferred -__evolved_assign = function(entity, fragment, ...) - if __defer_depth > 0 then - __defer_assign(entity, fragment, ...) - return false, true - end - - if __debug_mode then - __debug_fns.validate_fragment(fragment) - end - - local entity_index = entity % 0x100000 - - if __freelist_ids[entity_index] ~= entity then - return false, false - end - - local entity_chunks = __entity_chunks - local entity_places = __entity_places - - local chunk = entity_chunks[entity_index] - local place = entity_places[entity_index] - - if not chunk or not chunk.__fragment_set[fragment] then - return false, false - end - - ---@type evolved.set_hook?, evolved.assign_hook? - local fragment_on_set, fragment_on_assign - - if chunk.__has_set_or_assign_hooks then - fragment_on_set, fragment_on_assign = __evolved_get(fragment, - __ON_SET, __ON_ASSIGN) - end - - __evolved_defer() - - do - local component_indices = chunk.__component_indices - local component_storages = chunk.__component_storages - - local component_index = component_indices[fragment] - - if component_index then - local component_storage = component_storages[component_index] - - if chunk.__has_defaults_or_constructs then - local new_component = __component_construct(fragment, ...) - - if fragment_on_set or fragment_on_assign then - local old_component = component_storage[place] - - component_storage[place] = new_component - - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment, new_component, old_component) - end - - if fragment_on_assign then - __defer_call_hook(fragment_on_assign, entity, fragment, new_component, old_component) - end - else - component_storage[place] = new_component - end - else - local new_component = ... - - if new_component == nil then - new_component = true - end - - if fragment_on_set or fragment_on_assign then - local old_component = component_storage[place] - - component_storage[place] = new_component - - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment, new_component, old_component) - end - - if fragment_on_assign then - __defer_call_hook(fragment_on_assign, entity, fragment, new_component, old_component) - end - else - component_storage[place] = new_component - end - end - else - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment) - end - - if fragment_on_assign then - __defer_call_hook(fragment_on_assign, entity, fragment) - end - end - end - - __evolved_commit() - return true, false -end - ----@param entity evolved.entity ----@param fragment evolved.fragment ----@param ... any component arguments ----@return boolean is_inserted ----@return boolean is_deferred -__evolved_insert = function(entity, fragment, ...) - if __defer_depth > 0 then - __defer_insert(entity, fragment, ...) - return false, true - end - - if __debug_mode then - __debug_fns.validate_fragment(fragment) - end - - local entity_index = entity % 0x100000 - - if __freelist_ids[entity_index] ~= entity then - return false, false - end - - local entity_chunks = __entity_chunks - local entity_places = __entity_places - - local old_chunk = entity_chunks[entity_index] - local old_place = entity_places[entity_index] - - local new_chunk = __chunk_with_fragment(old_chunk, fragment) - - if not new_chunk or old_chunk == new_chunk then - return false, false - end - - ---@type evolved.set_hook?, evolved.insert_hook? - local fragment_on_set, fragment_on_insert - - if new_chunk.__has_set_or_insert_hooks then - fragment_on_set, fragment_on_insert = __evolved_get(fragment, - __ON_SET, __ON_INSERT) - end - - __evolved_defer() - - do local new_entity_list = new_chunk.__entity_list local new_entity_count = new_chunk.__entity_count @@ -6191,259 +5132,6 @@ __evolved_multi_set = function(entity, fragments, components) return true, false end ----@param entity evolved.entity ----@param fragments evolved.fragment[] ----@param components? evolved.component[] ----@return boolean is_any_assigned ----@return boolean is_deferred -__evolved_multi_assign = function(entity, fragments, components) - local fragment_count = #fragments - - if fragment_count == 0 then - return false, false - end - - if not components then - components = __safe_tbls.__EMPTY_COMPONENT_LIST - end - - if __defer_depth > 0 then - __defer_multi_assign(entity, fragments, fragment_count, components, #components) - return false, true - end - - if __debug_mode then - __debug_fns.validate_fragment_list(fragments, fragment_count) - end - - local entity_index = entity % 0x100000 - - if __freelist_ids[entity_index] ~= entity then - return false, false - end - - local entity_chunks = __entity_chunks - local entity_places = __entity_places - - local chunk = entity_chunks[entity_index] - local place = entity_places[entity_index] - - if not chunk or not __chunk_has_any_fragment_list(chunk, fragments, fragment_count) then - return false, false - end - - __evolved_defer() - - do - local chunk_fragment_set = chunk.__fragment_set - local chunk_component_indices = chunk.__component_indices - local chunk_component_storages = chunk.__component_storages - - local chunk_has_defaults_or_constructs = chunk.__has_defaults_or_constructs - local chunk_has_set_or_assign_hooks = chunk.__has_set_or_assign_hooks - - for i = 1, fragment_count do - local fragment = fragments[i] - - if chunk_fragment_set[fragment] then - ---@type evolved.set_hook?, evolved.assign_hook? - local fragment_on_set, fragment_on_assign - - if chunk_has_set_or_assign_hooks then - fragment_on_set, fragment_on_assign = __evolved_get(fragment, __ON_SET, __ON_ASSIGN) - end - - local component_index = chunk_component_indices[fragment] - - if component_index then - local component_storage = chunk_component_storages[component_index] - - local new_component = components[i] - - if chunk_has_defaults_or_constructs and new_component == nil then - new_component = __evolved_get(fragment, __DEFAULT) - end - - if new_component == nil then - new_component = true - end - - if fragment_on_set or fragment_on_assign then - local old_component = component_storage[place] - - component_storage[place] = new_component - - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment, new_component, old_component) - end - - if fragment_on_assign then - __defer_call_hook(fragment_on_assign, entity, fragment, new_component, old_component) - end - else - component_storage[place] = new_component - end - else - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment) - end - - if fragment_on_assign then - __defer_call_hook(fragment_on_assign, entity, fragment) - end - end - end - end - end - - __evolved_commit() - return true, false -end - ----@param entity evolved.entity ----@param fragments evolved.fragment[] ----@param components? evolved.component[] ----@return boolean is_any_inserted ----@return boolean is_deferred -__evolved_multi_insert = function(entity, fragments, components) - local fragment_count = #fragments - - if fragment_count == 0 then - return false, false - end - - if not components then - components = __safe_tbls.__EMPTY_COMPONENT_LIST - end - - if __defer_depth > 0 then - __defer_multi_insert(entity, fragments, fragment_count, components, #components) - return false, true - end - - if __debug_mode then - __debug_fns.validate_fragment_list(fragments, fragment_count) - end - - local entity_index = entity % 0x100000 - - if __freelist_ids[entity_index] ~= entity then - return false, false - end - - local entity_chunks = __entity_chunks - local entity_places = __entity_places - - local old_chunk = entity_chunks[entity_index] - local old_place = entity_places[entity_index] - - local new_chunk = __chunk_with_fragment_list(old_chunk, fragments, fragment_count) - - if not new_chunk or old_chunk == new_chunk then - return false, false - end - - __evolved_defer() - - do - local new_entity_list = new_chunk.__entity_list - local new_entity_count = new_chunk.__entity_count - - local new_component_indices = new_chunk.__component_indices - local new_component_storages = new_chunk.__component_storages - - local new_chunk_has_defaults_or_constructs = new_chunk.__has_defaults_or_constructs - local new_chunk_has_set_or_insert_hooks = new_chunk.__has_set_or_insert_hooks - - local old_fragment_set = old_chunk and old_chunk.__fragment_set or __safe_tbls.__EMPTY_FRAGMENT_SET - - local new_place = new_entity_count + 1 - new_chunk.__entity_count = new_place - - new_entity_list[new_place] = entity - - if old_chunk then - local old_component_count = old_chunk.__component_count - local old_component_storages = old_chunk.__component_storages - local old_component_fragments = old_chunk.__component_fragments - - for old_ci = 1, old_component_count do - local old_f = old_component_fragments[old_ci] - local old_cs = old_component_storages[old_ci] - local new_ci = new_component_indices[old_f] - local new_cs = new_component_storages[new_ci] - new_cs[new_place] = old_cs[old_place] - end - - __detach_entity(old_chunk, old_place) - end - - do - entity_chunks[entity_index] = new_chunk - entity_places[entity_index] = new_place - - __structural_changes = __structural_changes + 1 - end - - ---@type table - local inserted_set = __acquire_table(__table_pool_tag.fragment_set) - - for i = 1, fragment_count do - local fragment = fragments[i] - - if not inserted_set[fragment] and not old_fragment_set[fragment] then - inserted_set[fragment] = true - - ---@type evolved.set_hook?, evolved.insert_hook? - local fragment_on_set, fragment_on_insert - - if new_chunk_has_set_or_insert_hooks then - fragment_on_set, fragment_on_insert = __evolved_get(fragment, __ON_SET, __ON_INSERT) - end - - local new_component_index = new_component_indices[fragment] - - if new_component_index then - local new_component_storage = new_component_storages[new_component_index] - - local new_component = components[i] - - if new_chunk_has_defaults_or_constructs and new_component == nil then - new_component = __evolved_get(fragment, __DEFAULT) - end - - if new_component == nil then - new_component = true - end - - new_component_storage[new_place] = new_component - - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment, new_component) - end - - if fragment_on_insert then - __defer_call_hook(fragment_on_insert, entity, fragment, new_component) - end - else - if fragment_on_set then - __defer_call_hook(fragment_on_set, entity, fragment) - end - - if fragment_on_insert then - __defer_call_hook(fragment_on_insert, entity, fragment) - end - end - end - end - - __release_table(__table_pool_tag.fragment_set, inserted_set) - end - - __evolved_commit() - return true, false -end - ---@param entity evolved.entity ---@param fragments evolved.fragment[] ---@return boolean is_all_removed @@ -6605,106 +5293,6 @@ __evolved_batch_set = function(chunk_or_query, fragment, ...) return set_count, false end ----@param chunk_or_query evolved.chunk | evolved.query ----@param fragment evolved.fragment ----@param ... any component arguments ----@return integer assigned_count ----@return boolean is_deferred -__evolved_batch_assign = function(chunk_or_query, fragment, ...) - if __defer_depth > 0 then - __defer_batch_assign(chunk_or_query, fragment, ...) - return 0, true - end - - if __debug_mode then - __debug_fns.validate_fragment(fragment) - end - - local assigned_count = 0 - - __evolved_defer() - do - if __lua_type(chunk_or_query) ~= 'number' then - ---@cast chunk_or_query -evolved.query - local chunk = chunk_or_query --[[@as evolved.chunk]] - - assigned_count = assigned_count + __chunk_assign(chunk, fragment, ...) - else - ---@cast chunk_or_query -evolved.chunk - local query = chunk_or_query --[[@as evolved.query]] - - ---@type evolved.chunk[] - local chunk_list = __acquire_table(__table_pool_tag.chunk_stack) - local chunk_count = 0 - - for chunk in __evolved_execute(query) do - chunk_count = chunk_count + 1 - chunk_list[chunk_count] = chunk - end - - for chunk_index = 1, chunk_count do - local chunk = chunk_list[chunk_index] - assigned_count = assigned_count + __chunk_assign(chunk, fragment, ...) - end - - __release_table(__table_pool_tag.chunk_stack, chunk_list) - end - end - __evolved_commit() - - return assigned_count, false -end - ----@param chunk_or_query evolved.chunk | evolved.query ----@param fragment evolved.fragment ----@param ... any component arguments ----@return integer inserted_count ----@return boolean is_deferred -__evolved_batch_insert = function(chunk_or_query, fragment, ...) - if __defer_depth > 0 then - __defer_batch_insert(chunk_or_query, fragment, ...) - return 0, true - end - - if __debug_mode then - __debug_fns.validate_fragment(fragment) - end - - local inserted_count = 0 - - __evolved_defer() - do - if __lua_type(chunk_or_query) ~= 'number' then - ---@cast chunk_or_query -evolved.query - local chunk = chunk_or_query --[[@as evolved.chunk]] - - inserted_count = inserted_count + __chunk_insert(chunk, fragment, ...) - else - ---@cast chunk_or_query -evolved.chunk - local query = chunk_or_query --[[@as evolved.query]] - - ---@type evolved.chunk[] - local chunk_list = __acquire_table(__table_pool_tag.chunk_stack) - local chunk_count = 0 - - for chunk in __evolved_execute(query) do - chunk_count = chunk_count + 1 - chunk_list[chunk_count] = chunk - end - - for chunk_index = 1, chunk_count do - local chunk = chunk_list[chunk_index] - inserted_count = inserted_count + __chunk_insert(chunk, fragment, ...) - end - - __release_table(__table_pool_tag.chunk_stack, chunk_list) - end - end - __evolved_commit() - - return inserted_count, false -end - ---@param chunk_or_query evolved.chunk | evolved.query ---@param ... evolved.fragment fragments ---@return integer removed_count @@ -6932,126 +5520,6 @@ __evolved_batch_multi_set = function(chunk_or_query, fragments, components) return set_count, false end ----@param chunk_or_query evolved.chunk | evolved.query ----@param fragments evolved.fragment[] ----@param components? evolved.component[] ----@return integer assigned_count ----@return boolean is_deferred -__evolved_batch_multi_assign = function(chunk_or_query, fragments, components) - local fragment_count = #fragments - - if fragment_count == 0 then - return 0, false - end - - if not components then - components = __safe_tbls.__EMPTY_COMPONENT_LIST - end - - if __defer_depth > 0 then - __defer_batch_multi_assign(chunk_or_query, fragments, fragment_count, components, #components) - return 0, true - end - - if __debug_mode then - __debug_fns.validate_fragment_list(fragments, fragment_count) - end - - local assigned_count = 0 - - __evolved_defer() - do - if __lua_type(chunk_or_query) ~= 'number' then - ---@cast chunk_or_query -evolved.query - local chunk = chunk_or_query --[[@as evolved.chunk]] - - assigned_count = assigned_count + __chunk_multi_assign(chunk, fragments, fragment_count, components) - else - ---@cast chunk_or_query -evolved.chunk - local query = chunk_or_query --[[@as evolved.query]] - - ---@type evolved.chunk[] - local chunk_list = __acquire_table(__table_pool_tag.chunk_stack) - local chunk_count = 0 - - for chunk in __evolved_execute(query) do - chunk_count = chunk_count + 1 - chunk_list[chunk_count] = chunk - end - - for chunk_index = 1, chunk_count do - local chunk = chunk_list[chunk_index] - assigned_count = assigned_count + __chunk_multi_assign(chunk, fragments, fragment_count, components) - end - - __release_table(__table_pool_tag.chunk_stack, chunk_list) - end - end - __evolved_commit() - - return assigned_count, false -end - ----@param chunk_or_query evolved.chunk | evolved.query ----@param fragments evolved.fragment[] ----@param components? evolved.component[] ----@return integer inserted_count ----@return boolean is_deferred -__evolved_batch_multi_insert = function(chunk_or_query, fragments, components) - local fragment_count = #fragments - - if fragment_count == 0 then - return 0, false - end - - if not components then - components = __safe_tbls.__EMPTY_COMPONENT_LIST - end - - if __defer_depth > 0 then - __defer_batch_multi_insert(chunk_or_query, fragments, fragment_count, components, #components) - return 0, true - end - - if __debug_mode then - __debug_fns.validate_fragment_list(fragments, fragment_count) - end - - local inserted_count = 0 - - __evolved_defer() - do - if __lua_type(chunk_or_query) ~= 'number' then - ---@cast chunk_or_query -evolved.query - local chunk = chunk_or_query --[[@as evolved.chunk]] - - inserted_count = inserted_count + __chunk_multi_insert(chunk, fragments, fragment_count, components) - else - ---@cast chunk_or_query -evolved.chunk - local query = chunk_or_query --[[@as evolved.query]] - - ---@type evolved.chunk[] - local chunk_list = __acquire_table(__table_pool_tag.chunk_stack) - local chunk_count = 0 - - for chunk in __evolved_execute(query) do - chunk_count = chunk_count + 1 - chunk_list[chunk_count] = chunk - end - - for chunk_index = 1, chunk_count do - local chunk = chunk_list[chunk_index] - inserted_count = inserted_count + __chunk_multi_insert(chunk, fragments, fragment_count, components) - end - - __release_table(__table_pool_tag.chunk_stack, chunk_list) - end - end - __evolved_commit() - - return inserted_count, false -end - ---@param chunk_or_query evolved.chunk | evolved.query ---@param fragments evolved.fragment[] ---@return integer removed_count @@ -8330,15 +6798,15 @@ local function __update_fragment_hooks(fragment) __trace_fragment_chunks(fragment, __update_chunk_caches_trace, fragment) end -assert(__evolved_insert(__ON_SET, __ON_INSERT, __update_fragment_hooks)) -assert(__evolved_insert(__ON_ASSIGN, __ON_INSERT, __update_fragment_hooks)) -assert(__evolved_insert(__ON_INSERT, __ON_INSERT, __update_fragment_hooks)) -assert(__evolved_insert(__ON_REMOVE, __ON_INSERT, __update_fragment_hooks)) +assert(__evolved_set(__ON_SET, __ON_INSERT, __update_fragment_hooks)) +assert(__evolved_set(__ON_ASSIGN, __ON_INSERT, __update_fragment_hooks)) +assert(__evolved_set(__ON_INSERT, __ON_INSERT, __update_fragment_hooks)) +assert(__evolved_set(__ON_REMOVE, __ON_INSERT, __update_fragment_hooks)) -assert(__evolved_insert(__ON_SET, __ON_REMOVE, __update_fragment_hooks)) -assert(__evolved_insert(__ON_ASSIGN, __ON_REMOVE, __update_fragment_hooks)) -assert(__evolved_insert(__ON_INSERT, __ON_REMOVE, __update_fragment_hooks)) -assert(__evolved_insert(__ON_REMOVE, __ON_REMOVE, __update_fragment_hooks)) +assert(__evolved_set(__ON_SET, __ON_REMOVE, __update_fragment_hooks)) +assert(__evolved_set(__ON_ASSIGN, __ON_REMOVE, __update_fragment_hooks)) +assert(__evolved_set(__ON_INSERT, __ON_REMOVE, __update_fragment_hooks)) +assert(__evolved_set(__ON_REMOVE, __ON_REMOVE, __update_fragment_hooks)) --- --- @@ -8413,14 +6881,14 @@ local function __update_fragment_constructs(fragment) __trace_fragment_chunks(fragment, __update_chunk_caches_trace, fragment) end -assert(__evolved_insert(__TAG, __ON_INSERT, __update_fragment_tags)) -assert(__evolved_insert(__TAG, __ON_REMOVE, __update_fragment_tags)) +assert(__evolved_set(__TAG, __ON_INSERT, __update_fragment_tags)) +assert(__evolved_set(__TAG, __ON_REMOVE, __update_fragment_tags)) -assert(__evolved_insert(__DEFAULT, __ON_INSERT, __update_fragment_defaults)) -assert(__evolved_insert(__DEFAULT, __ON_REMOVE, __update_fragment_defaults)) +assert(__evolved_set(__DEFAULT, __ON_INSERT, __update_fragment_defaults)) +assert(__evolved_set(__DEFAULT, __ON_REMOVE, __update_fragment_defaults)) -assert(__evolved_insert(__CONSTRUCT, __ON_INSERT, __update_fragment_constructs)) -assert(__evolved_insert(__CONSTRUCT, __ON_REMOVE, __update_fragment_constructs)) +assert(__evolved_set(__CONSTRUCT, __ON_INSERT, __update_fragment_constructs)) +assert(__evolved_set(__CONSTRUCT, __ON_REMOVE, __update_fragment_constructs)) --- --- @@ -8428,35 +6896,35 @@ assert(__evolved_insert(__CONSTRUCT, __ON_REMOVE, __update_fragment_constructs)) --- --- -assert(__evolved_insert(__TAG, __NAME, 'TAG')) +assert(__evolved_set(__TAG, __NAME, 'TAG')) -assert(__evolved_insert(__NAME, __NAME, 'NAME')) -assert(__evolved_insert(__DEFAULT, __NAME, 'DEFAULT')) -assert(__evolved_insert(__CONSTRUCT, __NAME, 'CONSTRUCT')) +assert(__evolved_set(__NAME, __NAME, 'NAME')) +assert(__evolved_set(__DEFAULT, __NAME, 'DEFAULT')) +assert(__evolved_set(__CONSTRUCT, __NAME, 'CONSTRUCT')) -assert(__evolved_insert(__INCLUDES, __NAME, 'INCLUDES')) -assert(__evolved_insert(__EXCLUDES, __NAME, 'EXCLUDES')) +assert(__evolved_set(__INCLUDES, __NAME, 'INCLUDES')) +assert(__evolved_set(__EXCLUDES, __NAME, 'EXCLUDES')) -assert(__evolved_insert(__ON_SET, __NAME, 'ON_SET')) -assert(__evolved_insert(__ON_ASSIGN, __NAME, 'ON_ASSIGN')) -assert(__evolved_insert(__ON_INSERT, __NAME, 'ON_INSERT')) -assert(__evolved_insert(__ON_REMOVE, __NAME, 'ON_REMOVE')) +assert(__evolved_set(__ON_SET, __NAME, 'ON_SET')) +assert(__evolved_set(__ON_ASSIGN, __NAME, 'ON_ASSIGN')) +assert(__evolved_set(__ON_INSERT, __NAME, 'ON_INSERT')) +assert(__evolved_set(__ON_REMOVE, __NAME, 'ON_REMOVE')) -assert(__evolved_insert(__PHASE, __NAME, 'PHASE')) -assert(__evolved_insert(__GROUP, __NAME, 'GROUP')) -assert(__evolved_insert(__AFTER, __NAME, 'AFTER')) +assert(__evolved_set(__PHASE, __NAME, 'PHASE')) +assert(__evolved_set(__GROUP, __NAME, 'GROUP')) +assert(__evolved_set(__AFTER, __NAME, 'AFTER')) -assert(__evolved_insert(__QUERY, __NAME, 'QUERY')) -assert(__evolved_insert(__EXECUTE, __NAME, 'EXECUTE')) +assert(__evolved_set(__QUERY, __NAME, 'QUERY')) +assert(__evolved_set(__EXECUTE, __NAME, 'EXECUTE')) -assert(__evolved_insert(__PROLOGUE, __NAME, 'PROLOGUE')) -assert(__evolved_insert(__EPILOGUE, __NAME, 'EPILOGUE')) +assert(__evolved_set(__PROLOGUE, __NAME, 'PROLOGUE')) +assert(__evolved_set(__EPILOGUE, __NAME, 'EPILOGUE')) -assert(__evolved_insert(__DISABLED, __NAME, 'DISABLED')) +assert(__evolved_set(__DISABLED, __NAME, 'DISABLED')) -assert(__evolved_insert(__DESTROY_POLICY, __NAME, 'DESTROY_POLICY')) -assert(__evolved_insert(__DESTROY_POLICY_DESTROY_ENTITY, __NAME, 'DESTROY_POLICY_DESTROY_ENTITY')) -assert(__evolved_insert(__DESTROY_POLICY_REMOVE_FRAGMENT, __NAME, 'DESTROY_POLICY_REMOVE_FRAGMENT')) +assert(__evolved_set(__DESTROY_POLICY, __NAME, 'DESTROY_POLICY')) +assert(__evolved_set(__DESTROY_POLICY_DESTROY_ENTITY, __NAME, 'DESTROY_POLICY_DESTROY_ENTITY')) +assert(__evolved_set(__DESTROY_POLICY_REMOVE_FRAGMENT, __NAME, 'DESTROY_POLICY_REMOVE_FRAGMENT')) --- --- @@ -8464,14 +6932,14 @@ assert(__evolved_insert(__DESTROY_POLICY_REMOVE_FRAGMENT, __NAME, 'DESTROY_POLIC --- --- -assert(__evolved_insert(__TAG, __TAG)) +assert(__evolved_set(__TAG, __TAG)) -assert(__evolved_insert(__INCLUDES, __CONSTRUCT, __component_list)) -assert(__evolved_insert(__EXCLUDES, __CONSTRUCT, __component_list)) +assert(__evolved_set(__INCLUDES, __CONSTRUCT, __component_list)) +assert(__evolved_set(__EXCLUDES, __CONSTRUCT, __component_list)) -assert(__evolved_insert(__AFTER, __CONSTRUCT, __component_list)) +assert(__evolved_set(__AFTER, __CONSTRUCT, __component_list)) -assert(__evolved_insert(__DISABLED, __TAG)) +assert(__evolved_set(__DISABLED, __TAG)) --- --- @@ -8481,7 +6949,7 @@ assert(__evolved_insert(__DISABLED, __TAG)) ---@param query evolved.query ---@param include_list evolved.fragment[] -assert(__evolved_insert(__INCLUDES, __ON_SET, function(query, _, include_list) +assert(__evolved_set(__INCLUDES, __ON_SET, function(query, _, include_list) local include_count = #include_list if include_count == 0 then @@ -8500,7 +6968,7 @@ assert(__evolved_insert(__INCLUDES, __ON_SET, function(query, _, include_list) __query_sorted_includes[query] = sorted_includes end)) -assert(__evolved_insert(__INCLUDES, __ON_REMOVE, function(query) +assert(__evolved_set(__INCLUDES, __ON_REMOVE, function(query) __query_sorted_includes[query] = nil end)) @@ -8512,7 +6980,7 @@ end)) ---@param query evolved.query ---@param exclude_list evolved.fragment[] -assert(__evolved_insert(__EXCLUDES, __ON_SET, function(query, _, exclude_list) +assert(__evolved_set(__EXCLUDES, __ON_SET, function(query, _, exclude_list) local exclude_count = #exclude_list if exclude_count == 0 then @@ -8531,7 +6999,7 @@ assert(__evolved_insert(__EXCLUDES, __ON_SET, function(query, _, exclude_list) __query_sorted_excludes[query] = sorted_excludes end)) -assert(__evolved_insert(__EXCLUDES, __ON_REMOVE, function(query) +assert(__evolved_set(__EXCLUDES, __ON_REMOVE, function(query) __query_sorted_excludes[query] = nil end)) @@ -8544,7 +7012,7 @@ end)) ---@param group evolved.group ---@param new_phase evolved.phase ---@param old_phase? evolved.phase -assert(__evolved_insert(__PHASE, __ON_SET, function(group, _, new_phase, old_phase) +assert(__evolved_set(__PHASE, __ON_SET, function(group, _, new_phase, old_phase) if new_phase == old_phase then return end @@ -8573,7 +7041,7 @@ end)) ---@param group evolved.group ---@param old_phase evolved.phase -assert(__evolved_insert(__PHASE, __ON_REMOVE, function(group, _, old_phase) +assert(__evolved_set(__PHASE, __ON_REMOVE, function(group, _, old_phase) local old_phase_groups = __phase_groups[old_phase] if old_phase_groups then @@ -8594,7 +7062,7 @@ end)) ---@param system evolved.system ---@param new_group evolved.group ---@param old_group? evolved.group -assert(__evolved_insert(__GROUP, __ON_SET, function(system, _, new_group, old_group) +assert(__evolved_set(__GROUP, __ON_SET, function(system, _, new_group, old_group) if new_group == old_group then return end @@ -8623,7 +7091,7 @@ end)) ---@param system evolved.system ---@param old_group evolved.group -assert(__evolved_insert(__GROUP, __ON_REMOVE, function(system, _, old_group) +assert(__evolved_set(__GROUP, __ON_REMOVE, function(system, _, old_group) local old_group_systems = __group_systems[old_group] if old_group_systems then @@ -8643,7 +7111,7 @@ end)) ---@param group evolved.group ---@param new_after_list evolved.group[] -assert(__evolved_insert(__AFTER, __ON_SET, function(group, _, new_after_list) +assert(__evolved_set(__AFTER, __ON_SET, function(group, _, new_after_list) local new_after_count = #new_after_list if new_after_count == 0 then @@ -8662,7 +7130,7 @@ assert(__evolved_insert(__AFTER, __ON_SET, function(group, _, new_after_list) end)) ---@param group evolved.group -assert(__evolved_insert(__AFTER, __ON_REMOVE, function(group) +assert(__evolved_set(__AFTER, __ON_REMOVE, function(group) __group_dependencies[group] = nil end)) @@ -8724,27 +7192,19 @@ evolved.has_all = __evolved_has_all evolved.has_any = __evolved_has_any evolved.set = __evolved_set -evolved.assign = __evolved_assign -evolved.insert = __evolved_insert evolved.remove = __evolved_remove evolved.clear = __evolved_clear evolved.destroy = __evolved_destroy evolved.multi_set = __evolved_multi_set -evolved.multi_assign = __evolved_multi_assign -evolved.multi_insert = __evolved_multi_insert evolved.multi_remove = __evolved_multi_remove evolved.batch_set = __evolved_batch_set -evolved.batch_assign = __evolved_batch_assign -evolved.batch_insert = __evolved_batch_insert evolved.batch_remove = __evolved_batch_remove evolved.batch_clear = __evolved_batch_clear evolved.batch_destroy = __evolved_batch_destroy evolved.batch_multi_set = __evolved_batch_multi_set -evolved.batch_multi_assign = __evolved_batch_multi_assign -evolved.batch_multi_insert = __evolved_batch_multi_insert evolved.batch_multi_remove = __evolved_batch_multi_remove evolved.chunk = __evolved_chunk