41#define EFFECTS_FILE "effects.xml"
55 event.setActor(
"source",
this);
92 [](
const Particle *p) { return p->isExtinct(); }),
127 for (
const auto &sprite : display.
sprites)
145 for (
const auto &particle : display.
particles)
171 static const std::string
targetCursor =
"graphics/target-cursor-%s-%s.png";
172 static const char *
const cursorTypeStr[
NUM_TCT] = {
176 static const int targetWidths[
NUM_TC] = { 44, 62, 82 };
177 static const int targetHeights[
NUM_TC] = { 35, 44, 60 };
178 static const char *
const cursorSizeStr[
NUM_TC] = {
"s",
"m",
"l" };
181 for (
int size = 0; size <
NUM_TC; size++)
183 for (
int type = 0; type <
NUM_TCT; type++)
187 cursorSizeStr[size]),
189 targetHeights[size], type, size);
196 for (
int size = 0; size <
NUM_TC; size++)
198 for (
int type = 0; type <
NUM_TCT; type++)
207 int width,
int height,
int type,
int size)
213 auto currentImageSet = resman->
getImageSet(filename, width, height);
214 if (!currentImageSet)
216 Log::info(
"Error loading target cursor: %s", filename.c_str());
222 for (
unsigned int i = 0; i < currentImageSet->size(); ++i)
225 -(currentImageSet->getWidth() / 2),
226 -(currentImageSet->getHeight() / 2));
bool draw(Graphics *graphics, int offsetX, int offsetY) const override
Draws the Actor to the given graphics context.
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.
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.
void setupSpriteDisplay(const SpriteDisplay &display, bool forceDisplay=true)
void untarget()
Untargets the actor.
SimpleAnimation * mUsedTargetCursor
Target cursor being used.
int getDrawOrder() const override
Returns the pixel Y coordinate that the actor should be drawn at.
std::vector< ParticleHandle > mChildParticleEffects
virtual void setMap(Map *map)
int getPixelX() const
Returns the pixels X coordinate of the actor.
int getPixelY() const
Returns the pixel Y coordinate of the actor.
virtual int getDrawOrder() const
Returns the pixel Y coordinate that the actor should be drawn at.
Vector mPos
Position in pixels relative to map.
An animation consists of several frames, each with their own delay and offset.
void addFrame(Image *image, int delay, int offsetX, int offsetY)
Appends a new animation at the end of the sequence.
bool draw(Graphics *graphics, int posX, int posY) const
std::string getStringValue(const std::string &key) const
int getIntValue(const std::string &key) const
returns a value corresponding to the given key.
A central point of control for graphics.
A particle spawned by a ParticleEmitter.
void moveTo(const Vector &pos)
Sets the position in 3 dimensional space in pixels relative to map.
Particle * addEffect(const std::string &particleEffectFile, int pixelX, int pixelY, int rotation=0)
Creates a child particle that hosts some emitters described in the particleEffectFile.
static bool enabled
true when non-crucial particle effects are disabled
A class for loading and managing resources.
static ResourceManager * getInstance()
Returns an instance of the class, creating one if it does not already exist.
ResourceRef< ImageSet > getImageSet(const std::string &imagePath, int w, int h)
Loads a image set based on the image referenced by the given path and the supplied sprite sizes.
Automatically counting Resource reference.
This class is a leightweight alternative to the Sprite class.
bool draw(Graphics *graphics, int posX, int posY) const
static Sprite * load(const std::string &filename, int variant=0)
An helper function, which will request the sprite to animate from the resource manager.
Configuration paths
XML default paths information reader.
Particle * particleEngine
void info(const char *log_text,...) LOG_PRINTF_ATTR
unsigned deltaTimeMs()
The time in milliseconds since the last frame, but never more than 1000.
const int DEFAULT_FRAME_DELAY
std::string strprintf(char const *format,...)
A safe version of sprintf that returns a std::string of the result.
std::vector< SpriteReference > sprites
std::vector< std::string > particles