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