Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/ProductionQueue.js
Show First 20 Lines • Show All 329 Lines • ▼ Show 20 Lines | else if (type == "technology") | ||||
(tech.top == templateName || tech.bottom == templateName)))) | (tech.top == templateName || tech.bottom == templateName)))) | ||||
{ | { | ||||
error("This entity cannot research " + templateName); | error("This entity cannot research " + templateName); | ||||
return; | return; | ||||
} | } | ||||
let template = TechnologyTemplates.Get(templateName); | let template = TechnologyTemplates.Get(templateName); | ||||
let techCostMultiplier = this.GetTechCostMultiplier(); | let techCostMultiplier = this.GetTechCostMultiplier(); | ||||
let time = techCostMultiplier.time * template.researchTime * cmpPlayer.GetTimeMultiplier(); | let time = techCostMultiplier.time * template.researchTime; | ||||
Stan: Whitespace | |||||
let cost = {}; | let cost = {}; | ||||
for (let res in template.cost) | for (let res in template.cost) | ||||
cost[res] = Math.floor((techCostMultiplier[res] || 1) * template.cost[res]); | cost[res] = Math.floor((techCostMultiplier[res] || 1) * template.cost[res]); | ||||
// TrySubtractResources should report error to player (they ran out of resources) | // TrySubtractResources should report error to player (they ran out of resources) | ||||
if (!cmpPlayer.TrySubtractResources(cost)) | if (!cmpPlayer.TrySubtractResources(cost)) | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | ProductionQueue.prototype.ResetQueue = function() | ||||
while (this.queue.length) | while (this.queue.length) | ||||
this.RemoveBatch(this.queue[0].id); | this.RemoveBatch(this.queue[0].id); | ||||
}; | }; | ||||
/* | /* | ||||
* Returns batch build time. | * Returns batch build time. | ||||
*/ | */ | ||||
ProductionQueue.prototype.GetBatchTime = function(batchSize) | ProductionQueue.prototype.GetBatchTime = function(batchSize) | ||||
{ | { | ||||
var cmpPlayer = QueryOwnerInterface(this.entity); | |||||
var batchTimeModifier = ApplyValueModificationsToEntity("ProductionQueue/BatchTimeModifier", +this.template.BatchTimeModifier, this.entity); | |||||
// TODO: work out what equation we should use here. | // TODO: work out what equation we should use here. | ||||
Not Done Inline Actions? leper: ? | |||||
Not Done Inline ActionsNext to @Stan's comments, this is redundant also. Freagarach: Next to @Stan's comments, this is redundant also. | |||||
return Math.pow(batchSize, batchTimeModifier) * cmpPlayer.GetTimeMultiplier(); | return Math.pow(batchSize, ApplyValueModificationsToEntity("ProductionQueue/BatchTimeModifier", +this.template.BatchTimeModifier, this.entity)); | ||||
Done Inline ActionsWill fix™ wraitii: Will fix™ | |||||
}; | }; | ||||
ProductionQueue.prototype.OnOwnershipChanged = function(msg) | ProductionQueue.prototype.OnOwnershipChanged = function(msg) | ||||
{ | { | ||||
if (msg.from != INVALID_PLAYER) | if (msg.from != INVALID_PLAYER) | ||||
{ | { | ||||
// Unset flag that previous owner's training may be blocked | // Unset flag that previous owner's training may be blocked | ||||
var cmpPlayer = QueryPlayerIDInterface(msg.from); | var cmpPlayer = QueryPlayerIDInterface(msg.from); | ||||
▲ Show 20 Lines • Show All 319 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Whitespace