Differential D3150 Diff 16739 ps/trunk/binaries/data/mods/public/simulation/components/BuildingAI.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/BuildingAI.js
Show All 24 Lines | |||||
BuildingAI.prototype.Init = function() | BuildingAI.prototype.Init = function() | ||||
{ | { | ||||
this.currentRound = 0; | this.currentRound = 0; | ||||
this.archersGarrisoned = 0; | this.archersGarrisoned = 0; | ||||
this.arrowsLeft = 0; | this.arrowsLeft = 0; | ||||
this.targetUnits = []; | this.targetUnits = []; | ||||
}; | }; | ||||
BuildingAI.prototype.OnGarrisonedUnitsChanged = function() | BuildingAI.prototype.OnGarrisonedUnitsChanged = function(msg) | ||||
{ | { | ||||
this.RecalculateProjectileCount(); | |||||
}; | |||||
BuildingAI.prototype.OnTurretsChanged = function() | |||||
{ | |||||
this.RecalculateProjectileCount(); | |||||
}; | |||||
BuildingAI.prototype.RecalculateProjectileCount = function() | |||||
{ | |||||
this.archersGarrisoned = 0; | |||||
let classes = this.template.GarrisonArrowClasses; | let classes = this.template.GarrisonArrowClasses; | ||||
for (let ent of msg.added) | |||||
let cmpTurretHolder = Engine.QueryInterface(this.entity, IID_TurretHolder); | |||||
let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); | |||||
for (let ent of cmpGarrisonHolder.GetEntities()) | |||||
{ | { | ||||
// Only count non-visible garrisoned entities towards extra arrows. | |||||
if (cmpTurretHolder && cmpTurretHolder.OccupiesTurret(ent)) | |||||
continue; | |||||
let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); | let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); | ||||
if (!cmpIdentity) | if (cmpIdentity && MatchesClassList(cmpIdentity.GetClassesList(), classes)) | ||||
continue; | |||||
if (MatchesClassList(cmpIdentity.GetClassesList(), classes)) | |||||
++this.archersGarrisoned; | ++this.archersGarrisoned; | ||||
} | } | ||||
for (let ent of msg.removed) | |||||
{ | |||||
let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); | |||||
if (cmpIdentity && MatchesClassList(cmpIdentity.GetClassesList(), classes)) | |||||
--this.archersGarrisoned; | |||||
} | |||||
}; | }; | ||||
BuildingAI.prototype.OnOwnershipChanged = function(msg) | BuildingAI.prototype.OnOwnershipChanged = function(msg) | ||||
{ | { | ||||
this.targetUnits = []; | this.targetUnits = []; | ||||
this.SetupRangeQuery(); | this.SetupRangeQuery(); | ||||
this.SetupGaiaRangeQuery(); | this.SetupGaiaRangeQuery(); | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 338 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator