Refactor actors update

This commit is contained in:
scrawl 2014-02-05 09:50:21 +01:00
parent 73c9efc5e3
commit 677fc84223

View file

@ -776,24 +776,7 @@ namespace MWMechanics
{
if(!paused)
{
// Note: we need to do this before any of the animations are updated.
// Reaching the text keys may trigger Hit / Spellcast (and as such, particles),
// so updating VFX immediately after that would just remove the particle effects instantly.
// There needs to be a magic effect update in between.
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
iter->second->updateContinuousVfx();
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
{
if (iter->first.getClass().getCreatureStats(iter->first).getMagicEffects().get(
ESM::MagicEffect::Paralyze).mMagnitude > 0)
iter->second->skipAnim();
iter->second->update(duration);
}
}
if (!paused)
{
// Reset data from previous frame
for (PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter)
{
// Reset last hit object, which is only valid for one frame
@ -802,6 +785,35 @@ namespace MWMechanics
iter->first.getClass().getCreatureStats(iter->first).setLastHitObject(std::string());
}
// AI and magic effects update
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
{
if (!iter->first.getClass().getCreatureStats(iter->first).isDead())
{
updateActor(iter->first, duration);
if(iter->first.getTypeName() == typeid(ESM::NPC).name())
updateNpc(iter->first, duration, paused);
}
}
// Looping magic VFX update
// Note: we need to do this before any of the animations are updated.
// Reaching the text keys may trigger Hit / Spellcast (and as such, particles),
// so updating VFX immediately after that would just remove the particle effects instantly.
// There needs to be a magic effect update in between.
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
iter->second->updateContinuousVfx();
// Animation/movement update
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
{
if (iter->first.getClass().getCreatureStats(iter->first).getMagicEffects().get(
ESM::MagicEffect::Paralyze).mMagnitude > 0)
iter->second->skipAnim();
iter->second->update(duration);
}
// Kill dead actors
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();iter++)
{
const MWWorld::Class &cls = MWWorld::Class::get(iter->first);
@ -812,10 +824,6 @@ namespace MWMechanics
if(iter->second->isDead())
iter->second->resurrect();
updateActor(iter->first, duration);
if(iter->first.getTypeName() == typeid(ESM::NPC).name())
updateNpc(iter->first, duration, paused);
if(!stats.isDead())
continue;
}