Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/BuildingAI.js
//Number of rounds of firing per 2 seconds | // Number of rounds of firing per 2 seconds. | ||||
Freagarach: +`.` whilst at it. | |||||
const roundCount = 10; | const roundCount = 10; | ||||
const attackType = "Ranged"; | const attackType = "Ranged"; | ||||
function BuildingAI() {} | function BuildingAI() {} | ||||
BuildingAI.prototype.Schema = | BuildingAI.prototype.Schema = | ||||
"<element name='DefaultArrowCount'>" + | "<element name='DefaultArrowCount'>" + | ||||
"<data type='nonNegativeInteger'/>" + | "<data type='nonNegativeInteger'/>" + | ||||
Show All 21 Lines | |||||
}; | }; | ||||
BuildingAI.prototype.OnGarrisonedUnitsChanged = function(msg) | BuildingAI.prototype.OnGarrisonedUnitsChanged = function(msg) | ||||
{ | { | ||||
let classes = this.template.GarrisonArrowClasses; | let classes = this.template.GarrisonArrowClasses; | ||||
for (let ent of msg.added) | for (let ent of msg.added) | ||||
{ | { | ||||
if (msg.visible[ent]) | |||||
continue; | |||||
let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); | let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); | ||||
if (!cmpIdentity) | if (!cmpIdentity) | ||||
continue; | continue; | ||||
if (MatchesClassList(cmpIdentity.GetClassesList(), classes)) | if (MatchesClassList(cmpIdentity.GetClassesList(), classes)) | ||||
++this.archersGarrisoned; | ++this.archersGarrisoned; | ||||
} | } | ||||
for (let ent of msg.removed) | for (let ent of msg.removed) | ||||
{ | { | ||||
if (msg.visible[ent]) | |||||
continue; | |||||
let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); | let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); | ||||
if (!cmpIdentity) | if (!cmpIdentity) | ||||
Done Inline Actions!msg.visible[ent] ? also it may be better to have that check before getting identity component ? Silier: !msg.visible[ent] ?
also it may be better to have that check before getting identity component… | |||||
Done Inline ActionsCheck is correct :) We don't want to add arrows if visibly garisonned :) Check could be before yes :) Stan: Check is correct :) We don't want to add arrows if visibly garisonned :) Check could be before… | |||||
continue; | continue; | ||||
if (MatchesClassList(cmpIdentity.GetClassesList(), classes)) | if (MatchesClassList(cmpIdentity.GetClassesList(), classes)) | ||||
--this.archersGarrisoned; | --this.archersGarrisoned; | ||||
} | } | ||||
}; | }; | ||||
BuildingAI.prototype.OnOwnershipChanged = function(msg) | BuildingAI.prototype.OnOwnershipChanged = function(msg) | ||||
{ | { | ||||
this.targetUnits = []; | this.targetUnits = []; | ||||
▲ Show 20 Lines • Show All 321 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
+. whilst at it.