Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/UnitAI.js
Show First 20 Lines • Show All 3,463 Lines • ▼ Show 20 Lines | UnitAI.prototype.Init = function() | ||||
this.isGuardOf = undefined; | this.isGuardOf = undefined; | ||||
this.formationAnimationVariant = undefined; | this.formationAnimationVariant = undefined; | ||||
this.cheeringTime = +(this.template.CheeringTime || 0); | this.cheeringTime = +(this.template.CheeringTime || 0); | ||||
this.SetStance(this.template.DefaultStance); | this.SetStance(this.template.DefaultStance); | ||||
}; | }; | ||||
UnitAI.prototype.Update = function(newTemplate) { | |||||
this.template = newTemplate; | |||||
this.cheeringTime = +(this.template.CheeringTime || 0); | |||||
// The current order might not be so achievable anymore, so re-run it. | |||||
// TODO: would it be better to send an event to the FSM? Probably | |||||
// TODO: this should be done after all components are updated. | |||||
if (!this.orderQueue.length) | |||||
return; | |||||
let order = this.orderQueue.splice(0, 1)[0]; | |||||
this.PushOrderFront(order.type, order.data); | |||||
}; | |||||
/** | /** | ||||
* @param {cmpTurretable} cmpTurretable - Optionally the component to save a query here. | * @param {cmpTurretable} cmpTurretable - Optionally the component to save a query here. | ||||
* @return {boolean} - Whether we are occupying a turret point. | * @return {boolean} - Whether we are occupying a turret point. | ||||
*/ | */ | ||||
UnitAI.prototype.IsTurret = function(cmpTurretable) | UnitAI.prototype.IsTurret = function(cmpTurretable) | ||||
{ | { | ||||
if (!cmpTurretable) | if (!cmpTurretable) | ||||
cmpTurretable = Engine.QueryInterface(this.entity, IID_Turretable); | cmpTurretable = Engine.QueryInterface(this.entity, IID_Turretable); | ||||
▲ Show 20 Lines • Show All 3,045 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator