Attempt to select an AI action directly instead of waiting for the next frame

pull/3236/head
Evil Eye 6 months ago
parent 3a5ed998e7
commit 134c099df9

@ -455,27 +455,37 @@ namespace MWMechanics
void AiWander::doPerFrameActionsForState(const MWWorld::Ptr& actor, float duration,
MWWorld::MovementDirectionFlags supportedMovementDirections, AiWanderStorage& storage)
{
switch (storage.mState)
// Attempt to fast forward to the next state instead of remaining in an intermediate state for a frame
for (int i = 0; i < 2; ++i)
{
case AiWanderStorage::Wander_IdleNow:
onIdleStatePerFrameActions(actor, duration, storage);
break;
case AiWanderStorage::Wander_Walking:
onWalkingStatePerFrameActions(actor, duration, supportedMovementDirections, storage);
break;
case AiWanderStorage::Wander_ChooseAction:
onChooseActionStatePerFrameActions(actor, storage);
break;
switch (storage.mState)
{
case AiWanderStorage::Wander_IdleNow:
{
onIdleStatePerFrameActions(actor, duration, storage);
if (storage.mState != AiWanderStorage::Wander_ChooseAction)
return;
continue;
}
case AiWanderStorage::Wander_Walking:
onWalkingStatePerFrameActions(actor, duration, supportedMovementDirections, storage);
return;
case AiWanderStorage::Wander_MoveNow:
break; // nothing to do
case AiWanderStorage::Wander_ChooseAction:
{
onChooseActionStatePerFrameActions(actor, storage);
if (storage.mState != AiWanderStorage::Wander_IdleNow)
return;
continue;
}
case AiWanderStorage::Wander_MoveNow:
return; // nothing to do
default:
// should never get here
assert(false);
break;
default:
// should never get here
assert(false);
return;
}
}
}

Loading…
Cancel
Save