pub struct UnitAction { /* private fields */ }Expand description
A struct that represents an action that can be performed by a “Unit”.
Implementations§
Source§impl UnitAction
impl UnitAction
Sourcepub fn set_reaction(&mut self, val: f32)
pub fn set_reaction(&mut self, val: f32)
Sets the length of the reaction time for the “UnitAction”, in seconds. The reaction time will affect the AI check cycling time.
Sourcepub fn get_reaction(&self) -> f32
pub fn get_reaction(&self) -> f32
Gets the length of the reaction time for the “UnitAction”, in seconds. The reaction time will affect the AI check cycling time.
Sourcepub fn set_recovery(&mut self, val: f32)
pub fn set_recovery(&mut self, val: f32)
Sets the length of the recovery time for the “UnitAction”, in seconds.
The recovery time will mainly affect how long the Playable animation model will do transitions between animations played by different actions.
Sourcepub fn get_recovery(&self) -> f32
pub fn get_recovery(&self) -> f32
Gets the length of the recovery time for the “UnitAction”, in seconds.
The recovery time will mainly affect how long the Playable animation model will do transitions between animations played by different actions.
Sourcepub fn is_doing(&self) -> bool
pub fn is_doing(&self) -> bool
Gets whether the “Unit” is currently performing the “UnitAction” or not.
Sourcepub fn get_elapsed_time(&self) -> f32
pub fn get_elapsed_time(&self) -> f32
Gets the elapsed time since the “UnitAction” was started, in seconds.
Sourcepub fn add(
name: &str,
priority: i32,
reaction: f32,
recovery: f32,
queued: bool,
available: Box<dyn FnMut(&Unit, &UnitAction) -> bool>,
create: Box<dyn FnMut(&Unit, &UnitAction) -> ActionUpdate>,
stop: Box<dyn FnMut(&Unit, &UnitAction)>,
)
pub fn add( name: &str, priority: i32, reaction: f32, recovery: f32, queued: bool, available: Box<dyn FnMut(&Unit, &UnitAction) -> bool>, create: Box<dyn FnMut(&Unit, &UnitAction) -> ActionUpdate>, stop: Box<dyn FnMut(&Unit, &UnitAction)>, )
Adds a new “UnitAction” to the “UnitActionClass” with the specified name and parameters.
§Arguments
name- The name of the “UnitAction”.priority- The priority level for the “UnitAction”.UnitActionwith higher priority (larger number) will replace the running lower priorityUnitAction. If performingUnitActionhaving the same priority with the runningUnitActionand theUnitActionto perform having the param ‘queued’ to be true, the runningUnitActionwon’t be replaced.reaction- The length of the reaction time for the “UnitAction”, in seconds. The reaction time will affect the AI check cycling time. Set to 0.0 to make AI check run in every update.recovery- The length of the recovery time for the “UnitAction”, in seconds. The recovery time will mainly affect how long thePlayableanimation model will do transitions between animations played by different actions.queued- Whether the “UnitAction” is currently queued or not. The queued “UnitAction” won’t replace the running “UnitAction” with a same priority.available- A function that takes aUnitobject and aUnitActionobject and returns a boolean value indicating whether the “UnitAction” is available to be performed.create- A function that takes aUnitobject and aUnitActionobject and returns aWasmActionUpdateobject that contains the update function for the “UnitAction”.stop- A function that takes aUnitobject and aUnitActionobject and stops the “UnitAction”.