Function System.from
Dynamically generate a new System
instance given a function.
When a generated System is run it will try to apply the World's Entities, Components, and Resources to the function's parameters.
See isCallableAsSystem § Satisfaction Requirements to understand the requirements of isCallableAsSystem
.
See Parameter Application to understand how parameters are applied at runtime.
See Also: isCallableAsSystem
Parameter Application
When ran, a generated System will:- For each of the World's Entities, either:
- Apply a constant reference to the World for
World
parameters - Apply a constant reference to the current Entity for
Entity
parameters - Apply a constant reference to the World's Resources for
Resources
parameters - Apply a constant reference to the generated System for
System
parameters - Try to find a matching Entity Component to apply given a parameter's type and name:
struct
andComponent
parameter names must match an Entity's Component name- Try to find a matching World Resource to apply given the parameter's type is one of:
- Basic Data
- arrays
- string
struct
- Or, if a parameter could not be applied, continue to the next Entity
- Call the user-provided function for Entities if and only if all parameters were be applied
- For all
struct
andComponent
parameters with theref
storage class, update the Component
Returns
A newly instantiated SystemGenerator
, a function that initializes a new generated System
given a World
reference.