From c47496cf185b8887d83d8c071f413c309f634da2 Mon Sep 17 00:00:00 2001 From: Angen Date: Wed, 15 Apr 2020 21:26:25 +0000 Subject: [PATCH] Cleanup ResearchTechnology function Remove unused variable since e16c4c4800 and call for ranged manager. Transform comment to javadoc. var -> let Differential Revision: https://code.wildfiregames.com/D2631 Patch by: Freagarach Reviewed by: Angen This was SVN commit r23587. --- .../components/TechnologyManager.js | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/binaries/data/mods/public/simulation/components/TechnologyManager.js b/binaries/data/mods/public/simulation/components/TechnologyManager.js index c43dd660fe..8182c30545 100644 --- a/binaries/data/mods/public/simulation/components/TechnologyManager.js +++ b/binaries/data/mods/public/simulation/components/TechnologyManager.js @@ -207,15 +207,20 @@ TechnologyManager.prototype.OnGlobalOwnershipChanged = function(msg) } }; -// Marks a technology as researched. Note that this does not verify that the requirements are met. +/** + * Marks a technology as researched. + * Note that this does not verify that the requirements are met. + * + * @param {String} tech - The technology to mark as researched. + */ TechnologyManager.prototype.ResearchTechnology = function(tech) { this.StoppedResearch(tech, false); - var modifiedComponents = {}; + let modifiedComponents = {}; this.researchedTechs.add(tech); - // store the modifications in an easy to access structure + // Store the modifications in an easy to access structure. let template = TechnologyTemplates.Get(tech); if (template.modifications) { @@ -225,14 +230,14 @@ TechnologyManager.prototype.ResearchTechnology = function(tech) if (template.replaces && template.replaces.length > 0) { - for (var i of template.replaces) + for (let i of template.replaces) { if (!i || this.IsTechnologyResearched(i)) continue; this.researchedTechs.add(i); - // Change the EntityLimit if any + // Change the EntityLimit if any. let cmpPlayer = Engine.QueryInterface(this.entity, IID_Player); if (cmpPlayer && cmpPlayer.GetPlayerID() !== undefined) { @@ -246,16 +251,13 @@ TechnologyManager.prototype.ResearchTechnology = function(tech) this.UpdateAutoResearch(); - var cmpPlayer = Engine.QueryInterface(this.entity, IID_Player); + let cmpPlayer = Engine.QueryInterface(this.entity, IID_Player); if (!cmpPlayer || cmpPlayer.GetPlayerID() === undefined) return; - var playerID = cmpPlayer.GetPlayerID(); - var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); - var ents = cmpRangeManager.GetEntitiesByPlayer(playerID); - ents.push(this.entity); + let playerID = cmpPlayer.GetPlayerID(); - // Change the EntityLimit if any - var cmpPlayerEntityLimits = QueryPlayerIDInterface(playerID, IID_EntityLimits); + // Change the EntityLimit if any. + let cmpPlayerEntityLimits = QueryPlayerIDInterface(playerID, IID_EntityLimits); if (cmpPlayerEntityLimits) cmpPlayerEntityLimits.UpdateLimitsFromTech(tech);