Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/ProductionQueue.js
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | ProductionQueue.prototype.CalculateEntitiesList = function() | ||||
// filter out disabled and invalid entities | // filter out disabled and invalid entities | ||||
let disabledEntities = cmpPlayer.GetDisabledTemplates(); | let disabledEntities = cmpPlayer.GetDisabledTemplates(); | ||||
entitiesList = entitiesList.filter(ent => !disabledEntities[ent] && cmpTemplateManager.TemplateExists(ent)); | entitiesList = entitiesList.filter(ent => !disabledEntities[ent] && cmpTemplateManager.TemplateExists(ent)); | ||||
// check if some templates need to show their advanced or elite version | // check if some templates need to show their advanced or elite version | ||||
let upgradeTemplate = function(templateName) | let upgradeTemplate = function(templateName) | ||||
{ | { | ||||
let template = cmpTemplateManager.GetTemplate(templateName); | let template = cmpTemplateManager.GetTemplate(templateName); | ||||
while (template && template.Promotion !== undefined) | while (template && template.Promotion && template.Promotion.Entity) | ||||
Stan: !! not needed? | |||||
{ | { | ||||
let requiredXp = ApplyValueModificationsToTemplate("Promotion/RequiredXp", +template.Promotion.RequiredXp, cmpPlayer.GetPlayerID(), template); | let requiredXp = ApplyValueModificationsToTemplate("Promotion/RequiredXp", +template.Promotion.RequiredXp, cmpPlayer.GetPlayerID(), template); | ||||
if (requiredXp > 0) | if (requiredXp > 0) | ||||
break; | break; | ||||
templateName = template.Promotion.Entity; | templateName = template.Promotion.Entity; | ||||
template = cmpTemplateManager.GetTemplate(templateName); | template = cmpTemplateManager.GetTemplate(templateName); | ||||
} | } | ||||
return templateName; | return templateName; | ||||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | if (type == "unit") | ||||
return; | return; | ||||
} | } | ||||
// Find the template data so we can determine the build costs | // Find the template data so we can determine the build costs | ||||
let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | ||||
let template = cmpTemplateManager.GetTemplate(templateName); | let template = cmpTemplateManager.GetTemplate(templateName); | ||||
if (!template) | if (!template) | ||||
return; | return; | ||||
if (template.Promotion && ApplyValueModificationsToTemplate("Promotion/RequiredXp", +template.Promotion.RequiredXp, cmpPlayer.GetPlayerID(), template) == 0) | if (template.Promotion && template.Promotion.Entity && ApplyValueModificationsToTemplate("Promotion/RequiredXp", +template.Promotion.RequiredXp, cmpPlayer.GetPlayerID(), template) == 0) | ||||
{ | { | ||||
this.AddBatch(template.Promotion.Entity, type, count, metadata); | this.AddBatch(template.Promotion.Entity, type, count, metadata); | ||||
return; | return; | ||||
} | } | ||||
// Apply a time discount to larger batches. | // Apply a time discount to larger batches. | ||||
let timeMult = this.GetBatchTime(count); | let timeMult = this.GetBatchTime(count); | ||||
▲ Show 20 Lines • Show All 555 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
!! not needed?