diff --git a/OpenRA.Game/Orders/UnitOrderGenerator.cs b/OpenRA.Game/Orders/UnitOrderGenerator.cs index 7ee5e66689..26f1a79ece 100644 --- a/OpenRA.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRA.Game/Orders/UnitOrderGenerator.cs @@ -21,7 +21,7 @@ namespace OpenRA.Orders { var underCursor = world.FindUnitsAtMouse(mi.Location) .Where(a => a.HasTrait()) - .OrderByDescending(a => a.SelectionPriority()) + .OrderByDescending(a => a.Info.SelectionPriority()) .FirstOrDefault(); var orders = world.Selection.Actors @@ -51,7 +51,7 @@ namespace OpenRA.Orders var underCursor = world.FindUnitsAtMouse(mi.Location) .Where(a => a.HasTrait()) - .OrderByDescending(a => a.SelectionPriority()) + .OrderByDescending(a => a.Info.SelectionPriority()) .FirstOrDefault(); if (underCursor != null && (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any())) @@ -135,9 +135,9 @@ namespace OpenRA.Orders public static class SelectableExts { - public static int SelectionPriority(this Actor a) + public static int SelectionPriority(this ActorInfo a) { - var selectableInfo = a.Info.Traits.GetOrDefault(); + var selectableInfo = a.Traits.GetOrDefault(); return selectableInfo != null ? selectableInfo.Priority : int.MinValue; } } diff --git a/OpenRA.Game/Widgets/ViewportControllerWidget.cs b/OpenRA.Game/Widgets/ViewportControllerWidget.cs index 23a1a597ca..7a3ed4b510 100755 --- a/OpenRA.Game/Widgets/ViewportControllerWidget.cs +++ b/OpenRA.Game/Widgets/ViewportControllerWidget.cs @@ -14,6 +14,7 @@ using System.Linq; using OpenRA.FileFormats; using OpenRA.GameRules; using OpenRA.Graphics; +using OpenRA.Orders; using OpenRA.Traits; namespace OpenRA.Widgets @@ -101,13 +102,17 @@ namespace OpenRA.Widgets return; } - var actor = world.FindUnitsAtMouse(Viewport.LastMousePos).FirstOrDefault(); - if (actor == null) - return; + var underCursor = world.FindUnitsAtMouse(Viewport.LastMousePos) + .Where(a => a.HasTrait()) + .OrderByDescending(a => a.Info.SelectionPriority()) + .FirstOrDefault(); - ActorTooltip = actor.TraitsImplementing().FirstOrDefault(); - if (ActorTooltip != null) + if (underCursor != null) + { + ActorTooltip = underCursor.TraitsImplementing().First(); TooltipType = WorldTooltipType.Actor; + return; + } } public static string GetScrollCursor(Widget w, ScrollDirection edge, int2 pos)