diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-07-10 22:42:45 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-07-10 22:52:53 +0300 |
commit | cdc8f4ad535d39adb89f238c6f9b2c68d71f6151 (patch) | |
tree | ec2ecc06c9cfb870b3a11aaec5326bf987593494 | |
parent | 4aa184df5a208c51cb0141ae6a609c60294d8323 (diff) | |
download | manaverse-s20160712.tar.gz manaverse-s20160712.tar.bz2 manaverse-s20160712.tar.xz manaverse-s20160712.zip |
Add support for permanent particle effect.s20160712
Attribute name "particle".
This effect cant be played at start, if existing "start-particle"
but will be played if effect continues.
-rw-r--r-- | src/being/actorsprite.cpp | 6 | ||||
-rw-r--r-- | src/resources/db/statuseffectdb.cpp | 2 | ||||
-rw-r--r-- | src/statuseffect.cpp | 9 | ||||
-rw-r--r-- | src/statuseffect.h | 7 |
4 files changed, 20 insertions, 4 deletions
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp index d5527f161..f0dfc07ec 100644 --- a/src/being/actorsprite.cpp +++ b/src/being/actorsprite.cpp @@ -386,11 +386,9 @@ void ActorSprite::handleStatusEffect(const StatusEffect *const effect, { Particle *particle = nullptr; if (start == IsStart_true) - { particle = effect->getStartParticle(); - } - // +++ here also need enable permanent status effects, - // need new field in StatusEffect + if (!particle) + particle = effect->getParticle(); if (particle) mStatusParticleEffects.setLocally(effectId, particle); } diff --git a/src/resources/db/statuseffectdb.cpp b/src/resources/db/statuseffectdb.cpp index 4e73b8ee7..0b0618783 100644 --- a/src/resources/db/statuseffectdb.cpp +++ b/src/resources/db/statuseffectdb.cpp @@ -168,6 +168,8 @@ void StatusEffectDB::loadXmlFile(const std::string &fileName, node, "start-audio", ""); startEffect->mStartParticleEffect = XML::getProperty( node, "start-particle", ""); + startEffect->mParticleEffect = XML::getProperty( + node, "particle", ""); startEffect->mIcon = XML::getProperty(node, "icon", ""); startEffect->mAction = XML::getProperty(node, "action", ""); diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index 7e89ae0f2..a53f239b2 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -39,6 +39,7 @@ StatusEffect::StatusEffect() : mMessage(), mSFXEffect(), mStartParticleEffect(), + mParticleEffect(), mIcon(), mAction(), mName(), @@ -75,6 +76,14 @@ Particle *StatusEffect::getStartParticle() const return particleEngine->addEffect(mStartParticleEffect, 0, 0); } +Particle *StatusEffect::getParticle() const +{ + if (!particleEngine || mParticleEffect.empty()) + return nullptr; + else + return particleEngine->addEffect(mParticleEffect, 0, 0); +} + AnimatedSprite *StatusEffect::getIcon() const { if (mIcon.empty()) diff --git a/src/statuseffect.h b/src/statuseffect.h index 7ef6f212f..83a721852 100644 --- a/src/statuseffect.h +++ b/src/statuseffect.h @@ -58,6 +58,12 @@ class StatusEffect final Particle *getStartParticle() const A_WARN_UNUSED; /** + * Creates the particle effect associated with this status effect, if + * possible. + */ + Particle *getParticle() const A_WARN_UNUSED; + + /** * Retrieves the status icon for this effect, if applicable */ AnimatedSprite *getIcon() const A_WARN_UNUSED; @@ -70,6 +76,7 @@ class StatusEffect final std::string mMessage; std::string mSFXEffect; std::string mStartParticleEffect; + std::string mParticleEffect; std::string mIcon; std::string mAction; std::string mName; |