Mana
Loading...
Searching...
No Matches
statuseffect.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2008-2009 The Mana World Development Team
4 * Copyright (C) 2009-2025 The Mana Developers
5 *
6 * This file is part of The Mana 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#include "statuseffect.h"
23
24#include "event.h"
25#include "particle.h"
26#include "sound.h"
27
28#include "configuration.h"
29
33void StatusEffect::playSfx(bool enabled) const
34{
35 auto &sfx = enabled ? start.sfx : end.sfx;
36 if (!sfx.empty())
37 sound.playSfx(sfx);
38}
39
44void StatusEffect::deliverMessage(bool enabled) const
45{
46 auto &message = enabled ? start.message : end.message;
47 if (!message.empty())
48 serverNotice(message);
49}
50
56{
57 auto &particleEffect = enabled ? start.particleEffect : end.particleEffect;
58 if (particleEffect.empty())
59 return nullptr;
60 return particleEngine->addEffect(particleEffect, 0, 0);
61}
62
67{
68 if (icon.empty())
69 return nullptr;
70 return Sprite::load(paths.getStringValue("sprites") + icon);
71}
std::string getStringValue(const std::string &key) const
A particle spawned by a ParticleEmitter.
Definition particle.h:42
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.
Definition particle.cpp:249
void playSfx(const std::string &path, int x=0, int y=0)
Plays a sound at the specified location.
Definition sound.cpp:248
Animates a sprite by adding playback state.
Definition sprite.h:37
static Sprite * load(const std::string &filename, int variant=0)
An helper function, which will request the sprite to animate from the resource manager.
Definition sprite.cpp:42
Sprite * getIconSprite() const
Retrieves the status icon for this effect, if applicable.
void playSfx(bool enabled) const
Plays the sound effect associated with this status effect, if possible.
void deliverMessage(bool enabled) const
Delivers the chat message associated with this status effect, if possible.
std::string icon
Particle * getParticle(bool enabled) const
Creates the particle effect associated with this status effect, if possible.
Configuration paths
XML default paths information reader.
Definition client.cpp:99
Sound sound
Definition client.cpp:109
void serverNotice(const std::string &message)
Definition event.h:319
Particle * particleEngine
Definition game.cpp:113
std::string message
std::string particleEffect