diff --git a/binaries/data/mods/public/globalscripts/Templates.js b/binaries/data/mods/public/globalscripts/Templates.js
index 8f76311..e461f29 100644
a
|
b
|
function GetTemplateDataHelper(template, player, auraTemplates)
|
303 | 303 | ret.speed.run = getEntityValue("UnitMotion/Run/Speed"); |
304 | 304 | } |
305 | 305 | |
| 306 | if (template.Upgrade) |
| 307 | { |
| 308 | ret.upgrades = []; |
| 309 | for (let upKey in template.Upgrade) |
| 310 | { |
| 311 | let upgrade = { |
| 312 | "name": upKey, |
| 313 | "entity": template.Upgrade[upKey].Entity, |
| 314 | "tooltip": template.Upgrade[upKey].Tooltip, |
| 315 | "cost": {}, |
| 316 | }; |
| 317 | |
| 318 | for (let res in template.Upgrade[upKey].Cost) |
| 319 | upgrade.cost[res] = getEntityValue("Upgrade/" + upKey + "/Cost/" + res); |
| 320 | |
| 321 | if (template.Upgrade[upKey].Time) |
| 322 | upgrade.cost.time = getEntityValue("Upgrade/" + upKey + "/Time"); |
| 323 | |
| 324 | if (template.Upgrade[upKey].Icon) |
| 325 | upgrade.icon = template.Upgrade[upKey].Icon; |
| 326 | |
| 327 | if (template.RequiredTechnology) |
| 328 | upgrade.requiredTechnology = template.RequiredTechnology; |
| 329 | |
| 330 | ret.upgrades.push(upgrade); |
| 331 | } |
| 332 | } |
| 333 | |
306 | 334 | if (template.ProductionQueue) |
307 | 335 | { |
308 | 336 | ret.techCostMultiplier = {}; |
diff --git a/binaries/data/mods/public/gui/structree/draw.js b/binaries/data/mods/public/gui/structree/draw.js
index 92c60ce..388b665 100644
a
|
b
|
function draw()
|
82 | 82 | p++; |
83 | 83 | } |
84 | 84 | |
| 85 | if (stru.upgrades[prod_pha]) |
| 86 | for (let upgrade of stru.upgrades[prod_pha]) |
| 87 | { |
| 88 | if (!drawProdIcon(i, s, r, p, upgrade.data)) |
| 89 | break; |
| 90 | p++; |
| 91 | } |
| 92 | |
85 | 93 | if (stru.wallset && prod_pha == pha) |
86 | | for (let prod of [stru.wallset.gate, stru.wallset.tower]) |
| 94 | for (let prod of [stru.wallset.tower]) |
87 | 95 | { |
88 | 96 | if (!drawProdIcon(i, s, r, p, prod)) |
89 | 97 | break; |
… |
… |
function draw()
|
156 | 164 | thisEle.hidden = false; |
157 | 165 | |
158 | 166 | let p = 0; |
159 | | for (let prodType in trainer.production) |
160 | | { |
161 | | for (let prod of trainer.production[prodType]) |
| 167 | if (trainer.production) |
| 168 | for (let prodType in trainer.production) |
162 | 169 | { |
163 | | switch (prodType) |
| 170 | for (let prod of trainer.production[prodType]) |
164 | 171 | { |
165 | | case "units": |
166 | | prod = g_ParsedData.units[prod]; |
167 | | break; |
168 | | case "techs": |
169 | | prod = clone(g_ParsedData.techs[prod]); |
170 | | for (let res in trainer.techCostMultiplier) |
171 | | if (prod.cost[res]) |
172 | | prod.cost[res] *= trainer.techCostMultiplier[res]; |
173 | | break; |
174 | | default: |
175 | | continue; |
| 172 | switch (prodType) |
| 173 | { |
| 174 | case "units": |
| 175 | prod = g_ParsedData.units[prod]; |
| 176 | break; |
| 177 | case "techs": |
| 178 | prod = clone(g_ParsedData.techs[prod]); |
| 179 | for (let res in trainer.techCostMultiplier) |
| 180 | if (prod.cost[res]) |
| 181 | prod.cost[res] *= trainer.techCostMultiplier[res]; |
| 182 | break; |
| 183 | default: |
| 184 | continue; |
| 185 | } |
| 186 | if (!drawProdIcon(null, t, null, p, prod)) |
| 187 | break; |
| 188 | ++p; |
176 | 189 | } |
177 | | if (!drawProdIcon(null, t, null, p, prod)) |
| 190 | } |
| 191 | if (trainer.upgrades) |
| 192 | for (let upgrade of trainer.upgrades) |
| 193 | { |
| 194 | if (!drawProdIcon(null, t, null, p, upgrade.data)) |
178 | 195 | break; |
179 | 196 | ++p; |
180 | 197 | } |
181 | | } |
182 | 198 | hideRemaining("trainer["+t+"]_prod[", p, "]"); |
183 | 199 | |
184 | 200 | let size = thisEle.size; |
diff --git a/binaries/data/mods/public/gui/structree/helper.js b/binaries/data/mods/public/gui/structree/helper.js
index 8c7fe49..6653c0d 100644
a
|
b
|
function fetchTokens(templateName, keypath)
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
| 96 | * Function is used to move attribute values from an Upgrade component |
| 97 | * entry to its designated entity data object, overriding current values. |
| 98 | */ |
| 99 | function transferUpgradeData(from, to) |
| 100 | { |
| 101 | to.cost = from.cost; |
| 102 | to.icon = from.icon || to.icon; |
| 103 | to.tooltip = from.tooltip || to.tooltip; |
| 104 | to.requiredTechnology = from.requiredTechnology || to.requiredTechnology; |
| 105 | return to; |
| 106 | } |
| 107 | |
| 108 | /** |
96 | 109 | * This is needed because getEntityCostTooltip in tooltip.js needs to get |
97 | 110 | * the template data of the different wallSet pieces. In the session this |
98 | 111 | * function does some caching, but here we do that in loadTemplate already. |
diff --git a/binaries/data/mods/public/gui/structree/load.js b/binaries/data/mods/public/gui/structree/load.js
index 79205ba..63ee899 100644
a
|
b
|
function loadUnit(templateName)
|
78 | 78 | g_Lists.structures.push(build); |
79 | 79 | } |
80 | 80 | |
| 81 | if (unit.upgrades) |
| 82 | for (let idx in unit.upgrades) |
| 83 | { |
| 84 | unit.upgrades[idx].entity = unit.upgrades[idx].entity.replace("{civ}", g_SelectedCiv); |
| 85 | |
| 86 | let data = loadUnit(unit.upgrades[idx].entity); |
| 87 | data = transferUpgradeData(unit.upgrades[idx], data); |
| 88 | unit.upgrades[idx].data = data; |
| 89 | } |
| 90 | |
81 | 91 | return unit; |
82 | 92 | } |
83 | 93 | |
… |
… |
function loadStructure(templateName)
|
111 | 121 | } |
112 | 122 | } |
113 | 123 | |
| 124 | if (structure.upgrades) |
| 125 | for (let idx in structure.upgrades) |
| 126 | { |
| 127 | structure.upgrades[idx].entity = structure.upgrades[idx].entity.replace("{civ}", g_SelectedCiv); |
| 128 | |
| 129 | let data = loadStructure(structure.upgrades[idx].entity); |
| 130 | data = transferUpgradeData(structure.upgrades[idx], data); |
| 131 | structure.upgrades[idx].data = data; |
| 132 | } |
| 133 | |
114 | 134 | if (structure.wallSet) |
115 | 135 | { |
116 | 136 | structure.wallset = {}; |
117 | 137 | |
| 138 | if (!structure.upgrades) |
| 139 | structure.upgrades = []; |
| 140 | |
118 | 141 | // Note: Assume wall segments of all lengths have the same armor and auras |
119 | 142 | let struct = loadStructure(structure.wallSet.templates.long); |
120 | 143 | structure.armour = struct.armour; |
… |
… |
function loadStructure(templateName)
|
134 | 157 | for (let research of wPart.production.technology) |
135 | 158 | structure.production.technology.push(research); |
136 | 159 | |
| 160 | if (wPart.upgrades) |
| 161 | structure.upgrades = structure.upgrades.concat(wPart.upgrades); |
| 162 | |
137 | 163 | if (["gate", "tower"].indexOf(wSegm) != -1) |
138 | 164 | continue; |
139 | 165 | |
diff --git a/binaries/data/mods/public/gui/structree/structree.js b/binaries/data/mods/public/gui/structree/structree.js
index a254e3b..57f22e0 100644
a
|
b
|
function selectCiv(civCode)
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | | // Group production lists of structures by phase |
| 164 | // Group production and upgrade lists of structures by phase |
165 | 165 | for (let structCode of g_Lists.structures) |
166 | 166 | { |
167 | 167 | let structInfo = g_ParsedData.structures[structCode]; |
… |
… |
function selectCiv(civCode)
|
222 | 222 | "technology": newProdTech, |
223 | 223 | "units": newProdUnits |
224 | 224 | }; |
| 225 | |
| 226 | // Sort upgrades by phase |
| 227 | let newUpgrades = {}; |
| 228 | if (structInfo.upgrades) |
| 229 | { |
| 230 | for (let upgrade of structInfo.upgrades) |
| 231 | { |
| 232 | let phase = GetPhaseOfTemplate(upgrade.data); |
| 233 | |
| 234 | if (g_ParsedData.phaseList.indexOf(phase) < structPhaseIdx) |
| 235 | phase = structInfo.phase; |
| 236 | |
| 237 | if (!(phase in newUpgrades)) |
| 238 | newUpgrades[phase] = []; |
| 239 | newUpgrades[phase].push(upgrade); |
| 240 | } |
| 241 | } |
| 242 | g_ParsedData.structures[structCode].upgrades = newUpgrades; |
225 | 243 | } |
226 | 244 | |
227 | 245 | // Determine the buildList for the civ (grouped by phase) |
… |
… |
function selectCiv(civCode)
|
234 | 252 | let phase = g_ParsedData.structures[structCode].phase; |
235 | 253 | buildList[phase].push(structCode); |
236 | 254 | } |
| 255 | |
237 | 256 | for (let unitCode of g_Lists.units) |
238 | | if (g_ParsedData.units[unitCode] && g_ParsedData.units[unitCode].production) |
| 257 | if (g_ParsedData.units[unitCode] && (g_ParsedData.units[unitCode].production || g_ParsedData.units[unitCode].upgrades)) |
239 | 258 | trainerList.push(unitCode); |
240 | 259 | |
241 | 260 | g_CivData[g_SelectedCiv].buildList = buildList; |
diff --git a/binaries/data/mods/public/simulation/templates/template_structure_defense_wall_gate.xml b/binaries/data/mods/public/simulation/templates/template_structure_defense_wall_gate.xml
index 53f0d01..aef15c3 100644
a
|
b
|
|
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | 2 | <Entity parent="template_structure_defense_wall_long"> |
3 | 3 | <Auras disable=""/> |
| 4 | <Cost disable=""/> |
4 | 5 | <GarrisonHolder disable=""/> |
5 | 6 | <Gate> |
6 | 7 | <PassRange>20</PassRange> |