Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp
Show First 20 Lines • Show All 810 Lines • ▼ Show 20 Lines | if (m_State == STATE_STOPPING) | ||||
if (cmpObstruction) | if (cmpObstruction) | ||||
cmpObstruction->SetMovingFlag(false); | cmpObstruction->SetMovingFlag(false); | ||||
return; | return; | ||||
} | } | ||||
if (m_State == STATE_IDLE) | if (m_State == STATE_IDLE) | ||||
return; | return; | ||||
if (PossiblyAtDestination()) | |||||
MoveSucceeded(); | |||||
CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle()); | CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle()); | ||||
if (!cmpPosition || !cmpPosition->IsInWorld()) | if (!cmpPosition || !cmpPosition->IsInWorld()) | ||||
return; | return; | ||||
CFixedVector2D initialPos = cmpPosition->GetPosition2D(); | CFixedVector2D initialPos = cmpPosition->GetPosition2D(); | ||||
// Keep track of the current unit's position during the update | // Keep track of the current unit's position during the update | ||||
CFixedVector2D pos = initialPos; | CFixedVector2D pos = initialPos; | ||||
Show All 24 Lines | else | ||||
UpdateMovementState(offset.Length() / dt); | UpdateMovementState(offset.Length() / dt); | ||||
} | } | ||||
if (wasObstructed && HandleObstructedMove()) | if (wasObstructed && HandleObstructedMove()) | ||||
return; | return; | ||||
if (m_PathState == PATHSTATE_FOLLOWING) | if (m_PathState == PATHSTATE_FOLLOWING) | ||||
{ | { | ||||
if (PossiblyAtDestination()) | |||||
{ | |||||
m_State = STATE_STOPPING; | |||||
return; | |||||
} | |||||
// We may need to recompute our path sometimes (e.g. if our target moves). | // We may need to recompute our path sometimes (e.g. if our target moves). | ||||
// Since we request paths asynchronously anyways, this does not need to be done before moving. | // Since we request paths asynchronously anyways, this does not need to be done before moving. | ||||
if (IsFormationMember()) | if (IsFormationMember()) | ||||
CheckTargetMovement(pos, CHECK_TARGET_MOVEMENT_MIN_DELTA_FORMATION); | CheckTargetMovement(pos, CHECK_TARGET_MOVEMENT_MIN_DELTA_FORMATION); | ||||
else | else | ||||
CheckTargetMovement(pos, CHECK_TARGET_MOVEMENT_MIN_DELTA); | CheckTargetMovement(pos, CHECK_TARGET_MOVEMENT_MIN_DELTA); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 790 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator