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  *
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  ~ActorSprite() override;
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 
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:
207  virtual void updateStatusEffect(const int32_t index,
208  const Enable newStatus,
209  const IsStart start);
210 
217  virtual void handleStatusEffect(const StatusEffect *const effect,
218  const int32_t effectId,
219  const Enable newStatus,
220  const IsStart start);
221 
222  void setupSpriteDisplay(const SpriteDisplay &display,
223  const ForceDisplay forceDisplay,
224  const DisplayTypeT displayType,
225  const std::string &color);
226 
228  static void initTargetCursor();
229 
231  static void cleanupTargetCursors();
232 
237 
238  static bool loaded;
239 
241  std::set<int32_t> mStatusEffects;
242 
245  int mHorseId;
247 
250 
251  typedef std::list<ActorSpriteListener*> ActorSpriteListeners;
252  typedef ActorSpriteListeners::iterator ActorSpriteListenerIterator;
254 
257 
260  bool mPoison;
261  bool mHaveCart;
263 };
264 
265 #endif // BEING_ACTORSPRITE_H
ActorSprite::mStatusEffects
std::set< int32_t > mStatusEffects
Definition: actorsprite.h:241
ActorSprite::ActorSpriteListeners
std::list< ActorSpriteListener * > ActorSpriteListeners
Definition: actorsprite.h:251
BlockType::NONE
@ NONE
Definition: blocktype.h:30
ActorSprite::getBlockType
virtual BlockTypeT getBlockType() const
Definition: actorsprite.h:82
ActorType::Unknown
@ Unknown
Definition: actortype.h:29
targetcursortype.h
ActorSprite::getHeight
int getHeight() const
Definition: actorsprite.h:142
ActorSprite::mHaveCart
bool mHaveCart
Definition: actorsprite.h:261
CompoundSprite
Definition: compoundsprite.h:36
BeingId
int BeingId
Definition: beingid.h:29
ActorSprite::mChildParticleEffects
ParticleList mChildParticleEffects
Definition: actorsprite.h:244
CAST_SIZE
#define CAST_SIZE
Definition: cast.h:33
ActorSprite::mPoison
bool mPoison
Definition: actorsprite.h:260
ActorSprite::addActorSpriteListener
void addActorSpriteListener(ActorSpriteListener *const listener)
Definition: actorsprite.cpp:453
anonymous_namespace{stringutils.cpp}::start
unsigned int start
Definition: stringutils.cpp:227
TargetCursorSize::NUM_TC
@ NUM_TC
Definition: targetcursorsize.h:32
ActorSprite::handleStatusEffect
virtual void handleStatusEffect(const StatusEffect *const effect, const int32_t effectId, const Enable newStatus, const IsStart start)
Definition: actorsprite.cpp:337
Particle
Definition: particle.h:44
ActorSprite::getTargetOffsetY
virtual int getTargetOffsetY() const
Definition: actorsprite.h:104
displaytype.h
ActorSpriteListener
Definition: actorspritelistener.h:29
ActorSprite::getTargetCursorSize
virtual TargetCursorSizeT getTargetCursorSize() const
Definition: actorsprite.h:98
map.h
TargetCursorType::NUM_TCT
@ NUM_TCT
Definition: targetcursortype.h:32
ActorSprite::loaded
static bool loaded
Definition: actorsprite.h:238
DisplayTypeT
DisplayType ::T DisplayTypeT
Definition: displaytype.h:31
A_DELETE_COPY
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
ActorSprite::setupSpriteDisplay
void setupSpriteDisplay(const SpriteDisplay &display, const ForceDisplay forceDisplay, const DisplayTypeT displayType, const std::string &color)
Definition: actorsprite.cpp:364
ActorSprite::mTrickDead
bool mTrickDead
Definition: actorsprite.h:262
ActorSprite::getId
BeingId getId() const
Definition: actorsprite.h:63
ActorSprite::setTrickDead
virtual void setTrickDead(const bool b)
Definition: actorsprite.h:180
ActorSprite::ActorSprite
ActorSprite(const BeingId id)
Definition: actorsprite.cpp:68
ActorSprite::getStatusEffectsString
std::string getStatusEffectsString() const
Definition: actorsprite.cpp:519
ActorSprite::mCursorPaddingX
int mCursorPaddingX
Definition: actorsprite.h:255
ActorSprite::getParticlesCount
size_t getParticlesCount() const
Definition: actorsprite.h:194
ActorSprite::updateStatusEffect
virtual void updateStatusEffect(const int32_t index, const Enable newStatus, const IsStart start)
Definition: actorsprite.cpp:316
isstart.h
particlevector.h
Actor
Definition: actor.h:40
ActorSprite::stopCast
virtual void stopCast(const bool b)
Definition: actorsprite.h:191
A_UNUSED
#define A_UNUSED
Definition: localconsts.h:159
notfinal
#define notfinal
Definition: localconsts.h:260
beingid.h
TargetCursorSizeT
TargetCursorSize ::T TargetCursorSizeT
Definition: targetcursorsize.h:34
ActorSprite::removeActorSpriteListener
void removeActorSpriteListener(ActorSpriteListener *const listener)
Definition: actorsprite.cpp:458
localconsts.h
ActorSprite::ActorSpriteListenerIterator
ActorSpriteListeners::iterator ActorSpriteListenerIterator
Definition: actorsprite.h:252
ParticleList
Definition: particlelist.h:37
ActorSprite::mHorseId
int mHorseId
Definition: actorsprite.h:245
enable.h
ActorSprite::setTargetType
void setTargetType(const TargetCursorTypeT type)
Definition: actorsprite.cpp:172
ActorSprite::getPoison
bool getPoison() const
Definition: actorsprite.h:168
bool
particlelist.h
noexcept2
#define noexcept2
Definition: localconsts.h:49
ActorSprite::mMustResetParticles
bool mMustResetParticles
Definition: actorsprite.h:259
ParticleList::size
size_t size() const
Definition: particlelist.h:61
ActorSprite::controlCustomParticle
void controlCustomParticle(Particle *const particle)
Definition: actorsprite.cpp:156
ActorSprite::controlAutoParticle
void controlAutoParticle(Particle *const particle)
Definition: actorsprite.cpp:147
ActorSprite::getActorY
int getActorY() const
Definition: actorsprite.h:162
final
#define final
Definition: localconsts.h:45
ActorSprite::mUsedTargetCursor
AnimatedSprite * mUsedTargetCursor
Definition: actorsprite.h:249
ActorSprite::getTargetOffsetX
virtual int getTargetOffsetX() const
Definition: actorsprite.h:101
Actor::getPixelY
virtual int getPixelY() const
Definition: actor.h:92
ActorSprite::getAlpha
float getAlpha() const
Definition: actorsprite.h:136
ActorSprite::load
static void load()
Definition: actorsprite.cpp:434
ActorSprite::setHaveCart
void setHaveCart(const bool b)
Definition: actorsprite.h:171
CompoundSprite::getHeight
int getHeight() const
Definition: compoundsprite.cpp:212
ActorSprite
Definition: actorsprite.h:54
forcedisplay.h
BlockTypeT
BlockType ::T BlockTypeT
Definition: blocktype.h:40
ActorSprite::cleanupTargetCursors
static void cleanupTargetCursors()
Definition: actorsprite.cpp:510
ActorSprite::mCursorPaddingY
int mCursorPaddingY
Definition: actorsprite.h:256
ActorSprite::setAlpha
void setAlpha(const float alpha)
Definition: actorsprite.h:133
StatusEffect
Definition: statuseffect.h:33
compoundsprite.h
ActorTypeT
ActorType ::T ActorTypeT
Definition: actortype.h:42
ActorSprite::setStatusEffectOpiton0
void setStatusEffectOpiton0(const uint32_t option)
Definition: actorsprite.cpp:310
ActorSprite::logic
virtual void logic()
Definition: actorsprite.cpp:109
targetcursorsize.h
ActorSprite::setPoison
void setPoison(const bool b)
Definition: actorsprite.h:165
SpriteDisplay
Definition: spritedisplay.h:32
ParticleVector::usedSize
size_t usedSize() const
Definition: particlevector.cpp:99
ActorSprite::getStatusEffects
const std::set< int32_t > & getStatusEffects() const
Definition: actorsprite.h:186
Actor::getPixelX
int getPixelX() const
Definition: actor.h:86
Sprite::getAlpha
virtual float getAlpha() const
Definition: sprite.h:102
ActorSprite::setRiding
virtual void setRiding(const bool b)
Definition: actorsprite.h:177
ActorSprite::setId
void setId(const BeingId id)
Definition: actorsprite.h:66
ActorSprite::isTrickDead
bool isTrickDead() const
Definition: actorsprite.h:183
ActorSprite::setStatusEffect
void setStatusEffect(const int32_t index, const Enable active, const IsStart start)
Definition: actorsprite.cpp:197
override
#define override
Definition: localconsts.h:46
CompoundSprite::getWidth
int getWidth() const
Definition: compoundsprite.cpp:200
TargetCursorTypeT
TargetCursorType ::T TargetCursorTypeT
Definition: targetcursortype.h:34
TargetCursorSize::MEDIUM
@ MEDIUM
Definition: targetcursorsize.h:30
ActorSprite::mId
BeingId mId
Definition: actorsprite.h:246
CompoundSprite::setAlpha
void setAlpha(float alpha)
Definition: compoundsprite.cpp:396
anonymous_namespace{itemlinkhandler.cpp}::listener
OpenUrlListener listener
Definition: itemlinkhandler.cpp:55
Map
Definition: map.h:71
ActorSprite::setStatusEffectOpitons
void setStatusEffectOpitons(const uint32_t option, const uint32_t opt1, const uint32_t opt2, const uint32_t opt3)
Definition: actorsprite.cpp:283
ActorSprite::~ActorSprite
~ActorSprite()
Definition: actorsprite.cpp:87
ActorSprite::getActorX
int getActorX() const
Definition: actorsprite.h:159
actor.h
ActorSprite::initTargetCursor
static void initTargetCursor()
Definition: actorsprite.cpp:493
AnimatedSprite
Definition: animatedsprite.h:35
blocktype.h
ActorSprite::mActorSpriteListeners
ActorSpriteListeners mActorSpriteListeners
Definition: actorsprite.h:253
A_WARN_UNUSED
#define A_WARN_UNUSED
Definition: localconsts.h:160
ActorSprite::getHaveCart
bool getHaveCart() const
Definition: actorsprite.h:174
ActorSprite::mStatusParticleEffects
ParticleVector mStatusParticleEffects
Definition: actorsprite.h:243
actortype.h
ActorSprite::setMap
void setMap(Map *const map)
Definition: actorsprite.cpp:138
ActorSprite::getType
virtual ActorTypeT getType() const
Definition: actorsprite.h:72
ActorSprite::untarget
void untarget()
Definition: actorsprite.h:115
ActorSprite::getWidth
int getWidth() const
Definition: actorsprite.h:139
ActorSprite::controlParticleDeleted
void controlParticleDeleted(const Particle *const particle)
Definition: actorsprite.cpp:166
mapTileSize
static const int mapTileSize
Definition: map.h:26
ActorSprite::targetCursor
static AnimatedSprite * targetCursor[static_cast< size_t >(TargetCursorType::NUM_TCT)][static_cast< size_t >(TargetCursorSize::NUM_TC)]
Definition: actorsprite.h:236
ParticleVector
Definition: particlevector.h:37
ActorSprite::unload
static void unload()
Definition: actorsprite.cpp:444