![]() |
Kale
|
#include <StateAnimatable.hpp>
Public Member Functions | |
StateAnimatable () | |
StateAnimatable (JSON json) | |
void | updateState (float deltaTime) |
template<typename T > | |
void | addStructure (T state, const S &structure) |
template<typename T > | |
void | removeStructure (T state) |
template<typename T > | |
S | getStructure (T state) const |
template<typename T > | |
void | animateTo (T state, float duration) |
template<typename T > | |
void | animateOnce (std::vector< std::pair< T, float > > stages) |
template<typename T > | |
void | animateLoop (std::vector< std::pair< T, float > > stages) |
template<typename T > | |
void | setState (T state) |
template<typename T > | |
T | getCurrentState () const |
template<typename T > | |
std::vector< std::pair< T, float > > | getStateComposition () const |
bool | isTransitioning () const |
Protected Attributes | |
int | state |
int | transitionState |
bool | transitioning |
float | transitionTime |
float | transitionDuration |
std::unordered_map< int, S > | structures |
std::vector< std::pair< int, float > > | animationInfo |
size_t | animationIndex |
bool | animationLoop |
This class allows for nodes to have animation states and to lerp between them.
S | A structure holding the data for a particular state |
Definition at line 39 of file StateAnimatable.hpp.
|
inline |
Default constructor
Definition at line 92 of file StateAnimatable.hpp.
|
inline |
Creates a state animatable from a JSON config
json | The json |
Definition at line 98 of file StateAnimatable.hpp.
|
inline |
Adds a structure to the map of states
An | enum containing all the states, the underlying type must be int. |
state | The state to add the structure to |
structure | THe structure to add |
Definition at line 171 of file StateAnimatable.hpp.
|
inline |
Animates through multiple states in an infinite loop
T | An enum containing all the states, the underlying type must be int. |
stages | An array of pairs of each state with the duration to spend animating to the state |
Definition at line 232 of file StateAnimatable.hpp.
|
inline |
Animates through multiple states once
T | An enum containing all the states, the underlying type must be int. |
stages | An array of pairs of each state with the duration to spend animating to the state |
Definition at line 214 of file StateAnimatable.hpp.
|
inline |
Animates to a state in a duration, thread safe. If called in pre-update then the state may be updated next frame depending on whether or not preUpdate has already been called.
An | enum containing all the states, the underlying type must be int. |
state | The state to animate to |
duration | The duration of the animation, set 0 to immediately change |
Definition at line 201 of file StateAnimatable.hpp.
|
inline |
Gets the current state, if the node is currently animating between two states then the state closer to the current one is used Thread safe if called in update. If called in pre-update, there may be a data race as to whether or not the animation has been updated for this frame.
An | enum containing all the states, the underlying type must be int. |
Definition at line 264 of file StateAnimatable.hpp.
|
inline |
Gets the state composition for this frame. Thread safe if called in update. If called in pre-update, there may be a data race as to whether or not the animation has been updated for this frame.
An | enum containing all the states, the underlying type must be int. |
Definition at line 276 of file StateAnimatable.hpp.
|
inline |
Gets a structure for a specific state
An | enum containing all the states, the underlying type must be int. |
state | The state to get the structure for |
Definition at line 190 of file StateAnimatable.hpp.
|
inline |
Returns whether or not the animation is transitioning between two states. Thread safe if called in update. If called in pre-update, there may be a data race as to whether or not the animation has been updated for this frame.
Definition at line 294 of file StateAnimatable.hpp.
|
inline |
Removes a structure from the map of states
An | enum containing all the states, the underlying type must be int. |
state | The state to remove the structure from |
Definition at line 180 of file StateAnimatable.hpp.
|
inline |
Instantly sets a state, thread safe. If called in pre-update then the state may be updated next frame depending on whether or not preUpdate has already been called.
An | enum containing all the states, the underlying type must be int. |
state | The state to set |
Definition at line 251 of file StateAnimatable.hpp.
|
inline |
Updates the state of the node
deltaTime | The duration of the last frame in microseconds |
Definition at line 131 of file StateAnimatable.hpp.
|
protected |
The current animation index in animationInfo
Definition at line 80 of file StateAnimatable.hpp.
|
protected |
Information regarding the current animation. If set, it means we're currently animating through a series of states and durations
Definition at line 75 of file StateAnimatable.hpp.
|
protected |
Whether or not we are to loop through the information in animationInfo in an infinite loop
Definition at line 85 of file StateAnimatable.hpp.
|
protected |
The path state currently being rendered
Definition at line 45 of file StateAnimatable.hpp.
|
protected |
Contains structures for each state
Definition at line 70 of file StateAnimatable.hpp.
|
protected |
The duration in seconds for the transition to last
Definition at line 65 of file StateAnimatable.hpp.
|
protected |
Whether or not the path is morphing between two paths
Definition at line 55 of file StateAnimatable.hpp.
|
protected |
The state currently being transitioned to
Definition at line 50 of file StateAnimatable.hpp.
|
protected |
The transition time between the two paths
Definition at line 60 of file StateAnimatable.hpp.