ManaPlus
actorsprite.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2010 The Mana Developers
4  * Copyright (C) 2011-2019 The ManaPlus Developers
5  * Copyright (C) 2019-2021 Andrei Karas
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef BEING_ACTORSPRITE_H
24 #define BEING_ACTORSPRITE_H
25 
26 #include "being/actor.h"
27 #include "being/compoundsprite.h"
28 
30 
31 #include "enums/being/actortype.h"
34 
39 
41 
43 
44 #include "particle/particlelist.h"
46 
47 #include "localconsts.h"
48 
49 class AnimatedSprite;
50 class StatusEffect;
52 
53 struct SpriteDisplay;
54 
55 class ActorSprite notfinal : public CompoundSprite, public Actor
56 {
57  public:
58  explicit ActorSprite(const BeingId id);
59 
61 
62  ~ActorSprite() override;
63 
65  { return mId; }
66 
67  void setId(const BeingId id) noexcept2
68  { mId = id; }
69 
74  { return ActorType::Unknown; }
75 
76  virtual void logic();
77 
78  void setMap(Map *const map) override;
79 
84  { return BlockType::NONE; }
85 
89  void controlAutoParticle(Particle *const particle);
90 
94  void controlCustomParticle(Particle *const particle);
95 
100  { return TargetCursorSize::MEDIUM; }
101 
102  virtual int getTargetOffsetX() const A_WARN_UNUSED
103  { return 0; }
104 
105  virtual int getTargetOffsetY() const A_WARN_UNUSED
106  { return 0; }
107 
111  void setTargetType(const TargetCursorTypeT type);
112 
116  void untarget()
117  { mUsedTargetCursor = nullptr; }
118 
119  void setStatusEffect(const int32_t index,
120  const Enable active,
121  const IsStart start);
122 
123  void setStatusEffectOpitons(const uint32_t option,
124  const uint32_t opt1,
125  const uint32_t opt2,
126  const uint32_t opt3);
127 
128  void setStatusEffectOpitons(const uint32_t option,
129  const uint32_t opt1,
130  const uint32_t opt2);
131 
132  void setStatusEffectOpiton0(const uint32_t option);
133 
134  void setAlpha(const float alpha) override final
135  { CompoundSprite::setAlpha(alpha); }
136 
138  { return CompoundSprite::getAlpha(); }
139 
141  { return CompoundSprite::getWidth(); }
142 
144  { return CompoundSprite::getHeight(); }
145 
146  static void load();
147 
148  static void unload();
149 
154 
159 
161  { return getPixelX() - mapTileSize / 2; }
162 
164  { return getPixelY() - mapTileSize; }
165 
166  void setPoison(const bool b)
167  { mPoison = b; }
168 
170  { return mPoison; }
171 
172  void setHaveCart(const bool b)
173  { mHaveCart = b; }
174 
176  { return mHaveCart; }
177 
178  virtual void setRiding(const bool b)
179  { mHorseId = b ? 1 : 0; }
180 
181  virtual void setTrickDead(const bool b)
182  { mTrickDead = b; }
183 
185  { return mTrickDead; }
186 
187  const std::set<int32_t> &getStatusEffects() const A_WARN_UNUSED
188  { return mStatusEffects; }
189 
190  std::string getStatusEffectsString() const;
191 
192  virtual void stopCast(const bool b A_UNUSED)
193  { }
194 
195  size_t getParticlesCount() const
196  {
199  }
200 
201  void controlParticleDeleted(const Particle *const particle);
202 
203  protected:
208  virtual void updateStatusEffect(const int32_t index,
209  const Enable newStatus,
210  const IsStart start);
211 
218  virtual void handleStatusEffect(const StatusEffect *const effect,
219  const int32_t effectId,
220  const Enable newStatus,
221  const IsStart start);
222 
223  void setupSpriteDisplay(const SpriteDisplay &display,
224  const ForceDisplay forceDisplay,
225  const DisplayTypeT displayType,
226  const std::string &color);
227 
229  static void initTargetCursor();
230 
232  static void cleanupTargetCursors();
233 
238 
239  static bool loaded;
240 
242  std::set<int32_t> mStatusEffects;
243 
246  int mHorseId;
248 
251 
252  typedef std::list<ActorSpriteListener*> ActorSpriteListeners;
253  typedef ActorSpriteListeners::iterator ActorSpriteListenerIterator;
255 
258 
261  bool mPoison;
262  bool mHaveCart;
264 };
265 
266 #endif // BEING_ACTORSPRITE_H
ActorType ::T ActorTypeT
Definition: actortype.h:43
int BeingId
Definition: beingid.h:30
BlockType ::T BlockTypeT
Definition: blocktype.h:41
#define CAST_SIZE
Definition: cast.h:34
int getWidth() const
Definition: actorsprite.h:140
virtual void logic()
AnimatedSprite * mUsedTargetCursor
Definition: actorsprite.h:250
bool mTrickDead
Definition: actorsprite.h:263
int mCursorPaddingY
Definition: actorsprite.h:257
ParticleList mChildParticleEffects
Definition: actorsprite.h:245
void setStatusEffectOpitons(const uint32_t option, const uint32_t opt1, const uint32_t opt2, const uint32_t opt3)
bool mHaveCart
Definition: actorsprite.h:262
ActorSpriteListeners mActorSpriteListeners
Definition: actorsprite.h:254
void setMap(Map *const map)
std::list< ActorSpriteListener * > ActorSpriteListeners
Definition: actorsprite.h:252
static void initTargetCursor()
virtual BlockTypeT getBlockType() const
Definition: actorsprite.h:83
bool getHaveCart() const
Definition: actorsprite.h:175
void setId(const BeingId id)
Definition: actorsprite.h:67
size_t getParticlesCount() const
Definition: actorsprite.h:195
void setupSpriteDisplay(const SpriteDisplay &display, const ForceDisplay forceDisplay, const DisplayTypeT displayType, const std::string &color)
bool getPoison() const
Definition: actorsprite.h:169
void setPoison(const bool b)
Definition: actorsprite.h:166
int getHeight() const
Definition: actorsprite.h:143
void setAlpha(const float alpha)
Definition: actorsprite.h:134
float getAlpha() const
Definition: actorsprite.h:137
virtual TargetCursorSizeT getTargetCursorSize() const
Definition: actorsprite.h:99
BeingId mId
Definition: actorsprite.h:247
bool isTrickDead() const
Definition: actorsprite.h:184
ActorSprite(const BeingId id)
Definition: actorsprite.cpp:69
void setStatusEffectOpiton0(const uint32_t option)
virtual void setRiding(const bool b)
Definition: actorsprite.h:178
virtual ActorTypeT getType() const
Definition: actorsprite.h:73
ParticleVector mStatusParticleEffects
Definition: actorsprite.h:244
static void cleanupTargetCursors()
virtual int getTargetOffsetX() const
Definition: actorsprite.h:102
BeingId getId() const
Definition: actorsprite.h:64
static AnimatedSprite * targetCursor[static_cast< size_t >(TargetCursorType::NUM_TCT)][static_cast< size_t >(TargetCursorSize::NUM_TC)]
Definition: actorsprite.h:237
virtual void stopCast(const bool b)
Definition: actorsprite.h:192
virtual int getTargetOffsetY() const
Definition: actorsprite.h:105
bool mMustResetParticles
Definition: actorsprite.h:260
ActorSpriteListeners::iterator ActorSpriteListenerIterator
Definition: actorsprite.h:253
virtual void setTrickDead(const bool b)
Definition: actorsprite.h:181
void untarget()
Definition: actorsprite.h:116
static bool loaded
Definition: actorsprite.h:239
void controlParticleDeleted(const Particle *const particle)
std::set< int32_t > mStatusEffects
Definition: actorsprite.h:242
static void load()
void setTargetType(const TargetCursorTypeT type)
void controlCustomParticle(Particle *const particle)
int getActorX() const
Definition: actorsprite.h:160
const std::set< int32_t > & getStatusEffects() const
Definition: actorsprite.h:187
int getActorY() const
Definition: actorsprite.h:163
void controlAutoParticle(Particle *const particle)
static void unload()
int mCursorPaddingX
Definition: actorsprite.h:256
void setStatusEffect(const int32_t index, const Enable active, const IsStart start)
virtual void updateStatusEffect(const int32_t index, const Enable newStatus, const IsStart start)
void removeActorSpriteListener(ActorSpriteListener *const listener)
std::string getStatusEffectsString() const
void addActorSpriteListener(ActorSpriteListener *const listener)
virtual void handleStatusEffect(const StatusEffect *const effect, const int32_t effectId, const Enable newStatus, const IsStart start)
void setHaveCart(const bool b)
Definition: actorsprite.h:172
Definition: actor.h:42
virtual int getPixelY() const
Definition: actor.h:93
int getPixelX() const
Definition: actor.h:87
int getHeight() const
void setAlpha(float alpha)
int getWidth() const
Definition: map.h:75
size_t size() const
Definition: particlelist.h:62
size_t usedSize() const
virtual float getAlpha() const
Definition: sprite.h:103
static const int mapTileSize
Definition: map.h:27
DisplayType ::T DisplayTypeT
Definition: displaytype.h:32
bool Enable
Definition: enable.h:30
bool ForceDisplay
Definition: forcedisplay.h:30
bool IsStart
Definition: isstart.h:30
#define override
Definition: localconsts.h:47
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define notfinal
Definition: localconsts.h:261
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
#define A_UNUSED
Definition: localconsts.h:160
TargetCursorSize ::T TargetCursorSizeT
TargetCursorType ::T TargetCursorTypeT