Differential D154 Diff 1212 ps/trunk/binaries/data/mods/public/simulation/components/TechnologyManager.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/TechnologyManager.js
Show First 20 Lines • Show All 264 Lines • ▼ Show 20 Lines | if (!template) | ||||
return; | return; | ||||
} | } | ||||
var modifiedComponents = {}; | var modifiedComponents = {}; | ||||
this.researchedTechs[tech] = template; | this.researchedTechs[tech] = template; | ||||
// store the modifications in an easy to access structure | // store the modifications in an easy to access structure | ||||
if (template.modifications) | if (template.modifications) | ||||
{ | { | ||||
var affects = []; | let derivedModifiers = DeriveModificationsFromTech(template); | ||||
if (template.affects && template.affects.length > 0) | for (let modifierPath in derivedModifiers) | ||||
{ | { | ||||
for (let affect of template.affects) | if (!this.modifications[modifierPath]) | ||||
{ | this.modifications[modifierPath] = []; | ||||
// Put the list of classes into an array for convenient access | this.modifications[modifierPath] = this.modifications[modifierPath].concat(derivedModifiers[modifierPath]); | ||||
affects.push(affect.split(/\s+/)); | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
affects.push([]); | |||||
} | |||||
// We add an item to this.modifications for every modification in the template.modifications array | |||||
for (var i in template.modifications) | |||||
{ | |||||
var modification = template.modifications[i]; | |||||
if (!this.modifications[modification.value]) | |||||
this.modifications[modification.value] = []; | |||||
var modAffects = affects.slice(); | |||||
if (modification.affects) | |||||
{ | |||||
var extraAffects = modification.affects.split(/\s+/); | |||||
for (var a in modAffects) | |||||
modAffects[a] = modAffects[a].concat(extraAffects); | |||||
} | |||||
var mod = {"affects": modAffects}; | |||||
// copy the modification data into our new data structure | |||||
for (var j in modification) | |||||
if (j !== "value" && j !== "affects") | |||||
mod[j] = modification[j]; | |||||
this.modifications[modification.value].push(mod); | let component = modifierPath.split("/")[0]; | ||||
var component = modification.value.split("/")[0]; | |||||
if (!modifiedComponents[component]) | if (!modifiedComponents[component]) | ||||
modifiedComponents[component] = []; | modifiedComponents[component] = []; | ||||
modifiedComponents[component].push(modification.value); | modifiedComponents[component].push(modifierPath); | ||||
this.modificationCache[modification.value] = {}; | this.modificationCache[modifierPath] = {}; | ||||
} | } | ||||
} | } | ||||
if (template.replaces && template.replaces.length > 0) | if (template.replaces && template.replaces.length > 0) | ||||
{ | { | ||||
for (var i of template.replaces) | for (var i of template.replaces) | ||||
{ | { | ||||
if (!i || this.IsTechnologyResearched(i)) | if (!i || this.IsTechnologyResearched(i)) | ||||
▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator