mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-23 20:39:57 +00:00
Refactor actors update
This commit is contained in:
parent
73c9efc5e3
commit
677fc84223
1 changed files with 30 additions and 22 deletions
|
@ -776,24 +776,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
if(!paused)
|
if(!paused)
|
||||||
{
|
{
|
||||||
// Note: we need to do this before any of the animations are updated.
|
// Reset data from previous frame
|
||||||
// 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)
|
|
||||||
{
|
|
||||||
for (PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter)
|
for (PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter)
|
||||||
{
|
{
|
||||||
// Reset last hit object, which is only valid for one frame
|
// 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());
|
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++)
|
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();iter++)
|
||||||
{
|
{
|
||||||
const MWWorld::Class &cls = MWWorld::Class::get(iter->first);
|
const MWWorld::Class &cls = MWWorld::Class::get(iter->first);
|
||||||
|
@ -812,10 +824,6 @@ namespace MWMechanics
|
||||||
if(iter->second->isDead())
|
if(iter->second->isDead())
|
||||||
iter->second->resurrect();
|
iter->second->resurrect();
|
||||||
|
|
||||||
updateActor(iter->first, duration);
|
|
||||||
if(iter->first.getTypeName() == typeid(ESM::NPC).name())
|
|
||||||
updateNpc(iter->first, duration, paused);
|
|
||||||
|
|
||||||
if(!stats.isDead())
|
if(!stats.isDead())
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue