Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/GarrisonHolder.js
Show First 20 Lines • Show All 685 Lines • ▼ Show 20 Lines | GarrisonHolder.prototype.IsEjectable = function(entity) | ||||
let ejectableClasses = this.template.EjectClassesOnDestroy._string; | let ejectableClasses = this.template.EjectClassesOnDestroy._string; | ||||
let entityClasses = Engine.QueryInterface(entity, IID_Identity).GetClassesList(); | let entityClasses = Engine.QueryInterface(entity, IID_Identity).GetClassesList(); | ||||
return MatchesClassList(entityClasses, ejectableClasses); | return MatchesClassList(entityClasses, ejectableClasses); | ||||
}; | }; | ||||
/** | /** | ||||
* Sets the intitGarrison to the specified entities. Used by Atlas' mapreader. | |||||
* | |||||
* @param {number} entity - An entity ID to garrison on init. | |||||
*/ | |||||
GarrisonHolder.prototype.AddInitGarrisonEntity = function(entity) | |||||
Silier: The name says `add` but comment and code says `set` | |||||
{ | |||||
if (!this.initGarrison) | |||||
Done Inline Actionsshould clone to avoid issue from D2562 when some script decides to spawn entity with garrisoned entities and uses this function for it. Silier: should clone to avoid issue from D2562 when some script decides to spawn entity with garrisoned… | |||||
this.initGarrison = []; | |||||
this.initGarrison.push(entity); | |||||
}; | |||||
/** | |||||
* Initialise the garrisoned units. | * Initialise the garrisoned units. | ||||
*/ | */ | ||||
GarrisonHolder.prototype.OnGlobalInitGame = function(msg) | GarrisonHolder.prototype.OnGlobalInitGame = function(msg) | ||||
{ | { | ||||
if (!this.initGarrison) | if (!this.initGarrison || !this.initGarrison.length) | ||||
Done Inline Actionsthis is changing postcondition of the function. Silier: this is changing postcondition of the function.
this.initGarrison was always undefined after… | |||||
return; | return; | ||||
for (let ent of this.initGarrison) | for (let ent of this.initGarrison) | ||||
{ | { | ||||
let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); | let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); | ||||
if (cmpUnitAI && cmpUnitAI.CanGarrison(this.entity) && this.Garrison(ent)) | if (cmpUnitAI && cmpUnitAI.CanGarrison(this.entity) && this.Garrison(ent)) | ||||
cmpUnitAI.Autogarrison(this.entity); | cmpUnitAI.Autogarrison(this.entity); | ||||
} | } | ||||
Show All 23 Lines |
Wildfire Games · Phabricator
The name says add but comment and code says set