diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/being/being.cpp | 24 | ||||
-rw-r--r-- | src/effectmanager.cpp | 35 | ||||
-rw-r--r-- | src/effectmanager.h | 8 | ||||
-rw-r--r-- | src/gui/windows/skilldialog.cpp | 20 | ||||
-rw-r--r-- | src/gui/windows/skilldialog.h | 4 |
5 files changed, 56 insertions, 35 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index e37d29fd1..93dd6abc5 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -1245,29 +1245,15 @@ void Being::setAction(const BeingAction::Action &action, const int attackId) reset(); // attack particle effect - if (Particle::enabled) + if (Particle::enabled && effectManager) { const int effectId = mInfo->getAttack(attackId)->mEffectId; - - int rotation; - switch (mSpriteDirection) + if (effectId >= 0) { - case SpriteDirection::DOWN: - default: - rotation = 0; - break; - case SpriteDirection::LEFT: - rotation = 90; - break; - case SpriteDirection::UP: - rotation = 180; - break; - case SpriteDirection::RIGHT: - rotation = 270; - break; + effectManager->triggerDirection(effectId, + this, + mSpriteDirection); } - if (effectManager && effectId >= 0) - effectManager->trigger(effectId, this, rotation); } } break; diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index 1f5db8344..a6671870b 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -80,6 +80,30 @@ EffectManager::~EffectManager() { } +bool EffectManager::triggerDirection(const int id, Being *const being, + const SpriteDirection::Type &direction) +{ + int rotation; + switch (direction) + { + case SpriteDirection::DOWN: + default: + rotation = 0; + break; + case SpriteDirection::LEFT: + rotation = 90; + break; + case SpriteDirection::UP: + rotation = 180; + break; + case SpriteDirection::RIGHT: + rotation = 270; + break; + } + + return trigger(id, being, rotation); +} + bool EffectManager::trigger(const int id, Being *const being, const int rotation) { @@ -162,3 +186,14 @@ bool EffectManager::trigger(const int id, const int x, const int y, } return rValue; } + +void EffectManager::triggerDefault(int effectId, + Being *const being, + const int defaultEffectId) +{ + if (effectId == -1) + effectId = defaultEffectId; + if (effectId == -1) + return; + trigger(effectId, being); +} diff --git a/src/effectmanager.h b/src/effectmanager.h index 3ebc0f805..0e81ffa44 100644 --- a/src/effectmanager.h +++ b/src/effectmanager.h @@ -24,6 +24,7 @@ #define EFFECTMANAGER_H #include "resources/effectdescription.h" +#include "resources/spritedirection.h" #include <vector> @@ -49,6 +50,9 @@ class EffectManager final */ bool trigger(const int id, Being *const being, const int rotation = 0); + bool triggerDirection(const int id, Being *const being, + const SpriteDirection::Type &direction); + Particle *triggerReturn(const int id, Being *const being, const int rotation = 0); @@ -59,6 +63,10 @@ class EffectManager final bool trigger(const int id, const int x, const int y, const int rotation = 0); + void triggerDefault(int effectId, + Being *const being, + const int defaultEffectId); + private: std::vector<EffectDescription> mEffects; }; diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index fb82633fe..04d883402 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -590,33 +590,27 @@ SkillData *SkillDialog::getSkillData(const int id) const return nullptr; } -void SkillDialog::triggerEffect(int effectId, - const int defaultEffectId) const +void SkillDialog::playUpdateEffect(const int id) const { if (!effectManager) return; - if (effectId == -1) - effectId = defaultEffectId; - if (effectId == -1) - return; - effectManager->trigger(effectId, localPlayer); -} - -void SkillDialog::playUpdateEffect(const int id) const -{ const SkillData *const data = getSkillData(id); if (!data) return; - triggerEffect(data->updateEffectId, + effectManager->triggerDefault(data->updateEffectId, + localPlayer, paths.getIntValue("skillLevelUpEffectId")); } void SkillDialog::playRemoveEffect(const int id) const { + if (!effectManager) + return; const SkillData *const data = getSkillData(id); if (!data) return; - triggerEffect(data->removeEffectId, + effectManager->triggerDefault(data->removeEffectId, + localPlayer, paths.getIntValue("skillRemoveEffectId")); } diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h index 1fa182e8b..0b2180191 100644 --- a/src/gui/windows/skilldialog.h +++ b/src/gui/windows/skilldialog.h @@ -30,6 +30,7 @@ #include "resources/skillowner.h" #include "resources/skilltype.h" +class Being; class Button; class Label; class SkillModel; @@ -130,9 +131,6 @@ class SkillDialog final : public Window, private: void addSkillDuration(SkillInfo *const skill); - void triggerEffect(int effectId, - const int defaultEffectId) const; - typedef std::map<int, SkillInfo*> SkillMap; SkillMap mSkills; std::vector<SkillInfo*> mDurations; |