Mana
Loading...
Searching...
No Matches
actorsprite.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2010-2012 The Mana Developers
4 *
5 * This file is part of The Mana Client.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include "actor.h"
24#include "compoundsprite.h"
25#include "map.h"
26#include "particle.h"
27
28class SimpleAnimation;
29
30class ActorSprite : public Actor
31{
32public:
42
50
58
59 ActorSprite(int id);
60
61 ~ActorSprite() override;
62
63 int getId() const
64 { return mId; }
65
66 void setId(int id) { mId = id; }
67
71 virtual Type getType() const { return UNKNOWN; }
72
73 int getDrawOrder() const override;
74
75 bool draw(Graphics *graphics, int offsetX, int offsetY) const override;
76
77 bool drawSpriteAt(Graphics *graphics, int x, int y) const;
78
79 virtual void logic();
80
81 void setMap(Map* map) override;
82
87 { return Map::BLOCKTYPE_NONE; }
88
92 void controlParticle(Particle *particle);
93
98 { return TC_MEDIUM; }
99
104
108 void untarget() { mUsedTargetCursor = nullptr; }
109
110 void setAlpha(float alpha) override { mSprites.setAlpha(alpha); }
111 float getAlpha() const override { return mSprites.getAlpha(); }
112
113 int getWidth() const { return mSprites.getWidth(); }
114 int getHeight() const { return mSprites.getHeight(); }
115
116 static void load();
117 static void unload();
118
119protected:
120 void setupSpriteDisplay(const SpriteDisplay &display,
121 bool forceDisplay = true);
122
123 int mId;
124 std::vector<ParticleHandle> mChildParticleEffects;
125
127
128private:
130 static void initTargetCursor();
131
133 static void cleanupTargetCursors();
134
138 static void loadTargetCursor(const std::string &filename,
139 int width, int height, int type, int size);
140
143
146
147 static bool loaded;
148
151};
int getWidth() const
bool draw(Graphics *graphics, int offsetX, int offsetY) const override
Draws the Actor to the given graphics context.
virtual void logic()
void setAlpha(float alpha) override
Sets the alpha value used to draw the actor.
~ActorSprite() override
static void loadTargetCursor(const std::string &filename, int width, int height, int type, int size)
Helper function for loading target cursors.
static ResourceRef< ImageSet > targetCursorImages[NUM_TCT][NUM_TC]
Images of the target cursor.
void controlParticle(Particle *particle)
Take control of a particle.
void setTargetType(TargetCursorType type)
Sets the target animation for this actor.
static void initTargetCursor()
Load the target cursors into memory.
virtual TargetCursorSize getTargetCursorSize() const
Returns the required size of a target cursor for this being.
Definition actorsprite.h:97
int getId() const
Definition actorsprite.h:63
int getHeight() const
void setId(int id)
Definition actorsprite.h:66
static void cleanupTargetCursors()
Remove the target cursors from memory.
void setMap(Map *map) override
bool drawSpriteAt(Graphics *graphics, int x, int y) const
static SimpleAnimation * targetCursor[NUM_TCT][NUM_TC]
Animated target cursors.
float getAlpha() const override
Returns the current alpha value used to draw the actor.
void setupSpriteDisplay(const SpriteDisplay &display, bool forceDisplay=true)
void untarget()
Untargets the actor.
static bool loaded
SimpleAnimation * mUsedTargetCursor
Target cursor being used.
static void load()
CompoundSprite mSprites
static void unload()
virtual Type getType() const
Returns the type of the ActorSprite.
Definition actorsprite.h:71
int getDrawOrder() const override
Returns the pixel Y coordinate that the actor should be drawn at.
virtual Map::BlockType getBlockType() const
Gets the way the object blocks pathfinding for other objects.
Definition actorsprite.h:86
std::vector< ParticleHandle > mChildParticleEffects
Definition actor.h:35
int getHeight() const
Gets the height in pixels of the first sprite in the list.
void setAlpha(float alpha)
float getAlpha() const
int getWidth() const
Gets the width in pixels of the first sprite in the list.
A central point of control for graphics.
Definition graphics.h:78
A tile map.
Definition map.h:147
BlockType
Definition map.h:150
@ BLOCKTYPE_NONE
Definition map.h:151
A particle spawned by a ParticleEmitter.
Definition particle.h:42
Automatically counting Resource reference.
Definition resource.h:74
This class is a leightweight alternative to the Sprite class.
Graphics * graphics
Definition client.cpp:104