diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-05-17 15:55:37 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-17 15:55:37 -0400 |
| commit | 90aadf3844386824140a20d7fbb847bc16009a94 (patch) | |
| tree | 6f83fce90e71abb22b1a8f3e09c79963b2a34d5d /src/components/animatable.h | |
| parent | bc63fa57ced1c7329f7fdcfd168eaf7e290158bc (diff) | |
| parent | 86f0106d0523825549f1e74b835688c78a10cf6c (diff) | |
| download | therapy-90aadf3844386824140a20d7fbb847bc16009a94.tar.gz therapy-90aadf3844386824140a20d7fbb847bc16009a94.tar.bz2 therapy-90aadf3844386824140a20d7fbb847bc16009a94.zip | |
Merge pull request #7 from hatkirby/es-rewrite
The ECS rewrite exceeds the original branch in functionality, so it is time to merge it in.
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 */ | ||
