LeaveFoundation should put formation members into a discrete state to avoid prematurely disbanding.
This was SVN commit r12636.
This commit is contained in:
parent
b3d85df2fd
commit
ef2c9e338d
@ -54,6 +54,16 @@ Formation.prototype.SetInPosition = function(ent)
|
||||
this.Disband();
|
||||
};
|
||||
|
||||
/**
|
||||
* Called by formation members upon entering non-walking states.
|
||||
*/
|
||||
Formation.prototype.UnsetInPosition = function(ent)
|
||||
{
|
||||
var ind = this.inPosition.indexOf(ent);
|
||||
if (ind != -1)
|
||||
this.inPosition.splice(ind, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether we should rearrange formation members if
|
||||
* units are removed from the formation.
|
||||
@ -125,7 +135,12 @@ Formation.prototype.FindInPosition = function()
|
||||
{
|
||||
var cmpUnitMotion = Engine.QueryInterface(this.members[i], IID_UnitMotion);
|
||||
if (!cmpUnitMotion.IsMoving())
|
||||
this.SetInPosition(this.members[i]);
|
||||
{
|
||||
// Verify that members are stopped in FORMATIONMEMBER.WALKING
|
||||
var cmpUnitAI = Engine.QueryInterface(this.members[i], IID_UnitAI);
|
||||
if (cmpUnitAI.IsWalking())
|
||||
this.SetInPosition(this.members[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -654,7 +654,7 @@ var UnitFsmSpec = {
|
||||
if (ok)
|
||||
{
|
||||
// We've started walking to the given point
|
||||
this.SetNextState("WALKING");
|
||||
this.SetNextState("WALKINGTOPOINT");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -683,6 +683,19 @@ var UnitFsmSpec = {
|
||||
cmpFormation.SetInPosition(this.entity);
|
||||
},
|
||||
},
|
||||
|
||||
// Special case used by Order.LeaveFoundation
|
||||
"WALKINGTOPOINT": {
|
||||
"enter": function() {
|
||||
var cmpFormation = Engine.QueryInterface(this.formationController, IID_Formation);
|
||||
cmpFormation.UnsetInPosition(this.entity);
|
||||
this.SelectAnimation("move");
|
||||
},
|
||||
|
||||
"MoveCompleted": function() {
|
||||
this.FinishOrder();
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@ -1876,6 +1889,12 @@ UnitAI.prototype.IsGarrisoned = function()
|
||||
return this.isGarrisoned;
|
||||
};
|
||||
|
||||
UnitAI.prototype.IsWalking = function()
|
||||
{
|
||||
var state = this.GetCurrentState().split(".").pop();
|
||||
return (state == "WALKING");
|
||||
};
|
||||
|
||||
UnitAI.prototype.CanAttackGaia = function()
|
||||
{
|
||||
var cmpAttack = Engine.QueryInterface(this.entity, IID_Attack);
|
||||
|
Loading…
Reference in New Issue
Block a user