Tramway SDK
animationtable.h
Go to the documentation of this file.
1// TRAMWAY DRIFT AND DUNGEON EXPLORATION SIMULATOR 2022
2// All rights reserved.
3
4#ifndef TRAM_SDK_EXTENSIONS_KITCHENSINK_SOUNDTABLE_H
5#define TRAM_SDK_EXTENSIONS_KITCHENSINK_SOUNDTABLE_H
6
7#include <vector>
8#include <framework/uid.h>
9#include <framework/math.h>
11
12namespace tram {
13 class AnimationComponent;
14}
15
16namespace tram::Ext::Kitchensink {
17
21};
22
23struct AnimState {
25
27 uint32_t repeats;
28 float weight;
29 float speed;
32
34
36};
37
41
42 float fade_time;
43};
44
48
49 float fade_time;
50};
51
54
57};
58
60
62public:
63 AnimationTable(name_t name) : name(name) {}
64
65 void SwitchState(name_t state, AnimationStateComponent* state_component);
66
67 void AddStateSpace(name_t name, name_t parent);
68 void AddState(name_t state, name_t space);
69
70 void SetStateAnimation(name_t state, name_t animation_name, uint32_t repeats, float weight, float speed, bool pause_last);
71 void SetStateNextState(name_t state, name_t next_state);
72
76
77 static AnimationTable* Find(name_t name);
78private:
79 AnimationComponent* component = nullptr;
80
81 name_t name;
82
83 std::vector<AnimStateSpace> state_spaces;
84 std::vector<AnimState> states;
85
86 std::vector<AnimStateTransitionFrom> transition_from;
87 std::vector<AnimStateTransitionInto> transition_into;
88 std::vector<AnimStateTransitionDefault> transition_default;
89};
90
92public:
93 void EventHandler(Event &event) {}
94 void Start();
95
96 void SwitchState(name_t state) { table->SwitchState(state, this); }
97
98 void SetAnimationTable(name_t name) { this->table = AnimationTable::Find(name); }
101protected:
104 std::vector<name_t> states;
105 friend class AnimationTable;
106};
107
108}
109
110#endif // TRAM_SDK_EXTENSIONS_KITCHENSINK_SOUNDTABLE_H
Definition: animation.h:13
Definition: entitycomponent.h:18
void SetAnimationComponent(AnimationComponent *component)
Definition: animationtable.h:99
void SwitchState(name_t state)
Definition: animationtable.h:96
AnimationTable * table
Definition: animationtable.h:102
void SetAnimationTable(name_t name)
Definition: animationtable.h:98
std::vector< name_t > states
Definition: animationtable.h:104
AnimationComponent * GetAnimationComponent()
Definition: animationtable.h:100
AnimationComponent * component
Definition: animationtable.h:103
void EventHandler(Event &event)
Definition: animationtable.h:93
Definition: animationtable.h:61
AnimationTable(name_t name)
Definition: animationtable.h:63
void AddTransition(AnimStateTransitionFrom)
Definition: animationtable.cpp:194
void AddStateSpace(name_t name, name_t parent)
Definition: animationtable.cpp:155
void SetStateAnimation(name_t state, name_t animation_name, uint32_t repeats, float weight, float speed, bool pause_last)
Definition: animationtable.cpp:170
void SetStateNextState(name_t state, name_t next_state)
Definition: animationtable.cpp:184
void SwitchState(name_t state, AnimationStateComponent *state_component)
Definition: animationtable.cpp:33
static AnimationTable * Find(name_t name)
Definition: animationtable.cpp:22
void AddState(name_t state, name_t space)
Definition: animationtable.cpp:165
Definition: ai.cpp:16
Definition: api.h:9
Definition: event.h:24
Definition: animationtable.h:23
uint32_t repeats
Definition: animationtable.h:27
name_t name
Definition: animationtable.h:24
bool interpolate
Definition: animationtable.h:30
name_t state_space
Definition: animationtable.h:33
float speed
Definition: animationtable.h:29
bool pause_last
Definition: animationtable.h:31
name_t next_state
Definition: animationtable.h:35
float weight
Definition: animationtable.h:28
name_t animation
Definition: animationtable.h:26
Definition: animationtable.h:18
name_t parent
Definition: animationtable.h:20
name_t name
Definition: animationtable.h:19
float fade_out_time
Definition: animationtable.h:56
float fade_in_time
Definition: animationtable.h:55
name_t state
Definition: animationtable.h:53
name_t into_state
Definition: animationtable.h:40
float fade_time
Definition: animationtable.h:42
name_t from_state
Definition: animationtable.h:39
name_t into_state
Definition: animationtable.h:47
float fade_time
Definition: animationtable.h:49
name_t from_state
Definition: animationtable.h:46
Definition: uid.h:11