3
* Copyright (C) 2010 The Mana Developers
4
* Copyright (C) 2011-2013 The ManaPlus Developers
6
* This file is part of The ManaPlus Client.
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
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.
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/>.
26
#include "compoundsprite.h"
27
#include "localconsts.h"
29
#include "particlecontainer.h"
31
#include <SDL_types.h>
36
#include "localconsts.h"
40
class ActorSpriteListener;
42
class ActorSprite : public CompoundSprite, public Actor
73
explicit ActorSprite(const int id);
75
A_DELETE_COPY(ActorSprite)
79
int getId() const A_WARN_UNUSED
82
void setId(const int id)
86
* Returns the type of the ActorSprite.
88
virtual Type getType() const A_WARN_UNUSED
91
virtual bool draw(Graphics *const graphics,
92
const int offsetX, const int offsetY) const override;
94
virtual bool drawSpriteAt(Graphics *const graphics,
95
const int x, const int y) const;
99
static void actorLogic();
101
void setMap(Map *const map) override;
104
* Gets the way the object blocks pathfinding for other objects
106
virtual Map::BlockType getBlockType() const A_WARN_UNUSED
107
{ return Map::BLOCKTYPE_NONE; }
110
* Take control of a particle.
112
void controlParticle(Particle *const particle);
115
* Returns the required size of a target cursor for this being.
117
virtual TargetCursorSize getTargetCursorSize() const A_WARN_UNUSED
118
{ return TC_MEDIUM; }
120
virtual int getTargetOffsetX() const A_WARN_UNUSED
123
virtual int getTargetOffsetY() const A_WARN_UNUSED
127
* Sets the target animation for this actor.
129
void setTargetType(const TargetCursorType type);
132
* Untargets the actor.
135
{ mUsedTargetCursor = nullptr; }
138
* Sets the actor's stun mode. If zero, the being is `normal', otherwise it
139
* is `stunned' in some fashion.
141
void setStunMode(const uint16_t stunMode)
143
if (mStunMode != stunMode)
144
updateStunMode(mStunMode, stunMode);
145
mStunMode = stunMode;
148
void setStatusEffect(const int index, const bool active);
151
* A status effect block is a 16 bit mask of status effects. We assign each
152
* such flag a block ID of offset + bitnr.
154
* These are NOT the same as the status effect indices.
156
void setStatusEffectBlock(const int offset, const uint16_t flags);
158
virtual void setAlpha(const float alpha) override
159
{ CompoundSprite::setAlpha(alpha); }
161
virtual float getAlpha() const override A_WARN_UNUSED
162
{ return CompoundSprite::getAlpha(); }
164
virtual int getWidth() const override A_WARN_UNUSED
165
{ return CompoundSprite::getWidth(); }
167
virtual int getHeight() const override A_WARN_UNUSED
168
{ return CompoundSprite::getHeight(); }
172
static void unload();
175
* Add an ActorSprite listener.
177
void addActorSpriteListener(ActorSpriteListener *const listener);
180
* Remove an ActorSprite listener.
182
void removeActorSpriteListener(ActorSpriteListener *const listener);
186
* Notify self that the stun mode has been updated. Invoked by
187
* setStunMode if something changed.
189
virtual void updateStunMode(const int oldMode, const int newMode);
192
* Notify self that a status effect has flipped.
193
* The new flag is passed.
195
virtual void updateStatusEffect(const int index, const bool newStatus);
198
* Handle an update to a status or stun effect
200
* \param The StatusEffect to effect
201
* \param effectId -1 for stun, otherwise the effect index
203
virtual void handleStatusEffect(StatusEffect *const effect,
206
void setupSpriteDisplay(const SpriteDisplay &display,
207
const bool forceDisplay = true,
208
const int imageType = 0,
209
const std::string &color = "");
211
std::set<int> mStatusEffects; /**< set of active status effects */
213
ParticleList mStunParticleEffects;
214
ParticleVector mStatusParticleEffects;
215
ParticleList mChildParticleEffects;
217
uint16_t mStunMode; /**< Stun mode; zero if not stunned */
220
/** Load the target cursors into memory */
221
static void initTargetCursor();
223
/** Remove the target cursors from memory */
224
static void cleanupTargetCursors();
226
/** Animated target cursors. */
227
static AnimatedSprite *targetCursor[NUM_TCT][NUM_TC];
231
/** Target cursor being used */
232
AnimatedSprite *mUsedTargetCursor;
234
typedef std::list<ActorSpriteListener*> ActorSpriteListeners;
235
typedef ActorSpriteListeners::iterator ActorSpriteListenerIterator;
236
ActorSpriteListeners mActorSpriteListeners;
241
/** Reset particle status effects on next redraw? */
242
bool mMustResetParticles;
245
#endif // ACTORSPRITE_H