Task
The Task
component is used to schedule tasks to be executed at a later time.
A task can either complete when a predicate is met, or after a certain amount
of time has passed, or as soon as possible. The Children component can be
additionally used to create dependencies between tasks, with child tasks
blocking the parent.
instantiate(game, [
task_then(() => do_something()),
children([
task_delay(10),
children([
task_when(() => is_something_true()),
]),
]),
]);
When a task completes, its entity is destroyed. For this reason, when adding
tasks to entities which represent game objects, don't mix them with other
components; add them as children instead.
instantiate(game, [
transform(...),
render(...),
control_player(...),
children([
task_then(() => do_something()),
children([
task_delay(10),
]),
]),
]);