mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-14 04:00:14 +07:00
systems can be queries themselves
This commit is contained in:
27
README.md
27
README.md
@@ -671,6 +671,29 @@ The [`evolved.process`](#evolvedprocess) function is used to process systems. It
|
||||
function evolved.process(...) end
|
||||
```
|
||||
|
||||
If you don't specify a query for the system, the system itself will be treated as a query. This means the system can contain `evolved.INCLUDES` and `evolved.EXCLUDES` fragments, and it will be processed according to them. This is useful for creating systems with unique queries that don't need to be reused in other systems.
|
||||
|
||||
```lua
|
||||
local evolved = require 'evolved'
|
||||
|
||||
local health = evolved.id()
|
||||
|
||||
local system = evolved.builder()
|
||||
:include(health)
|
||||
:execute(function(chunk, entity_list, entity_count)
|
||||
local health_components = chunk:components(health)
|
||||
|
||||
for i = 1, entity_count do
|
||||
print(i)
|
||||
health_components[i] = math.max(
|
||||
health_components[i] - 1,
|
||||
0)
|
||||
end
|
||||
end):spawn()
|
||||
|
||||
evolved.process(system)
|
||||
```
|
||||
|
||||
To group systems together, you can use the [`evolved.GROUP`](#evolvedgroup) fragment. Systems with a specified group will be processed when you call the [`evolved.process`](#evolvedprocess) function with this group. For example, you can group all physics systems together and process them in one [`evolved.process`](#evolvedprocess) call.
|
||||
|
||||
```lua
|
||||
@@ -1125,6 +1148,10 @@ builder_mt:destruction_policy :: id -> builder
|
||||
|
||||
# Changelog
|
||||
|
||||
## vX.X.X-dev
|
||||
|
||||
- Systems can be queries themselves
|
||||
|
||||
## v1.0.0
|
||||
|
||||
- Initial release
|
||||
|
||||
Reference in New Issue
Block a user