Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
Show First 20 Lines • Show All 3,530 Lines • ▼ Show 20 Lines | |||||
//// FSM linkage functions //// | //// FSM linkage functions //// | ||||
// Setting the next state to the current state will leave/re-enter the top-most substate. | // Setting the next state to the current state will leave/re-enter the top-most substate. | ||||
UnitAI.prototype.SetNextState = function(state) | UnitAI.prototype.SetNextState = function(state) | ||||
{ | { | ||||
this.UnitFsm.SetNextState(this, state); | this.UnitFsm.SetNextState(this, state); | ||||
}; | }; | ||||
UnitAI.prototype.DeferMessage = function(msg) | UnitAI.prototype.DeferMessage = function(msg) | ||||
{ | { | ||||
this.UnitFsm.DeferMessage(this, msg); | this.UnitFsm.DeferMessage(this, msg); | ||||
}; | }; | ||||
UnitAI.prototype.GetCurrentState = function() | UnitAI.prototype.GetCurrentState = function() | ||||
{ | { | ||||
return this.UnitFsm.GetCurrentState(this); | return this.UnitFsm.GetCurrentState(this); | ||||
Show All 39 Lines | if (ret && ret.discardOrder) | ||||
return this.FinishOrder(); | return this.FinishOrder(); | ||||
// Otherwise we've successfully processed a new order | // Otherwise we've successfully processed a new order | ||||
return true; | return true; | ||||
} | } | ||||
this.orderQueue = []; | this.orderQueue = []; | ||||
this.order = undefined; | this.order = undefined; | ||||
// Switch to IDLE as a default state, but only if our current state is not IDLE | |||||
// as this can trigger infinite loops by entering IDLE repeatedly. | |||||
if (!this.GetCurrentState().endsWith(".IDLE")) | |||||
this.SetNextState("IDLE"); | this.SetNextState("IDLE"); | ||||
Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() }); | Engine.PostMessage(this.entity, MT_UnitAIOrderDataChanged, { "to": this.GetOrderData() }); | ||||
// Check if there are queued formation orders | // Check if there are queued formation orders | ||||
if (this.IsFormationMember()) | if (this.IsFormationMember()) | ||||
{ | { | ||||
let cmpUnitAI = Engine.QueryInterface(this.formationController, IID_UnitAI); | let cmpUnitAI = Engine.QueryInterface(this.formationController, IID_UnitAI); | ||||
if (cmpUnitAI) | if (cmpUnitAI) | ||||
▲ Show 20 Lines • Show All 2,366 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator