simplify UOG
This commit is contained in:
@@ -21,11 +21,7 @@ namespace OpenRA.Orders
|
||||
{
|
||||
var underCursor = world.FindUnitsAtMouse(mi.Location)
|
||||
.Where(a => a.HasTrait<ITargetable>())
|
||||
.OrderByDescending(
|
||||
a =>
|
||||
a.Info.Traits.Contains<SelectableInfo>()
|
||||
? a.Info.Traits.Get<SelectableInfo>().Priority
|
||||
: int.MinValue)
|
||||
.OrderByDescending(a => a.SelectionPriority())
|
||||
.FirstOrDefault();
|
||||
|
||||
var orders = world.Selection.Actors
|
||||
@@ -55,7 +51,7 @@ namespace OpenRA.Orders
|
||||
|
||||
var underCursor = world.FindUnitsAtMouse(mi.Location)
|
||||
.Where(a => a.HasTrait<ITargetable>())
|
||||
.OrderByDescending(a => a.Info.Traits.Contains<SelectableInfo>() ? a.Info.Traits.Get<SelectableInfo>().Priority : int.MinValue)
|
||||
.OrderByDescending(a => a.SelectionPriority())
|
||||
.FirstOrDefault();
|
||||
|
||||
if (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any())
|
||||
@@ -130,4 +126,13 @@ namespace OpenRA.Orders
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SelectableExts
|
||||
{
|
||||
public static int SelectionPriority(this Actor a)
|
||||
{
|
||||
var selectableInfo = a.Info.Traits.GetOrDefault<SelectableInfo>();
|
||||
return selectableInfo != null ? selectableInfo.Priority : int.MinValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user