Tramway SDK
animationtable.h
Go to the documentation of this file.
1// Tramway Drifting and Dungeon Exploration Simulator SDK Runtime
2
3#ifndef TRAM_SDK_EXTENSIONS_KITCHENSINK_SOUNDTABLE_H
4#define TRAM_SDK_EXTENSIONS_KITCHENSINK_SOUNDTABLE_H
5
6#include <vector>
7#include <framework/uid.h>
8#include <framework/math.h>
10
11namespace tram {
12 class AnimationComponent;
13}
14
15namespace tram::Ext::Kitchensink {
16
20};
21
22struct AnimState {
24
26 uint32_t repeats;
27 float weight;
28 float speed;
31
33
35};
36
40
41 float fade_time;
42};
43
47
48 float fade_time;
49};
50
53
56};
57
59
61public:
62 AnimationTable(name_t name) : name(name) {}
63
64 void SwitchState(name_t state, AnimationStateComponent* state_component);
65
66 void AddStateSpace(name_t name, name_t parent);
67 void AddState(name_t state, name_t space);
68
69 void SetStateAnimation(name_t state, name_t animation_name, uint32_t repeats, float weight, float speed, bool pause_last);
70 void SetStateNextState(name_t state, name_t next_state);
71
75
76 static AnimationTable* Find(name_t name);
77private:
78 AnimationComponent* component = nullptr;
79
80 name_t name;
81
82 std::vector<AnimStateSpace> state_spaces;
83 std::vector<AnimState> states;
84
85 std::vector<AnimStateTransitionFrom> transition_from;
86 std::vector<AnimStateTransitionInto> transition_into;
87 std::vector<AnimStateTransitionDefault> transition_default;
88};
89
91public:
92 void EventHandler(Event &event) {}
93 void Start();
94
95 void SwitchState(name_t state) { table->SwitchState(state, this); }
96
97 void SetAnimationTable(name_t name) { this->table = AnimationTable::Find(name); }
100protected:
103 std::vector<name_t> states;
104 friend class AnimationTable;
105};
106
107}
108
109#endif // TRAM_SDK_EXTENSIONS_KITCHENSINK_SOUNDTABLE_H
Plays back Animations.
Definition: animation.h:13
Component base class.
Definition: entitycomponent.h:16
void SetAnimationComponent(AnimationComponent *component)
Definition: animationtable.h:98
void SwitchState(name_t state)
Definition: animationtable.h:95
AnimationTable * table
Definition: animationtable.h:101
void SetAnimationTable(name_t name)
Definition: animationtable.h:97
std::vector< name_t > states
Definition: animationtable.h:103
AnimationComponent * GetAnimationComponent()
Definition: animationtable.h:99
AnimationComponent * component
Definition: animationtable.h:102
void EventHandler(Event &event)
Definition: animationtable.h:92
Definition: animationtable.h:60
AnimationTable(name_t name)
Definition: animationtable.h:62
void AddTransition(AnimStateTransitionFrom)
Definition: animationtable.cpp:212
void AddStateSpace(name_t name, name_t parent)
Definition: animationtable.cpp:173
void SetStateAnimation(name_t state, name_t animation_name, uint32_t repeats, float weight, float speed, bool pause_last)
Definition: animationtable.cpp:188
void SetStateNextState(name_t state, name_t next_state)
Definition: animationtable.cpp:202
void SwitchState(name_t state, AnimationStateComponent *state_component)
Definition: animationtable.cpp:51
static AnimationTable * Find(name_t name)
Definition: animationtable.cpp:40
void AddState(name_t state, name_t space)
Definition: animationtable.cpp:183
Extension containing random stuff that doesn't fit in anywhere else.
Definition: ai.cpp:15
Serialization, i.e.
Event data.
Definition: event.h:24
Definition: animationtable.h:22
uint32_t repeats
Definition: animationtable.h:26
name_t name
Definition: animationtable.h:23
bool interpolate
Definition: animationtable.h:29
name_t state_space
Definition: animationtable.h:32
float speed
Definition: animationtable.h:28
bool pause_last
Definition: animationtable.h:30
name_t next_state
Definition: animationtable.h:34
float weight
Definition: animationtable.h:27
name_t animation
Definition: animationtable.h:25
Definition: animationtable.h:17
name_t parent
Definition: animationtable.h:19
name_t name
Definition: animationtable.h:18
float fade_out_time
Definition: animationtable.h:55
float fade_in_time
Definition: animationtable.h:54
name_t state
Definition: animationtable.h:52
name_t into_state
Definition: animationtable.h:39
float fade_time
Definition: animationtable.h:41
name_t from_state
Definition: animationtable.h:38
name_t into_state
Definition: animationtable.h:46
float fade_time
Definition: animationtable.h:48
name_t from_state
Definition: animationtable.h:45
Interned string type.
Definition: uid.h:10