Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Upgrade.js
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | Upgrade.prototype.Schema = | ||||
"</oneOrMore>"; | "</oneOrMore>"; | ||||
Upgrade.prototype.Init = function() | Upgrade.prototype.Init = function() | ||||
{ | { | ||||
this.elapsedTime = 0; | this.elapsedTime = 0; | ||||
this.expendedResources = {}; | this.expendedResources = {}; | ||||
}; | }; | ||||
Upgrade.prototype.Update = function(newTemplate) { | |||||
this.template = newTemplate; | |||||
const cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); | |||||
if (!cmpOwnership) { | |||||
warn("Upgrade needs an Ownership component to work - updating template to for " + this.entity); | |||||
return; | |||||
} | |||||
this.owner = cmpOwnership.GetOwner(); | |||||
if (!this.completed) | |||||
this.CancelUpgrade(this.owner); | |||||
this.DetermineUpgrades(); | |||||
}; | |||||
// This will also deal with the "OnDestroy" case. | // This will also deal with the "OnDestroy" case. | ||||
Upgrade.prototype.OnOwnershipChanged = function(msg) | Upgrade.prototype.OnOwnershipChanged = function(msg) | ||||
{ | { | ||||
if (!this.completed) | if (!this.completed) | ||||
this.CancelUpgrade(msg.from); | this.CancelUpgrade(msg.from); | ||||
if (msg.to != INVALID_PLAYER) | if (msg.to != INVALID_PLAYER) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 299 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator