mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-07 04:45:35 +00:00
extract function onWalkingStatePerFrameActions().
This commit is contained in:
parent
5ec310dfba
commit
76f95eafe7
2 changed files with 24 additions and 17 deletions
|
@ -201,24 +201,9 @@ namespace MWMechanics
|
||||||
onIdleStatePerFrameActions(actor, duration, storage);
|
onIdleStatePerFrameActions(actor, duration, storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are we there yet?
|
if (wanderState == Wander_Walking)
|
||||||
if ((wanderState == Wander_Walking) &&
|
|
||||||
storage.mPathFinder.checkPathCompleted(pos.pos[0], pos.pos[1], DESTINATION_TOLERANCE))
|
|
||||||
{
|
{
|
||||||
stopWalking(actor, storage);
|
onWalkingStatePerFrameActions(actor, duration, storage, pos);
|
||||||
wanderState = Wander_ChooseAction;
|
|
||||||
mHasReturnPosition = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
@ -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)
|
void AiWander::evadeObstacles(const MWWorld::Ptr& actor, AiWanderStorage& storage, float duration)
|
||||||
{
|
{
|
||||||
if (mObstacleCheck.check(actor, duration))
|
if (mObstacleCheck.check(actor, duration))
|
||||||
|
|
|
@ -84,6 +84,7 @@ namespace MWMechanics
|
||||||
void playIdleDialogueRandomly(const MWWorld::Ptr& actor);
|
void playIdleDialogueRandomly(const MWWorld::Ptr& actor);
|
||||||
void turnActorToFacePlayer(const osg::Vec3f& actorPosition, const osg::Vec3f& playerPosition, AiWanderStorage& storage);
|
void turnActorToFacePlayer(const osg::Vec3f& actorPosition, const osg::Vec3f& playerPosition, AiWanderStorage& storage);
|
||||||
void onIdleStatePerFrameActions(const MWWorld::Ptr& actor, float duration, 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 mDistance; // how far the actor can wander from the spawn point
|
||||||
int mDuration;
|
int mDuration;
|
||||||
|
|
Loading…
Reference in a new issue