Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/reference/common/load.js
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
function loadUnit(templateName) | function loadUnit(templateName) | ||||
{ | { | ||||
if (!Engine.TemplateExists(templateName)) | if (!Engine.TemplateExists(templateName)) | ||||
return null; | return null; | ||||
let template = loadTemplate(templateName); | let template = loadTemplate(templateName); | ||||
let unit = GetTemplateDataHelper(template, null, g_AuraData, g_ResourceData, g_DamageTypes, g_CurrentModifiers); | let unit = GetTemplateDataHelper(template, null, g_AuraData, g_ResourceData, g_DamageTypes, g_CurrentModifiers); | ||||
unit.production = loadProductionQueue(template); | |||||
if (template.ProductionQueue) | |||||
{ | |||||
unit.production = {}; | |||||
if (template.ProductionQueue.Entities) | |||||
{ | |||||
unit.production.units = []; | |||||
for (let build of template.ProductionQueue.Entities._string.split(" ")) | |||||
{ | |||||
build = build.replace(/\{(civ|native)\}/g, g_SelectedCiv); | |||||
if (Engine.TemplateExists(build)) | |||||
unit.production.units.push(build); | |||||
} | |||||
} | |||||
if (template.ProductionQueue.Technologies) | |||||
{ | |||||
unit.production.techs = []; | |||||
for (let research of template.ProductionQueue.Technologies._string.split(" ")) | |||||
{ | |||||
if (research.indexOf("{civ}") != -1) | |||||
{ | |||||
let civResearch = research.replace("{civ}", g_SelectedCiv); | |||||
research = techDataExists(civResearch) ? | |||||
civResearch : research.replace("{civ}", "generic"); | |||||
} | |||||
if (isPairTech(research)) | |||||
for (let tech of loadTechnologyPair(research).techs) | |||||
unit.production.techs.push(tech); | |||||
else | |||||
unit.production.techs.push(research); | |||||
} | |||||
} | |||||
} | |||||
if (template.Builder && template.Builder.Entities._string) | if (template.Builder && template.Builder.Entities._string) | ||||
{ | { | ||||
unit.builder = []; | unit.builder = []; | ||||
for (let build of template.Builder.Entities._string.split(" ")) | for (let build of template.Builder.Entities._string.split(" ")) | ||||
{ | { | ||||
build = build.replace(/\{(civ|native)\}/g, g_SelectedCiv); | build = build.replace(/\{(civ|native)\}/g, g_SelectedCiv); | ||||
if (Engine.TemplateExists(build)) | if (Engine.TemplateExists(build)) | ||||
Show All 16 Lines | |||||
function loadStructure(templateName) | function loadStructure(templateName) | ||||
{ | { | ||||
if (!Engine.TemplateExists(templateName)) | if (!Engine.TemplateExists(templateName)) | ||||
return null; | return null; | ||||
let template = loadTemplate(templateName); | let template = loadTemplate(templateName); | ||||
let structure = GetTemplateDataHelper(template, null, g_AuraData, g_ResourceData, g_DamageTypes, g_CurrentModifiers); | let structure = GetTemplateDataHelper(template, null, g_AuraData, g_ResourceData, g_DamageTypes, g_CurrentModifiers); | ||||
structure.production = { | structure.production = loadProductionQueue(template); | ||||
"technology": [], | |||||
"units": [] | |||||
}; | |||||
if (template.ProductionQueue) | |||||
{ | |||||
if (template.ProductionQueue.Entities && template.ProductionQueue.Entities._string) | |||||
for (let build of template.ProductionQueue.Entities._string.split(" ")) | |||||
{ | |||||
build = build.replace(/\{(civ|native)\}/g, g_SelectedCiv); | |||||
if (Engine.TemplateExists(build)) | |||||
structure.production.units.push(build); | |||||
} | |||||
if (template.ProductionQueue.Technologies && template.ProductionQueue.Technologies._string) | |||||
for (let research of template.ProductionQueue.Technologies._string.split(" ")) | |||||
{ | |||||
if (research.indexOf("{civ}") != -1) | |||||
{ | |||||
let civResearch = research.replace("{civ}", g_SelectedCiv); | |||||
research = techDataExists(civResearch) ? | |||||
civResearch : research.replace("{civ}", "generic"); | |||||
} | |||||
if (isPairTech(research)) | |||||
for (let tech of loadTechnologyPair(research).techs) | |||||
structure.production.technology.push(tech); | |||||
else | |||||
structure.production.technology.push(research); | |||||
} | |||||
} | |||||
if (structure.upgrades) | if (structure.upgrades) | ||||
structure.upgrades = getActualUpgradeData(structure.upgrades); | structure.upgrades = getActualUpgradeData(structure.upgrades); | ||||
if (structure.wallSet) | if (structure.wallSet) | ||||
{ | { | ||||
structure.wallset = {}; | structure.wallset = {}; | ||||
Show All 14 Lines | if (structure.wallSet) | ||||
for (let wSegm in structure.wallSet.templates) | for (let wSegm in structure.wallSet.templates) | ||||
{ | { | ||||
if (wSegm == "fort" || wSegm == "curves") | if (wSegm == "fort" || wSegm == "curves") | ||||
continue; | continue; | ||||
let wPart = loadStructure(structure.wallSet.templates[wSegm]); | let wPart = loadStructure(structure.wallSet.templates[wSegm]); | ||||
structure.wallset[wSegm] = wPart; | structure.wallset[wSegm] = wPart; | ||||
for (let research of wPart.production.technology) | for (let research of wPart.production.techs) | ||||
structure.production.technology.push(research); | structure.production.techs.push(research); | ||||
if (wPart.upgrades) | if (wPart.upgrades) | ||||
structure.upgrades = structure.upgrades.concat(wPart.upgrades); | structure.upgrades = structure.upgrades.concat(wPart.upgrades); | ||||
if (["gate", "tower"].indexOf(wSegm) != -1) | if (["gate", "tower"].indexOf(wSegm) != -1) | ||||
continue; | continue; | ||||
if (!health) | if (!health) | ||||
▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator