mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-13 19:48:00 +07:00
Merge branch 'dev'
This commit is contained in:
@@ -94,7 +94,9 @@ batch_multi_remove :: query, fragment[] -> integer, boolean
|
||||
|
||||
chunk :: fragment... -> chunk?, entity[]?, integer?
|
||||
select :: chunk, fragment... -> component[]...
|
||||
|
||||
entities :: chunk -> entity[], integer
|
||||
fragments :: chunk -> fragment[], integer
|
||||
|
||||
each :: entity -> {each_state? -> fragment?, component?}, each_state?
|
||||
execute :: query -> {execute_state? -> chunk?, entity[]?, integer?}, execute_state?
|
||||
|
||||
@@ -7119,3 +7119,68 @@ do
|
||||
assert(evo.get(f2, evo.ON_DESTROY) == evo.DESTROY_ENTITY_POLICY)
|
||||
assert(evo.get(f3, evo.ON_DESTROY) == evo.REMOVE_FRAGMENT_POLICY)
|
||||
end
|
||||
|
||||
do
|
||||
local f1, f2, f3 = evo.id(3)
|
||||
|
||||
local c1 = evo.chunk(f1)
|
||||
local c23 = evo.chunk(f2, f3)
|
||||
|
||||
assert(c1 and c23)
|
||||
|
||||
assert(#evo.fragments(c1) == 1)
|
||||
assert(evo.fragments(c1)[1] == f1)
|
||||
|
||||
assert(#evo.fragments(c23) == 2)
|
||||
assert(evo.fragments(c23)[1] == f2)
|
||||
assert(evo.fragments(c23)[2] == f3)
|
||||
end
|
||||
|
||||
do
|
||||
local f0, f1, f2, f3 = evo.id(4)
|
||||
|
||||
local e1 = evo.entity():set(f0, 0):set(f1, 1):build()
|
||||
local e12 = evo.entity():set(f0, 0):set(f1, 2):set(f2, 3):build()
|
||||
local e123 = evo.entity():set(f0, 0):set(f1, 4):set(f2, 5):set(f3, 6):build()
|
||||
|
||||
evo.entity():set(f1, 41):build()
|
||||
evo.entity():set(f1, 42):set(f2, 43):build()
|
||||
|
||||
do
|
||||
local q1 = evo.query():include(f0, f1):build()
|
||||
|
||||
local iter, state = evo.execute(q1)
|
||||
|
||||
local chunk, entity_list = iter(state)
|
||||
assert(entity_list and #entity_list == 1)
|
||||
assert(chunk == evo.chunk(f0, f1) and entity_list[1] == e1)
|
||||
|
||||
chunk, entity_list = iter(state)
|
||||
assert(entity_list and #entity_list == 1)
|
||||
assert(chunk == evo.chunk(f0, f1, f2) and entity_list[1] == e12)
|
||||
|
||||
chunk, entity_list = iter(state)
|
||||
assert(entity_list and #entity_list == 1)
|
||||
assert(chunk == evo.chunk(f0, f1, f2, f3) and entity_list[1] == e123)
|
||||
|
||||
chunk, entity_list = iter(state)
|
||||
assert(not chunk and not entity_list)
|
||||
end
|
||||
|
||||
do
|
||||
local q1 = evo.query():include(f0, f1):exclude(f3):build()
|
||||
|
||||
local iter, state = evo.execute(q1)
|
||||
|
||||
local chunk, entity_list = iter(state)
|
||||
assert(entity_list and #entity_list == 1)
|
||||
assert(chunk == evo.chunk(f0, f1) and entity_list[1] == e1)
|
||||
|
||||
chunk, entity_list = iter(state)
|
||||
assert(entity_list and #entity_list == 1)
|
||||
assert(chunk == evo.chunk(f0, f1, f2) and entity_list[1] == e12)
|
||||
|
||||
chunk, entity_list = iter(state)
|
||||
assert(not chunk and not entity_list)
|
||||
end
|
||||
end
|
||||
|
||||
377
evolved.lua
377
evolved.lua
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user