From 4464ef501c562cf6eeda3b59b1dfcf21d9dfb5a9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 19 Feb 2013 03:10:42 +0300 Subject: Add support for away particle effect. --- src/being.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/being.cpp') diff --git a/src/being.cpp b/src/being.cpp index 29ffefcfd..aad803ba2 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -188,6 +188,7 @@ bool Being::mShowLevel = false; bool Being::mShowPlayersStatus = false; bool Being::mEnableReorderSprites = true; bool Being::mHideErased = false; +int Being::mAwayEffect = -1; std::list beingInfoCache; typedef std::map::const_iterator GuildsMapCIter; @@ -245,7 +246,8 @@ Being::Being(const int id, const Type type, const uint16_t subtype, mAway(false), mInactive(false), mNumber(100), - mHairColor(0) + mHairColor(0), + mAfkParticle(nullptr) { for (int f = 0; f < 20; f ++) @@ -1899,6 +1901,7 @@ void Being::reReadConfig() BLOCK_START("Being::reReadConfig") if (mUpdateConfigTime + 1 < cur_time) { + mAwayEffect = paths.getIntValue("afkEffectId"); mHighlightMapPortals = config.getBoolValue("highlightMapPortals"); mConfLineLim = config.getIntValue("chatMaxCharLimit"); mSpeechType = config.getIntValue("speech"); @@ -1951,6 +1954,7 @@ bool Being::updateFromCache() mInactive = false; } + updateAwayEffect(); if (mType == PLAYER) updateColors(); return true; @@ -2678,6 +2682,7 @@ void Being::setState(const uint8_t state) mShop = shop; mAway = away; mInactive = inactive; + updateAwayEffect(); if (needUpdate) { @@ -2753,6 +2758,26 @@ int Being::getSpriteID(const int slot) const return mSpriteIDs[slot]; } +void Being::addAfkEffect() +{ + if (effectManager && !mAfkParticle && mAwayEffect != -1) + mAfkParticle = effectManager->triggerReturn(mAwayEffect, this); +} + +void Being::removeAfkEffect() +{ + if (effectManager && mAfkParticle) + mChildParticleEffects.removeLocally(mAfkParticle); +} + +void Being::updateAwayEffect() +{ + if (mAway) + addAfkEffect(); + else + removeAfkEffect(); +} + BeingEquipBackend::BeingEquipBackend(Being *const being): mBeing(being) { -- cgit v1.2.3-60-g2f50