Fix floating units when a building they were tasked to construct finishes while they're still en-route, based on a patch by mattlott.

This was SVN commit r11775.
This commit is contained in:
vts 2012-05-06 14:38:03 +00:00
parent cb599d4ae5
commit e8cb2a71da

View file

@ -1368,6 +1368,11 @@ var UnitFsmSpec = {
// Save the current order's data in case we need it later
var oldAutocontinue = this.order.data.autocontinue;
// Save the current state so we can continue walking if necessary
// FinishOrder() below will switch to IDLE if there's no order, which sets the idle animation.
// Idle animation while moving towards finished construction looks weird (ghosty).
var oldState = this.GetCurrentState();
// We finished building it.
// Switch to the next order (if any)
if (this.FinishOrder())
@ -1413,6 +1418,13 @@ var UnitFsmSpec = {
this.Repair(nearbyFoundation, oldAutocontinue, true);
return;
}
// Unit was approaching and there's nothing to do now, so switch to walking
if (oldState === "INDIVIDUAL.REPAIR.APPROACHING")
{
// We've already started walking to the given point
this.SetNextState("INDIVIDUAL.WALKING");
}
},
// Override the LeaveFoundation order since we don't want to be