From b07cd683e8e45bd133302f7703604e2217e6b82e Mon Sep 17 00:00:00 2001 From: atlimit8 Date: Sun, 15 Nov 2015 11:30:40 -0600 Subject: [PATCH] Easier actor selection in game by actor bounds center --- OpenRA.Game/Orders/GenericSelectTarget.cs | 15 ++++++---- OpenRA.Game/Orders/IOrderGenerator.cs | 4 +-- OpenRA.Game/Orders/UnitOrderGenerator.cs | 28 +++++++++---------- OpenRA.Game/SelectableExts.cs | 17 ++++++++--- .../WorldInteractionControllerWidget.cs | 8 ++++-- .../Orders/BeaconOrderGenerator.cs | 11 +++++--- .../Orders/GlobalButtonOrderGenerator.cs | 4 +-- .../Orders/PlaceBuildingOrderGenerator.cs | 10 +++---- .../Orders/RepairOrderGenerator.cs | 4 +-- OpenRA.Mods.Common/Traits/Guard.cs | 2 +- .../Traits/SupportPowers/GrantUpgradePower.cs | 10 +++---- .../SupportPowers/SupportPowerManager.cs | 11 +++++--- OpenRA.Mods.Common/Widgets/RadarWidget.cs | 5 ++-- .../Widgets/ViewportControllerWidget.cs | 9 +++--- OpenRA.Mods.RA/Traits/Minelayer.cs | 9 ++++-- OpenRA.Mods.RA/Traits/PortableChrono.cs | 14 +++++----- .../Traits/SupportPowers/ChronoshiftPower.cs | 14 +++++----- 17 files changed, 100 insertions(+), 75 deletions(-) diff --git a/OpenRA.Game/Orders/GenericSelectTarget.cs b/OpenRA.Game/Orders/GenericSelectTarget.cs index 71909a62af..f0b87c4841 100644 --- a/OpenRA.Game/Orders/GenericSelectTarget.cs +++ b/OpenRA.Game/Orders/GenericSelectTarget.cs @@ -37,23 +37,26 @@ namespace OpenRA.Orders public GenericSelectTarget(Actor subject, string order, string cursor, MouseButton button) : this(new Actor[] { subject }, order, cursor, button) { } - public override IEnumerable Order(World world, CPos xy, MouseInput mi) + public override IEnumerable Order(World world, CPos cell, int2 worldPixel, MouseInput mi) { if (mi.Button != ExpectedButton) world.CancelInputMode(); - return OrderInner(world, xy, mi); + return OrderInner(world, cell, mi); } - protected virtual IEnumerable OrderInner(World world, CPos xy, MouseInput mi) + protected virtual IEnumerable OrderInner(World world, CPos cell, MouseInput mi) { - if (mi.Button == ExpectedButton && world.Map.Contains(xy)) + if (mi.Button == ExpectedButton && world.Map.Contains(cell)) { world.CancelInputMode(); foreach (var subject in Subjects) - yield return new Order(OrderName, subject, false) { TargetLocation = xy }; + yield return new Order(OrderName, subject, false) { TargetLocation = cell }; } } - public override string GetCursor(World world, CPos xy, MouseInput mi) { return world.Map.Contains(xy) ? Cursor : "generic-blocked"; } + public override string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) + { + return world.Map.Contains(cell) ? Cursor : "generic-blocked"; + } } } diff --git a/OpenRA.Game/Orders/IOrderGenerator.cs b/OpenRA.Game/Orders/IOrderGenerator.cs index 5d751ef63d..6384d4a323 100644 --- a/OpenRA.Game/Orders/IOrderGenerator.cs +++ b/OpenRA.Game/Orders/IOrderGenerator.cs @@ -15,10 +15,10 @@ namespace OpenRA { public interface IOrderGenerator { - IEnumerable Order(World world, CPos xy, MouseInput mi); + IEnumerable Order(World world, CPos cell, int2 worldPixel, MouseInput mi); void Tick(World world); IEnumerable Render(WorldRenderer wr, World world); IEnumerable RenderAfterWorld(WorldRenderer wr, World world); - string GetCursor(World world, CPos xy, MouseInput mi); + string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi); } } diff --git a/OpenRA.Game/Orders/UnitOrderGenerator.cs b/OpenRA.Game/Orders/UnitOrderGenerator.cs index 4f6b3057e8..5167300b73 100644 --- a/OpenRA.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRA.Game/Orders/UnitOrderGenerator.cs @@ -17,31 +17,31 @@ namespace OpenRA.Orders { public class UnitOrderGenerator : IOrderGenerator { - static Target TargetForInput(World world, CPos xy, MouseInput mi) + static Target TargetForInput(World world, CPos cell, int2 worldPixel, MouseInput mi) { var actor = world.ScreenMap.ActorsAt(mi) .Where(a => !world.FogObscures(a) && a.Info.HasTraitInfo()) - .WithHighestSelectionPriority(); + .WithHighestSelectionPriority(worldPixel); if (actor != null) return Target.FromActor(actor); var frozen = world.ScreenMap.FrozenActorsAt(world.RenderPlayer, mi) .Where(a => a.Info.HasTraitInfo() && a.Visible && a.HasRenderables) - .WithHighestSelectionPriority(); + .WithHighestSelectionPriority(worldPixel); if (frozen != null) return Target.FromFrozenActor(frozen); - return Target.FromCell(world, xy); + return Target.FromCell(world, cell); } - public virtual IEnumerable Order(World world, CPos xy, MouseInput mi) + public virtual IEnumerable Order(World world, CPos cell, int2 worldPixel, MouseInput mi) { - var target = TargetForInput(world, xy, mi); - var actorsAt = world.ActorMap.GetActorsAt(xy).ToList(); + var target = TargetForInput(world, cell, worldPixel, mi); + var actorsAt = world.ActorMap.GetActorsAt(cell).ToList(); var orders = world.Selection.Actors - .Select(a => OrderForUnit(a, target, actorsAt, xy, mi)) + .Select(a => OrderForUnit(a, target, actorsAt, cell, mi)) .Where(o => o != null) .ToList(); @@ -62,18 +62,18 @@ namespace OpenRA.Orders public virtual IEnumerable Render(WorldRenderer wr, World world) { yield break; } public virtual IEnumerable RenderAfterWorld(WorldRenderer wr, World world) { yield break; } - public virtual string GetCursor(World world, CPos xy, MouseInput mi) + public virtual string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { var useSelect = false; - var target = TargetForInput(world, xy, mi); - var actorsAt = world.ActorMap.GetActorsAt(xy).ToList(); + var target = TargetForInput(world, cell, worldPixel, mi); + var actorsAt = world.ActorMap.GetActorsAt(cell).ToList(); if (target.Type == TargetType.Actor && target.Actor.Info.HasTraitInfo() && (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any())) useSelect = true; var ordersWithCursor = world.Selection.Actors - .Select(a => OrderForUnit(a, target, actorsAt, xy, mi)) + .Select(a => OrderForUnit(a, target, actorsAt, cell, mi)) .Where(o => o != null && o.Cursor != null); var cursorOrder = ordersWithCursor.MaxByOrDefault(o => o.Order.OrderPriority); @@ -84,14 +84,14 @@ namespace OpenRA.Orders // Used for classic mouse orders, determines whether or not action at xy is move or select public static bool InputOverridesSelection(World world, int2 xy, MouseInput mi) { - var actor = world.ScreenMap.ActorsAt(xy).WithHighestSelectionPriority(); + var actor = world.ScreenMap.ActorsAt(xy).WithHighestSelectionPriority(xy); if (actor == null) return true; var target = Target.FromActor(actor); var cell = world.Map.CellContaining(target.CenterPosition); var actorsAt = world.ActorMap.GetActorsAt(cell).ToList(); - var underCursor = world.Selection.Actors.WithHighestSelectionPriority(); + var underCursor = world.Selection.Actors.WithHighestSelectionPriority(xy); var o = OrderForUnit(underCursor, target, actorsAt, cell, mi); if (o != null && o.Order.OverrideSelection) diff --git a/OpenRA.Game/SelectableExts.cs b/OpenRA.Game/SelectableExts.cs index dcc01788dc..f3b449c762 100644 --- a/OpenRA.Game/SelectableExts.cs +++ b/OpenRA.Game/SelectableExts.cs @@ -10,6 +10,7 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; namespace OpenRA.Traits @@ -43,14 +44,22 @@ namespace OpenRA.Traits } } - public static Actor WithHighestSelectionPriority(this IEnumerable actors) + public static Actor WithHighestSelectionPriority(this IEnumerable actors, int2 selectionPixel) { - return actors.MaxByOrDefault(a => a.Info.SelectionPriority()); + return actors.MaxByOrDefault(a => CalculateActorSelectionPriority(a.Info, a.Bounds, selectionPixel)); } - public static FrozenActor WithHighestSelectionPriority(this IEnumerable actors) + public static FrozenActor WithHighestSelectionPriority(this IEnumerable actors, int2 selectionPixel) { - return actors.MaxByOrDefault(a => a.Info.SelectionPriority()); + return actors.MaxByOrDefault(a => CalculateActorSelectionPriority(a.Info, a.Bounds, selectionPixel)); + } + + static long CalculateActorSelectionPriority(ActorInfo info, Rectangle bounds, int2 selectionPixel) + { + var centerPixel = new int2(bounds.X, bounds.Y); + var pixelDistance = (centerPixel - selectionPixel).Length; + + return ((long)-pixelDistance << 32) + info.SelectionPriority(); } static readonly Actor[] NoActors = { }; diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index e19f56a7a3..e958e0b5bc 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -114,7 +114,7 @@ namespace OpenRA.Widgets if (multiClick) { var unit = World.ScreenMap.ActorsAt(xy) - .WithHighestSelectionPriority(); + .WithHighestSelectionPriority(xy); if (unit != null && unit.Owner == (World.RenderPlayer ?? World.LocalPlayer)) { @@ -193,7 +193,8 @@ namespace OpenRA.Widgets return; var cell = worldRenderer.Viewport.ViewToWorld(mi.Location); - var orders = world.OrderGenerator.Order(world, cell, mi).ToArray(); + var worldPixel = worldRenderer.Viewport.ViewToWorldPx(mi.Location); + var orders = world.OrderGenerator.Order(world, cell, worldPixel, mi).ToArray(); world.PlayVoiceForOrders(orders); var flashed = false; @@ -231,6 +232,7 @@ namespace OpenRA.Widgets return null; var cell = worldRenderer.Viewport.ViewToWorld(screenPos); + var worldPixel = worldRenderer.Viewport.ViewToWorldPx(screenPos); var mi = new MouseInput { @@ -239,7 +241,7 @@ namespace OpenRA.Widgets Modifiers = Game.GetModifierKeys() }; - return World.OrderGenerator.GetCursor(World, cell, mi); + return World.OrderGenerator.GetCursor(World, cell, worldPixel, mi); }); } diff --git a/OpenRA.Mods.Common/Orders/BeaconOrderGenerator.cs b/OpenRA.Mods.Common/Orders/BeaconOrderGenerator.cs index 6caaaa5b99..05f62762ea 100644 --- a/OpenRA.Mods.Common/Orders/BeaconOrderGenerator.cs +++ b/OpenRA.Mods.Common/Orders/BeaconOrderGenerator.cs @@ -15,20 +15,23 @@ namespace OpenRA.Mods.Common.Orders { public class BeaconOrderGenerator : IOrderGenerator { - public IEnumerable Order(World world, CPos xy, MouseInput mi) + public IEnumerable Order(World world, CPos cell, int2 worldPixel, MouseInput mi) { if (mi.Button != MouseButton.Left) world.CancelInputMode(); - else if (!world.ShroudObscures(xy)) + else if (!world.ShroudObscures(cell)) { world.CancelInputMode(); - yield return new Order("PlaceBeacon", world.LocalPlayer.PlayerActor, false) { TargetLocation = xy, SuppressVisualFeedback = true }; + yield return new Order("PlaceBeacon", world.LocalPlayer.PlayerActor, false) { TargetLocation = cell, SuppressVisualFeedback = true }; } } public virtual void Tick(World world) { } public IEnumerable Render(WorldRenderer wr, World world) { yield break; } public IEnumerable RenderAfterWorld(WorldRenderer wr, World world) { yield break; } - public string GetCursor(World world, CPos xy, MouseInput mi) { return !world.ShroudObscures(xy) ? "ability" : "generic-blocked"; } + public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) + { + return !world.ShroudObscures(cell) ? "ability" : "generic-blocked"; + } } } diff --git a/OpenRA.Mods.Common/Orders/GlobalButtonOrderGenerator.cs b/OpenRA.Mods.Common/Orders/GlobalButtonOrderGenerator.cs index 47db4e7308..5aa7b3f295 100644 --- a/OpenRA.Mods.Common/Orders/GlobalButtonOrderGenerator.cs +++ b/OpenRA.Mods.Common/Orders/GlobalButtonOrderGenerator.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Orders this.order = order; } - public IEnumerable Order(World world, CPos xy, MouseInput mi) + public IEnumerable Order(World world, CPos cell, int2 worldPixel, MouseInput mi) { if (mi.Button == MouseButton.Right) world.CancelInputMode(); @@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Orders public IEnumerable Render(WorldRenderer wr, World world) { yield break; } public IEnumerable RenderAfterWorld(WorldRenderer wr, World world) { yield break; } - public string GetCursor(World world, CPos xy, MouseInput mi) + public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { mi.Button = MouseButton.Left; return cursor + (OrderInner(world, mi).Any() ? "" : "-blocked"); diff --git a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs index e8953d2a58..04a47dcba8 100644 --- a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs @@ -62,12 +62,12 @@ namespace OpenRA.Mods.Common.Orders buildingInfluence = producer.World.WorldActor.Trait(); } - public IEnumerable Order(World world, CPos xy, MouseInput mi) + public IEnumerable Order(World world, CPos cell, int2 worldPixel, MouseInput mi) { if (mi.Button == MouseButton.Right) world.CancelInputMode(); - var ret = InnerOrder(world, xy, mi).ToArray(); + var ret = InnerOrder(world, cell, mi).ToArray(); // If there was a successful placement order if (ret.Any(o => o.OrderString == "PlaceBuilding" @@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Orders return ret; } - IEnumerable InnerOrder(World world, CPos xy, MouseInput mi) + IEnumerable InnerOrder(World world, CPos cell, MouseInput mi) { if (world.Paused) yield break; @@ -86,7 +86,7 @@ namespace OpenRA.Mods.Common.Orders if (mi.Button == MouseButton.Left) { var orderType = "PlaceBuilding"; - var topLeft = xy - FootprintUtils.AdjustForBuildingSize(buildingInfo); + var topLeft = cell - FootprintUtils.AdjustForBuildingSize(buildingInfo); var plugInfo = world.Map.Rules.Actors[building].TraitInfoOrDefault(); if (plugInfo != null) @@ -219,7 +219,7 @@ namespace OpenRA.Mods.Common.Orders } } - public string GetCursor(World world, CPos xy, MouseInput mi) { return "default"; } + public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { return "default"; } IEnumerable ClearBlockersOrders(World world, CPos topLeft) { diff --git a/OpenRA.Mods.Common/Orders/RepairOrderGenerator.cs b/OpenRA.Mods.Common/Orders/RepairOrderGenerator.cs index 7422ca2fad..2394188616 100644 --- a/OpenRA.Mods.Common/Orders/RepairOrderGenerator.cs +++ b/OpenRA.Mods.Common/Orders/RepairOrderGenerator.cs @@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Orders { public class RepairOrderGenerator : IOrderGenerator { - public IEnumerable Order(World world, CPos xy, MouseInput mi) + public IEnumerable Order(World world, CPos cell, int2 worldPixel, MouseInput mi) { if (mi.Button == MouseButton.Right) world.CancelInputMode(); @@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Orders public IEnumerable Render(WorldRenderer wr, World world) { yield break; } public IEnumerable RenderAfterWorld(WorldRenderer wr, World world) { yield break; } - public string GetCursor(World world, CPos xy, MouseInput mi) + public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { mi.Button = MouseButton.Left; return OrderInner(world, mi).Any() diff --git a/OpenRA.Mods.Common/Traits/Guard.cs b/OpenRA.Mods.Common/Traits/Guard.cs index 7ca77f34a1..8bec2c52a6 100644 --- a/OpenRA.Mods.Common/Traits/Guard.cs +++ b/OpenRA.Mods.Common/Traits/Guard.cs @@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.Traits world.CancelInputMode(); } - public override string GetCursor(World world, CPos xy, MouseInput mi) + public override string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { if (!Subjects.Any()) return null; diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/GrantUpgradePower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/GrantUpgradePower.cs index c796400af8..73c34759b9 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/GrantUpgradePower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/GrantUpgradePower.cs @@ -125,11 +125,11 @@ namespace OpenRA.Mods.Common.Traits tile = world.Map.SequenceProvider.GetSequence("overlay", "target-select").GetSprite(0); } - public IEnumerable Order(World world, CPos xy, MouseInput mi) + public IEnumerable Order(World world, CPos cell, int2 worldPixel, MouseInput mi) { world.CancelInputMode(); - if (mi.Button == MouseButton.Left && power.UnitsInRange(xy).Any()) - yield return new Order(order, manager.Self, false) { TargetLocation = xy, SuppressVisualFeedback = true }; + if (mi.Button == MouseButton.Left && power.UnitsInRange(cell).Any()) + yield return new Order(order, manager.Self, false) { TargetLocation = cell, SuppressVisualFeedback = true }; } public void Tick(World world) @@ -155,9 +155,9 @@ namespace OpenRA.Mods.Common.Traits yield return new SpriteRenderable(tile, wr.World.Map.CenterOfCell(t), WVec.Zero, -511, pal, 1f, true); } - public string GetCursor(World world, CPos xy, MouseInput mi) + public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { - return power.UnitsInRange(xy).Any() ? "ability" : "move-blocked"; + return power.UnitsInRange(cell).Any() ? "ability" : "move-blocked"; } } } diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs index eeb32378f8..59bad1d91b 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPowerManager.cs @@ -267,11 +267,11 @@ namespace OpenRA.Mods.Common.Traits expectedButton = button; } - public IEnumerable Order(World world, CPos xy, MouseInput mi) + public IEnumerable Order(World world, CPos cell, int2 worldPixel, MouseInput mi) { world.CancelInputMode(); - if (mi.Button == expectedButton && world.Map.Contains(xy)) - yield return new Order(order, manager.Self, false) { TargetLocation = xy, SuppressVisualFeedback = true }; + if (mi.Button == expectedButton && world.Map.Contains(cell)) + yield return new Order(order, manager.Self, false) { TargetLocation = cell, SuppressVisualFeedback = true }; } public virtual void Tick(World world) @@ -283,6 +283,9 @@ namespace OpenRA.Mods.Common.Traits public IEnumerable Render(WorldRenderer wr, World world) { yield break; } public IEnumerable RenderAfterWorld(WorldRenderer wr, World world) { yield break; } - public string GetCursor(World world, CPos xy, MouseInput mi) { return world.Map.Contains(xy) ? cursor : "generic-blocked"; } + public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) + { + return world.Map.Contains(cell) ? cursor : "generic-blocked"; + } } } diff --git a/OpenRA.Mods.Common/Widgets/RadarWidget.cs b/OpenRA.Mods.Common/Widgets/RadarWidget.cs index 970bd69012..06b263be49 100644 --- a/OpenRA.Mods.Common/Widgets/RadarWidget.cs +++ b/OpenRA.Mods.Common/Widgets/RadarWidget.cs @@ -219,7 +219,8 @@ namespace OpenRA.Mods.Common.Widgets return null; var cell = MinimapPixelToCell(pos); - var location = worldRenderer.Viewport.WorldToViewPx(worldRenderer.ScreenPxPosition(world.Map.CenterOfCell(cell))); + var worldPixel = worldRenderer.ScreenPxPosition(world.Map.CenterOfCell(cell)); + var location = worldRenderer.Viewport.WorldToViewPx(worldPixel); var mi = new MouseInput { @@ -228,7 +229,7 @@ namespace OpenRA.Mods.Common.Widgets Modifiers = Game.GetModifierKeys() }; - var cursor = world.OrderGenerator.GetCursor(world, cell, mi); + var cursor = world.OrderGenerator.GetCursor(world, cell, worldPixel, mi); if (cursor == null) return "default"; diff --git a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs index 20289ea7b5..da2fcf62ed 100644 --- a/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ViewportControllerWidget.cs @@ -128,9 +128,10 @@ namespace OpenRA.Mods.Common.Widgets return; } - var underCursor = world.ScreenMap.ActorsAt(worldRenderer.Viewport.ViewToWorldPx(Viewport.LastMousePos)) + var worldPixel = worldRenderer.Viewport.ViewToWorldPx(Viewport.LastMousePos); + var underCursor = world.ScreenMap.ActorsAt(worldPixel) .Where(a => !world.FogObscures(a) && a.Info.HasTraitInfo()) - .WithHighestSelectionPriority(); + .WithHighestSelectionPriority(worldPixel); if (underCursor != null) { @@ -140,9 +141,9 @@ namespace OpenRA.Mods.Common.Widgets return; } - var frozen = world.ScreenMap.FrozenActorsAt(world.RenderPlayer, worldRenderer.Viewport.ViewToWorldPx(Viewport.LastMousePos)) + var frozen = world.ScreenMap.FrozenActorsAt(world.RenderPlayer, worldPixel) .Where(a => a.TooltipInfo != null && a.IsValid) - .WithHighestSelectionPriority(); + .WithHighestSelectionPriority(worldPixel); if (frozen != null) { diff --git a/OpenRA.Mods.RA/Traits/Minelayer.cs b/OpenRA.Mods.RA/Traits/Minelayer.cs index 6af1edf56b..8234b54023 100644 --- a/OpenRA.Mods.RA/Traits/Minelayer.cs +++ b/OpenRA.Mods.RA/Traits/Minelayer.cs @@ -144,7 +144,7 @@ namespace OpenRA.Mods.RA.Traits tileBlocked = self.World.Map.SequenceProvider.GetSequence("overlay", "build-invalid").GetSprite(0); } - public IEnumerable Order(World world, CPos xy, MouseInput mi) + public IEnumerable Order(World world, CPos cell, int2 worldPixel, MouseInput mi) { if (mi.Button == Game.Settings.Game.MouseButtonPreference.Cancel) { @@ -160,7 +160,7 @@ namespace OpenRA.Mods.RA.Traits if (mi.Button == Game.Settings.Game.MouseButtonPreference.Action && underCursor == null) { minelayer.World.CancelInputMode(); - yield return new Order("PlaceMinefield", minelayer, false) { TargetLocation = xy }; + yield return new Order("PlaceMinefield", minelayer, false) { TargetLocation = cell }; } } @@ -190,7 +190,10 @@ namespace OpenRA.Mods.RA.Traits } } - public string GetCursor(World world, CPos xy, MouseInput mi) { lastMousePos = xy; return "ability"; } /* TODO */ + public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) + { + lastMousePos = cell; return "ability"; /* TODO */ + } } class BeginMinefieldOrderTargeter : IOrderTargeter diff --git a/OpenRA.Mods.RA/Traits/PortableChrono.cs b/OpenRA.Mods.RA/Traits/PortableChrono.cs index 58ded32349..67a4fd7161 100644 --- a/OpenRA.Mods.RA/Traits/PortableChrono.cs +++ b/OpenRA.Mods.RA/Traits/PortableChrono.cs @@ -151,7 +151,7 @@ namespace OpenRA.Mods.RA.Traits this.self = self; } - public IEnumerable Order(World world, CPos xy, MouseInput mi) + public IEnumerable Order(World world, CPos cell, int2 worldPixel, MouseInput mi) { if (mi.Button == Game.Settings.Game.MouseButtonPreference.Cancel) { @@ -159,11 +159,11 @@ namespace OpenRA.Mods.RA.Traits yield break; } - if (self.IsInWorld && self.Location != xy - && self.Trait().CanTeleport && self.Owner.Shroud.IsExplored(xy)) + if (self.IsInWorld && self.Location != cell + && self.Trait().CanTeleport && self.Owner.Shroud.IsExplored(cell)) { world.CancelInputMode(); - yield return new Order("PortableChronoTeleport", self, mi.Modifiers.HasModifier(Modifiers.Shift)) { TargetLocation = xy }; + yield return new Order("PortableChronoTeleport", self, mi.Modifiers.HasModifier(Modifiers.Shift)) { TargetLocation = cell }; } } @@ -194,10 +194,10 @@ namespace OpenRA.Mods.RA.Traits Color.FromArgb(96, Color.Black)); } - public string GetCursor(World world, CPos xy, MouseInput mi) + public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { - if (self.IsInWorld && self.Location != xy - && self.Trait().CanTeleport && self.Owner.Shroud.IsExplored(xy)) + if (self.IsInWorld && self.Location != cell + && self.Trait().CanTeleport && self.Owner.Shroud.IsExplored(cell)) return "chrono-target"; else return "move-blocked"; diff --git a/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs b/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs index 91325dd111..09f590eb32 100644 --- a/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs +++ b/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs @@ -115,11 +115,11 @@ namespace OpenRA.Mods.RA.Traits tile = world.Map.SequenceProvider.GetSequence("overlay", "target-select").GetSprite(0); } - public IEnumerable Order(World world, CPos xy, MouseInput mi) + public IEnumerable Order(World world, CPos cell, int2 worldPixel, MouseInput mi) { world.CancelInputMode(); if (mi.Button == MouseButton.Left) - world.OrderGenerator = new SelectDestination(world, order, manager, power, xy); + world.OrderGenerator = new SelectDestination(world, order, manager, power, cell); yield break; } @@ -150,7 +150,7 @@ namespace OpenRA.Mods.RA.Traits yield return new SpriteRenderable(tile, wr.World.Map.CenterOfCell(t), WVec.Zero, -511, pal, 1f, true); } - public string GetCursor(World world, CPos xy, MouseInput mi) + public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { return "chrono-select"; } @@ -179,7 +179,7 @@ namespace OpenRA.Mods.RA.Traits sourceTile = world.Map.SequenceProvider.GetSequence("overlay", "target-select").GetSprite(0); } - public IEnumerable Order(World world, CPos xy, MouseInput mi) + public IEnumerable Order(World world, CPos cell, int2 worldPixel, MouseInput mi) { if (mi.Button == MouseButton.Right) { @@ -187,7 +187,7 @@ namespace OpenRA.Mods.RA.Traits yield break; } - var ret = OrderInner(xy).FirstOrDefault(); + var ret = OrderInner(cell).FirstOrDefault(); if (ret == null) yield break; @@ -281,9 +281,9 @@ namespace OpenRA.Mods.RA.Traits return canTeleport; } - public string GetCursor(World world, CPos xy, MouseInput mi) + public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { - return IsValidTarget(xy) ? "chrono-target" : "move-blocked"; + return IsValidTarget(cell) ? "chrono-target" : "move-blocked"; } } }