diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-04-28 09:22:44 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-04-28 09:22:44 -0400 |
commit | 8016a7146fec3f6f43ca05723441750e5aae3d4d (patch) | |
tree | 0d527c1af80cf9ac34a027f9ee6f1acbb95db9f4 /src/components/animatable.h | |
parent | f782b81ba10c9b7a1e221b16de0aaa7b6c521729 (diff) | |
download | therapy-8016a7146fec3f6f43ca05723441750e5aae3d4d.tar.gz therapy-8016a7146fec3f6f43ca05723441750e5aae3d4d.tar.bz2 therapy-8016a7146fec3f6f43ca05723441750e5aae3d4d.zip |
Restructured the way the world is loaded
The World class was removed and replaced by the RealizingSystem and RealizableComponent. The realizable entity is intended to be a singleton and to represent the world. The Map class was also removed and integrated into the MappableComponent. These changes are to facilitate implementation of map objects without needing special intermediary objects (including the Map class). Now, map entities are created as soon as the world is created, and map object entities will be as well. They will simply be deactivated while the map is not active. Multiple players are now slightly better supported, which will be important in the future. This will likely become inefficient as the world becomes bigger, and some sort of sector-loading process will have to be designed. This also reduces the usefulness of EntityManager's entity-searching capabilities (which are not the most efficiently implemented currently anyway), and will likely in the future require some added functionality to better search subsets of entities. A lot of the components were also rewritten to use bare member variables instead of accessor methods, as they never had special functionality and just took up space. These components were also documented.
Diffstat (limited to 'src/components/animatable.h')
-rw-r--r-- | src/components/animatable.h | 146 |
1 files changed, 72 insertions, 74 deletions
diff --git a/src/components/animatable.h b/src/components/animatable.h index ec72be0..1a678ba 100644 --- a/src/components/animatable.h +++ b/src/components/animatable.h | |||
@@ -8,88 +8,86 @@ | |||
8 | class AnimatableComponent : public Component { | 8 | class AnimatableComponent : public Component { |
9 | public: | 9 | public: |
10 | 10 | ||
11 | /** | ||
12 | * Constructor for initializing the animation set, because it is not default | ||
13 | * constructible. | ||
14 | */ | ||
11 | AnimatableComponent( | 15 | AnimatableComponent( |
12 | AnimationSet animationSet, | 16 | AnimationSet animationSet) : |
13 | std::string animation) : | 17 | animationSet(std::move(animationSet)) |
14 | animationSet_(std::move(animationSet)), | ||
15 | animation_(std::move(animation)) | ||
16 | { | 18 | { |
17 | } | 19 | } |
18 | 20 | ||
19 | inline size_t getFrame() const | 21 | /** |
20 | { | 22 | * The animation set that this entity will use -- an object describing the |
21 | return frame_; | 23 | * different animations that can be used to render the entity. |
22 | } | 24 | * |
23 | 25 | * @managed_by RealizingSystem | |
24 | inline void setFrame(size_t v) | 26 | */ |
25 | { | 27 | AnimationSet animationSet; |
26 | frame_ = v; | 28 | |
27 | } | 29 | /** |
28 | 30 | * The name of the currently active animation. | |
29 | inline size_t getCountdown() const | 31 | * |
30 | { | 32 | * @managed_by AnimatingSystem |
31 | return countdown_; | 33 | */ |
32 | } | 34 | std::string animation; |
33 | 35 | ||
34 | inline void setCountdown(size_t v) | 36 | /** |
35 | { | 37 | * For prototypes, the name of the original animation. |
36 | countdown_ = v; | 38 | * |
37 | } | 39 | * @managed_by RealizingSystem |
38 | 40 | */ | |
39 | inline const AnimationSet& getAnimationSet() const | 41 | std::string origAnimation; |
40 | { | 42 | |
41 | return animationSet_; | 43 | /** |
42 | } | 44 | * Helper method for accessing the currently active animation. |
43 | 45 | */ | |
44 | inline const Animation& getAnimation() const | 46 | inline const Animation& getAnimation() const |
45 | { | 47 | { |
46 | return animationSet_.getAnimation(animation_); | 48 | return animationSet.getAnimation(animation); |
47 | } | 49 | } |
48 | 50 | ||
49 | inline void setAnimation(std::string animation) | 51 | /** |
50 | { | 52 | * The frame of animation that is currently being rendered. |
51 | animation_ = std::move(animation); | 53 | * |
52 | } | 54 | * @managed_by AnimatingSystem |
53 | 55 | */ | |
54 | inline bool isFlickering() const | 56 | size_t frame = 0; |
55 | { | 57 | |
56 | return flickering_; | 58 | /** |
57 | } | 59 | * The amount of time (in game frames) before the animation is advanced. |
58 | 60 | * | |
59 | inline void setFlickering(bool v) | 61 | * @managed_by AnimatingSystem |
60 | { | 62 | */ |
61 | flickering_ = v; | 63 | size_t countdown = 0; |
62 | } | 64 | |
63 | 65 | /** | |
64 | inline size_t getFlickerTimer() const | 66 | * This option allows to give the sprite a "flickering" effect (as in, it is |
65 | { | 67 | * not rendered in some frames). |
66 | return flickerTimer_; | 68 | */ |
67 | } | 69 | bool flickering = false; |
68 | 70 | ||
69 | inline void setFlickerTimer(size_t v) | 71 | /** |
70 | { | 72 | * Used for the flickering effect. |
71 | flickerTimer_ = v; | 73 | * |
72 | } | 74 | * @managed_by AnimatingSystem |
73 | 75 | */ | |
74 | inline bool isFrozen() const | 76 | size_t flickerTimer = 0; |
75 | { | 77 | |
76 | return frozen_; | 78 | /** |
77 | } | 79 | * If enabled, this will prevent the sprite's animation from progressing (but |
78 | 80 | * will not affect things such as placement on screen and flickering). | |
79 | inline void setFrozen(bool v) | 81 | */ |
80 | { | 82 | bool frozen = false; |
81 | frozen_ = v; | 83 | |
82 | } | 84 | /** |
83 | 85 | * If this flag is disabled, the entity will be ignored by the animating | |
84 | private: | 86 | * system. |
85 | 87 | * | |
86 | AnimationSet animationSet_; | 88 | * @managed_by RealizingSystem |
87 | std::string animation_; | 89 | */ |
88 | size_t frame_ = 0; | 90 | bool active = false; |
89 | size_t countdown_ = 0; | ||
90 | bool flickering_ = false; | ||
91 | size_t flickerTimer_ = 0; | ||
92 | bool frozen_ = false; | ||
93 | }; | 91 | }; |
94 | 92 | ||
95 | #endif /* end of include guard: SPRITE_RENDERABLE_H_D3AACBBF */ | 93 | #endif /* end of include guard: SPRITE_RENDERABLE_H_D3AACBBF */ |