Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/ProductionQueue.js
Show First 20 Lines • Show All 362 Lines • ▼ Show 20 Lines | else if (type == "technology") | ||||
{ | { | ||||
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 cost = {}; | let cost = {}; | ||||
Stan: Maybe not create the object. | |||||
if (template.cost) | |||||
for (let res in template.cost) | for (let res in template.cost) | ||||
Done Inline ActionsMaybe you can go in template.cost || []? I'm not sure. wraitii: Maybe you can go `in template.cost || []`? I'm not sure. | |||||
Done Inline Actionsyou should be able too, but if anything I would expect that to be slower, though I didn't test bb: you should be able too, but if anything I would expect that to be slower, though I didn't test | |||||
Done Inline ActionsMoreover, I think it may be less readable. Freagarach: Moreover, I think it may be less readable. | |||||
cost[res] = Math.floor((techCostMultiplier[res] || 1) * template.cost[res]); | cost[res] = Math.floor((techCostMultiplier[res] || 1) * template.cost[res]); | ||||
Not Done Inline ActionsOut of scope, but this is problematic: I want a techCostMultiplier of 0 bb: Out of scope, but this is problematic: I want a techCostMultiplier of 0 | |||||
// 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; | ||||
// Tell the technology manager that we have started researching this so that people can't research the same | // Tell the technology manager that we have started researching this so that people can't research the same | ||||
// thing twice. | // thing twice. | ||||
let cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager); | let cmpTechnologyManager = QueryOwnerInterface(this.entity, IID_TechnologyManager); | ||||
cmpTechnologyManager.QueuedResearch(templateName, this.entity); | cmpTechnologyManager.QueuedResearch(templateName, this.entity); | ||||
if (!this.queue.length) | if (!this.queue.length) | ||||
{ | { | ||||
cmpTechnologyManager.StartedResearch(templateName, false); | cmpTechnologyManager.StartedResearch(templateName, false); | ||||
this.SetAnimation("researching"); | this.SetAnimation("researching"); | ||||
} | } | ||||
let time = techCostMultiplier.time * template.researchTime * 1000; | let time = techCostMultiplier.time * (template.researchTime || 0) * 1000; | ||||
this.queue.push({ | this.queue.push({ | ||||
"id": this.nextID++, | "id": this.nextID++, | ||||
"player": cmpPlayer.GetPlayerID(), | "player": cmpPlayer.GetPlayerID(), | ||||
"count": 1, | "count": 1, | ||||
"technologyTemplate": templateName, | "technologyTemplate": templateName, | ||||
"resources": cost, | "resources": cost, | ||||
FreagarachAuthorUnsubmitted Done Inline ActionsIts needed here. Freagarach: Its needed here. | |||||
"productionStarted": false, | "productionStarted": false, | ||||
"timeTotal": time, | "timeTotal": time, | ||||
"timeRemaining": time | "timeRemaining": time | ||||
}); | }); | ||||
// Call the related trigger event. | // Call the related trigger event. | ||||
let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); | let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); | ||||
cmpTrigger.CallEvent("ResearchQueued", { | cmpTrigger.CallEvent("ResearchQueued", { | ||||
▲ Show 20 Lines • Show All 477 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Maybe not create the object.