Example #1
0
    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();
    }
Example #2
0
 MagicEffects Spells::getMagicEffects() const
 {
     if (mSpellsChanged) {
         rebuildEffects();
         mSpellsChanged = false;
     }
     return mEffects;
 }
Example #3
0
    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());
            }
        }
    }