Line data Source code
1 : #ifndef __ANIMATION_DATA_HPP__
2 : #define __ANIMATION_DATA_HPP__
3 :
4 : #include "core/data/FileReader.hpp"
5 : #include "core/data/IFileReader.hpp"
6 :
7 : #include "core/math/Glm.hpp"
8 :
9 : #include <vector>
10 : #include <string>
11 : #include <memory>
12 :
13 : namespace Soldank
14 : {
15 : enum class AnimationType
16 : {
17 : Stand = 0,
18 : Run,
19 : RunBack,
20 : Jump,
21 : JumpSide,
22 : Fall,
23 : Crouch,
24 : CrouchRun,
25 : Reload,
26 : Throw,
27 : Recoil,
28 : SmallRecoil,
29 : Shotgun,
30 : ClipOut,
31 : ClipIn,
32 : SlideBack,
33 : Change,
34 : ThrowWeapon,
35 : WeaponNone,
36 : Punch,
37 : ReloadBow,
38 : Barret,
39 : Roll,
40 : RollBack,
41 : CrouchRunBack,
42 : Cigar,
43 : Match,
44 : Smoke,
45 : Wipe,
46 : Groin,
47 : Piss,
48 : Mercy,
49 : Mercy2,
50 : TakeOff,
51 : Prone,
52 : Victory,
53 : Aim,
54 : HandsUpAim,
55 : ProneMove,
56 : GetUp,
57 : AimRecoil,
58 : HandsUpRecoil,
59 : Melee,
60 : Own,
61 : };
62 :
63 : constexpr const std::string_view ANIMATION_BASE_DIRECTORY_PATH = "anims/";
64 : constexpr const std::string_view ANIMATION_STAND_FILE = "stoi.poa";
65 : constexpr const std::string_view ANIMATION_RUN_FILE = "biega.poa";
66 : constexpr const std::string_view ANIMATION_RUN_BACK_FILE = "biegatyl.poa";
67 : constexpr const std::string_view ANIMATION_JUMP_FILE = "skok.poa";
68 : constexpr const std::string_view ANIMATION_JUMP_SIDE_FILE = "skokwbok.poa";
69 : constexpr const std::string_view ANIMATION_FALL_FILE = "spada.poa";
70 : constexpr const std::string_view ANIMATION_CROUCH_FILE = "kuca.poa";
71 : constexpr const std::string_view ANIMATION_CROUCH_RUN_FILE = "kucaidzie.poa";
72 : constexpr const std::string_view ANIMATION_RELOAD_FILE = "laduje.poa";
73 : constexpr const std::string_view ANIMATION_THROW_FILE = "rzuca.poa";
74 : constexpr const std::string_view ANIMATION_RECOIL_FILE = "odrzut.poa";
75 : constexpr const std::string_view ANIMATION_SMALL_RECOIL_FILE = "odrzut2.poa";
76 : constexpr const std::string_view ANIMATION_SHOTGUN_FILE = "shotgun.poa";
77 : constexpr const std::string_view ANIMATION_CLIP_OUT_FILE = "clipout.poa";
78 : constexpr const std::string_view ANIMATION_CLIP_IN_FILE = "clipin.poa";
79 : constexpr const std::string_view ANIMATION_SLIDE_BACK_FILE = "slideback.poa";
80 : constexpr const std::string_view ANIMATION_CHANGE_FILE = "change.poa";
81 : constexpr const std::string_view ANIMATION_THROW_WEAPON_FILE = "wyrzuca.poa";
82 : constexpr const std::string_view ANIMATION_WEAPON_NONE_FILE = "bezbroni.poa";
83 : constexpr const std::string_view ANIMATION_PUNCH_FILE = "bije.poa";
84 : constexpr const std::string_view ANIMATION_RELOAD_BOW_FILE = "strzala.poa";
85 : constexpr const std::string_view ANIMATION_BARRET_FILE = "barret.poa";
86 : constexpr const std::string_view ANIMATION_ROLL_FILE = "skokdolobrot.poa";
87 : constexpr const std::string_view ANIMATION_ROLL_BACK_FILE = "skokdolobrottyl.poa";
88 : constexpr const std::string_view ANIMATION_CROUCH_RUN_BACK_FILE = "kucaidzietyl.poa";
89 : constexpr const std::string_view ANIMATION_CIGAR_FILE = "cigar.poa";
90 : constexpr const std::string_view ANIMATION_MATCH_FILE = "match.poa";
91 : constexpr const std::string_view ANIMATION_SMOKE_FILE = "smoke.poa";
92 : constexpr const std::string_view ANIMATION_WIPE_FILE = "wipe.poa";
93 : constexpr const std::string_view ANIMATION_GROIN_FILE = "krocze.poa";
94 : constexpr const std::string_view ANIMATION_PISS_FILE = "szcza.poa";
95 : constexpr const std::string_view ANIMATION_MERCY_FILE = "samo.poa";
96 : constexpr const std::string_view ANIMATION_MERCY2_FILE = "samo2.poa";
97 : constexpr const std::string_view ANIMATION_TAKE_OFF_FILE = "takeoff.poa";
98 : constexpr const std::string_view ANIMATION_PRONE_FILE = "lezy.poa";
99 : constexpr const std::string_view ANIMATION_VICTORY_FILE = "cieszy.poa";
100 : constexpr const std::string_view ANIMATION_AIM_FILE = "celuje.poa";
101 : constexpr const std::string_view ANIMATION_HANDS_UP_AIM_FILE = "gora.poa";
102 : constexpr const std::string_view ANIMATION_PRONE_MOVE_FILE = "lezyidzie.poa";
103 : constexpr const std::string_view ANIMATION_GET_UP_FILE = "wstaje.poa";
104 : constexpr const std::string_view ANIMATION_AIM_RECOIL_FILE = "celujeodrzut.poa";
105 : constexpr const std::string_view ANIMATION_HANDS_UP_RECOIL_FILE = "goraodrzut.poa";
106 : constexpr const std::string_view ANIMATION_MELEE_FILE = "kolba.poa";
107 : constexpr const std::string_view ANIMATION_OWN_FILE = "rucha.poa";
108 :
109 : struct AnimationFrame
110 : {
111 : std::vector<glm::vec2> positions;
112 : };
113 :
114 : class AnimationData
115 : {
116 : public:
117 0 : AnimationData(AnimationType animation_type,
118 : bool looped,
119 : int speed,
120 : const std::vector<AnimationFrame>& frames)
121 0 : : animation_type_(animation_type)
122 0 : , looped_(looped)
123 0 : , speed_(speed)
124 0 : , frames_(frames){};
125 :
126 0 : AnimationType GetAnimationType() const { return animation_type_; }
127 0 : bool GetLooped() const { return looped_; }
128 0 : int GetSpeed() const { return speed_; }
129 0 : const std::vector<AnimationFrame>& GetFrames() const { return frames_; }
130 :
131 : private:
132 : AnimationType animation_type_;
133 : bool looped_;
134 : int speed_;
135 : std::vector<AnimationFrame> frames_;
136 : };
137 :
138 : class AnimationDataManager
139 : {
140 : public:
141 : // TODO: add error handling for when animation could not be read from file
142 : // TODO: add error handling for when animation of type animation_type had already been loaded
143 : // before
144 : void LoadAnimationData(AnimationType animation_type,
145 : const std::string& file_path,
146 : bool looped,
147 : int speed,
148 : const IFileReader& file_reader = FileReader());
149 : void LoadAllAnimationDatas(const IFileReader& file_reader = FileReader());
150 :
151 : std::shared_ptr<const AnimationData> Get(AnimationType animation_type) const;
152 :
153 : private:
154 : std::vector<std::shared_ptr<const AnimationData>> animation_datas_;
155 : };
156 : } // namespace Soldank
157 :
158 : #endif
|