From cdc8f4ad535d39adb89f238c6f9b2c68d71f6151 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 10 Jul 2016 22:42:45 +0300 Subject: Add support for permanent particle effect. Attribute name "particle". This effect cant be played at start, if existing "start-particle" but will be played if effect continues. --- src/being/actorsprite.cpp | 6 ++---- src/resources/db/statuseffectdb.cpp | 2 ++ src/statuseffect.cpp | 9 +++++++++ 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 @@ -57,6 +57,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 */ @@ -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; -- cgit v1.2.3-70-g09d2