mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-14 12:10:23 +07:00
evolved.TAG is a TAG :-)
This commit is contained in:
18
README.md
18
README.md
@@ -1,5 +1,23 @@
|
||||
# evolved.lua (work in progress)
|
||||
|
||||
## Constants
|
||||
|
||||
```
|
||||
TAG :: fragment
|
||||
DEFAULT :: fragment
|
||||
CONSTRUCT :: fragment
|
||||
|
||||
ON_SET :: fragment
|
||||
ON_ASSIGN :: fragment
|
||||
ON_INSERT :: fragment
|
||||
ON_REMOVE :: fragment
|
||||
|
||||
INCLUDE_LIST :: fragment
|
||||
EXCLUDE_LIST :: fragment
|
||||
```
|
||||
|
||||
## Functions
|
||||
|
||||
```
|
||||
id :: integer? -> id...
|
||||
|
||||
|
||||
@@ -2223,3 +2223,80 @@ do
|
||||
assert(evo.get(e1, f1) == nil)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local f1, f2 = evo.id(2)
|
||||
|
||||
local q = evo.id()
|
||||
evo.set(q, evo.INCLUDE_LIST, { f1 })
|
||||
evo.set(q, evo.INCLUDE_LIST, { f2 })
|
||||
|
||||
local e1 = evo.id()
|
||||
assert(evo.insert(e1, f1, 41))
|
||||
|
||||
local e2 = evo.id()
|
||||
assert(evo.insert(e2, f2, 42))
|
||||
|
||||
do
|
||||
local iter, state = evo.execute(q)
|
||||
local chunk, entities = iter(state)
|
||||
|
||||
assert(chunk == evo.chunk(f2))
|
||||
assert(entities and entities[1] == e2)
|
||||
end
|
||||
|
||||
evo.set(q, evo.INCLUDE_LIST)
|
||||
|
||||
do
|
||||
local iter, state = evo.execute(q)
|
||||
local chunk, entities = iter(state)
|
||||
|
||||
assert(not chunk)
|
||||
assert(not entities)
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local f1, f2 = evo.id(2)
|
||||
|
||||
local q = evo.id()
|
||||
evo.set(q, evo.INCLUDE_LIST, { f1 })
|
||||
|
||||
evo.set(q, evo.EXCLUDE_LIST, { f1 })
|
||||
evo.set(q, evo.EXCLUDE_LIST, { f2 })
|
||||
|
||||
local e1 = evo.id()
|
||||
assert(evo.insert(e1, f1, 41))
|
||||
|
||||
local e2 = evo.id()
|
||||
assert(evo.insert(e2, f1, 43))
|
||||
assert(evo.insert(e2, f2, 44))
|
||||
|
||||
do
|
||||
local iter, state = evo.execute(q)
|
||||
local chunk, entities = iter(state)
|
||||
assert(chunk == evo.chunk(f1))
|
||||
assert(entities and entities[1] == e1)
|
||||
|
||||
chunk, entities = iter(state)
|
||||
assert(not chunk)
|
||||
assert(not entities)
|
||||
end
|
||||
|
||||
evo.set(q, evo.EXCLUDE_LIST)
|
||||
|
||||
do
|
||||
local iter, state = evo.execute(q)
|
||||
local chunk, entities = iter(state)
|
||||
assert(chunk == evo.chunk(f1))
|
||||
assert(entities and entities[1] == e1)
|
||||
|
||||
chunk, entities = iter(state)
|
||||
assert(chunk == evo.chunk(f1, f2))
|
||||
assert(entities and entities[1] == e2)
|
||||
|
||||
chunk, entities = iter(state)
|
||||
assert(not chunk)
|
||||
assert(not entities)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2123,6 +2123,8 @@ local __EXCLUDE_SET = __acquire_id()
|
||||
local __SORTED_INCLUDE_LIST = __acquire_id()
|
||||
local __SORTED_EXCLUDE_LIST = __acquire_id()
|
||||
|
||||
assert(evolved.insert(evolved.TAG, evolved.TAG))
|
||||
|
||||
assert(evolved.insert(evolved.INCLUDE_LIST, evolved.CONSTRUCT, function(_, _, include_list)
|
||||
return include_list or {}
|
||||
end))
|
||||
|
||||
Reference in New Issue
Block a user