Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/globalscripts/Templates.js
Show First 20 Lines • Show All 282 Lines • ▼ Show 20 Lines | if (template.Cost.Population) | ||||
ret.cost.population = getEntityValue("Cost/Population"); | ret.cost.population = getEntityValue("Cost/Population"); | ||||
if (template.Cost.PopulationBonus) | if (template.Cost.PopulationBonus) | ||||
ret.cost.populationBonus = getEntityValue("Cost/PopulationBonus"); | ret.cost.populationBonus = getEntityValue("Cost/PopulationBonus"); | ||||
if (template.Cost.BuildTime) | if (template.Cost.BuildTime) | ||||
ret.cost.time = getEntityValue("Cost/BuildTime"); | ret.cost.time = getEntityValue("Cost/BuildTime"); | ||||
} | } | ||||
else if (template.Identity && template.Identity.Composition) | |||||
{ | |||||
let maxCost = {}; | |||||
let composition = template.Identity.Composition; | |||||
let entriesToRecruit = Object.keys(composition.Entries); | |||||
let mutuallyExclusive = composition.MutuallyExclusive != false; | |||||
if (entriesToRecruit.length > 1) | |||||
{ | |||||
for (let entry in composition.Entries) | |||||
{ | |||||
let entTemplateName = composition.Entries[entry].Template; | |||||
let entData = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface).GetTemplateData(player, entTemplateName); | |||||
let neededCost = {}; | |||||
let amount = composition.Entries[entry].Amount; | |||||
if (entData.cost) | |||||
{ | |||||
for (let cost in entData.cost) | |||||
maxCost[cost] = entData.cost[cost] * amount; | |||||
if (mutuallyExclusive) | |||||
for (let cost in neededCost) | |||||
maxCost[cost] = Math.max(maxCost[cost], +(neededCost[cost] || 0)); | |||||
else | |||||
for (let cost in neededCost) | |||||
maxCost[cost] += +(neededCost[cost] || 0); | |||||
} | |||||
} | |||||
} | |||||
ret.cost = {}; | |||||
for (let cost in maxCost) | |||||
ret.cost[cost] = maxCost[cost]; | |||||
} | |||||
if (template.Footprint) | if (template.Footprint) | ||||
{ | { | ||||
ret.footprint = { "height": template.Footprint.Height }; | ret.footprint = { "height": template.Footprint.Height }; | ||||
if (template.Footprint.Square) | if (template.Footprint.Square) | ||||
ret.footprint.square = { | ret.footprint.square = { | ||||
"width": +template.Footprint.Square["@width"], | "width": +template.Footprint.Square["@width"], | ||||
▲ Show 20 Lines • Show All 247 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator