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)))