From 470001dfb96c563cfab76449cd669df16efb73bc Mon Sep 17 00:00:00 2001 From: dnqbob Date: Wed, 12 Jun 2024 09:18:12 +0800 Subject: [PATCH] SupportPower: Check Level before using Level and get crashed --- .../Effects/AirstrikePowerASEffect.cs | 6 +++- .../Traits/SupportPowers/AirstrikePowerRV.cs | 12 ++++--- .../SupportPowers/DetonateWeaponPower.cs | 16 ++++++--- .../Traits/SupportPowers/FireArmamentPower.cs | 6 +++- .../SupportPowers/RA2ChronoshiftPower.cs | 34 +++++++++++++++---- .../Traits/SupportPowers/AirstrikePower.cs | 12 ++++--- .../GrantExternalConditionPower.cs | 18 +++++++--- .../Traits/SupportPowers/NukePower.cs | 8 +++-- .../Traits/SupportPowers/ParatroopersPower.cs | 12 ++++--- .../Traits/SupportPowers/SpawnActorPower.cs | 14 ++++++-- 10 files changed, 105 insertions(+), 33 deletions(-) diff --git a/OpenRA.Mods.AS/Effects/AirstrikePowerASEffect.cs b/OpenRA.Mods.AS/Effects/AirstrikePowerASEffect.cs index 6e13950c6976..46c4ca4bed30 100644 --- a/OpenRA.Mods.AS/Effects/AirstrikePowerASEffect.cs +++ b/OpenRA.Mods.AS/Effects/AirstrikePowerASEffect.cs @@ -33,6 +33,10 @@ public class AirstrikePowerASEffect : IEffect public AirstrikePowerASEffect(World world, Player p, WPos pos, IEnumerable planes, AirstrikePowerAS power, AirstrikePowerASInfo info) { + var level = power.GetLevel(); + if (level == 0) + return; + this.info = info; this.world = world; owner = p; @@ -49,7 +53,7 @@ public AirstrikePowerASEffect(World world, Player p, WPos pos, IEnumerable bp.Key == power.GetLevel()).Value, + info.BeaconPosters.First(bp => bp.Key == level).Value, info.BeaconPosterPalette, info.BeaconSequence, info.ArrowSequence, diff --git a/OpenRA.Mods.AS/Traits/SupportPowers/AirstrikePowerRV.cs b/OpenRA.Mods.AS/Traits/SupportPowers/AirstrikePowerRV.cs index 2bd231a5a76d..1dfa39844665 100644 --- a/OpenRA.Mods.AS/Traits/SupportPowers/AirstrikePowerRV.cs +++ b/OpenRA.Mods.AS/Traits/SupportPowers/AirstrikePowerRV.cs @@ -84,11 +84,15 @@ public override void Activate(Actor self, Order order, SupportPowerManager manag public Actor[] SendAirstrike(Actor self, WPos target, WAngle? facing = null) { + var level = GetLevel(); + if (level == 0) + return Array.Empty(); + var aircraft = new List(); if (!facing.HasValue) facing = new WAngle(1024 * self.World.SharedRandom.Next(info.QuantizedFacings) / info.QuantizedFacings); - var altitude = self.World.Map.Rules.Actors[info.UnitTypes.First(ut => ut.Key == GetLevel()).Value].TraitInfo().CruiseAltitude.Length; + var altitude = self.World.Map.Rules.Actors[info.UnitTypes.First(ut => ut.Key == level).Value].TraitInfo().CruiseAltitude.Length; var attackRotation = WRot.FromYaw(facing.Value); var delta = new WVec(0, -1024, 0).Rotate(attackRotation); target += new WVec(0, 0, altitude); @@ -139,7 +143,7 @@ void OnRemovedFromWorld(Actor a) } // Create the actors immediately so they can be returned - var squadSize = info.SquadSizes.First(ss => ss.Key == GetLevel()).Value; + var squadSize = info.SquadSizes.First(ss => ss.Key == level).Value; for (var i = -squadSize / 2; i <= squadSize / 2; i++) { // Even-sized squads skip the lead plane @@ -150,7 +154,7 @@ void OnRemovedFromWorld(Actor a) var so = info.SquadOffset; var spawnOffset = new WVec(i * so.Y, -Math.Abs(i) * so.X, 0).Rotate(attackRotation); var targetOffset = new WVec(i * so.Y, 0, 0).Rotate(attackRotation); - var a = self.World.CreateActor(false, info.UnitTypes.First(ut => ut.Key == GetLevel()).Value, new TypeDictionary + var a = self.World.CreateActor(false, info.UnitTypes.First(ut => ut.Key == level).Value, new TypeDictionary { new CenterPositionInit(startEdge + spawnOffset), new OwnerInit(self.Owner), @@ -171,7 +175,7 @@ void OnRemovedFromWorld(Actor a) { PlayLaunchSounds(); - var effect = new AirstrikePowerRVEffect(self.World, self.Owner, target, startEdge, finishEdge, attackRotation, altitude, GetLevel(), aircraft.ToArray(), this, info); + var effect = new AirstrikePowerRVEffect(self.World, self.Owner, target, startEdge, finishEdge, attackRotation, altitude, level, aircraft.ToArray(), this, info); self.World.Add(effect); }); diff --git a/OpenRA.Mods.AS/Traits/SupportPowers/DetonateWeaponPower.cs b/OpenRA.Mods.AS/Traits/SupportPowers/DetonateWeaponPower.cs index 6ea7c42c3c52..3691d77ebd3b 100644 --- a/OpenRA.Mods.AS/Traits/SupportPowers/DetonateWeaponPower.cs +++ b/OpenRA.Mods.AS/Traits/SupportPowers/DetonateWeaponPower.cs @@ -99,6 +99,10 @@ public DetonateWeaponPower(Actor self, DetonateWeaponPowerInfo info) public override void Activate(Actor self, Order order, SupportPowerManager manager) { + var level = GetLevel(); + if (level == 0) + return; + base.Activate(self, order, manager); PlayLaunchSounds(); @@ -114,7 +118,7 @@ public override void Activate(Actor self, Order order, SupportPowerManager manag } var targetPosition = order.Target.CenterPosition + new WVec(WDist.Zero, WDist.Zero, Info.AirburstAltitude); - var weapon = Info.WeaponInfos.First(wi => wi.Key == GetLevel()).Value; + var weapon = Info.WeaponInfos.First(wi => wi.Key == level).Value; self.World.AddFrameEndTask(w => w.Add(new DelayedAction(Info.ActivationDelay, () => self.World.AddFrameEndTask(w => weapon.Impact(Target.FromPos(targetPosition), self))))); if (Info.CameraRange != WDist.Zero) @@ -135,7 +139,7 @@ public override void Activate(Actor self, Order order, SupportPowerManager manag Info.BeaconPaletteIsPlayerPalette, Info.BeaconPalette, Info.BeaconImage, - Info.BeaconPosters.First(bp => bp.Key == GetLevel()).Value, + Info.BeaconPosters.First(bp => bp.Key == level).Value, Info.BeaconPosterPalette, Info.BeaconSequence, Info.ArrowSequence, @@ -206,9 +210,13 @@ protected override void Tick(World world) protected override IEnumerable RenderAnnotations(WorldRenderer wr, World world) { + var level = power.GetLevel(); + if (level == 0) + yield break; + var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos); - if (power.Info.TargetCircleRanges == null || power.Info.TargetCircleRanges.Count <= 0 || power.GetLevel() == 0) + if (power.Info.TargetCircleRanges == null || power.Info.TargetCircleRanges.Count <= 0 || level == 0) { yield break; } @@ -216,7 +224,7 @@ protected override IEnumerable RenderAnnotations(WorldRenderer wr, { yield return new RangeCircleAnnotationRenderable( world.Map.CenterOfCell(xy), - power.Info.TargetCircleRanges[power.GetLevel()], + power.Info.TargetCircleRanges[level], 0, power.Info.TargetCircleUsePlayerColor ? power.Self.Owner.Color : power.Info.TargetCircleColor, power.Info.TargetCircleWidth, diff --git a/OpenRA.Mods.AS/Traits/SupportPowers/FireArmamentPower.cs b/OpenRA.Mods.AS/Traits/SupportPowers/FireArmamentPower.cs index 38a9ffa4827e..fb1cacd02eb3 100644 --- a/OpenRA.Mods.AS/Traits/SupportPowers/FireArmamentPower.cs +++ b/OpenRA.Mods.AS/Traits/SupportPowers/FireArmamentPower.cs @@ -149,13 +149,17 @@ void Activation(Actor self, Order order) if (FireArmamentPowerInfo.DisplayBeacon) { + var level = GetLevel(); + if (level == 0) + return; + var beacon = new Beacon( order.Player, target.CenterPosition, FireArmamentPowerInfo.BeaconPaletteIsPlayerPalette, FireArmamentPowerInfo.BeaconPalette, FireArmamentPowerInfo.BeaconImage, - FireArmamentPowerInfo.BeaconPosters.First(bp => bp.Key == GetLevel()).Value, + FireArmamentPowerInfo.BeaconPosters.First(bp => bp.Key == level).Value, FireArmamentPowerInfo.BeaconPosterPalette, FireArmamentPowerInfo.BeaconSequence, FireArmamentPowerInfo.ArrowSequence, diff --git a/OpenRA.Mods.AS/Traits/SupportPowers/RA2ChronoshiftPower.cs b/OpenRA.Mods.AS/Traits/SupportPowers/RA2ChronoshiftPower.cs index e15f536b857e..ed22cc34c145 100644 --- a/OpenRA.Mods.AS/Traits/SupportPowers/RA2ChronoshiftPower.cs +++ b/OpenRA.Mods.AS/Traits/SupportPowers/RA2ChronoshiftPower.cs @@ -128,6 +128,10 @@ public override void SelectTarget(Actor self, string order, SupportPowerManager public override void Activate(Actor self, Order order, SupportPowerManager manager) { + var level = GetLevel(); + if (level == 0) + return; + base.Activate(self, order, manager); var info = (RA2ChronoshiftPowerInfo)Info; @@ -161,7 +165,6 @@ public override void Activate(Actor self, Order order, SupportPowerManager manag var targetDelta = self.World.Map.CellContaining(order.Target.CenterPosition) - order.ExtraLocation; - var level = GetLevel(); var teleportCells = CellsMatching(self.World.Map.CellContaining(order.Target.CenterPosition), footprints.First(f => f.Key == level).Value, dimensions.First(d => d.Key == level).Value).ToList(); foreach (var target in UnitsInRange(order.ExtraLocation)) @@ -179,9 +182,13 @@ public override void Activate(Actor self, Order order, SupportPowerManager manag public IEnumerable UnitsInRange(CPos xy) { + var units = new HashSet(); var level = GetLevel(); + if (level == 0) + return units; + var tiles = CellsMatching(xy, footprints.First(f => f.Key == level).Value, dimensions.First(d => d.Key == level).Value); - var units = new HashSet(); + foreach (var t in tiles) units.UnionWith(Self.World.ActorMap.GetActorsAt(t)); @@ -190,10 +197,13 @@ public IEnumerable UnitsInRange(CPos xy) public bool SimilarTerrain(CPos xy, CPos sourceLocation) { + var level = GetLevel(); + if (level == 0) + return false; + if (!Self.Owner.Shroud.IsExplored(xy)) return false; - var level = GetLevel(); var footprint = footprints.First(f => f.Key == level).Value; var dimension = dimensions.First(f => f.Key == level).Value; var sourceTiles = CellsMatching(xy, footprint, dimension); @@ -285,8 +295,12 @@ protected override IEnumerable RenderAnnotations(WorldRenderer wr, protected override IEnumerable Render(WorldRenderer wr, World world) { - var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos); var level = power.GetLevel(); + if (level == 0) + yield break; + + var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos); + var tiles = power.CellsMatching(xy, footprints.First(f => f.Key == level).Value, dimensions.First(d => d.Key == level).Value); var palette = wr.Palette(((RA2ChronoshiftPowerInfo)power.Info).TargetOverlayPalette); foreach (var t in tiles) @@ -398,12 +412,16 @@ protected override void Tick(World world) protected override IEnumerable RenderAboveShroud(WorldRenderer wr, World world) { + var level = power.GetLevel(); + if (level == 0) + yield break; + var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos); var palette = wr.Palette(power.Info.IconPalette); // Destination tiles var delta = xy - sourceLocation; - var level = power.GetLevel(); + foreach (var t in power.CellsMatching(sourceLocation, footprints.First(f => f.Key == level).Value, dimensions.First(d => d.Key == level).Value)) { var isValid = manager.Self.Owner.Shroud.IsExplored(t + delta); @@ -450,6 +468,10 @@ protected override IEnumerable RenderAnnotations(WorldRenderer wr, protected override IEnumerable Render(WorldRenderer wr, World world) { + var level = power.GetLevel(); + if (level == 0) + yield break; + if (overlay != null) { var powerInfo = (RA2ChronoshiftPowerInfo)power.Info; @@ -459,7 +481,7 @@ protected override IEnumerable Render(WorldRenderer wr, World world // Source tiles var palette = wr.Palette(power.Info.IconPalette); - var level = power.GetLevel(); + foreach (var t in power.CellsMatching(sourceLocation, footprints.First(f => f.Key == level).Value, dimensions.First(d => d.Key == level).Value)) yield return new SpriteRenderable(sourceTile, wr.World.Map.CenterOfCell(t), WVec.Zero, -511, palette, 1f, sourceAlpha, float3.Ones, TintModifiers.IgnoreWorldTint, true); } diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/AirstrikePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/AirstrikePower.cs index ae03d93a7dd2..62d33b78d810 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/AirstrikePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/AirstrikePower.cs @@ -65,11 +65,15 @@ public override void Activate(Actor self, Order order, SupportPowerManager manag public Actor[] SendAirstrike(Actor self, WPos target, WAngle? facing = null) { + var level = GetLevel(); + if (level == 0) + return Array.Empty(); + var aircraft = new List(); if (!facing.HasValue) facing = new WAngle(1024 * self.World.SharedRandom.Next(info.QuantizedFacings) / info.QuantizedFacings); - var altitude = self.World.Map.Rules.Actors[info.UnitTypes.First(ut => ut.Key == GetLevel()).Value].TraitInfo().CruiseAltitude.Length; + var altitude = self.World.Map.Rules.Actors[info.UnitTypes.First(ut => ut.Key == level).Value].TraitInfo().CruiseAltitude.Length; var attackRotation = WRot.FromYaw(facing.Value); var delta = new WVec(0, -1024, 0).Rotate(attackRotation); target += new WVec(0, 0, altitude); @@ -124,7 +128,7 @@ void OnRemovedFromWorld(Actor a) } // Create the actors immediately so they can be returned - var squadSize = info.SquadSizes.First(ss => ss.Key == GetLevel()).Value; + var squadSize = info.SquadSizes.First(ss => ss.Key == level).Value; for (var i = -squadSize / 2; i <= squadSize / 2; i++) { // Even-sized squads skip the lead plane @@ -135,7 +139,7 @@ void OnRemovedFromWorld(Actor a) var so = info.SquadOffset; var spawnOffset = new WVec(i * so.Y, -Math.Abs(i) * so.X, 0).Rotate(attackRotation); var targetOffset = new WVec(i * so.Y, 0, 0).Rotate(attackRotation); - var a = self.World.CreateActor(false, info.UnitTypes.First(ut => ut.Key == GetLevel()).Value, new TypeDictionary + var a = self.World.CreateActor(false, info.UnitTypes.First(ut => ut.Key == level).Value, new TypeDictionary { new CenterPositionInit(startEdge + spawnOffset), new OwnerInit(self.Owner), @@ -187,7 +191,7 @@ void OnRemovedFromWorld(Actor a) Info.BeaconPaletteIsPlayerPalette, Info.BeaconPalette, Info.BeaconImage, - Info.BeaconPosters.First(bp => bp.Key == GetLevel()).Value, + Info.BeaconPosters.First(bp => bp.Key == level).Value, Info.BeaconPosterPalette, Info.BeaconSequence, Info.ArrowSequence, diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs index b637abc44e92..6fa005d67448 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/GrantExternalConditionPower.cs @@ -85,6 +85,10 @@ public override void SelectTarget(Actor self, string order, SupportPowerManager public override void Activate(Actor self, Order order, SupportPowerManager manager) { + var level = GetLevel(); + if (level == 0) + return; + base.Activate(self, order, manager); PlayLaunchSounds(); @@ -100,15 +104,18 @@ public override void Activate(Actor self, Order order, SupportPowerManager manag foreach (var a in UnitsInRange(self.World.Map.CellContaining(position))) a.TraitsImplementing() - .FirstOrDefault(t => t.Info.Condition == info.Conditions.First(c => c.Key == GetLevel()).Value && t.CanGrantCondition(self)) - ?.GrantCondition(a, self, info.Durations.First(d => d.Key == GetLevel()).Value); + .FirstOrDefault(t => t.Info.Condition == info.Conditions.First(c => c.Key == level).Value && t.CanGrantCondition(self)) + ?.GrantCondition(a, self, info.Durations.First(d => d.Key == level).Value); } public IEnumerable UnitsInRange(CPos xy) { + var units = new HashSet(); var level = GetLevel(); + if (level == 0) + return units; + var tiles = CellsMatching(xy, footprints.First(f => f.Key == level).Value, info.Dimensions.First(d => d.Key == level).Value); - var units = new HashSet(); foreach (var t in tiles) foreach (var a in Self.World.ActorMap.GetActorsAt(t)) units.Add(a); @@ -183,10 +190,13 @@ protected override IEnumerable RenderAnnotations(WorldRenderer wr, protected override IEnumerable Render(WorldRenderer wr, World world) { + var level = power.GetLevel(); + if (level == 0) + yield break; + var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos); var pal = wr.Palette(TileSet.TerrainPaletteInternalName); - var level = power.GetLevel(); foreach (var t in power.CellsMatching(xy, footprints.First(f => f.Key == level).Value, dimensions.First(d => d.Key == level).Value)) yield return new SpriteRenderable(tile, wr.World.Map.CenterOfCell(t), WVec.Zero, -511, pal, 1f, alpha, float3.Ones, TintModifiers.IgnoreWorldTint, true); } diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs index 0754931a1897..441f34dd12b7 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs @@ -173,11 +173,15 @@ public override void Activate(Actor self, Order order, SupportPowerManager manag public void Activate(Actor self, WPos targetPosition) { + var level = GetLevel(); + if (level == 0) + return; + var palette = Info.IsPlayerPalette ? Info.MissilePalette + self.Owner.InternalName : Info.MissilePalette; var skipAscent = Info.SkipAscent || body == null; var launchPos = skipAscent ? WPos.Zero : self.CenterPosition + body.LocalToWorld(Info.SpawnOffset); - var weaponInfo = Info.WeaponInfos.First(wi => wi.Key == GetLevel()).Value; + var weaponInfo = Info.WeaponInfos.First(wi => wi.Key == level).Value; var missile = new NukeLaunch(self.Owner, Info.MissileImage, weaponInfo, palette, Info.MissileUp, Info.MissileDown, launchPos, targetPosition, Info.DetonationAltitude, Info.RemoveMissileOnDetonation, @@ -203,7 +207,7 @@ public void Activate(Actor self, WPos targetPosition) Info.BeaconPaletteIsPlayerPalette, Info.BeaconPalette, Info.BeaconImage, - Info.BeaconPosters.First(bp => bp.Key == GetLevel()).Value, + Info.BeaconPosters.First(bp => bp.Key == level).Value, Info.BeaconPosterPalette, Info.BeaconSequence, Info.ArrowSequence, diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs index 99461cbc2e8d..1ed5daac5dbe 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/ParatroopersPower.cs @@ -86,10 +86,14 @@ public override void Activate(Actor self, Order order, SupportPowerManager manag var aircraft = new List(); var units = new List(); + var level = GetLevel(); + if (level == 0) + return (aircraft.ToArray(), units.ToArray()); + if (!facing.HasValue) facing = new WAngle(1024 * self.World.SharedRandom.Next(info.QuantizedFacings) / info.QuantizedFacings); - var utLower = info.UnitTypes.First(ut => ut.Key == GetLevel()).Value.ToLowerInvariant(); + var utLower = info.UnitTypes.First(ut => ut.Key == level).Value.ToLowerInvariant(); if (!self.World.Map.Rules.Actors.TryGetValue(utLower, out var unitType)) throw new YamlException($"Actors ruleset does not include the entry '{utLower}'"); @@ -156,7 +160,7 @@ void OnRemovedFromWorld(Actor a) } // Create the actors immediately so they can be returned - var squadSize = info.SquadSizes.First(ss => ss.Key == GetLevel()).Value; + var squadSize = info.SquadSizes.First(ss => ss.Key == level).Value; for (var i = -squadSize / 2; i <= squadSize / 2; i++) { // Even-sized squads skip the lead plane @@ -175,7 +179,7 @@ void OnRemovedFromWorld(Actor a) })); } - var dropItems = info.DropItems.First(di => di.Key == GetLevel()).Value; + var dropItems = info.DropItems.First(di => di.Key == level).Value; foreach (var p in dropItems) { units.Add(self.World.CreateActor(false, p.ToLowerInvariant(), new TypeDictionary @@ -240,7 +244,7 @@ void OnRemovedFromWorld(Actor a) Info.BeaconPaletteIsPlayerPalette, Info.BeaconPalette, Info.BeaconImage, - Info.BeaconPosters.First(bp => bp.Key == GetLevel()).Value, + Info.BeaconPosters.First(bp => bp.Key == level).Value, Info.BeaconPosterPalette, Info.BeaconSequence, Info.ArrowSequence, diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SpawnActorPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SpawnActorPower.cs index f43516196a18..c51b72b6df21 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SpawnActorPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SpawnActorPower.cs @@ -68,6 +68,10 @@ public SpawnActorPower(Actor self, SpawnActorPowerInfo info) public override void Activate(Actor self, Order order, SupportPowerManager manager) { + var level = GetLevel(); + if (level == 0) + return; + var position = order.Target.CenterPosition; var cell = self.World.Map.CellContaining(position); @@ -84,7 +88,7 @@ public override void Activate(Actor self, Order order, SupportPowerManager manag if (!string.IsNullOrEmpty(Info.EffectSequence) && !string.IsNullOrEmpty(Info.EffectPalette)) w.Add(new SpriteEffect(position, w, Info.EffectImage, Info.EffectSequence, Info.EffectPalette)); - var actor = w.CreateActor(Info.Actors.First(a => a.Key == GetLevel()).Value, new TypeDictionary + var actor = w.CreateActor(Info.Actors.First(a => a.Key == level).Value, new TypeDictionary { new LocationInit(cell), new OwnerInit(self.Owner), @@ -171,9 +175,13 @@ protected override void Tick(World world) protected override IEnumerable RenderAnnotations(WorldRenderer wr, World world) { + var level = power.GetLevel(); + if (level == 0) + yield break; + var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos); - if (power.Info.TargetCircleRanges == null || power.Info.TargetCircleRanges.Count == 0 || power.GetLevel() == 0) + if (power.Info.TargetCircleRanges == null || power.Info.TargetCircleRanges.Count == 0 || level == 0) { yield break; } @@ -181,7 +189,7 @@ protected override IEnumerable RenderAnnotations(WorldRenderer wr, { yield return new RangeCircleAnnotationRenderable( world.Map.CenterOfCell(xy), - power.Info.TargetCircleRanges[power.GetLevel()], + power.Info.TargetCircleRanges[level], 0, power.Info.TargetCircleUsePlayerColor ? power.Self.Owner.Color : power.Info.TargetCircleColor, power.Info.TargetCircleWidth,