Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Upgrade.js
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | "<element>" + | ||||
"<element name='RequiredTechnology' a:help='Define what technology is required for this upgrade'>" + | "<element name='RequiredTechnology' a:help='Define what technology is required for this upgrade'>" + | ||||
"<choice>" + | "<choice>" + | ||||
"<text/>" + | "<text/>" + | ||||
"<empty/>" + | "<empty/>" + | ||||
"</choice>" + | "</choice>" + | ||||
"</element>" + | "</element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"<optional>" + | "<optional>" + | ||||
ModificationsSchema + | |||||
"</optional>" + | |||||
"<optional>" + | |||||
"<element name='CheckPlacementRestrictions' a:help='Upgrading will check for placement restrictions (nb:GUI only)'><empty/></element>" + | "<element name='CheckPlacementRestrictions' a:help='Upgrading will check for placement restrictions (nb:GUI only)'><empty/></element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"</interleave>" + | "</interleave>" + | ||||
"</element>" + | "</element>" + | ||||
"</oneOrMore>"; | "</oneOrMore>"; | ||||
Upgrade.prototype.Init = function() | Upgrade.prototype.Init = function() | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Lines | Upgrade.prototype.Upgrade = function(template) | ||||
} | } | ||||
this.upgrading = template; | this.upgrading = template; | ||||
this.SetUpgradeAnimationVariant(); | this.SetUpgradeAnimationVariant(); | ||||
// Prevent cheating | // Prevent cheating | ||||
this.ChangeUpgradedEntityCount(1); | this.ChangeUpgradedEntityCount(1); | ||||
if (this.template[this.upgradeTemplates[template]].Modifiers) | |||||
{ | |||||
let cmpModifiersManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ModifiersManager); | |||||
bb: const | |||||
cmpModifiersManager.AddModifiers("upgrade_" + this.entity, | |||||
bbUnsubmitted Not Done Inline Actionsif two upgrades are done simultaneously we give them the same name here, maybe we should add the this.upgradeTemplates[template] to the name too? bb: if two upgrades are done simultaneously we give them the same name here, maybe we should add… | |||||
wraitiiAuthorUnsubmitted Done Inline ActionsIs that possible? Still, probably not a bad call. wraitii: Is that possible? Still, probably not a bad call. | |||||
DeriveModificationsFromXMLTemplate(this.template[this.upgradeTemplates[template]].Modifiers), | |||||
this.entity); | |||||
} | |||||
if (this.GetUpgradeTime(template) !== 0) | if (this.GetUpgradeTime(template) !== 0) | ||||
{ | { | ||||
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | ||||
this.timer = cmpTimer.SetInterval(this.entity, IID_Upgrade, "UpgradeProgress", 0, UPGRADING_PROGRESS_INTERVAL, { "upgrading": template }); | this.timer = cmpTimer.SetInterval(this.entity, IID_Upgrade, "UpgradeProgress", 0, UPGRADING_PROGRESS_INTERVAL, { "upgrading": template }); | ||||
} | } | ||||
else | else | ||||
this.UpgradeProgress(); | this.UpgradeProgress(); | ||||
return true; | return true; | ||||
}; | }; | ||||
Upgrade.prototype.CancelUpgrade = function(owner) | Upgrade.prototype.CancelUpgrade = function(owner) | ||||
{ | { | ||||
if (!this.IsUpgrading()) | if (!this.IsUpgrading()) | ||||
return; | return; | ||||
if (this.template[this.upgradeTemplates[this.upgrading]].Modifiers) | |||||
{ | |||||
let cmpModifiersManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ModifiersManager); | |||||
bbUnsubmitted Not Done Inline Actionsconst bb: const | |||||
cmpModifiersManager.RemoveAllModifiers("upgrade_" + this.entity, this.entity); | |||||
} | |||||
let cmpPlayer = QueryPlayerIDInterface(owner, IID_Player); | let cmpPlayer = QueryPlayerIDInterface(owner, IID_Player); | ||||
if (cmpPlayer) | if (cmpPlayer) | ||||
cmpPlayer.AddResources(this.expendedResources); | cmpPlayer.AddResources(this.expendedResources); | ||||
this.expendedResources = {}; | this.expendedResources = {}; | ||||
this.ChangeUpgradedEntityCount(-1); | this.ChangeUpgradedEntityCount(-1); | ||||
// Do not update visual actor if the animation didn't change. | // Do not update visual actor if the animation didn't change. | ||||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
const