mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 18:15:35 +00:00
extracted function UpdateActorsMovement().
This commit is contained in:
parent
aba7225817
commit
b3d5b47fea
2 changed files with 29 additions and 13 deletions
|
@ -214,20 +214,8 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
actorClass.getMovementSettings(actor) = movement;
|
||||
actorClass.getMovementSettings(actor).mRotation[0] = 0;
|
||||
actorClass.getMovementSettings(actor).mRotation[2] = 0;
|
||||
UpdateActorsMovement(actor, movement);
|
||||
|
||||
if(movement.mRotation[2] != 0)
|
||||
{
|
||||
if(zTurn(actor, movement.mRotation[2])) movement.mRotation[2] = 0;
|
||||
}
|
||||
|
||||
if(movement.mRotation[0] != 0)
|
||||
{
|
||||
if(smoothTurn(actor, movement.mRotation[0], 0)) movement.mRotation[0] = 0;
|
||||
}
|
||||
|
||||
bool& attack = storage.mAttack;
|
||||
bool& readyToAttack = storage.mReadyToAttack;
|
||||
|
||||
|
@ -579,6 +567,29 @@ namespace MWMechanics
|
|||
return false;
|
||||
}
|
||||
|
||||
void AiCombat::UpdateActorsMovement(const MWWorld::Ptr& actor, MWMechanics::Movement& desiredMovement)
|
||||
{
|
||||
MWMechanics::Movement& actorMovementSettings = actor.getClass().getMovementSettings(actor);
|
||||
actorMovementSettings = desiredMovement;
|
||||
RotateActorOnAxis(actor, 2, actorMovementSettings, desiredMovement);
|
||||
RotateActorOnAxis(actor, 0, actorMovementSettings, desiredMovement);
|
||||
}
|
||||
|
||||
void AiCombat::RotateActorOnAxis(const MWWorld::Ptr& actor, int axis,
|
||||
MWMechanics::Movement& actorMovementSettings, MWMechanics::Movement& desiredMovement)
|
||||
{
|
||||
actorMovementSettings.mRotation[axis] = 0;
|
||||
float& targetAngleRadians = desiredMovement.mRotation[axis];
|
||||
if (targetAngleRadians != 0)
|
||||
{
|
||||
if (smoothTurn(actor, targetAngleRadians, axis))
|
||||
{
|
||||
// actor now facing desired direction, no need to turn any more
|
||||
targetAngleRadians = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool AiCombat::doesPathNeedRecalc(ESM::Pathgrid::Point dest, const ESM::Cell *cell)
|
||||
{
|
||||
if (!mPathFinder.getPath().empty())
|
||||
|
|
|
@ -60,6 +60,11 @@ namespace MWMechanics
|
|||
|
||||
|
||||
void buildNewPath(const MWWorld::Ptr& actor, const MWWorld::Ptr& target);
|
||||
|
||||
/// Transfer desired movement (from AiCombatStorage) to Actor
|
||||
void UpdateActorsMovement(const MWWorld::Ptr& actor, MWMechanics::Movement& movement);
|
||||
void RotateActorOnAxis(const MWWorld::Ptr& actor, int axis,
|
||||
MWMechanics::Movement& actorMovementSettings, MWMechanics::Movement& desiredMovement);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue