Skip to main content

Character

Struct Character 

Source
pub struct Character {
    pub desc: CharacterDescription,
    pub position: [f32; 3],
    pub yaw: f32,
    pub direction: [f32; 3],
    pub speed: f32,
    pub target_heading: f32,
    pub flag_28: bool,
    pub scale: f32,
    pub animation: AnimationStack,
    pub stack: ActionStack,
    pub tree_slot: i32,
}
Expand description

The character state the actions drive.

Fields§

§desc: CharacterDescription

The character description: speeds and turning.

§position: [f32; 3]

The position of the model.

§yaw: f32

The heading in degrees, including the model’s yaw offset.

§direction: [f32; 3]

The walking direction.

§speed: f32

The walking speed.

§target_heading: f32

The heading it turns towards.

§flag_28: bool

Set with a heading of its own, cleared when a waypoint is faced; no byte read of it was found in the Application outside the saves, which keep it.

Original: FUN_14010f5b0.

§scale: f32

The model’s z scale, which scales the walking speed.

§animation: AnimationStack

The model’s animation state, its clips blending into each other.

§stack: ActionStack

The actions it runs.

§tree_slot: i32

Its slot in the characters’ tree (Game), −1 while in none.

Implementations§

Source§

impl Character

Source

pub fn new( desc: CharacterDescription, position: [f32; 3], scale: f32, ) -> Character

A character at a position, with its description and its model’s scale.

Source

pub fn play(&mut self, anim: usize, group: &AnimationGroup, speed: f32)

Play clip anim (a looping clip already playing keeps its time, AnimationState::PlayAnimation) and set the speed to scale * speed.

Original: FUN_14010f6c0.

Source

pub fn update(&mut self, world: &mut World<'_>, group: &AnimationGroup, dt: f32)

Run the actions, turn and move. dt is the manager’s iteration delta. Call Character::animate first: AnimationManager::Update runs before the entity manager in each iteration, and the move uses that step’s root motion.

Original: FUN_14010e990.

Source

pub fn animate(&mut self, group: &AnimationGroup, dt: f32)

Graphics::AnimationManager::Update: advance the clip; the root delta moves the body.

Source

pub fn walk(&mut self, world: &World<'_>, group: &AnimationGroup)

The movement part of a character’s update, after the actions ran and the clip advanced.

Original: the second half of FUN_14010e990.

Source

pub fn face(&mut self, target: [f32; 3])

Face a point and walk toward it (the end of a MoveTo). The direction is the 2D unit vector normalised again in 3D; the heading comes from the 2D vector.

Original: FUN_1400ce1f0.

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.