From 31892dd10429f96dbc7002ed349ea2db3132dff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 9 Jul 2015 12:32:03 +0200 Subject: [PATCH 1/6] fix copy paste error --- OpenRA.Game/WDist.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenRA.Game/WDist.cs b/OpenRA.Game/WDist.cs index c12356ee90..ee2b1af488 100644 --- a/OpenRA.Game/WDist.cs +++ b/OpenRA.Game/WDist.cs @@ -143,6 +143,7 @@ namespace OpenRA { case "Range": return Length; default: throw new LuaException("WPos does not define a member '{0}'".F(key)); + default: throw new LuaException("WDist does not define a member '{0}'".F(key)); } } From ff7fe2bab5afceed61cf73679cc665f99bc8ea74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 9 Jul 2015 12:36:15 +0200 Subject: [PATCH 2/6] rename WRange to WDist in the Lua API --- OpenRA.Game/WDist.cs | 11 +++++------ mods/cnc/maps/nod05/nod05.lua | 2 +- mods/ra/maps/allies-03b/allies03b.lua | 2 +- .../monster-tank-madness/monster-tank-madness.lua | 2 +- mods/ra/maps/soviet-05/main.lua | 2 +- mods/ra/maps/survival02/survival02.lua | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/OpenRA.Game/WDist.cs b/OpenRA.Game/WDist.cs index ee2b1af488..5cf1ed7fe5 100644 --- a/OpenRA.Game/WDist.cs +++ b/OpenRA.Game/WDist.cs @@ -110,7 +110,7 @@ namespace OpenRA WDist a; WDist b; if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b)) - throw new LuaException("Attempted to call WRange.Add(WRange, WRange) with invalid arguments."); + throw new LuaException("Attempted to call WDist.Add(WDist, WDist) with invalid arguments."); return new LuaCustomClrObject(a + b); } @@ -120,7 +120,7 @@ namespace OpenRA WDist a; WDist b; if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b)) - throw new LuaException("Attempted to call WRange.Subtract(WRange, WRange) with invalid arguments."); + throw new LuaException("Attempted to call WDist.Subtract(WDist, WDist) with invalid arguments."); return new LuaCustomClrObject(a - b); } @@ -130,7 +130,7 @@ namespace OpenRA WDist a; WDist b; if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b)) - throw new LuaException("Attempted to call WRange.Equals(WRange, WRange) with invalid arguments."); + throw new LuaException("Attempted to call WDist.Equals(WDist, WDist) with invalid arguments."); return a == b; } @@ -141,15 +141,14 @@ namespace OpenRA { switch (key.ToString()) { - case "Range": return Length; - default: throw new LuaException("WPos does not define a member '{0}'".F(key)); + case "Length": return Length; default: throw new LuaException("WDist does not define a member '{0}'".F(key)); } } set { - throw new LuaException("WRange is read-only. Use WRange.New to create a new value"); + throw new LuaException("WDist is read-only. Use WDist.New to create a new value"); } } #endregion diff --git a/mods/cnc/maps/nod05/nod05.lua b/mods/cnc/maps/nod05/nod05.lua index cf62fb655c..ea2c5c301d 100644 --- a/mods/cnc/maps/nod05/nod05.lua +++ b/mods/cnc/maps/nod05/nod05.lua @@ -332,7 +332,7 @@ getAirstrikeTarget = function() local list = Nod.GetGroundAttackers() local target = list[DateTime.GameTime % #list + 1].CenterPosition - local sams = Map.ActorsInCircle(target, WRange.New(8 * 1024), function(actor) + local sams = Map.ActorsInCircle(target, WDist.New(8 * 1024), function(actor) return actor.Type == "sam" end) if #sams == 0 then diff --git a/mods/ra/maps/allies-03b/allies03b.lua b/mods/ra/maps/allies-03b/allies03b.lua index 1d13d462d6..6067316ad4 100644 --- a/mods/ra/maps/allies-03b/allies03b.lua +++ b/mods/ra/maps/allies-03b/allies03b.lua @@ -284,7 +284,7 @@ InitTriggers = function() USSRTruk.Move(BaseCameraWaypoint.Location) end end) - Trigger.OnEnteredProximityTrigger(BaseCameraWaypoint.CenterPosition, WRange.New(7 * 1024), function(a, id) + Trigger.OnEnteredProximityTrigger(BaseCameraWaypoint.CenterPosition, WDist.New(7 * 1024), function(a, id) if a.Type == "truk" and not baseCamera then Trigger.RemoveProximityTrigger(id) baseCamera = Actor.Create("camera", true, { Owner = player, Location = BaseCameraWaypoint.Location }) diff --git a/mods/ra/maps/monster-tank-madness/monster-tank-madness.lua b/mods/ra/maps/monster-tank-madness/monster-tank-madness.lua index 72afafbf2c..d51a01c2f6 100644 --- a/mods/ra/maps/monster-tank-madness/monster-tank-madness.lua +++ b/mods/ra/maps/monster-tank-madness/monster-tank-madness.lua @@ -391,7 +391,7 @@ InitTriggers = function() end) local tanksLeft = 0 - Trigger.OnExitedProximityTrigger(ProvingGroundsCameraPoint.CenterPosition, WRange.New(10 * 1024), function(a, id) + Trigger.OnExitedProximityTrigger(ProvingGroundsCameraPoint.CenterPosition, WDist.New(10 * 1024), function(a, id) if a.Type == "5tnk" then tanksLeft = tanksLeft + 1 if tanksLeft == 3 then diff --git a/mods/ra/maps/soviet-05/main.lua b/mods/ra/maps/soviet-05/main.lua index 028256abe4..a0a6533d86 100644 --- a/mods/ra/maps/soviet-05/main.lua +++ b/mods/ra/maps/soviet-05/main.lua @@ -240,7 +240,7 @@ WorldLoaded = function() end) end) - Trigger.OnEnteredProximityTrigger(USSRExpansionPoint.CenterPosition, WRange.New(4 * 1024), function(unit, id) + Trigger.OnEnteredProximityTrigger(USSRExpansionPoint.CenterPosition, WDist.New(4 * 1024), function(unit, id) if unit.Owner == player and Radar.Owner == player then Trigger.RemoveProximityTrigger(id) diff --git a/mods/ra/maps/survival02/survival02.lua b/mods/ra/maps/survival02/survival02.lua index 7e1af2cb19..c196631e48 100644 --- a/mods/ra/maps/survival02/survival02.lua +++ b/mods/ra/maps/survival02/survival02.lua @@ -243,8 +243,8 @@ SetupBridges = function() Media.DisplayMessage("Commander! The Soviets destroyed the bridges to disable our reinforcements. Repair them for additional reinforcements.", "Incoming Report") RepairBridges = allies.AddSecondaryObjective("Repair the two southern bridges.") - local bridgeA = Map.ActorsInCircle(BrokenBridge1.CenterPosition, WRange.FromCells(1), function(self) return self.Type == "bridge1" end) - local bridgeB = Map.ActorsInCircle(BrokenBridge2.CenterPosition, WRange.FromCells(1), function(self) return self.Type == "bridge1" end) + local bridgeA = Map.ActorsInCircle(BrokenBridge1.CenterPosition, WDist.FromCells(1), function(self) return self.Type == "bridge1" end) + local bridgeB = Map.ActorsInCircle(BrokenBridge2.CenterPosition, WDist.FromCells(1), function(self) return self.Type == "bridge1" end) Utils.Do(bridgeA, function(bridge) Trigger.OnDamaged(bridge, function() From 8d8d7ab8eacc8edf2c215a71ca9d77c506356271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 9 Jul 2015 12:36:29 +0200 Subject: [PATCH 3/6] rename WRange to WDist in documentation --- OpenRA.Game/Graphics/Viewport.cs | 2 +- OpenRA.Mods.Common/Effects/Bullet.cs | 2 +- OpenRA.Mods.Common/Effects/Missile.cs | 2 +- OpenRA.Mods.Common/Scripting/Global/CoordinateGlobals.cs | 6 +++--- OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index 25e4621d99..d67e9d37c1 100644 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -247,7 +247,7 @@ namespace OpenRA.Graphics } // Cells can be pushed up from below if they have non-zero height. - // Each height step is equivalent to 512 WRange units, which is + // Each height step is equivalent to 512 WDist units, which is // one MPos step for diamond cells, but only half a MPos step // for classic cells. Doh! var heightOffset = map.TileShape == TileShape.Diamond ? map.MaximumTerrainHeight : map.MaximumTerrainHeight / 2; diff --git a/OpenRA.Mods.Common/Effects/Bullet.cs b/OpenRA.Mods.Common/Effects/Bullet.cs index af3903b151..5f7d1c702e 100644 --- a/OpenRA.Mods.Common/Effects/Bullet.cs +++ b/OpenRA.Mods.Common/Effects/Bullet.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Effects { public class BulletInfo : IProjectileInfo { - [Desc("Projectile speed in WRange / tick, two values indicate variable velocity.")] + [Desc("Projectile speed in WDist / tick, two values indicate variable velocity.")] public readonly WDist[] Speed = { new WDist(17) }; [Desc("Maximum offset at the maximum range.")] public readonly WDist Inaccuracy = WDist.Zero; diff --git a/OpenRA.Mods.Common/Effects/Missile.cs b/OpenRA.Mods.Common/Effects/Missile.cs index a05f1521dd..170688f28f 100644 --- a/OpenRA.Mods.Common/Effects/Missile.cs +++ b/OpenRA.Mods.Common/Effects/Missile.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Effects [SequenceReference("Image")] public readonly string Sequence = "idle"; public readonly string Palette = "effect"; public readonly bool Shadow = false; - [Desc("Projectile speed in WRange / tick")] + [Desc("Projectile speed in WDist / tick")] public readonly WDist Speed = new WDist(8); [Desc("Maximum vertical pitch when changing altitude.")] public readonly WAngle MaximumPitch = WAngle.FromDegrees(30); diff --git a/OpenRA.Mods.Common/Scripting/Global/CoordinateGlobals.cs b/OpenRA.Mods.Common/Scripting/Global/CoordinateGlobals.cs index c75bda6eee..6fa8accb8a 100644 --- a/OpenRA.Mods.Common/Scripting/Global/CoordinateGlobals.cs +++ b/OpenRA.Mods.Common/Scripting/Global/CoordinateGlobals.cs @@ -59,15 +59,15 @@ namespace OpenRA.Mods.Common.Scripting public WVec Zero { get { return WVec.Zero; } } } - [ScriptGlobal("WRange")] + [ScriptGlobal("WDist")] public class WRangeGlobal : ScriptGlobal { public WRangeGlobal(ScriptContext context) : base(context) { } - [Desc("Create a new WRange.")] + [Desc("Create a new WDist.")] public WDist New(int r) { return new WDist(r); } - [Desc("Create a new WRange by cell distance")] + [Desc("Create a new WDist by cell distance")] public WDist FromCells(int numCells) { return WDist.FromCells(numCells); } } } diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs index bc3690f58f..ac3548ffdd 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/NukePower.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Travel time - split equally between ascent and descent")] public readonly int FlightDelay = 400; - [Desc("Visual ascent velocity in WRange / tick")] + [Desc("Visual ascent velocity in WDist / tick")] public readonly WDist FlightVelocity = new WDist(512); [Desc("Descend immediately on the target, with half the FlightDelay")] From 43ddf14998f6e678aa0853526e4e5466e6b2a38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 9 Jul 2015 12:39:51 +0200 Subject: [PATCH 4/6] rename internal API for consistency --- OpenRA.Mods.Common/Scripting/Global/CoordinateGlobals.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Scripting/Global/CoordinateGlobals.cs b/OpenRA.Mods.Common/Scripting/Global/CoordinateGlobals.cs index 6fa8accb8a..95882da41e 100644 --- a/OpenRA.Mods.Common/Scripting/Global/CoordinateGlobals.cs +++ b/OpenRA.Mods.Common/Scripting/Global/CoordinateGlobals.cs @@ -60,9 +60,9 @@ namespace OpenRA.Mods.Common.Scripting } [ScriptGlobal("WDist")] - public class WRangeGlobal : ScriptGlobal + public class WDistGlobal : ScriptGlobal { - public WRangeGlobal(ScriptContext context) : base(context) { } + public WDistGlobal(ScriptContext context) : base(context) { } [Desc("Create a new WDist.")] public WDist New(int r) { return new WDist(r); } From cae889fb678bd21f7b20b174a1b5ded58269141f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 9 Jul 2015 21:12:06 +0200 Subject: [PATCH 5/6] leave a warning for thirdparty scripters --- OpenRA.Game/WDist.cs | 1 + .../Scripting/Global/CoordinateGlobals.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/OpenRA.Game/WDist.cs b/OpenRA.Game/WDist.cs index 5cf1ed7fe5..2b80ca9b27 100644 --- a/OpenRA.Game/WDist.cs +++ b/OpenRA.Game/WDist.cs @@ -142,6 +142,7 @@ namespace OpenRA switch (key.ToString()) { case "Length": return Length; + case "Range": Game.Debug("WRange.Range is deprecated. Use WDist.Length instead"); return Length; default: throw new LuaException("WDist does not define a member '{0}'".F(key)); } } diff --git a/OpenRA.Mods.Common/Scripting/Global/CoordinateGlobals.cs b/OpenRA.Mods.Common/Scripting/Global/CoordinateGlobals.cs index 95882da41e..cc8271074b 100644 --- a/OpenRA.Mods.Common/Scripting/Global/CoordinateGlobals.cs +++ b/OpenRA.Mods.Common/Scripting/Global/CoordinateGlobals.cs @@ -70,4 +70,16 @@ namespace OpenRA.Mods.Common.Scripting [Desc("Create a new WDist by cell distance")] public WDist FromCells(int numCells) { return WDist.FromCells(numCells); } } + + [ScriptGlobal("WRange")] + public class WRangeGlobal : ScriptGlobal + { + public WRangeGlobal(ScriptContext context) : base(context) { } + + [Desc("Create a new WRange. DEPRECATED! Will be removed.")] + public WDist New(int r) { Game.Debug("WRange is deprecated. Use WDist instead."); return new WDist(r); } + + [Desc("Create a new WRange by cell distance. DEPRECATED! Will be removed.")] + public WDist FromCells(int numCells) { Game.Debug("WRange is deprecated. Use WDist instead."); return WDist.FromCells(numCells); } + } } From 56e9bcd96e2c50f689050b28d80268a1e8cac337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 9 Jul 2015 21:13:54 +0200 Subject: [PATCH 6/6] rename RangeSquard to LengthSquared --- OpenRA.Game/Traits/Target.cs | 2 +- OpenRA.Game/Traits/World/ActorMap.cs | 2 +- OpenRA.Game/Traits/World/Shroud.cs | 2 +- OpenRA.Game/WDist.cs | 2 +- OpenRA.Game/WorldUtils.cs | 2 +- OpenRA.Mods.Common/Activities/Enter.cs | 2 +- OpenRA.Mods.Common/Activities/Move/MoveWithinRange.cs | 4 ++-- OpenRA.Mods.Common/Effects/Missile.cs | 2 +- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 2 +- OpenRA.Mods.Common/Traits/Attack/AttackBase.cs | 2 +- OpenRA.Mods.Common/Traits/Repairable.cs | 2 +- OpenRA.Mods.Common/Traits/Upgrades/UpgradeActorsNear.cs | 2 +- OpenRA.Mods.Common/Traits/World/PathFinder.cs | 2 +- OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs | 2 +- OpenRA.Mods.D2k/Traits/Carryable.cs | 6 +++--- 15 files changed, 18 insertions(+), 18 deletions(-) diff --git a/OpenRA.Game/Traits/Target.cs b/OpenRA.Game/Traits/Target.cs index ecb11793ae..d5261e04fa 100644 --- a/OpenRA.Game/Traits/Target.cs +++ b/OpenRA.Game/Traits/Target.cs @@ -146,7 +146,7 @@ namespace OpenRA.Traits return false; // Target ranges are calculated in 2D, so ignore height differences - return Positions.Any(t => (t - origin).HorizontalLengthSquared <= range.RangeSquared); + return Positions.Any(t => (t - origin).HorizontalLengthSquared <= range.LengthSquared); } public override string ToString() diff --git a/OpenRA.Game/Traits/World/ActorMap.cs b/OpenRA.Game/Traits/World/ActorMap.cs index c5ef9b9b1a..b90a987052 100644 --- a/OpenRA.Game/Traits/World/ActorMap.cs +++ b/OpenRA.Game/Traits/World/ActorMap.cs @@ -132,7 +132,7 @@ namespace OpenRA.Traits var oldActors = currentActors; var delta = new WVec(Range, Range, WDist.Zero); currentActors = am.ActorsInBox(Position - delta, Position + delta) - .Where(a => (a.CenterPosition - Position).HorizontalLengthSquared < Range.RangeSquared) + .Where(a => (a.CenterPosition - Position).HorizontalLengthSquared < Range.LengthSquared) .ToList(); var entered = currentActors.Except(oldActors); diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index 62e4d1ac4c..e54a8d6685 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -75,7 +75,7 @@ namespace OpenRA.Traits public static IEnumerable CellsInRange(Map map, WPos pos, WDist range) { var r = (range.Length + 1023) / 1024; - var limit = range.RangeSquared; + var limit = range.LengthSquared; var cell = map.CellContaining(pos); foreach (var c in map.FindTilesInCircle(cell, r, true)) diff --git a/OpenRA.Game/WDist.cs b/OpenRA.Game/WDist.cs index 2b80ca9b27..ab4f0f1c9e 100644 --- a/OpenRA.Game/WDist.cs +++ b/OpenRA.Game/WDist.cs @@ -23,7 +23,7 @@ namespace OpenRA public struct WDist : IComparable, IComparable, IEquatable, IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaEqualityBinding, ILuaTableBinding { public readonly int Length; - public long RangeSquared { get { return (long)Length * (long)Length; } } + public long LengthSquared { get { return (long)Length * (long)Length; } } public WDist(int r) { Length = r; } public static readonly WDist Zero = new WDist(0); diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs index e251dc9258..89758ed662 100644 --- a/OpenRA.Game/WorldUtils.cs +++ b/OpenRA.Game/WorldUtils.cs @@ -37,7 +37,7 @@ namespace OpenRA // Target ranges are calculated in 2D, so ignore height differences var vec = new WVec(r, r, WDist.Zero); return world.ActorMap.ActorsInBox(origin - vec, origin + vec).Where( - a => (a.CenterPosition - origin).HorizontalLengthSquared <= r.RangeSquared); + a => (a.CenterPosition - origin).HorizontalLengthSquared <= r.LengthSquared); } } diff --git a/OpenRA.Mods.Common/Activities/Enter.cs b/OpenRA.Mods.Common/Activities/Enter.cs index b17e5e7d6e..71e4ac94ad 100644 --- a/OpenRA.Mods.Common/Activities/Enter.cs +++ b/OpenRA.Mods.Common/Activities/Enter.cs @@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Activities var diff = new WVec(radius, radius, WDist.Zero); var candidates = self.World.ActorMap.ActorsInBox(self.CenterPosition - diff, self.CenterPosition + diff) .Where(primaryFilter).Select(a => new { Actor = a, Ls = (self.CenterPosition - a.CenterPosition).HorizontalLengthSquared }) - .Where(p => p.Ls <= radius.RangeSquared).OrderBy(p => p.Ls).Select(p => p.Actor); + .Where(p => p.Ls <= radius.LengthSquared).OrderBy(p => p.Ls).Select(p => p.Actor); if (preferenceFilters != null) foreach (var filter in preferenceFilters) { diff --git a/OpenRA.Mods.Common/Activities/Move/MoveWithinRange.cs b/OpenRA.Mods.Common/Activities/Move/MoveWithinRange.cs index b0f47e7cc5..a9e6074b78 100644 --- a/OpenRA.Mods.Common/Activities/Move/MoveWithinRange.cs +++ b/OpenRA.Mods.Common/Activities/Move/MoveWithinRange.cs @@ -48,8 +48,8 @@ namespace OpenRA.Mods.Common.Activities var maxCells = (maxRange.Length + 1023) / 1024; var minCells = minRange.Length / 1024; - var outerSq = maxRange.RangeSquared; - var innerSq = minRange.RangeSquared; + var outerSq = maxRange.LengthSquared; + var innerSq = minRange.LengthSquared; var center = Target.CenterPosition; return map.FindTilesInAnnulus(targetPosition, minCells + 1, maxCells).Where(c => diff --git a/OpenRA.Mods.Common/Effects/Missile.cs b/OpenRA.Mods.Common/Effects/Missile.cs index 170688f28f..903e1a1b88 100644 --- a/OpenRA.Mods.Common/Effects/Missile.cs +++ b/OpenRA.Mods.Common/Effects/Missile.cs @@ -182,7 +182,7 @@ namespace OpenRA.Mods.Common.Effects var cell = world.Map.CellContaining(pos); var shouldExplode = (pos.Z < 0) // Hit the ground - || (dist.LengthSquared < info.CloseEnough.RangeSquared) // Within range + || (dist.LengthSquared < info.CloseEnough.LengthSquared) // Within range || (info.RangeLimit != 0 && ticks > info.RangeLimit) // Ran out of fuel || (info.Blockable && world.ActorMap.GetUnitsAt(cell).Any(a => a.HasTrait())) // Hit a wall or other blocking obstacle || !world.Map.Contains(cell) // This also avoids an IndexOutOfRangeException in GetTerrainInfo below. diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 8b95f28bfb..c666ba3e31 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Traits var d = self.CenterPosition - other.CenterPosition; var distSq = d.HorizontalLengthSquared; - if (distSq > info.IdealSeparation.RangeSquared) + if (distSq > info.IdealSeparation.LengthSquared) return WVec.Zero; if (distSq < 1) diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs index 74e6b7b610..7930675bfc 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs @@ -268,7 +268,7 @@ namespace OpenRA.Mods.Common.Traits if (modifiers.HasModifier(TargetModifiers.ForceAttack)) { var targetRange = (self.World.Map.CenterOfCell(location) - self.CenterPosition).HorizontalLengthSquared; - if (targetRange > ab.GetMaximumRange().RangeSquared) + if (targetRange > ab.GetMaximumRange().LengthSquared) cursor = ab.Info.OutsideRangeCursor; return true; diff --git a/OpenRA.Mods.Common/Traits/Repairable.cs b/OpenRA.Mods.Common/Traits/Repairable.cs index a0b25009c7..8210da205d 100644 --- a/OpenRA.Mods.Common/Traits/Repairable.cs +++ b/OpenRA.Mods.Common/Traits/Repairable.cs @@ -144,7 +144,7 @@ namespace OpenRA.Mods.Common.Traits return; var targetCell = self.World.Map.CellContaining(target.CenterPosition); - if ((self.CenterPosition - target.CenterPosition).LengthSquared < transport.MinimumDistance.RangeSquared) + if ((self.CenterPosition - target.CenterPosition).LengthSquared < transport.MinimumDistance.LengthSquared) return; transport.RequestTransport(targetCell, nextActivity); diff --git a/OpenRA.Mods.Common/Traits/Upgrades/UpgradeActorsNear.cs b/OpenRA.Mods.Common/Traits/Upgrades/UpgradeActorsNear.cs index 2d38a009f2..c55c761f19 100644 --- a/OpenRA.Mods.Common/Traits/Upgrades/UpgradeActorsNear.cs +++ b/OpenRA.Mods.Common/Traits/Upgrades/UpgradeActorsNear.cs @@ -107,7 +107,7 @@ namespace OpenRA.Mods.Common.Traits public void UnitProducedByOther(Actor self, Actor producer, Actor produced) { // Work around for actors produced within the region not triggering until the second tick - if ((produced.CenterPosition - self.CenterPosition).HorizontalLengthSquared <= info.Range.RangeSquared) + if ((produced.CenterPosition - self.CenterPosition).HorizontalLengthSquared <= info.Range.LengthSquared) { var stance = self.Owner.Stances[produced.Owner]; if (!info.ValidStances.HasFlag(stance)) diff --git a/OpenRA.Mods.Common/Traits/World/PathFinder.cs b/OpenRA.Mods.Common/Traits/World/PathFinder.cs index 5441302e6c..25d96aea35 100644 --- a/OpenRA.Mods.Common/Traits/World/PathFinder.cs +++ b/OpenRA.Mods.Common/Traits/World/PathFinder.cs @@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Traits // Select only the tiles that are within range from the requested SubCell // This assumes that the SubCell does not change during the path traversal var tilesInRange = world.Map.FindTilesInCircle(targetCell, range.Length / 1024 + 1) - .Where(t => (world.Map.CenterOfCell(t) - target).LengthSquared <= range.RangeSquared + .Where(t => (world.Map.CenterOfCell(t) - target).LengthSquared <= range.LengthSquared && mi.CanEnterCell(self.World as World, self as Actor, t)); // See if there is any cell within range that does not involve a cross-domain request diff --git a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs index 610f9a8eeb..2000363551 100644 --- a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs @@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Warheads continue; // If the impact position is within any actor's health radius, we have a direct hit - if ((unit.CenterPosition - pos).LengthSquared <= healthInfo.Radius.RangeSquared) + if ((unit.CenterPosition - pos).LengthSquared <= healthInfo.Radius.LengthSquared) return true; } diff --git a/OpenRA.Mods.D2k/Traits/Carryable.cs b/OpenRA.Mods.D2k/Traits/Carryable.cs index c2f6c31bc3..2915cb9cee 100644 --- a/OpenRA.Mods.D2k/Traits/Carryable.cs +++ b/OpenRA.Mods.D2k/Traits/Carryable.cs @@ -56,7 +56,7 @@ namespace OpenRA.Mods.D2k.Traits public void RequestTransport(CPos destination, Activity afterLandActivity) { var destPos = self.World.Map.CenterOfCell(destination); - if (destination == CPos.Zero || (self.CenterPosition - destPos).LengthSquared < info.MinDistance.RangeSquared) + if (destination == CPos.Zero || (self.CenterPosition - destPos).LengthSquared < info.MinDistance.LengthSquared) { WantsTransport = false; // Be sure to cancel any pending transports return; @@ -122,7 +122,7 @@ namespace OpenRA.Mods.D2k.Traits return false; var destPos = self.World.Map.CenterOfCell(Destination); - if ((self.CenterPosition - destPos).LengthSquared < info.MinDistance.RangeSquared) + if ((self.CenterPosition - destPos).LengthSquared < info.MinDistance.LengthSquared) { MovementCancelled(self); return false; @@ -150,7 +150,7 @@ namespace OpenRA.Mods.D2k.Traits // Last change to change our mind... var destPos = self.World.Map.CenterOfCell(Destination); - if ((self.CenterPosition - destPos).LengthSquared < info.MinDistance.RangeSquared) + if ((self.CenterPosition - destPos).LengthSquared < info.MinDistance.LengthSquared) { MovementCancelled(self); return false;