Differential D3347 Diff 17093 ps/trunk/binaries/data/mods/public/gui/reference/common/TemplateLister.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/reference/common/TemplateLister.js
Show All 30 Lines | compileTemplateLists(civCode, civData) | ||||
do | do | ||||
{ | { | ||||
const templatesThisIteration = templatesToParse; | const templatesThisIteration = templatesToParse; | ||||
templatesToParse = []; | templatesToParse = []; | ||||
for (let templateBeingParsed of templatesThisIteration) | for (let templateBeingParsed of templatesThisIteration) | ||||
{ | { | ||||
let baseOfTemplateBeingParsed = this.TemplateLoader.getVariantBaseAndType(templateBeingParsed, civCode)[0]; | |||||
let list = this.deriveTemplateListsFromTemplate(templateBeingParsed, civCode); | let list = this.deriveTemplateListsFromTemplate(templateBeingParsed, civCode); | ||||
for (let type in list) | for (let type in list) | ||||
for (let templateName of list[type]) | for (let templateName of list[type]) | ||||
{ | |||||
if (type != "techs") | |||||
{ | |||||
let templateVariance = this.TemplateLoader.getVariantBaseAndType(templateName, civCode); | |||||
if (templateVariance[1].passthru) | |||||
templateName = templateVariance[0]; | |||||
} | |||||
if (!templateLists[type].has(templateName)) | if (!templateLists[type].has(templateName)) | ||||
{ | { | ||||
templateLists[type].set(templateName, [templateBeingParsed]); | templateLists[type].set(templateName, [baseOfTemplateBeingParsed]); | ||||
if (type != "techs") | if (type != "techs") | ||||
templatesToParse.push(templateName); | templatesToParse.push(templateName); | ||||
} | } | ||||
else if (templateLists[type].get(templateName).indexOf(templateBeingParsed) == -1) | else if (templateLists[type].get(templateName).indexOf(baseOfTemplateBeingParsed) == -1) | ||||
templateLists[type].get(templateName).push(templateBeingParsed); | templateLists[type].get(templateName).push(baseOfTemplateBeingParsed); | ||||
} | |||||
} | } | ||||
} while (templatesToParse.length); | } while (templatesToParse.length); | ||||
// Expand/filter tech pairs | // Expand/filter tech pairs | ||||
for (let [techCode, researcherList] of templateLists.techs) | for (let [techCode, researcherList] of templateLists.techs) | ||||
{ | { | ||||
if (!this.TemplateLoader.isPairTech(techCode)) | if (!this.TemplateLoader.isPairTech(techCode)) | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | class TemplateLister | ||||
* Compiles lists of buildable, trainable, or researchable entities from | * Compiles lists of buildable, trainable, or researchable entities from | ||||
* a named template. | * a named template. | ||||
*/ | */ | ||||
deriveTemplateListsFromTemplate(templateName, civCode) | deriveTemplateListsFromTemplate(templateName, civCode) | ||||
{ | { | ||||
if (!templateName || !Engine.TemplateExists(templateName)) | if (!templateName || !Engine.TemplateExists(templateName)) | ||||
return {}; | return {}; | ||||
// If this is a non-promotion variant (ie. {civ}_support_female_citizen_house) | |||||
// then it is functionally equivalent to another unit being processed, so skip it. | |||||
if (this.TemplateLoader.getBaseTemplateName(templateName, civCode) != templateName) | |||||
return {}; | |||||
let template = this.TemplateLoader.loadEntityTemplate(templateName, civCode); | let template = this.TemplateLoader.loadEntityTemplate(templateName, civCode); | ||||
let templateLists = this.TemplateLoader.deriveProductionQueue(template, civCode); | let templateLists = this.TemplateLoader.deriveProductionQueue(template, civCode); | ||||
templateLists.structures = this.TemplateLoader.deriveBuildQueue(template, civCode); | templateLists.structures = this.TemplateLoader.deriveBuildQueue(template, civCode); | ||||
if (template.WallSet) | if (template.WallSet) | ||||
{ | { | ||||
templateLists.wallsetPieces = []; | templateLists.wallsetPieces = []; | ||||
Show All 11 Lines |
Wildfire Games · Phabricator