void ActiveSpells::update() const { bool rebuild = false; MWWorld::TimeStamp now = MWBase::Environment::get().getWorld()->getTimeStamp(); // Erase no longer active spells if (mLastUpdate!=now) { TContainer::iterator iter (mSpells.begin()); while (iter!=mSpells.end()) if (!timeToExpire (iter)) { mSpells.erase (iter++); rebuild = true; } else ++iter; mLastUpdate = now; } if (mSpellsChanged) { mSpellsChanged = false; rebuild = true; } if (rebuild) rebuildEffects(); }
MagicEffects Spells::getMagicEffects() const { if (mSpellsChanged) { rebuildEffects(); mSpellsChanged = false; } return mEffects; }
void Spells::visitEffectSources(EffectSourceVisitor &visitor) const { if (mSpellsChanged) { rebuildEffects(); mSpellsChanged = false; } for (std::map<SpellKey, MagicEffects>::const_iterator it = mSourcedEffects.begin(); it != mSourcedEffects.end(); ++it) { const ESM::Spell * spell = it->first; for (MagicEffects::Collection::const_iterator effectIt = it->second.begin(); effectIt != it->second.end(); ++effectIt) { visitor.visit(effectIt->first, spell->mName, spell->mId, -1, effectIt->second.getMagnitude()); } } }