diff options
Diffstat (limited to 'src/components/animatable.h')
| -rw-r--r-- | src/components/animatable.h | 93 |
1 files changed, 93 insertions, 0 deletions
| diff --git a/src/components/animatable.h b/src/components/animatable.h new file mode 100644 index 0000000..1a678ba --- /dev/null +++ b/src/components/animatable.h | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | #ifndef SPRITE_RENDERABLE_H_D3AACBBF | ||
| 2 | #define SPRITE_RENDERABLE_H_D3AACBBF | ||
| 3 | |||
| 4 | #include "component.h" | ||
| 5 | #include "animation.h" | ||
| 6 | #include <string> | ||
| 7 | |||
| 8 | class AnimatableComponent : public Component { | ||
| 9 | public: | ||
| 10 | |||
| 11 | /** | ||
| 12 | * Constructor for initializing the animation set, because it is not default | ||
| 13 | * constructible. | ||
| 14 | */ | ||
| 15 | AnimatableComponent( | ||
| 16 | AnimationSet animationSet) : | ||
| 17 | animationSet(std::move(animationSet)) | ||
| 18 | { | ||
| 19 | } | ||
| 20 | |||
| 21 | /** | ||
| 22 | * The animation set that this entity will use -- an object describing the | ||
| 23 | * different animations that can be used to render the entity. | ||
| 24 | * | ||
| 25 | * @managed_by RealizingSystem | ||
| 26 | */ | ||
| 27 | AnimationSet animationSet; | ||
| 28 | |||
| 29 | /** | ||
| 30 | * The name of the currently active animation. | ||
| 31 | * | ||
| 32 | * @managed_by AnimatingSystem | ||
| 33 | */ | ||
| 34 | std::string animation; | ||
| 35 | |||
| 36 | /** | ||
| 37 | * For prototypes, the name of the original animation. | ||
| 38 | * | ||
| 39 | * @managed_by RealizingSystem | ||
| 40 | */ | ||
| 41 | std::string origAnimation; | ||
| 42 | |||
| 43 | /** | ||
| 44 | * Helper method for accessing the currently active animation. | ||
| 45 | */ | ||
| 46 | inline const Animation& getAnimation() const | ||
| 47 | { | ||
| 48 | return animationSet.getAnimation(animation); | ||
| 49 | } | ||
| 50 | |||
| 51 | /** | ||
| 52 | * The frame of animation that is currently being rendered. | ||
| 53 | * | ||
| 54 | * @managed_by AnimatingSystem | ||
| 55 | */ | ||
| 56 | size_t frame = 0; | ||
| 57 | |||
| 58 | /** | ||
| 59 | * The amount of time (in game frames) before the animation is advanced. | ||
| 60 | * | ||
| 61 | * @managed_by AnimatingSystem | ||
| 62 | */ | ||
| 63 | size_t countdown = 0; | ||
| 64 | |||
| 65 | /** | ||
| 66 | * This option allows to give the sprite a "flickering" effect (as in, it is | ||
| 67 | * not rendered in some frames). | ||
| 68 | */ | ||
| 69 | bool flickering = false; | ||
| 70 | |||
| 71 | /** | ||
| 72 | * Used for the flickering effect. | ||
| 73 | * | ||
| 74 | * @managed_by AnimatingSystem | ||
| 75 | */ | ||
| 76 | size_t flickerTimer = 0; | ||
| 77 | |||
| 78 | /** | ||
| 79 | * If enabled, this will prevent the sprite's animation from progressing (but | ||
| 80 | * will not affect things such as placement on screen and flickering). | ||
| 81 | */ | ||
| 82 | bool frozen = false; | ||
| 83 | |||
| 84 | /** | ||
| 85 | * If this flag is disabled, the entity will be ignored by the animating | ||
| 86 | * system. | ||
| 87 | * | ||
| 88 | * @managed_by RealizingSystem | ||
| 89 | */ | ||
| 90 | bool active = false; | ||
| 91 | }; | ||
| 92 | |||
| 93 | #endif /* end of include guard: SPRITE_RENDERABLE_H_D3AACBBF */ | ||
