diff --git a/binaries/data/mods/public/simulation/components/TechnologyManager.js b/binaries/data/mods/public/simulation/components/TechnologyManager.js index bab7f92b02..bbd5066bec 100644 --- a/binaries/data/mods/public/simulation/components/TechnologyManager.js +++ b/binaries/data/mods/public/simulation/components/TechnologyManager.js @@ -210,8 +210,8 @@ TechnologyManager.prototype.Init = function() // Some technologies are automatically researched when their conditions are met. They have no cost and are // researched instantly. This allows civ bonuses and more complicated technologies. this.unresearchedAutoResearchTechs = new Set(); - let allTechs = TechnologyTemplates.GetAll(); - for (let key in allTechs) + const allTechs = TechnologyTemplates.GetAll(); + for (const key in allTechs) if (allTechs[key].autoResearch || allTechs[key].top) this.unresearchedAutoResearchTechs.add(key); }; @@ -260,9 +260,9 @@ TechnologyManager.prototype.OnUpdate = function() // This function checks if the requirements of any autoresearch techs are met and if they are it researches them TechnologyManager.prototype.UpdateAutoResearch = function() { - for (let key of this.unresearchedAutoResearchTechs) + for (const key of this.unresearchedAutoResearchTechs) { - let tech = TechnologyTemplates.Get(key); + const tech = TechnologyTemplates.Get(key); if ((tech.autoResearch && this.CanResearch(key)) || (tech.top && (this.IsTechnologyResearched(tech.top) || this.IsTechnologyResearched(tech.bottom)))) { @@ -298,7 +298,7 @@ TechnologyManager.prototype.IsTechnologyResearched = function(tech) // Checks the requirements for a technology to see if it can be researched at the current time TechnologyManager.prototype.CanResearch = function(tech) { - let template = TechnologyTemplates.Get(tech); + const template = TechnologyTemplates.Get(tech); if (!template) { @@ -331,7 +331,7 @@ TechnologyManager.prototype.CanResearch = function(tech) */ TechnologyManager.prototype.CheckTechnologyRequirements = function(reqs, civonly = false) { - let cmpPlayer = Engine.QueryInterface(this.entity, IID_Player); + const cmpPlayer = Engine.QueryInterface(this.entity, IID_Player); if (!reqs) return false; @@ -388,7 +388,7 @@ TechnologyManager.prototype.OnGlobalOwnershipChanged = function(msg) // don't use foundations for the class counts but check if techs apply (e.g. health increase) if (!Engine.QueryInterface(msg.entity, IID_Foundation)) { - for (let cls of classes) + for (const cls of classes) { this.classCounts[cls] = this.classCounts[cls] || 0; this.classCounts[cls] += 1; @@ -411,7 +411,7 @@ TechnologyManager.prototype.OnGlobalOwnershipChanged = function(msg) if (cmpIdentity) { var classes = cmpIdentity.GetClassesList(); - for (let cls of classes) + for (const cls of classes) { this.classCounts[cls] -= 1; if (this.classCounts[cls] <= 0) diff --git a/binaries/data/mods/public/simulation/components/TerritoryDecay.js b/binaries/data/mods/public/simulation/components/TerritoryDecay.js index f8ff328e48..a3aa4c1a89 100644 --- a/binaries/data/mods/public/simulation/components/TerritoryDecay.js +++ b/binaries/data/mods/public/simulation/components/TerritoryDecay.js @@ -71,7 +71,7 @@ TerritoryDecay.prototype.IsConnected = function() this.connectedNeighbours = cmpTerritoryManager.GetNeighbours(pos.x, pos.y, true); - let numPlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetNumPlayers(); + const numPlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetNumPlayers(); for (var i = 1; i < numPlayers; ++i) if (this.connectedNeighbours[i] > 0 && cmpDiplomacy.IsMutualAlly(i)) { @@ -108,7 +108,7 @@ TerritoryDecay.prototype.GetConnectedNeighbours = function() TerritoryDecay.prototype.UpdateDecayState = function() { - let decaying = !this.IsConnected() && this.GetDecayRate() > 0; + const decaying = !this.IsConnected() && this.GetDecayRate() > 0; if (decaying === this.decaying) return; this.decaying = decaying; @@ -117,13 +117,13 @@ TerritoryDecay.prototype.UpdateDecayState = function() TerritoryDecay.prototype.UpdateOwner = function() { - let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); - let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); + const cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); + const cmpPosition = Engine.QueryInterface(this.entity, IID_Position); if (!cmpOwnership || !cmpPosition || !cmpPosition.IsInWorld()) return; - let cmpTerritoryManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TerritoryManager); - let pos = cmpPosition.GetPosition2D(); - let tileOwner = cmpTerritoryManager.GetOwner(pos.x, pos.y); + const cmpTerritoryManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TerritoryManager); + const pos = cmpPosition.GetPosition2D(); + const tileOwner = cmpTerritoryManager.GetOwner(pos.x, pos.y); if (tileOwner != cmpOwnership.GetOwner()) cmpOwnership.SetOwner(tileOwner); }; @@ -156,7 +156,7 @@ TerritoryDecay.prototype.OnOwnershipChanged = function(msg) // Update the list of TerritoryDecay components in the manager if (msg.from == INVALID_PLAYER || msg.to == INVALID_PLAYER) { - let cmpTerritoryDecayManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TerritoryDecayManager); + const cmpTerritoryDecayManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TerritoryDecayManager); if (msg.from == INVALID_PLAYER) cmpTerritoryDecayManager.Add(this.entity); else diff --git a/binaries/data/mods/public/simulation/components/TerritoryDecayManager.js b/binaries/data/mods/public/simulation/components/TerritoryDecayManager.js index cf7924dd51..49fa8b0e64 100644 --- a/binaries/data/mods/public/simulation/components/TerritoryDecayManager.js +++ b/binaries/data/mods/public/simulation/components/TerritoryDecayManager.js @@ -20,7 +20,7 @@ TerritoryDecayManager.prototype.Remove = function(ent) TerritoryDecayManager.prototype.SetBlinkingEntities = function() { - for (let ent of this.list.values()) + for (const ent of this.list.values()) Engine.QueryInterface(ent, IID_TerritoryDecay).IsConnected(); }; diff --git a/binaries/data/mods/public/simulation/components/Timer.js b/binaries/data/mods/public/simulation/components/Timer.js index 8d7e785f4c..13ff24e9be 100644 --- a/binaries/data/mods/public/simulation/components/Timer.js +++ b/binaries/data/mods/public/simulation/components/Timer.js @@ -58,7 +58,7 @@ Timer.prototype.SetTimeout = function(ent, iid, funcname, time, data) */ Timer.prototype.SetInterval = function(ent, iid, funcname, time, repeattime, data) { - let id = ++this.id; + const id = ++this.id; this.timers.set(id, { "entity": ent, @@ -81,7 +81,7 @@ Timer.prototype.SetInterval = function(ent, iid, funcname, time, repeattime, dat */ Timer.prototype.UpdateRepeatTime = function(timerID, newRepeatTime) { - let timer = this.timers.get(timerID); + const timer = this.timers.get(timerID); if (timer) this.timers.set(timerID, { "entity": timer.entity, @@ -113,22 +113,22 @@ Timer.prototype.OnUpdate = function(msg) // Collect the timers that need to run // (We do this in two stages to avoid deleting from the timer list while // we're in the middle of iterating through it) - let run = []; + const run = []; this.timers.forEach((timer, id) => { if (timer.time <= this.time) run.push(id); }); - for (let id of run) + for (const id of run) { - let timer = this.timers.get(id); + const timer = this.timers.get(id); // An earlier timer might have cancelled this one, so skip it if (!timer) continue; // The entity was probably destroyed; clean up the timer - let timerTargetComponent = Engine.QueryInterface(timer.entity, timer.iid); + const timerTargetComponent = Engine.QueryInterface(timer.entity, timer.iid); if (!timerTargetComponent) { this.timers.delete(id); diff --git a/binaries/data/mods/public/simulation/components/Trader.js b/binaries/data/mods/public/simulation/components/Trader.js index 32fd8d5b63..682b3e9ae0 100644 --- a/binaries/data/mods/public/simulation/components/Trader.js +++ b/binaries/data/mods/public/simulation/components/Trader.js @@ -30,26 +30,26 @@ Trader.prototype.Init = function() Trader.prototype.CalculateGain = function(currentMarket, nextMarket) { - let cmpMarket = QueryMiragedInterface(currentMarket, IID_Market); - let gain = cmpMarket && cmpMarket.CalculateTraderGain(nextMarket, this.template, this.entity); + const cmpMarket = QueryMiragedInterface(currentMarket, IID_Market); + const gain = cmpMarket && cmpMarket.CalculateTraderGain(nextMarket, this.template, this.entity); if (!gain) // One of our markets must have been destroyed return null; // For garrisonable unit increase gain for each garrisoned trader // Calculate this here to save passing unnecessary stuff into the CalculateTraderGain function - let garrisonGainMultiplier = this.GetGarrisonGainMultiplier(); + const garrisonGainMultiplier = this.GetGarrisonGainMultiplier(); if (garrisonGainMultiplier === undefined) return gain; - let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); + const cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); if (!cmpGarrisonHolder) return gain; let garrisonMultiplier = 1; let garrisonedTradersCount = 0; - for (let entity of cmpGarrisonHolder.GetEntities()) + for (const entity of cmpGarrisonHolder.GetEntities()) { - let cmpGarrisonedUnitTrader = Engine.QueryInterface(entity, IID_Trader); + const cmpGarrisonedUnitTrader = Engine.QueryInterface(entity, IID_Trader); if (cmpGarrisonedUnitTrader) ++garrisonedTradersCount; } @@ -74,7 +74,7 @@ Trader.prototype.RemoveTargetMarket = function(target) { if (this.markets.length != 1 || this.markets[0] != target) return false; - let cmpTargetMarket = QueryMiragedInterface(target, IID_Market); + const cmpTargetMarket = QueryMiragedInterface(target, IID_Market); if (!cmpTargetMarket) return false; cmpTargetMarket.RemoveTrader(this.entity); @@ -87,14 +87,14 @@ Trader.prototype.RemoveTargetMarket = function(target) // Return true if at least one of markets was changed. Trader.prototype.SetTargetMarket = function(target, source) { - let cmpTargetMarket = QueryMiragedInterface(target, IID_Market); + const cmpTargetMarket = QueryMiragedInterface(target, IID_Market); if (!cmpTargetMarket) return false; if (source) { // Establish a trade route with both markets in one go. - let cmpSourceMarket = QueryMiragedInterface(source, IID_Market); + const cmpSourceMarket = QueryMiragedInterface(source, IID_Market); if (!cmpSourceMarket) return false; this.markets = [source]; @@ -103,9 +103,9 @@ Trader.prototype.SetTargetMarket = function(target, source) { // If we already have both markets - drop them // and use the target as first market - for (let market of this.markets) + for (const market of this.markets) { - let cmpMarket = QueryMiragedInterface(market, IID_Market); + const cmpMarket = QueryMiragedInterface(market, IID_Market); if (cmpMarket) cmpMarket.RemoveTrader(this.entity); } @@ -188,11 +188,11 @@ Trader.prototype.CanTrade = function(target) Trader.prototype.AddResources = function(ent, gain) { - let cmpPlayer = QueryOwnerInterface(ent); + const cmpPlayer = QueryOwnerInterface(ent); if (cmpPlayer) cmpPlayer.AddResource(this.goods.type, gain); - let cmpStatisticsTracker = QueryOwnerInterface(ent, IID_StatisticsTracker); + const cmpStatisticsTracker = QueryOwnerInterface(ent, IID_StatisticsTracker); if (cmpStatisticsTracker) cmpStatisticsTracker.IncreaseTradeIncomeCounter(gain); }; @@ -210,7 +210,7 @@ Trader.prototype.GenerateResources = function(currentMarket, nextMarket) Trader.prototype.PerformTrade = function(currentMarket) { - let previousMarket = this.markets[this.index]; + const previousMarket = this.markets[this.index]; if (previousMarket != currentMarket) // Inconsistent markets { this.goods.amount = null; @@ -218,12 +218,12 @@ Trader.prototype.PerformTrade = function(currentMarket) } this.index = ++this.index % this.markets.length; - let nextMarket = this.markets[this.index]; + const nextMarket = this.markets[this.index]; if (this.goods.amount && this.goods.amount.traderGain) this.GenerateResources(previousMarket, nextMarket); - let cmpPlayer = QueryOwnerInterface(this.entity); + const cmpPlayer = QueryOwnerInterface(this.entity); if (!cmpPlayer) return INVALID_ENTITY; @@ -251,11 +251,11 @@ Trader.prototype.HasMarket = function(market) */ Trader.prototype.RemoveMarket = function(market) { - let index = this.markets.indexOf(market); + const index = this.markets.indexOf(market); if (index == -1) return; this.markets.splice(index, 1); - let cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); + const cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); if (cmpUnitAI) cmpUnitAI.MarketRemoved(market); }; @@ -265,20 +265,20 @@ Trader.prototype.RemoveMarket = function(market) */ Trader.prototype.SwitchMarket = function(oldMarket, newMarket) { - let index = this.markets.indexOf(oldMarket); + const index = this.markets.indexOf(oldMarket); if (index == -1) return; this.markets[index] = newMarket; - let cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); + const cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); if (cmpUnitAI) cmpUnitAI.SwitchMarketOrder(oldMarket, newMarket); }; Trader.prototype.StopTrading = function() { - for (let market of this.markets) + for (const market of this.markets) { - let cmpMarket = QueryMiragedInterface(market, IID_Market); + const cmpMarket = QueryMiragedInterface(market, IID_Market); if (cmpMarket) cmpMarket.RemoveTrader(this.entity); } @@ -293,7 +293,7 @@ Trader.prototype.StopTrading = function() // to be able to trade with it. Trader.prototype.GetRange = function() { - let cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); + const cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); let max = 1; if (cmpObstruction) max += cmpObstruction.GetSize() * 1.5; diff --git a/binaries/data/mods/public/simulation/components/Treasure.js b/binaries/data/mods/public/simulation/components/Treasure.js index a61454e102..ac42931050 100644 --- a/binaries/data/mods/public/simulation/components/Treasure.js +++ b/binaries/data/mods/public/simulation/components/Treasure.js @@ -23,9 +23,9 @@ Treasure.prototype.Init = function() Treasure.prototype.ComputeReward = function() { - for (let resource in this.template.Resources) + for (const resource in this.template.Resources) { - let amount = ApplyValueModificationsToEntity("Treasure/Resources/" + resource, this.template.Resources[resource], this.entity); + const amount = ApplyValueModificationsToEntity("Treasure/Resources/" + resource, this.template.Resources[resource], this.entity); if (!amount) continue; if (!this.resources) @@ -59,22 +59,22 @@ Treasure.prototype.Reward = function(entity) if (this.isTaken) return false; - let cmpPlayer = QueryOwnerInterface(entity); + const cmpPlayer = QueryOwnerInterface(entity); if (!cmpPlayer) return false; - let cmpFogging = Engine.QueryInterface(this.entity, IID_Fogging); + const cmpFogging = Engine.QueryInterface(this.entity, IID_Fogging); if (cmpFogging) cmpFogging.Activate(); if (this.resources) cmpPlayer.AddResources(this.resources); - let cmpStatisticsTracker = QueryOwnerInterface(entity, IID_StatisticsTracker); + const cmpStatisticsTracker = QueryOwnerInterface(entity, IID_StatisticsTracker); if (cmpStatisticsTracker) cmpStatisticsTracker.IncreaseTreasuresCollectedCounter(); - let cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); + const cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); cmpTrigger.CallEvent("OnTreasureCollected", { "player": cmpPlayer.GetPlayerID(), "treasure": this.entity diff --git a/binaries/data/mods/public/simulation/components/TreasureCollector.js b/binaries/data/mods/public/simulation/components/TreasureCollector.js index 940a7cbfee..80f958b928 100644 --- a/binaries/data/mods/public/simulation/components/TreasureCollector.js +++ b/binaries/data/mods/public/simulation/components/TreasureCollector.js @@ -27,7 +27,7 @@ TreasureCollector.prototype.GetRange = function() */ TreasureCollector.prototype.CanCollect = function(target) { - let cmpTreasure = Engine.QueryInterface(target, IID_Treasure); + const cmpTreasure = Engine.QueryInterface(target, IID_Treasure); return cmpTreasure && cmpTreasure.IsAvailable(); }; @@ -42,11 +42,11 @@ TreasureCollector.prototype.StartCollecting = function(target, callerIID) if (this.target) this.StopCollecting(); - let cmpTreasure = Engine.QueryInterface(target, IID_Treasure); + const cmpTreasure = Engine.QueryInterface(target, IID_Treasure); if (!cmpTreasure || !cmpTreasure.IsAvailable()) return false; - let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); + const cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); if (cmpVisual) cmpVisual.SelectAnimation("collecting_treasure", false, 1.0); @@ -54,7 +54,7 @@ TreasureCollector.prototype.StartCollecting = function(target, callerIID) this.callerIID = callerIID; // ToDo: Implement rate modifiers. - let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + const cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); this.timer = cmpTimer.SetTimeout(this.entity, IID_TreasureCollector, "CollectTreasure", cmpTreasure.CollectionTime(), null); return true; @@ -68,24 +68,24 @@ TreasureCollector.prototype.StopCollecting = function(reason) if (!this.target) return; - let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + const cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); cmpTimer.CancelTimer(this.timer); delete this.timer; delete this.target; - let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); + const cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); if (cmpVisual) cmpVisual.SelectAnimation("idle", false, 1.0); // The callerIID component may start again, // replacing the callerIID, hence save that. - let callerIID = this.callerIID; + const callerIID = this.callerIID; delete this.callerIID; if (reason && callerIID) { - let component = Engine.QueryInterface(this.entity, callerIID); + const component = Engine.QueryInterface(this.entity, callerIID); if (component) component.ProcessMessage(reason, null); } @@ -96,7 +96,7 @@ TreasureCollector.prototype.StopCollecting = function(reason) */ TreasureCollector.prototype.CollectTreasure = function(data, lateness) { - let cmpTreasure = Engine.QueryInterface(this.target, IID_Treasure); + const cmpTreasure = Engine.QueryInterface(this.target, IID_Treasure); if (!cmpTreasure || !cmpTreasure.IsAvailable()) { this.StopCollecting("TargetInvalidated"); @@ -119,8 +119,8 @@ TreasureCollector.prototype.CollectTreasure = function(data, lateness) */ TreasureCollector.prototype.IsTargetInRange = function(target) { - let range = this.GetRange(); - let cmpObstructionManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ObstructionManager); + const range = this.GetRange(); + const cmpObstructionManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ObstructionManager); return cmpObstructionManager.IsInTargetRange(this.entity, target, range.min, range.max, false); }; diff --git a/binaries/data/mods/public/simulation/components/TurretHolder.js b/binaries/data/mods/public/simulation/components/TurretHolder.js index 7dbc47c0d3..f2905c0aca 100644 --- a/binaries/data/mods/public/simulation/components/TurretHolder.js +++ b/binaries/data/mods/public/simulation/components/TurretHolder.js @@ -8,8 +8,8 @@ class TurretHolder { this.turretPoints = []; - let points = this.template.TurretPoints; - for (let point in points) + const points = this.template.TurretPoints; + for (const point in points) this.turretPoints.push({ "name": point, "offset": { @@ -88,7 +88,7 @@ class TurretHolder if (!turretPoint.allowedClasses) return true; - let cmpIdentity = Engine.QueryInterface(entity, IID_Identity); + const cmpIdentity = Engine.QueryInterface(entity, IID_Identity); return cmpIdentity && MatchesClassList(cmpIdentity.GetClassesList(), turretPoint.allowedClasses); } @@ -110,11 +110,11 @@ class TurretHolder */ OccupyTurretPoint(entity, requestedTurretPoint) { - let cmpPositionOccupant = Engine.QueryInterface(entity, IID_Position); + const cmpPositionOccupant = Engine.QueryInterface(entity, IID_Position); if (!cmpPositionOccupant) return false; - let cmpPositionSelf = Engine.QueryInterface(this.entity, IID_Position); + const cmpPositionSelf = Engine.QueryInterface(this.entity, IID_Position); if (!cmpPositionSelf) return false; @@ -234,7 +234,7 @@ class TurretHolder */ GetOccupiedTurretPointName(entity) { - let turret = this.GetOccupiedTurretPoint(entity); + const turret = this.GetOccupiedTurretPoint(entity); return turret ? turret.name : ""; } @@ -243,8 +243,8 @@ class TurretHolder */ GetEntities() { - let entities = []; - for (let turretPoint of this.turretPoints) + const entities = []; + for (const turretPoint of this.turretPoints) if (turretPoint.entity) entities.push(turretPoint.entity); return entities; @@ -274,7 +274,7 @@ class TurretHolder { if (!this.template.Pickup || this.IsFull()) return false; - let cmpOwner = Engine.QueryInterface(this.entity, IID_Ownership); + const cmpOwner = Engine.QueryInterface(this.entity, IID_Ownership); return !!cmpOwner && IsOwnedByPlayer(cmpOwner.GetOwner(), ent); } @@ -283,13 +283,13 @@ class TurretHolder */ EjectOrKill(entities) { - let removedEntities = []; - for (let entity of entities) + const removedEntities = []; + for (const entity of entities) { - let cmpTurretable = Engine.QueryInterface(entity, IID_Turretable); + const cmpTurretable = Engine.QueryInterface(entity, IID_Turretable); if (!cmpTurretable || !cmpTurretable.LeaveTurret(true)) { - let cmpHealth = Engine.QueryInterface(entity, IID_Health); + const cmpHealth = Engine.QueryInterface(entity, IID_Health); if (cmpHealth) cmpHealth.Kill(); else @@ -331,13 +331,13 @@ class TurretHolder if (msg.entity == this.entity) { - let cmpTurretHolder = Engine.QueryInterface(msg.newentity, IID_TurretHolder); + const cmpTurretHolder = Engine.QueryInterface(msg.newentity, IID_TurretHolder); if (cmpTurretHolder) cmpTurretHolder.initTurrets = this.initTurrets; } else { - let entityIndex = this.initTurrets.indexOf(msg.entity); + const entityIndex = this.initTurrets.indexOf(msg.entity); if (entityIndex != -1) this.initTurrets[entityIndex] = msg.newentity; } @@ -351,9 +351,9 @@ class TurretHolder if (!this.initTurrets) return; - for (let [turretPointName, entity] of this.initTurrets) + for (const [turretPointName, entity] of this.initTurrets) { - let cmpTurretable = Engine.QueryInterface(entity, IID_Turretable); + const cmpTurretable = Engine.QueryInterface(entity, IID_Turretable); if (!cmpTurretable || !cmpTurretable.OccupyTurret(this.entity, turretPointName, this.TurretPointByName(turretPointName).ejectable)) warn("Entity " + entity + " could not occupy the turret point " + turretPointName + " of turret holder " + this.entity + "."); @@ -367,12 +367,12 @@ class TurretHolder */ OnEntityRenamed(msg) { - for (let entity of this.GetEntities()) + for (const entity of this.GetEntities()) { - let cmpTurretable = Engine.QueryInterface(entity, IID_Turretable); + const cmpTurretable = Engine.QueryInterface(entity, IID_Turretable); if (!cmpTurretable) continue; - let currentPoint = this.GetOccupiedTurretPointName(entity); + const currentPoint = this.GetOccupiedTurretPointName(entity); cmpTurretable.LeaveTurret(true); cmpTurretable.OccupyTurret(msg.newentity, currentPoint); } @@ -389,7 +389,7 @@ class TurretHolder return; } - for (let point of this.turretPoints) + for (const point of this.turretPoints) { // If we were created, create any subunits now. // This has to be done here (instead of on Init) @@ -403,13 +403,13 @@ class TurretHolder continue; if (!point.ejectable) { - let cmpTurretOwnership = Engine.QueryInterface(point.entity, IID_Ownership); + const cmpTurretOwnership = Engine.QueryInterface(point.entity, IID_Ownership); if (cmpTurretOwnership) cmpTurretOwnership.SetOwner(msg.to); } else if (!IsOwnedByMutualAllyOfEntity(point.entity, this.entity)) { - let cmpTurretable = Engine.QueryInterface(point.entity, IID_Turretable); + const cmpTurretable = Engine.QueryInterface(point.entity, IID_Turretable); if (cmpTurretable) cmpTurretable.LeaveTurret(); } diff --git a/binaries/data/mods/public/simulation/components/Turretable.js b/binaries/data/mods/public/simulation/components/Turretable.js index 2491c10d0f..f3e96d5a8f 100644 --- a/binaries/data/mods/public/simulation/components/Turretable.js +++ b/binaries/data/mods/public/simulation/components/Turretable.js @@ -14,7 +14,7 @@ Turretable.prototype.Init = function() */ Turretable.prototype.GetRange = function(type, target) { - let cmpTurretHolder = Engine.QueryInterface(target, IID_TurretHolder); + const cmpTurretHolder = Engine.QueryInterface(target, IID_TurretHolder); return cmpTurretHolder ? cmpTurretHolder.LoadingRange() : { "min": 0, "max": 1 }; }; @@ -51,7 +51,7 @@ Turretable.prototype.CanOccupy = function(target) if (this.holder) return false; - let cmpTurretHolder = Engine.QueryInterface(target, IID_TurretHolder); + const cmpTurretHolder = Engine.QueryInterface(target, IID_TurretHolder); return cmpTurretHolder && cmpTurretHolder.CanOccupy(this.entity); }; @@ -67,23 +67,23 @@ Turretable.prototype.OccupyTurret = function(target, turretPointName = "", eject if (!this.CanOccupy(target)) return false; - let cmpTurretHolder = Engine.QueryInterface(target, IID_TurretHolder); + const cmpTurretHolder = Engine.QueryInterface(target, IID_TurretHolder); if (!cmpTurretHolder || !cmpTurretHolder.OccupyNamedTurretPoint(this.entity, turretPointName)) return false; this.holder = target; this.ejectable = ejectable; - let cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); + const cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); if (cmpUnitAI) cmpUnitAI.SetTurretStance(); - let cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion); + const cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion); if (cmpUnitMotion) cmpUnitMotion.SetFacePointAfterMove(false); // Remove the unit's obstruction to avoid interfering with pathing. - let cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); + const cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); if (cmpObstruction) cmpObstruction.SetActive(false); @@ -107,31 +107,31 @@ Turretable.prototype.LeaveTurret = function(forced = false) if (!this.ejectable && !forced) return false; - let pos = PositionHelper.GetSpawnPosition(this.holder, this.entity, forced); + const pos = PositionHelper.GetSpawnPosition(this.holder, this.entity, forced); if (!pos) return false; - let cmpTurretHolder = Engine.QueryInterface(this.holder, IID_TurretHolder); + const cmpTurretHolder = Engine.QueryInterface(this.holder, IID_TurretHolder); if (!cmpTurretHolder || !cmpTurretHolder.LeaveTurretPoint(this.entity, forced)) return false; - let cmpUnitMotionEntity = Engine.QueryInterface(this.entity, IID_UnitMotion); + const cmpUnitMotionEntity = Engine.QueryInterface(this.entity, IID_UnitMotion); if (cmpUnitMotionEntity) cmpUnitMotionEntity.SetFacePointAfterMove(true); - let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); + const cmpPosition = Engine.QueryInterface(this.entity, IID_Position); if (cmpPosition) { cmpPosition.SetTurretParent(INVALID_ENTITY, new Vector3D()); cmpPosition.JumpTo(pos.x, pos.z); cmpPosition.SetHeightOffset(0); - let cmpHolderPosition = Engine.QueryInterface(this.holder, IID_Position); + const cmpHolderPosition = Engine.QueryInterface(this.holder, IID_Position); if (cmpHolderPosition) cmpPosition.SetYRotation(cmpHolderPosition.GetPosition().horizAngleTo(pos)); } - let cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); + const cmpUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); if (cmpUnitAI) { cmpUnitAI.Ungarrison(); @@ -139,7 +139,7 @@ Turretable.prototype.LeaveTurret = function(forced = false) } // Reset the obstruction flags to template defaults. - let cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); + const cmpObstruction = Engine.QueryInterface(this.entity, IID_Obstruction); if (cmpObstruction) cmpObstruction.SetActive(true); @@ -148,7 +148,7 @@ Turretable.prototype.LeaveTurret = function(forced = false) "holderID": INVALID_ENTITY }); - let cmpRallyPoint = Engine.QueryInterface(this.holder, IID_RallyPoint); + const cmpRallyPoint = Engine.QueryInterface(this.holder, IID_RallyPoint); // Need to delete this before ordering to a rally // point else we may not occupy another turret point. @@ -166,14 +166,14 @@ Turretable.prototype.OnEntityRenamed = function(msg) if (!this.holder) return; - let cmpTurretHolder = Engine.QueryInterface(this.holder, IID_TurretHolder); + const cmpTurretHolder = Engine.QueryInterface(this.holder, IID_TurretHolder); if (!cmpTurretHolder) return; - let holder = this.holder; - let currentPoint = cmpTurretHolder.GetOccupiedTurretPointName(this.entity); + const holder = this.holder; + const currentPoint = cmpTurretHolder.GetOccupiedTurretPointName(this.entity); this.LeaveTurret(true); - let cmpTurretableNew = Engine.QueryInterface(msg.newentity, IID_Turretable); + const cmpTurretableNew = Engine.QueryInterface(msg.newentity, IID_Turretable); if (cmpTurretableNew) cmpTurretableNew.OccupyTurret(holder, currentPoint); }; diff --git a/binaries/data/mods/public/simulation/components/UnitMotionFlying.js b/binaries/data/mods/public/simulation/components/UnitMotionFlying.js index f44ec91176..4f02fda024 100644 --- a/binaries/data/mods/public/simulation/components/UnitMotionFlying.js +++ b/binaries/data/mods/public/simulation/components/UnitMotionFlying.js @@ -65,16 +65,16 @@ UnitMotionFlying.prototype.Init = function() UnitMotionFlying.prototype.OnUpdate = function(msg) { - let turnLength = msg.turnLength; + const turnLength = msg.turnLength; if (!this.hasTarget) return; - let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); - let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); - let pos = cmpPosition.GetPosition(); - let angle = cmpPosition.GetRotation().y; - let cmpTerrain = Engine.QueryInterface(SYSTEM_ENTITY, IID_Terrain); - let cmpWaterManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_WaterManager); - let ground = Math.max(cmpTerrain.GetGroundLevel(pos.x, pos.z), cmpWaterManager.GetWaterLevel(pos.x, pos.z)); + const cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); + const cmpPosition = Engine.QueryInterface(this.entity, IID_Position); + const pos = cmpPosition.GetPosition(); + const angle = cmpPosition.GetRotation().y; + const cmpTerrain = Engine.QueryInterface(SYSTEM_ENTITY, IID_Terrain); + const cmpWaterManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_WaterManager); + const ground = Math.max(cmpTerrain.GetGroundLevel(pos.x, pos.z), cmpWaterManager.GetWaterLevel(pos.x, pos.z)); let newangle = angle; let canTurn = true; let distanceToTargetSquared = Math.euclidDistance2DSquared(pos.x, pos.z, this.targetX, this.targetZ); @@ -99,7 +99,7 @@ UnitMotionFlying.prototype.OnUpdate = function(msg) } else if (this.speed == 0 && this.onGround) { - let cmpHealth = Engine.QueryInterface(this.entity, IID_Health); + const cmpHealth = Engine.QueryInterface(this.entity, IID_Health); if (this.waterDeath && cmpHealth) cmpHealth.Kill(); else @@ -112,14 +112,14 @@ UnitMotionFlying.prototype.OnUpdate = function(msg) this.hasTarget = false; this.landing = false; // Summon planes back from the edge of the map. - let terrainSize = cmpTerrain.GetMapSize(); - let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); + const terrainSize = cmpTerrain.GetMapSize(); + const cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); if (cmpRangeManager.GetLosCircular()) { - let mapRadius = terrainSize/2; - let x = pos.x - mapRadius; - let z = pos.z - mapRadius; - let div = (mapRadius - 12) / Math.sqrt(x*x + z*z); + const mapRadius = terrainSize/2; + const x = pos.x - mapRadius; + const z = pos.z - mapRadius; + const div = (mapRadius - 12) / Math.sqrt(x*x + z*z); if (div < 1) { pos.x = mapRadius + x*div; @@ -143,13 +143,13 @@ UnitMotionFlying.prototype.OnUpdate = function(msg) // We need to slow down to land! this.speed = Math.max(this.template.LandingSpeed, this.speed - turnLength * this.template.SlowingRate); canTurn = false; - let targetHeight = ground; + const targetHeight = ground; // Steep, then gradual descent. if ((pos.y - targetHeight) / this.template.FlyingHeight > 1 / SHORT_FINAL) this.pitch = -Math.PI / 18; else this.pitch = Math.PI / 18; - let descentRate = ((pos.y - targetHeight) / this.template.FlyingHeight * this.template.ClimbRate + SHORT_FINAL) * SHORT_FINAL; + const descentRate = ((pos.y - targetHeight) / this.template.FlyingHeight * this.template.ClimbRate + SHORT_FINAL) * SHORT_FINAL; if (pos.y < targetHeight) pos.y = Math.max(targetHeight, pos.y + turnLength * descentRate); else if (pos.y > targetHeight) @@ -197,7 +197,7 @@ UnitMotionFlying.prototype.OnUpdate = function(msg) this.onGround = false; // Climb/sink to max height above ground. this.speed = Math.min(this.template.MaxSpeed, this.speed + turnLength * this.template.AccelRate); - let targetHeight = ground + (+this.template.FlyingHeight); + const targetHeight = ground + (+this.template.FlyingHeight); if (Math.abs(pos.y-targetHeight) > this.template.FlyingHeight/5) { this.pitch = Math.PI / 9; @@ -227,7 +227,7 @@ UnitMotionFlying.prototype.OnUpdate = function(msg) // If we're facing away from the target, and are still fairly close to it, // then carry on going straight so we overshoot in a straight line. - let isBehindTarget = ((this.targetX - pos.x) * Math.sin(angle) + (this.targetZ - pos.z) * Math.cos(angle) < 0); + const isBehindTarget = ((this.targetX - pos.x) * Math.sin(angle) + (this.targetZ - pos.z) * Math.cos(angle) < 0); // Overshoot the target: carry on straight. if (isBehindTarget && distanceToTargetSquared < this.template.MaxSpeed * this.template.MaxSpeed * this.template.OvershootTime * this.template.OvershootTime) canTurn = false; @@ -235,7 +235,7 @@ UnitMotionFlying.prototype.OnUpdate = function(msg) if (canTurn) { // Turn towards the target. - let targetAngle = Math.atan2(this.targetX - pos.x, this.targetZ - pos.z); + const targetAngle = Math.atan2(this.targetX - pos.x, this.targetZ - pos.z); let delta = targetAngle - angle; // Wrap delta to -pi..pi. delta = (delta + Math.PI) % (2*Math.PI); @@ -243,7 +243,7 @@ UnitMotionFlying.prototype.OnUpdate = function(msg) delta += 2 * Math.PI; delta -= Math.PI; // Clamp to max rate. - let deltaClamped = Math.min(Math.max(delta, -this.template.TurnRate * turnLength), this.template.TurnRate * turnLength); + const deltaClamped = Math.min(Math.max(delta, -this.template.TurnRate * turnLength), this.template.TurnRate * turnLength); // Calculate new orientation, in a peculiar way in order to make sure the // result gets close to targetAngle (rather than being n*2*pi out). newangle = targetAngle + deltaClamped - delta; @@ -280,11 +280,11 @@ UnitMotionFlying.prototype.MoveToPointRange = function(x, z, minRange, maxRange) UnitMotionFlying.prototype.MoveToTargetRange = function(target, minRange, maxRange) { - let cmpTargetPosition = Engine.QueryInterface(target, IID_Position); + const cmpTargetPosition = Engine.QueryInterface(target, IID_Position); if (!cmpTargetPosition || !cmpTargetPosition.IsInWorld()) return false; - let targetPos = cmpTargetPosition.GetPosition2D(); + const targetPos = cmpTargetPosition.GetPosition2D(); this.hasTarget = true; this.reachedTarget = false; @@ -327,10 +327,10 @@ UnitMotionFlying.prototype.GetRunMultiplier = function() */ UnitMotionFlying.prototype.EstimateFuturePosition = function(dt) { - let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); + const cmpPosition = Engine.QueryInterface(this.entity, IID_Position); if (!cmpPosition || !cmpPosition.IsInWorld()) return Vector2D(); - let position = cmpPosition.GetPosition2D(); + const position = cmpPosition.GetPosition2D(); return Vector2D.add(position, Vector2D.sub(position, cmpPosition.GetPreviousPosition2D()).mult(dt/Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer).GetLatestTurnLength())); }; diff --git a/binaries/data/mods/public/simulation/components/Upgrade.js b/binaries/data/mods/public/simulation/components/Upgrade.js index b89074494d..282c4be689 100644 --- a/binaries/data/mods/public/simulation/components/Upgrade.js +++ b/binaries/data/mods/public/simulation/components/Upgrade.js @@ -95,8 +95,8 @@ Upgrade.prototype.ChangeUpgradedEntityCount = function(amount) if (!this.IsUpgrading()) return; - let cmpTempMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); - let template = cmpTempMan.GetTemplate(this.upgrading); + const cmpTempMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); + const template = cmpTempMan.GetTemplate(this.upgrading); let categoryTo; if (template.TrainingRestrictions) @@ -108,8 +108,8 @@ Upgrade.prototype.ChangeUpgradedEntityCount = function(amount) return; let categoryFrom; - let cmpTrainingRestrictions = Engine.QueryInterface(this.entity, IID_TrainingRestrictions); - let cmpBuildRestrictions = Engine.QueryInterface(this.entity, IID_BuildRestrictions); + const cmpTrainingRestrictions = Engine.QueryInterface(this.entity, IID_TrainingRestrictions); + const cmpBuildRestrictions = Engine.QueryInterface(this.entity, IID_BuildRestrictions); if (cmpTrainingRestrictions) categoryFrom = cmpTrainingRestrictions.GetCategory(); else if (cmpBuildRestrictions) @@ -118,7 +118,7 @@ Upgrade.prototype.ChangeUpgradedEntityCount = function(amount) if (categoryTo == categoryFrom) return; - let cmpEntityLimits = QueryPlayerIDInterface(this.owner, IID_EntityLimits); + const cmpEntityLimits = QueryPlayerIDInterface(this.owner, IID_EntityLimits); if (cmpEntityLimits) cmpEntityLimits.ChangeCount(categoryTo, amount); }; @@ -130,7 +130,7 @@ Upgrade.prototype.CanUpgradeTo = function(template) Upgrade.prototype.GetUpgrades = function() { - let ret = []; + const ret = []; for (const option in this.upgradeTemplates) { @@ -142,7 +142,7 @@ Upgrade.prototype.GetUpgrades = function() if (choice.Time) cost.time = this.GetUpgradeTime(option); - let hasCost = choice.Cost || choice.Time; + const hasCost = choice.Cost || choice.Time; ret.push({ "entity": option, "icon": choice.Icon || undefined, @@ -160,7 +160,7 @@ Upgrade.prototype.CancelTimer = function() if (!this.timer) return; - let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + const cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); cmpTimer.CancelTimer(this.timer); delete this.timer; }; @@ -186,7 +186,7 @@ Upgrade.prototype.WillCheckPlacementRestrictions = function(template) Upgrade.prototype.GetRequirements = function(templateArg) { - let choice = this.upgradeTemplates[templateArg] || templateArg; + const choice = this.upgradeTemplates[templateArg] || templateArg; if (this.template[choice].Requirements) return this.template[choice].Requirements; @@ -194,14 +194,14 @@ Upgrade.prototype.GetRequirements = function(templateArg) if (!("Requirements" in this.template[choice])) return undefined; - let cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); - let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); + const cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); + const cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); let entType = this.template[choice].Entity; if (cmpIdentity) entType = entType.replace(/\{civ\}/g, cmpIdentity.GetCiv()); - let template = cmpTemplateManager.GetTemplate(entType); + const template = cmpTemplateManager.GetTemplate(entType); return template.Identity.Requirements || undefined; }; @@ -213,12 +213,12 @@ Upgrade.prototype.GetResourceCosts = function(template) if (this.IsUpgrading() && template == this.GetUpgradingTo()) return clone(this.expendedResources); - let choice = this.upgradeTemplates[template]; + const choice = this.upgradeTemplates[template]; if (!this.template[choice].Cost) return {}; - let costs = {}; - for (let r in this.template[choice].Cost) + const costs = {}; + for (const r in this.template[choice].Cost) costs[r] = ApplyValueModificationsToEntity("Upgrade/Cost/"+r, +this.template[choice].Cost[r], this.entity); return costs; @@ -229,14 +229,14 @@ Upgrade.prototype.Upgrade = function(template) if (this.IsUpgrading() || !this.upgradeTemplates[template]) return false; - let cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); + const cmpPlayer = QueryOwnerInterface(this.entity, IID_Player); if (!cmpPlayer) return false; - let cmpProductionQueue = Engine.QueryInterface(this.entity, IID_ProductionQueue); + const cmpProductionQueue = Engine.QueryInterface(this.entity, IID_ProductionQueue); if (cmpProductionQueue && cmpProductionQueue.HasQueuedProduction()) { - let cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); + const cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); cmpGUIInterface.PushNotification({ "players": [cmpPlayer.GetPlayerID()], "message": markForTranslation("Entity is producing. Cannot start upgrading."), @@ -260,7 +260,7 @@ Upgrade.prototype.Upgrade = function(template) if (this.GetUpgradeTime(template) !== 0) { - let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + const cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); this.timer = cmpTimer.SetInterval(this.entity, IID_Upgrade, "UpgradeProgress", 0, UPGRADING_PROGRESS_INTERVAL, { "upgrading": template }); } else @@ -274,7 +274,7 @@ Upgrade.prototype.CancelUpgrade = function(owner) if (!this.IsUpgrading()) return; - let cmpPlayer = QueryPlayerIDInterface(owner, IID_Player); + const cmpPlayer = QueryPlayerIDInterface(owner, IID_Player); if (cmpPlayer) cmpPlayer.AddResources(this.expendedResources); @@ -282,10 +282,10 @@ Upgrade.prototype.CancelUpgrade = function(owner) this.ChangeUpgradedEntityCount(-1); // Do not update visual actor if the animation didn't change. - let choice = this.upgradeTemplates[this.upgrading]; + const choice = this.upgradeTemplates[this.upgrading]; if (choice && this.template[choice].Variant) { - let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); + const cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); if (cmpVisual) cmpVisual.SelectAnimation("idle", false, 1.0); } @@ -297,8 +297,8 @@ Upgrade.prototype.CancelUpgrade = function(owner) Upgrade.prototype.GetUpgradeTime = function(templateArg) { - let template = this.upgrading || templateArg; - let choice = this.upgradeTemplates[template]; + const template = this.upgrading || templateArg; + const choice = this.upgradeTemplates[template]; if (!choice) return undefined; @@ -329,12 +329,12 @@ Upgrade.prototype.SetElapsedTime = function(time) Upgrade.prototype.SetUpgradeAnimationVariant = function() { - let choice = this.upgradeTemplates[this.upgrading]; + const choice = this.upgradeTemplates[this.upgrading]; if (!choice || !this.template[choice].Variant) return; - let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); + const cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); if (!cmpVisual) return; @@ -355,7 +355,7 @@ Upgrade.prototype.UpgradeProgress = function(data, lateness) this.ChangeUpgradedEntityCount(-1); this.expendedResources = {}; - let newEntity = ChangeEntityTemplate(this.entity, this.upgrading); + const newEntity = ChangeEntityTemplate(this.entity, this.upgrading); if (newEntity) PlaySound("upgraded", newEntity); diff --git a/binaries/data/mods/public/simulation/components/Upkeep.js b/binaries/data/mods/public/simulation/components/Upkeep.js index 5085e7f2ac..c0f03dd917 100644 --- a/binaries/data/mods/public/simulation/components/Upkeep.js +++ b/binaries/data/mods/public/simulation/components/Upkeep.js @@ -38,9 +38,9 @@ Upkeep.prototype.ComputeRates = function() { this.rates = {}; let hasUpkeep = false; - for (let resource in this.template.Rates) + for (const resource in this.template.Rates) { - let rate = ApplyValueModificationsToEntity("Upkeep/Rates/" + resource, +this.template.Rates[resource], this.entity); + const rate = ApplyValueModificationsToEntity("Upkeep/Rates/" + resource, +this.template.Rates[resource], this.entity); if (rate) { this.rates[resource] = rate; @@ -57,7 +57,7 @@ Upkeep.prototype.ComputeRates = function() */ Upkeep.prototype.Pay = function(data, lateness) { - let cmpPlayer = QueryOwnerInterface(this.entity); + const cmpPlayer = QueryOwnerInterface(this.entity); if (!cmpPlayer) return; @@ -75,7 +75,7 @@ Upkeep.prototype.HandleInsufficientUpkeep = function() if (this.unpayed) return; - let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); + const cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); if (cmpIdentity) cmpIdentity.SetControllable(false); this.unpayed = true; @@ -89,7 +89,7 @@ Upkeep.prototype.HandleSufficientUpkeep = function() if (!this.unpayed) return; - let cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); + const cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity); if (cmpIdentity) cmpIdentity.SetControllable(true); delete this.unpayed; @@ -113,17 +113,17 @@ Upkeep.prototype.CheckTimer = function() if (!this.timer) return; - let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + const cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); cmpTimer.CancelTimer(this.timer); delete this.timer; return; } - let oldUpkeepInterval = this.upkeepInterval; + const oldUpkeepInterval = this.upkeepInterval; this.upkeepInterval = ApplyValueModificationsToEntity("Upkeep/Interval", +this.template.Interval, this.entity); if (this.upkeepInterval < 0) { - let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + const cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); cmpTimer.CancelTimer(this.timer); delete this.timer; return; @@ -137,13 +137,13 @@ Upkeep.prototype.CheckTimer = function() // If the timer wasn't invalidated before (interval <= 0), just update it. if (oldUpkeepInterval > 0) { - let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + const cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); cmpTimer.UpdateRepeatTime(this.timer, this.upkeepInterval); return; } } - let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + const cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); this.timer = cmpTimer.SetInterval(this.entity, IID_Upkeep, "Pay", this.upkeepInterval, this.upkeepInterval, undefined); }; diff --git a/binaries/data/mods/public/simulation/components/Visibility.js b/binaries/data/mods/public/simulation/components/Visibility.js index beb97d2d2e..69f8f61907 100644 --- a/binaries/data/mods/public/simulation/components/Visibility.js +++ b/binaries/data/mods/public/simulation/components/Visibility.js @@ -36,7 +36,7 @@ Visibility.prototype.Init = function() */ Visibility.prototype.SetActivated = function(status) { - let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); + const cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); cmpRangeManager.ActivateScriptedVisibility(this.entity, status); this.activated = status; @@ -63,7 +63,7 @@ Visibility.prototype.GetVisibility = function(player, isVisible, isExplored) if (this.preview) { // For the owner only, mock the "RetainInFog" behavior - let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); + const cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); if (cmpOwnership && cmpOwnership.GetOwner() == player && isExplored) return isVisible ? VIS_VISIBLE : VIS_FOGGED; @@ -73,7 +73,7 @@ Visibility.prototype.GetVisibility = function(player, isVisible, isExplored) else if (this.corpse) { // For the owner only, mock the "RetainInFog" behavior - let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); + const cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); if (cmpOwnership && cmpOwnership.GetOwner() == player && isExplored) return isVisible ? VIS_VISIBLE : VIS_FOGGED; diff --git a/binaries/data/mods/public/simulation/components/VisionSharing.js b/binaries/data/mods/public/simulation/components/VisionSharing.js index 072560007f..334fc7793b 100644 --- a/binaries/data/mods/public/simulation/components/VisionSharing.js +++ b/binaries/data/mods/public/simulation/components/VisionSharing.js @@ -31,7 +31,7 @@ VisionSharing.prototype.Activate = function() { if (this.activated) return; - let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); + const cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); if (!cmpOwnership || cmpOwnership.GetOwner() <= 0) return; this.shared = new Set([cmpOwnership.GetOwner()]); @@ -42,10 +42,10 @@ VisionSharing.prototype.Activate = function() VisionSharing.prototype.CheckVisionSharings = function() { - let shared = new Set(); + const shared = new Set(); - let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); - let owner = cmpOwnership ? cmpOwnership.GetOwner() : INVALID_PLAYER; + const cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); + const owner = cmpOwnership ? cmpOwnership.GetOwner() : INVALID_PLAYER; if (owner >= 0) { // The owner has vision @@ -53,15 +53,15 @@ VisionSharing.prototype.CheckVisionSharings = function() shared.add(owner); // Vision sharing due to garrisoned units - let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); + const cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); if (cmpGarrisonHolder) { - for (let ent of cmpGarrisonHolder.GetEntities()) + for (const ent of cmpGarrisonHolder.GetEntities()) { - let cmpEntOwnership = Engine.QueryInterface(ent, IID_Ownership); + const cmpEntOwnership = Engine.QueryInterface(ent, IID_Ownership); if (!cmpEntOwnership) continue; - let entOwner = cmpEntOwnership.GetOwner(); + const entOwner = cmpEntOwnership.GetOwner(); if (entOwner > 0 && entOwner != owner) { shared.add(entOwner); @@ -73,7 +73,7 @@ VisionSharing.prototype.CheckVisionSharings = function() // vision sharing due to spies if (this.spies) - for (let spy of this.spies.values()) + for (const spy of this.spies.values()) if (spy > 0 && spy != owner) shared.add(spy); } @@ -82,11 +82,11 @@ VisionSharing.prototype.CheckVisionSharings = function() return; // compare with previous vision sharing, and update if needed - for (let player of shared) + for (const player of shared) if (!this.shared.has(player)) Engine.PostMessage(this.entity, MT_VisionSharingChanged, { "entity": this.entity, "player": player, "add": true }); - for (let player of this.shared) + for (const player of this.shared) if (!shared.has(player)) Engine.PostMessage(this.entity, MT_VisionSharingChanged, { "entity": this.entity, "player": player, "add": false }); @@ -114,15 +114,15 @@ VisionSharing.prototype.AddSpy = function(player, timeLength) if (!this.IsBribable()) return 0; - let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); + const cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); if (!cmpOwnership || cmpOwnership.GetOwner() == player || player <= 0) return 0; - let cmpTechnologyManager = QueryPlayerIDInterface(player, IID_TechnologyManager); + const cmpTechnologyManager = QueryPlayerIDInterface(player, IID_TechnologyManager); if (!cmpTechnologyManager || !cmpTechnologyManager.CanProduce("special/spy")) return 0; - let template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).GetTemplate("special/spy"); + const template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).GetTemplate("special/spy"); if (!IncurBribeCost(template, player, cmpOwnership.GetOwner(), false)) return 0; @@ -132,7 +132,7 @@ VisionSharing.prototype.AddSpy = function(player, timeLength) if (!duration && template.VisionSharing && template.VisionSharing.Duration) { duration = ApplyValueModificationsToTemplate("VisionSharing/Duration", +template.VisionSharing.Duration, player, template); - let cmpVision = Engine.QueryInterface(this.entity, IID_Vision); + const cmpVision = Engine.QueryInterface(this.entity, IID_Vision); if (cmpVision) duration *= 60 / Math.max(30, cmpVision.GetRange()); } @@ -143,14 +143,14 @@ VisionSharing.prototype.AddSpy = function(player, timeLength) this.spies.set(++this.spyId, player); if (duration) { - let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); + const cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); cmpTimer.SetTimeout(this.entity, IID_VisionSharing, "RemoveSpy", duration * 1000, { "id": this.spyId }); } this.Activate(); this.CheckVisionSharings(); // update statistics for successful bribes - let cmpBribesStatisticsTracker = QueryPlayerIDInterface(player, IID_StatisticsTracker); + const cmpBribesStatisticsTracker = QueryPlayerIDInterface(player, IID_StatisticsTracker); if (cmpBribesStatisticsTracker) cmpBribesStatisticsTracker.IncreaseSuccessfulBribesCounter(); @@ -171,7 +171,7 @@ VisionSharing.prototype.ShareVisionWith = function(player) if (this.activated) return this.shared.has(player); - let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); + const cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); return cmpOwnership && cmpOwnership.GetOwner() == player; };