Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/Upgrade.js
Show First 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | Upgrade.prototype.ChangeUpgradedEntityCount = function(amount) | ||||
let categoryFrom; | let categoryFrom; | ||||
let cmpTrainingRestrictions = Engine.QueryInterface(this.entity, IID_TrainingRestrictions); | let cmpTrainingRestrictions = Engine.QueryInterface(this.entity, IID_TrainingRestrictions); | ||||
let cmpBuildRestrictions = Engine.QueryInterface(this.entity, IID_BuildRestrictions); | let cmpBuildRestrictions = Engine.QueryInterface(this.entity, IID_BuildRestrictions); | ||||
if (cmpTrainingRestrictions) | if (cmpTrainingRestrictions) | ||||
categoryFrom = cmpTrainingRestrictions.GetCategory(); | categoryFrom = cmpTrainingRestrictions.GetCategory(); | ||||
else if (cmpBuildRestrictions) | else if (cmpBuildRestrictions) | ||||
categoryFrom = cmpBuildRestrictions.GetCategory(); | categoryFrom = cmpBuildRestrictions.GetCategory(); | ||||
if (categoryTo == categoryFrom) | if (categoryTo == categoryFrom) | ||||
return; | return; | ||||
let cmpEntityLimits = QueryPlayerIDInterface(this.owner, IID_EntityLimits); | let cmpEntityLimits = QueryPlayerIDInterface(this.owner, IID_EntityLimits); | ||||
cmpEntityLimits.ChangeCount(categoryTo, amount); | cmpEntityLimits.ChangeCount(categoryTo, amount); | ||||
}; | }; | ||||
Upgrade.prototype.CanUpgradeTo = function(template) | Upgrade.prototype.CanUpgradeTo = function(template) | ||||
{ | { | ||||
return this.upgradeTemplates[template] !== undefined; | return this.upgradeTemplates[template] !== undefined; | ||||
}; | }; | ||||
Upgrade.prototype.GetUpgrades = function() | Upgrade.prototype.GetUpgrades = function() | ||||
{ | { | ||||
let ret = []; | let ret = []; | ||||
let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); | let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); | ||||
for (let option in this.template) | for (let option in this.template) | ||||
{ | { | ||||
let choice = this.template[option]; | let choice = this.template[option]; | ||||
let templateName = cmpIdentity ? choice.Entity.replace(/\{civ\}/g, cmpIdentity.GetCiv()) : choice.Entity | let templateName = cmpIdentity ? choice.Entity.replace(/\{civ\}/g, cmpIdentity.GetCiv()) : choice.Entity; | ||||
let cost = {}; | let cost = {}; | ||||
if (choice.Cost) | if (choice.Cost) | ||||
cost = this.GetResourceCosts(templateName); | cost = this.GetResourceCosts(templateName); | ||||
if (choice.Time) | if (choice.Time) | ||||
cost.time = this.GetUpgradeTime(templateName); | cost.time = this.GetUpgradeTime(templateName); | ||||
let hasCost = choice.Cost || choice.Time; | let hasCost = choice.Cost || choice.Time; | ||||
▲ Show 20 Lines • Show All 182 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator