Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/ResourceSupply.js
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | ResourceSupply.prototype.Init = function() | ||||
if (this.template.Change) | if (this.template.Change) | ||||
{ | { | ||||
this.timers = {}; | this.timers = {}; | ||||
this.cachedChanges = {}; | this.cachedChanges = {}; | ||||
} | } | ||||
}; | }; | ||||
ResourceSupply.prototype.Update = function(newTemplate) | |||||
{ | |||||
this.template = newTemplate; | |||||
// TODO: figure out what we want to do with the amount exactly. | |||||
let oldAmount = this.amount; | |||||
let oldType = this.cachedType; | |||||
this.amount = +(this.template.Initial || this.template.Max); | |||||
let [type, subtype] = this.template.Type.split('.'); | |||||
this.cachedType = { "generic": type, "specific": subtype }; | |||||
if (oldType.generic != type || oldType.specific != subtype) { | |||||
// TODO: send message. | |||||
} else if (oldAmount != this.amount) { | |||||
Engine.PostMessage(this.entity, MT_ResourceSupplyChanged, { | |||||
"from": oldAmount, | |||||
"to": this.amount | |||||
}); | |||||
} | |||||
this.RecalculateValues(); | |||||
}; | |||||
ResourceSupply.prototype.IsInfinite = function() | ResourceSupply.prototype.IsInfinite = function() | ||||
{ | { | ||||
return !isFinite(+this.template.Max); | return !isFinite(+this.template.Max); | ||||
}; | }; | ||||
ResourceSupply.prototype.GetKillBeforeGather = function() | ResourceSupply.prototype.GetKillBeforeGather = function() | ||||
{ | { | ||||
return this.template.KillBeforeGather == "true"; | return this.template.KillBeforeGather == "true"; | ||||
▲ Show 20 Lines • Show All 378 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator