Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/TechnologyManager.js
Show All 33 Lines | |||||
// This function checks if the requirements of any autoresearch techs are met and if they are it researches them | // This function checks if the requirements of any autoresearch techs are met and if they are it researches them | ||||
TechnologyManager.prototype.UpdateAutoResearch = function() | TechnologyManager.prototype.UpdateAutoResearch = function() | ||||
{ | { | ||||
for (let key of this.unresearchedAutoResearchTechs) | for (let key of this.unresearchedAutoResearchTechs) | ||||
{ | { | ||||
let tech = TechnologyTemplates.Get(key); | let tech = TechnologyTemplates.Get(key); | ||||
if ((tech.autoResearch && this.CanResearch(key)) | if ((tech.autoResearch && this.CanResearch(key)) || | ||||
|| (tech.top && (this.IsTechnologyResearched(tech.top) || this.IsTechnologyResearched(tech.bottom)))) | (tech.top && (this.IsTechnologyResearched(tech.top) || this.IsTechnologyResearched(tech.bottom)))) | ||||
{ | { | ||||
this.unresearchedAutoResearchTechs.delete(key); | this.unresearchedAutoResearchTechs.delete(key); | ||||
this.ResearchTechnology(key); | this.ResearchTechnology(key); | ||||
return; // We will have recursively handled any knock-on effects so can just return | return; // We will have recursively handled any knock-on effects so can just return | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
// Checks an entity template to see if its technology requirements have been met | // Checks an entity template to see if its technology requirements have been met | ||||
TechnologyManager.prototype.CanProduce = function (templateName) | TechnologyManager.prototype.CanProduce = function(templateName) | ||||
{ | { | ||||
var cmpTempManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | var cmpTempManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); | ||||
var template = cmpTempManager.GetTemplate(templateName); | var template = cmpTempManager.GetTemplate(templateName); | ||||
if (template.Identity && template.Identity.RequiredTechnology) | if (template.Identity && template.Identity.RequiredTechnology) | ||||
return this.IsTechnologyResearched(template.Identity.RequiredTechnology); | return this.IsTechnologyResearched(template.Identity.RequiredTechnology); | ||||
// If there is no required technology then this entity can be produced | // If there is no required technology then this entity can be produced | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 315 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator