he default / initial state; ASAP it should switch to Spawn.
Spawn
It would stay in Spawn for at least 1 frame, before switching to Alive.
Can be prolonged.
Alive
The entity will remain in Alive, until its Health drops to 0; then switches to Death.
If the entity has no Health component, then it will stay alive forever (for now).
Death
Remain in Death for at least 1 frame, then switch to Despawn.
Can be prolonged.
Despawn
When in Despawn, the entity should be deleted.
Prolonging a lifecycle state
Spawn and Death states can be prolonged for one or more frames.
By calling a method (Lifecycle::prolong?) on the component.
Events/actions tie-in
Instead of having event actions such as OnSpawn or OnDeath, have an action such as
Lifecycle, which takes a lifecycle state as its unnamed field and
runs the action for each frame that the specified state is active.
Example config
events: {
Lifecycle(Spawn): Echo("Hello World!"),
Lifecycle(Alive): Echo("Still alive..."), // called every frame while Alive
Lifecycle(Death): Echo("Farewell cruel world."),
},
Introduce a
Lifecycle
component for entities. Instead of having event actions such asOnSpawn
andOnDeath
, tie those into an entity's lifecycle.Brief lifecycle state descriptions
Initial
he default / initial state; ASAP it should switch to
Spawn
.Spawn
It would stay in
Spawn
for at least 1 frame, before switching toAlive
. Can be prolonged.Alive
The entity will remain in
Alive
, until itsHealth
drops to0
; then switches toDeath
. If the entity has noHealth
component, then it will stay alive forever (for now).Death
Remain in
Death
for at least 1 frame, then switch toDespawn
. Can be prolonged.Despawn
When in
Despawn
, the entity should be deleted.Prolonging a lifecycle state
Spawn
andDeath
states can be prolonged for one or more frames. By calling a method (Lifecycle::prolong
?) on the component.Events/actions tie-in
Instead of having event actions such as
OnSpawn
orOnDeath
, have an action such asLifecycle
, which takes a lifecycle state as its unnamed field and runs the action for each frame that the specified state is active.Example config