Trait bevy_sequential_actions::Action
source · [−]pub trait Action: Send + Sync {
fn add(
&mut self,
actor: Entity,
world: &mut World,
commands: &mut ActionCommands
);
fn remove(&mut self, actor: Entity, world: &mut World);
fn stop(&mut self, actor: Entity, world: &mut World);
}
Expand description
The trait that all actions must implement.
Example
An empty action that does nothing.
All actions must declare when they are done.
This is done by calling ActionCommands::next_action
.
struct EmptyAction;
impl Action for EmptyAction {
fn add(&mut self, actor: Entity, world: &mut World, commands: &mut ActionCommands) {
// Action is finished, issue next.
commands.next_action(actor);
}
fn remove(&mut self, actor: Entity, world: &mut World) {}
fn stop(&mut self, actor: Entity, world: &mut World) {}
}
Required Methods
fn add(
&mut self,
actor: Entity,
world: &mut World,
commands: &mut ActionCommands
)
fn add(
&mut self,
actor: Entity,
world: &mut World,
commands: &mut ActionCommands
)
The method that is called when an Action
is started.
The method that is called when an Action
is removed.