15 #ifndef CORGI_COMPONENT_LIBRARY_ANIMATION_H_
16 #define CORGI_COMPONENT_LIBRARY_ANIMATION_H_
18 #include "breadboard/event.h"
20 #include "library_components_generated.h"
21 #include "motive/anim_table.h"
22 #include "motive/engine.h"
23 #include "motive/motivator.h"
32 namespace component_library {
34 BREADBOARD_DECLARE_EVENT(kAnimationCompleteEventId)
47 : anim_table_object(-1),
49 previous_time_remaining(motive::kMotiveTimeEndless),
50 debug_state(AnimationDebugState_None),
51 debug_bone(motive::kInvalidBoneIdx) {}
175 int anim_idx)
const {
177 const motive::RigAnim* anim =
179 return anim ==
nullptr ? 0 : anim->end_time();
191 return Data<AnimationData>(entity)->last_anim_idx;
200 motive::MotiveEngine&
engine() {
return engine_; }
208 const motive::MotiveEngine&
engine()
const {
return engine_; }
221 const motive::AnimTable&
anim_table()
const {
return anim_table_; }
231 motive::MotiveEngine engine_;
239 motive::AnimTable anim_table_;
249 #endif // CORGI_COMPONENT_LIBRARY_ANIMATION_H_
std::unique_ptr< uint8_t, std::function< void(uint8_t *)> > RawDataUniquePtr
A pointer type for exported raw data.
Definition: component_interface.h:63
int last_anim_idx
Tracks the index of the last animation that was played by AnimateFromTable().
Definition: animation.h:70
motive::MotiveTime previous_time_remaining
The amount of time remaning from the previous animation. This can be used for firing animation events...
Definition: animation.h:76
bool HasAnim(const corgi::EntityRef &entity, int anim_idx) const
Check if a certain animation exists with a given index in the AnimTable for a given Entity...
Definition: animation.h:160
motive::BoneIndex debug_bone
When debug_state outputs bone-specific information, this member specifies the bone. Ignored otherwise.
Definition: animation.h:89
A Component is an object that encapsulates all data and logic for Entities of a particular type...
Definition: component.h:43
AnimationDebugState debug_state
The debug information output to the log every frame, for this animating object. You probably want thi...
Definition: animation.h:83
motive::AnimTable & anim_table()
Get a reference to the animation table that is queried when AnimateFromTable() is called...
Definition: animation.h:214
motive::MotiveEngine & engine()
Get a reference to the engine that can be used for external Motivators as well. For the greatest effi...
Definition: animation.h:200
int WorldTime
A typedef that represents time in the game.
Definition: entity_common.h:49
bool AnimateFromTable(const corgi::EntityRef &entity, int anim_idx)
Query the AnimTable for an animation and then play it.
virtual void UpdateAllEntities(corgi::WorldTime delta_time)
Updates all Motivators in the AnimationData, as well as, any other Motivators that were initialized w...
motive::RigMotivator motivator
Holds and processes the animaton. Calls can be made to motivator.GlobalTransforms() to get an array o...
Definition: animation.h:58
const motive::AnimTable & anim_table() const
Get a const reference to the animation table that is queried when AnimateFromTable() is called...
Definition: animation.h:221
A Component that provides an elegant way to handle Entity animation by interacting with the Motive an...
Definition: animation.h:96
virtual void AddFromRawData(corgi::EntityRef &entity, const void *data)
Deserialize a flat binary buffer to create and populate an Entity from raw data.
int LastAnimIdx(const corgi::EntityRef &entity) const
Get the index of the last animation that was played.
Definition: animation.h:190
A reference object for pointing into the vector pool. It acts as a pointer for vector pool elements a...
Definition: vector_pool.h:72
The Component data structure that corresponds to each Entity that is registered with the AnimationCom...
Definition: animation.h:45
const motive::MotiveEngine & engine() const
Get a const reference to the engine that can be used for external Motivators as well. For the greatest efficiency, there should only be one MotiveEngine.
Definition: animation.h:208
void Animate(const corgi::EntityRef &entity, const motive::RigAnim &anim)
Begin playback of a given RigAnim on a given Entity.
virtual ~AnimationComponent()
Deconstructor of the Animation component.
Definition: animation.h:99
#define CORGI_REGISTER_COMPONENT(ComponentType, DataType)
Definition: component_id_lookup.h:48
int anim_table_object
Specifies the object-type query parameter for the AnimTable, which is used to index the first array o...
Definition: animation.h:64
motive::MotiveTime AnimLength(const corgi::EntityRef &entity, int anim_idx) const
Get the length of an Entity's animation, given an animation index.
Definition: animation.h:174
virtual RawDataUniquePtr ExportRawData(const corgi::EntityRef &entity) const
Serializes an AnimationComponent's data for a given Entity.