Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/UnitAI.js
Show First 20 Lines • Show All 1,238 Lines • ▼ Show 20 Lines | "Order.LeaveFoundation": function(msg) { | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
this.order.data.min = range; | this.order.data.min = range; | ||||
this.SetNextState("WALKINGTOPOINT"); | this.SetNextState("WALKINGTOPOINT"); | ||||
} | } | ||||
}, | }, | ||||
"enter": function() { | |||||
let cmpFormation = Engine.QueryInterface(this.formationController, IID_Formation); | |||||
if (cmpFormation) | |||||
this.SetAnimationVariant(cmpFormation.GetFormationAnimation(this.entity)); | |||||
}, | |||||
"leave": function() { | |||||
this.SetDefaultAnimationVariant(); | |||||
}, | |||||
"IDLE": { | "IDLE": { | ||||
"enter": function() { | "enter": function() { | ||||
if (this.IsAnimal()) | if (this.IsAnimal()) | ||||
this.SetNextState("ANIMAL.IDLE"); | this.SetNextState("ANIMAL.IDLE"); | ||||
else | else | ||||
this.SetNextState("INDIVIDUAL.IDLE"); | this.SetNextState("INDIVIDUAL.IDLE"); | ||||
return true; | return true; | ||||
}, | }, | ||||
}, | }, | ||||
"WALKING": { | "WALKING": { | ||||
"enter": function() { | "enter": function() { | ||||
var cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion); | var cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion); | ||||
cmpUnitMotion.MoveToFormationOffset(this.order.data.target, this.order.data.x, this.order.data.z); | cmpUnitMotion.MoveToFormationOffset(this.order.data.target, this.order.data.x, this.order.data.z); | ||||
var cmpFormation = Engine.QueryInterface(this.formationController, IID_Formation); | |||||
var cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); | |||||
if (cmpFormation && cmpVisual) | |||||
{ | |||||
cmpVisual.ReplaceMoveAnimation("walk", cmpFormation.GetFormationAnimation(this.entity, "walk")); | |||||
cmpVisual.ReplaceMoveAnimation("run", cmpFormation.GetFormationAnimation(this.entity, "run")); | |||||
} | |||||
this.SelectAnimation("move"); | this.SelectAnimation("move"); | ||||
}, | }, | ||||
// Occurs when the unit has reached its destination and the controller | // Occurs when the unit has reached its destination and the controller | ||||
// is done moving. The controller is notified. | // is done moving. The controller is notified. | ||||
"MovementUpdate": function(msg) { | "MovementUpdate": function(msg) { | ||||
// We can only finish this order if the move was really completed. | // We can only finish this order if the move was really completed. | ||||
if (!this.CheckRange(this.order.data) || msg.error) | if (!this.CheckRange(this.order.data) || msg.error) | ||||
return; | return; | ||||
if (this.FinishOrder()) | if (this.FinishOrder()) | ||||
return; | return; | ||||
let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); | |||||
if (cmpVisual) | |||||
{ | |||||
cmpVisual.ResetMoveAnimation("walk"); | |||||
cmpVisual.ResetMoveAnimation("run"); | |||||
} | |||||
let cmpFormation = Engine.QueryInterface(this.formationController, IID_Formation); | let cmpFormation = Engine.QueryInterface(this.formationController, IID_Formation); | ||||
if (cmpFormation) | if (cmpFormation) | ||||
cmpFormation.SetInPosition(this.entity); | cmpFormation.SetInPosition(this.entity); | ||||
}, | }, | ||||
}, | }, | ||||
// Special case used by Order.LeaveFoundation | // Special case used by Order.LeaveFoundation | ||||
"WALKINGTOPOINT": { | "WALKINGTOPOINT": { | ||||
▲ Show 20 Lines • Show All 4,581 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator