#[system]Expand description
Marks a function as a system
Validates that the function has the correct signature for a system:
- Exactly one parameter
- Parameter type must be
&mut Context
This macro doesn’t transform the function, it only validates at compile time.
The actual system registration happens via add_system() or add_startup_system().
§Example
ⓘ
#[system]
fn movement(ctx: &mut Context) {
ctx.world_mut()
.select_mut::<(Position, Velocity)>()
.each(|_, (pos, vel)| {
pos.x += vel.x;
});
}§Errors
Compile error if:
- Function has zero or multiple parameters
- Parameter is not
&mut Context