Struct UnitAction

Source
pub struct UnitAction { /* private fields */ }
Expand description

A struct that represents an action that can be performed by a “Unit”.

Implementations§

Source§

impl UnitAction

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn get_name(&self) -> String

Gets the name of the “UnitAction”.

Source

pub fn is_doing(&self) -> bool

Gets whether the “Unit” is currently performing the “UnitAction” or not.

Source

pub fn get_owner(&self) -> Unit

Gets the “Unit” that owns this “UnitAction”.

Source

pub fn get_elapsed_time(&self) -> f32

Gets the elapsed time since the “UnitAction” was started, in seconds.

Source

pub fn clear()

Removes all “UnitAction” objects from the “UnitActionClass”.

Source

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”. UnitAction with higher priority (larger number) will replace the running lower priority UnitAction. If performing UnitAction having the same priority with the running UnitAction and the UnitAction to perform having the param ‘queued’ to be true, the running UnitAction won’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 the Playable animation 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 a Unit object and a UnitAction object and returns a boolean value indicating whether the “UnitAction” is available to be performed.
  • create - A function that takes a Unit object and a UnitAction object and returns a WasmActionUpdate object that contains the update function for the “UnitAction”.
  • stop - A function that takes a Unit object and a UnitAction object and stops the “UnitAction”.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.