SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Sleak::AnimationStateMachine Class Reference

#include <AnimationStateMachine.hpp>

Public Member Functions

 AnimationStateMachine ()=default
 ~AnimationStateMachine ()=default
int AddState (const std::string &name, AnimationClip *clip, bool loop=true, float speed=1.0f)
 Adds a state bound to clip, returning its index for use in AddTransition.
int AddTransition (int from, int to, float blendDuration=0.3f, bool waitForClipEnd=false)
 Adds a transition edge from -> to, returning its index.
void AddTransitionCondition (int transIndex, const std::string &paramName, CompareOp op, ParamValue threshold)
 Appends a guard condition to the transition at transIndex.
const std::string & GetCurrentStateName () const
bool IsBlending () const
void SetBool (const std::string &name, bool value)
void SetDefaultState (int stateIndex)
 Sets the state the machine starts in, with no blend.
void SetFloat (const std::string &name, float value)
void SetInt (const std::string &name, int value)
SampleRequest Update (float deltaTime)
 Advances playback/blend time, evaluates transitions, and returns what to sample this frame.

Detailed Description

Graph of animation states and blended transitions, driven by named bool/float/int parameters set from gameplay code.

Definition at line 67 of file AnimationStateMachine.hpp.

Constructor & Destructor Documentation

◆ AnimationStateMachine()

Sleak::AnimationStateMachine::AnimationStateMachine ( )
default

◆ ~AnimationStateMachine()

Sleak::AnimationStateMachine::~AnimationStateMachine ( )
default

Member Function Documentation

◆ AddState()

int Sleak::AnimationStateMachine::AddState ( const std::string & name,
AnimationClip * clip,
bool loop = true,
float speed = 1.0f )

Adds a state bound to clip, returning its index for use in AddTransition.

Definition at line 9 of file AnimationStateMachine.cpp.

◆ AddTransition()

int Sleak::AnimationStateMachine::AddTransition ( int from,
int to,
float blendDuration = 0.3f,
bool waitForClipEnd = false )

Adds a transition edge from -> to, returning its index.

Definition at line 16 of file AnimationStateMachine.cpp.

◆ AddTransitionCondition()

void Sleak::AnimationStateMachine::AddTransitionCondition ( int transIndex,
const std::string & paramName,
CompareOp op,
ParamValue threshold )

Appends a guard condition to the transition at transIndex.

Definition at line 28 of file AnimationStateMachine.cpp.

◆ GetCurrentStateName()

const std::string & Sleak::AnimationStateMachine::GetCurrentStateName ( ) const

Definition at line 55 of file AnimationStateMachine.cpp.

◆ IsBlending()

bool Sleak::AnimationStateMachine::IsBlending ( ) const
inline

Definition at line 96 of file AnimationStateMachine.hpp.

◆ SetBool()

void Sleak::AnimationStateMachine::SetBool ( const std::string & name,
bool value )

Definition at line 43 of file AnimationStateMachine.cpp.

◆ SetDefaultState()

void Sleak::AnimationStateMachine::SetDefaultState ( int stateIndex)

Sets the state the machine starts in, with no blend.

Definition at line 37 of file AnimationStateMachine.cpp.

◆ SetFloat()

void Sleak::AnimationStateMachine::SetFloat ( const std::string & name,
float value )

Definition at line 47 of file AnimationStateMachine.cpp.

◆ SetInt()

void Sleak::AnimationStateMachine::SetInt ( const std::string & name,
int value )

Definition at line 51 of file AnimationStateMachine.cpp.

◆ Update()

SampleRequest Sleak::AnimationStateMachine::Update ( float deltaTime)

Advances playback/blend time, evaluates transitions, and returns what to sample this frame.

Definition at line 62 of file AnimationStateMachine.cpp.