Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/UnitAI.js
Show First 20 Lines • Show All 3,393 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
UnitAI.prototype.SetGarrisoned = function() | UnitAI.prototype.SetGarrisoned = function() | ||||
{ | { | ||||
this.isGarrisoned = true; | this.isGarrisoned = true; | ||||
}; | }; | ||||
UnitAI.prototype.GetGarrisonHolder = function() | UnitAI.prototype.GetGarrisonHolder = function() | ||||
{ | { | ||||
if (this.IsGarrisoned()) | if (!this.IsGarrisoned()) | ||||
Freagarach: Could be early return when `!this.IsGarrisoned()`. | |||||
{ | |||||
for (let order of this.orderQueue) | |||||
if (order.type == "Garrison") | |||||
return order.data.target; | |||||
} | |||||
return INVALID_ENTITY; | return INVALID_ENTITY; | ||||
let cmpGarrisonable = Engine.QueryInterface(this.entity, IID_Garrisonable) | |||||
return cmpGarrisonable ? cmpGarrisonable.GetGarrisonHolder() : INVALID_ENTITY; | |||||
}; | }; | ||||
UnitAI.prototype.ShouldRespondToEndOfAlert = function() | UnitAI.prototype.ShouldRespondToEndOfAlert = function() | ||||
{ | { | ||||
return !this.orderQueue.length || this.orderQueue[0].type == "Garrison"; | return !this.orderQueue.length || this.orderQueue[0].type == "Garrison"; | ||||
}; | }; | ||||
UnitAI.prototype.IsFleeing = function() | UnitAI.prototype.IsFleeing = function() | ||||
▲ Show 20 Lines • Show All 2,840 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Could be early return when !this.IsGarrisoned().