Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/reference/common/TemplateLoader.js
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | class TemplateLoader | ||||
{ | { | ||||
let template = this.loadTechnologyTemplate(templateName); | let template = this.loadTechnologyTemplate(templateName); | ||||
return { | return { | ||||
"techs": [template.top, template.bottom], | "techs": [template.top, template.bottom], | ||||
"reqs": DeriveTechnologyRequirements(template, civCode) | "reqs": DeriveTechnologyRequirements(template, civCode) | ||||
}; | }; | ||||
} | } | ||||
deriveProductionQueue(template, civCode) | deriveProductionQueue(template, civCode, civModifiers) | ||||
{ | { | ||||
let production = { | let production = { | ||||
"techs": [], | "techs": [], | ||||
"units": [] | "units": [] | ||||
}; | }; | ||||
if (!template.ProductionQueue) | if (!template.ProductionQueue) | ||||
return production; | return production; | ||||
if (template.ProductionQueue.Entities && template.ProductionQueue.Entities._string) | if (template.ProductionQueue.Entities && template.ProductionQueue.Entities._string) | ||||
for (let templateName of template.ProductionQueue.Entities._string.split(" ")) | for (let templateName of template.ProductionQueue.Entities._string.split(" ")) | ||||
{ | { | ||||
templateName = templateName.replace(/\{(civ|native)\}/g, civCode); | templateName = templateName.replace(/\{(civ|native)\}/g, civCode); | ||||
if (Engine.TemplateExists(templateName)) | if (Engine.TemplateExists(templateName)) | ||||
{ | |||||
// Substitute units promoted automatically by autoresearched technologies | |||||
const unitTemplate = this.loadEntityTemplate(templateName, civCode); | |||||
if (unitTemplate.Promotion) | |||||
{ | |||||
const unit = GetTemplateDataHelper(unitTemplate, null, this.auraData, civModifiers || {}); | |||||
if (unit.promotion.requiredXp == 0 && Engine.TemplateExists(unit.promotion.entity)) | |||||
templateName = unit.promotion.entity; | |||||
} | |||||
production.units.push(templateName); | production.units.push(templateName); | ||||
} | } | ||||
} | |||||
let appendTechnology = (technologyName) => { | let appendTechnology = (technologyName) => { | ||||
let technology = this.loadTechnologyTemplate(technologyName, civCode); | let technology = this.loadTechnologyTemplate(technologyName, civCode); | ||||
if (DeriveTechnologyRequirements(technology, civCode)) | if (DeriveTechnologyRequirements(technology, civCode)) | ||||
production.techs.push(technologyName); | production.techs.push(technologyName); | ||||
}; | }; | ||||
if (template.ProductionQueue.Technologies && template.ProductionQueue.Technologies._string) | if (template.ProductionQueue.Technologies && template.ProductionQueue.Technologies._string) | ||||
▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator