1 /* 2 * This file is part of EasyRPG Player. 3 * 4 * EasyRPG Player is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * EasyRPG Player is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef EP_SPRITE_ACTOR_H 19 #define EP_SPRITE_ACTOR_H 20 21 // Headers 22 #include "sprite_battler.h" 23 #include "async_handler.h" 24 25 class BattleAnimation; 26 class Game_Battler; 27 class Game_Actor; 28 29 /** 30 * Sprite_Actor class, used for battle sprites 31 */ 32 class Sprite_Actor : public Sprite_Battler { 33 public: 34 enum AnimationState { 35 AnimationState_Null, 36 AnimationState_Idle, 37 AnimationState_RightHand, 38 AnimationState_LeftHand, 39 AnimationState_SkillUse, 40 AnimationState_Dead, 41 AnimationState_Damage, 42 AnimationState_BadStatus, 43 AnimationState_Defending, 44 AnimationState_WalkingLeft, 45 AnimationState_WalkingRight, 46 AnimationState_Victory, 47 AnimationState_Item, 48 }; 49 50 enum LoopState { 51 LoopState_DefaultAnimationAfterFinish, 52 LoopState_LoopAnimation, 53 LoopState_WaitAfterFinish 54 }; 55 56 /** 57 * Constructor. 58 * 59 * @param actor game battler to display 60 */ 61 Sprite_Actor(Game_Actor* actor); 62 63 ~Sprite_Actor() override; 64 65 /** 66 * Updates sprite state. 67 */ 68 void Update(); 69 70 void SetAnimationState(int state, LoopState loop = LoopState_LoopAnimation, int animation_id = 0); 71 void SetAnimationLoop(LoopState loop); 72 73 /** 74 * Updates the current animation state of the actor depending on his state. 75 */ 76 void DetectStateChange(); 77 78 /** 79 * Returns true when the actor is in it's default state (Depending on 80 * conditions) 81 * 82 * @return Whether state is default 83 */ 84 bool IsIdling(); 85 86 void DoIdleAnimation(); 87 88 int GetWidth() const override; 89 int GetHeight() const override; 90 91 void Draw(Bitmap& dst) override; 92 93 Game_Actor* GetBattler() const; 94 95 void UpdatePosition(); 96 97 void ResetZ() final; 98 99 void SetNormalAttacking(bool nnormal_attacking); 100 101 void SetAfterimageAmount(unsigned amount); 102 void DoAfterimageFade(); 103 104 protected: 105 void CreateSprite(); 106 void OnMonsterSpriteReady(FileRequestResult* result); 107 void OnBattlercharsetReady(FileRequestResult* result, int32_t battler_index); 108 109 BitmapRef graphic; 110 int anim_state = AnimationState_Idle; 111 int cycle = 0; 112 int sprite_frame = -1; 113 LoopState loop_state = LoopState_DefaultAnimationAfterFinish; 114 bool old_hidden = false; 115 std::unique_ptr<BattleAnimation> animation; 116 // false when a newly set animation didn't loop once 117 bool idling = true; 118 119 FileRequestBinding request_id; 120 121 bool do_not_draw = false; 122 bool normal_attacking = false; 123 124 std::vector<Point> images; 125 int afterimage_fade = -1; 126 }; 127 128 129 #endif 130