mirror of
https://github.com/bakpakin/tiny-ecs.git
synced 2024-10-12 19:44:17 +00:00
Change sorted System calbacks.
This commit is contained in:
parent
994f3b6533
commit
e96d494526
@ -62,7 +62,9 @@ end
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Use It ##
|
## Use It ##
|
||||||
Copy paste tiny.lua into your source folder.
|
Copy paste tiny.lua into your source folder. For stability and consistent API,
|
||||||
|
please use a tagged release or use luarocks. Tagged releases will have a version
|
||||||
|
number in `tiny._VERSION`, while other commits will just have the string 'dev'.
|
||||||
|
|
||||||
## Luarocks ##
|
## Luarocks ##
|
||||||
Tiny-ecs is also on [Luarocks](https://luarocks.org/) and can be installed with
|
Tiny-ecs is also on [Luarocks](https://luarocks.org/) and can be installed with
|
||||||
|
7
tiny.lua
7
tiny.lua
@ -174,9 +174,9 @@ local function sortedSystemOnModify(system, dt)
|
|||||||
local entityIndices = system.entityIndices
|
local entityIndices = system.entityIndices
|
||||||
local sortDelegate = system.sortDelegate
|
local sortDelegate = system.sortDelegate
|
||||||
if not sortDelegate then
|
if not sortDelegate then
|
||||||
local sort = system.sort
|
local compare = system.compare
|
||||||
sortDelegate = function(e1, e2)
|
sortDelegate = function(e1, e2)
|
||||||
sort(system, e1, e2)
|
compare(system, e1, e2)
|
||||||
end
|
end
|
||||||
system.sortDelegate = sortDelegate
|
system.sortDelegate = sortDelegate
|
||||||
end
|
end
|
||||||
@ -197,7 +197,7 @@ end
|
|||||||
-- `function system:postProcess(entities, dt)` - returns nil,
|
-- `function system:postProcess(entities, dt)` - returns nil,
|
||||||
-- `function system:onAdd(entity)` - returns nil,
|
-- `function system:onAdd(entity)` - returns nil,
|
||||||
-- `function system:onRemove(entity)` - returns nil,
|
-- `function system:onRemove(entity)` - returns nil,
|
||||||
-- `function system:sort(entity1, entity2)` - returns boolean.
|
-- `function system:compare(entity1, entity2)` - returns boolean.
|
||||||
-- For Filters, it is conveient to use `tiny.requireAll` or `tiny.requireOne`,
|
-- For Filters, it is conveient to use `tiny.requireAll` or `tiny.requireOne`,
|
||||||
-- but one can write their own filters as well.
|
-- but one can write their own filters as well.
|
||||||
-- @param table A table to be used as a System, or `nil` to create a new
|
-- @param table A table to be used as a System, or `nil` to create a new
|
||||||
@ -207,6 +207,7 @@ function tiny.sortedSystem(table)
|
|||||||
table[systemTableKey] = true
|
table[systemTableKey] = true
|
||||||
table.update = processingSystemUpdate
|
table.update = processingSystemUpdate
|
||||||
table.onModify = sortedSystemOnModify
|
table.onModify = sortedSystemOnModify
|
||||||
|
table.sort = sortedSystemOnModify
|
||||||
return table
|
return table
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user