mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 15:15:31 +00:00
extract function onWalkingStatePerFrameActions().
This commit is contained in:
parent
5ec310dfba
commit
76f95eafe7
2 changed files with 24 additions and 17 deletions
|
@ -201,26 +201,11 @@ namespace MWMechanics
|
|||
onIdleStatePerFrameActions(actor, duration, storage);
|
||||
}
|
||||
|
||||
// Are we there yet?
|
||||
if ((wanderState == Wander_Walking) &&
|
||||
storage.mPathFinder.checkPathCompleted(pos.pos[0], pos.pos[1], DESTINATION_TOLERANCE))
|
||||
if (wanderState == Wander_Walking)
|
||||
{
|
||||
stopWalking(actor, storage);
|
||||
wanderState = Wander_ChooseAction;
|
||||
mHasReturnPosition = false;
|
||||
onWalkingStatePerFrameActions(actor, duration, storage, pos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (wanderState == Wander_Walking) // have not yet reached the destination
|
||||
{
|
||||
// turn towards the next point in mPath
|
||||
zTurn(actor, storage.mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]));
|
||||
actor.getClass().getMovementSettings(actor).mPosition[1] = 1;
|
||||
|
||||
evadeObstacles(actor, storage, duration);
|
||||
}
|
||||
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
|
||||
if (wanderState == Wander_ChooseAction)
|
||||
|
@ -363,6 +348,27 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
void AiWander::onWalkingStatePerFrameActions(const MWWorld::Ptr& actor,
|
||||
float duration, AiWanderStorage& storage, ESM::Position& pos)
|
||||
{
|
||||
// Are we there yet?
|
||||
if (storage.mPathFinder.checkPathCompleted(pos.pos[0], pos.pos[1], DESTINATION_TOLERANCE))
|
||||
{
|
||||
stopWalking(actor, storage);
|
||||
storage.mState = Wander_ChooseAction;
|
||||
mHasReturnPosition = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// have not yet reached the destination
|
||||
//... turn towards the next point in mPath
|
||||
zTurn(actor, storage.mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]));
|
||||
actor.getClass().getMovementSettings(actor).mPosition[1] = 1;
|
||||
|
||||
evadeObstacles(actor, storage, duration);
|
||||
}
|
||||
}
|
||||
|
||||
void AiWander::evadeObstacles(const MWWorld::Ptr& actor, AiWanderStorage& storage, float duration)
|
||||
{
|
||||
if (mObstacleCheck.check(actor, duration))
|
||||
|
|
|
@ -84,6 +84,7 @@ namespace MWMechanics
|
|||
void playIdleDialogueRandomly(const MWWorld::Ptr& actor);
|
||||
void turnActorToFacePlayer(const osg::Vec3f& actorPosition, const osg::Vec3f& playerPosition, AiWanderStorage& storage);
|
||||
void onIdleStatePerFrameActions(const MWWorld::Ptr& actor, float duration, AiWanderStorage& storage);
|
||||
void onWalkingStatePerFrameActions(const MWWorld::Ptr& actor, float duration, AiWanderStorage& storage, ESM::Position& pos);
|
||||
|
||||
int mDistance; // how far the actor can wander from the spawn point
|
||||
int mDuration;
|
||||
|
|
Loading…
Reference in a new issue