Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Builder.js
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | Builder.prototype.GetEntitiesList = function() | ||||
let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); | let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); | ||||
if (cmpIdentity) | if (cmpIdentity) | ||||
string = string.replace(/\{native\}/g, cmpIdentity.GetCiv()); | string = string.replace(/\{native\}/g, cmpIdentity.GetCiv()); | ||||
const entities = string.replace(/\{civ\}/g, QueryOwnerInterface(this.entity, IID_Identity).GetCiv()).split(/\s+/); | const entities = string.replace(/\{civ\}/g, QueryOwnerInterface(this.entity, IID_Identity).GetCiv()).split(/\s+/); | ||||
let disabledTemplates = cmpPlayer.GetDisabledTemplates(); | let disabledTemplates = cmpPlayer.GetDisabledTemplates(); | ||||
let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | return entities.filter(ent => !disabledTemplates[ent] && CheckTemplateExists(ent)); | ||||
return entities.filter(ent => !disabledTemplates[ent] && cmpTemplateManager.TemplateExists(ent)); | |||||
}; | }; | ||||
Builder.prototype.templateExistsCache = {}; | |||||
Freagarach: Is this the best datatype? | |||||
function CheckTemplateExists(template) | |||||
FreagarachUnsubmitted Not Done Inline ActionsSounds like a helper more components could benefit from? Freagarach: Sounds like a helper more components could benefit from? | |||||
{ | |||||
if (!(template in Builder.prototype.templateExistsCache)) | |||||
Builder.prototype.templateExistsCache[template] = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).TemplateExists(template); | |||||
return Builder.prototype.templateExistsCache[template]; | |||||
} | |||||
Builder.prototype.GetRange = function() | Builder.prototype.GetRange = function() | ||||
{ | { | ||||
let max = 2; | let max = 2; | ||||
let cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); | let cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); | ||||
if (cmpObstruction) | if (cmpObstruction) | ||||
max += cmpObstruction.GetSize(); | max += cmpObstruction.GetSize(); | ||||
return { "max": max, "min": 0 }; | return { "max": max, "min": 0 }; | ||||
▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Is this the best datatype?