1
1
forked from 0ad/0ad

Unit Motion - Face point when calling StopMoving()

FacePointAfterMoving intends for the unit to face the destination once a
move is done. Since 4fda917f46, stopping is the responsibility of UnitAI
(through a call to StopMoving()). Thus we should move that code in that
function, as this ensures we don't forget to do it and removes
duplications.

Differential Revision: https://code.wildfiregames.com/D1889
This was SVN commit r22355.
This commit is contained in:
wraitii 2019-06-09 17:06:24 +00:00
parent f2db913a7d
commit 70e22e2923

View File

@ -518,6 +518,13 @@ public:
virtual void StopMoving()
{
if (m_FacePointAfterMove)
{
CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle());
if (cmpPosition && cmpPosition->IsInWorld())
FaceTowardsPointFromPos(cmpPosition->GetPosition2D(), m_FinalGoal.x, m_FinalGoal.z);
}
m_MoveRequest = MoveRequest();
m_ExpectedPathTicket = 0;
m_State = STATE_STOPPING;
@ -750,9 +757,6 @@ void CCmpUnitMotion::PathResult(u32 ticket, const WaypointPath& path)
if (CloseEnoughFromDestinationToStop(pos))
{
MoveSucceeded();
if (m_FacePointAfterMove)
FaceTowardsPointFromPos(pos, m_FinalGoal.x, m_FinalGoal.z);
return;
}
@ -930,10 +934,6 @@ void CCmpUnitMotion::Move(fixed dt)
if (CloseEnoughFromDestinationToStop(pos))
{
MoveSucceeded();
if (m_FacePointAfterMove)
FaceTowardsPointFromPos(pos, m_FinalGoal.x, m_FinalGoal.z);
return;
}