8.2. Boost package for DECS
The DECS_BOOST module provides convenience macros and syntactic sugar for the DECS entity component system, including simplified component registration, entity creation, and system definition patterns.
See also DECS, Daslang entity component system for the core ECS runtime and DECS debug state reporting for entity state machines. See Entity Component System (DECS) for a hands-on tutorial.
All functions and symbols are in “decs_boost” module, use require to get access to it.
require daslib/decs_boost
Example:
options persistent_heap = true
require daslib/decs_boost
[export]
def main() {
restart()
create_entity() @(eid, cmp) {
cmp |> set("pos", float3(1, 2, 3))
cmp |> set("name", "hero")
}
commit()
query() $(pos : float3; name : string) {
print("{name} at {pos}\n")
}
}
// output:
// hero at 1,2,3
8.2.1. Function annotations
- REQUIRE
This annotation provides list of required components for entity.
- decs
This macro converts a function into a DECS pass stage query. Possible arguments are stage, REQUIRE, and REQUIRE_NOT.
- REQUIRE_NOT
This annotation provides list of components, which are required to not be part of the entity.
8.2.2. Call macros
- find_query
This macro implements find_query functionality.
- from_decs_template
This macro converts a DECS query over a [decs_template] struct into an iterator<tuple<...>>.
- query
This macro implements query functionality. There are 2 types of queries:
- from_decs
This macro converts a DECS query into an iterator<tuple<...>>.
8.2.3. Structure macros
- decs_template
This macro creates a template for the given structure.