mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-10-13 15:14:21 +00:00
Fixed formations so switching formation in-place doesn't leave entities in FORMATIONMEMBER.WALKING and short walk orders bring units into proper formation.
This was SVN commit r12563.
This commit is contained in:
@@ -390,6 +390,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool IsMoving()
|
||||
{
|
||||
return m_State != STATE_IDLE;
|
||||
}
|
||||
|
||||
virtual fixed GetWalkSpeed()
|
||||
{
|
||||
return m_WalkSpeed;
|
||||
@@ -903,9 +908,15 @@ void CCmpUnitMotion::Move(fixed dt)
|
||||
{
|
||||
if (IsFormationMember())
|
||||
{
|
||||
// If we're in formation, we've reached our assigned position.
|
||||
// so wait here.
|
||||
// (We'll try to continue following the formation next turn.)
|
||||
// We've reached our assigned position. If the controller
|
||||
// is idle, send a notification in case it should disband,
|
||||
// otherwise continue following the formation next turn.
|
||||
CmpPtr<ICmpUnitMotion> cmpUnitMotion(GetSimContext(), m_TargetEntity);
|
||||
if (cmpUnitMotion && !cmpUnitMotion->IsMoving())
|
||||
{
|
||||
CMessageMotionChanged msg(false, false);
|
||||
GetSimContext().GetComponentManager().PostMessage(GetEntityId(), msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1512,7 +1523,7 @@ bool CCmpUnitMotion::IsInTargetRange(entity_id_t target, entity_pos_t minRange,
|
||||
|
||||
void CCmpUnitMotion::MoveToFormationOffset(entity_id_t target, entity_pos_t x, entity_pos_t z)
|
||||
{
|
||||
CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), GetEntityId());
|
||||
CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), target);
|
||||
if (!cmpPosition || !cmpPosition->IsInWorld())
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user