From bf57eceeec34689e392e04efdc96e499cc8f0afb Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 8 Dec 2017 22:20:32 +0000 Subject: [PATCH] Select highest priority actor when not drag selecting. --- .../Widgets/WorldInteractionControllerWidget.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OpenRA.Mods.Common/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Mods.Common/Widgets/WorldInteractionControllerWidget.cs index a45b1752f4..0d6293dafd 100644 --- a/OpenRA.Mods.Common/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/WorldInteractionControllerWidget.cs @@ -323,12 +323,25 @@ namespace OpenRA.Mods.Common.Widgets }); } + static IEnumerable SelectHighestPriorityActorAtPoint(World world, int2 a) + { + var selected = world.ScreenMap.ActorsAtMouse(a) + .Where(x => x.Actor.Info.HasTraitInfo() && (x.Actor.Owner.IsAlliedWith(world.RenderPlayer) || !world.FogObscures(x.Actor))) + .WithHighestSelectionPriority(a); + + if (selected != null) + yield return selected; + } + static IEnumerable SelectActorsInBoxWithDeadzone(World world, int2 a, int2 b) { // For dragboxes that are too small, shrink the dragbox to a single point (point b) if ((a - b).Length <= Game.Settings.Game.SelectionDeadzone) a = b; + if (a == b) + return SelectHighestPriorityActorAtPoint(world, a); + return world.ScreenMap.ActorsInMouseBox(a, b) .Select(x => x.Actor) .Where(x => x.Info.HasTraitInfo() && (x.Owner.IsAlliedWith(world.RenderPlayer) || !world.FogObscures(x)))