simplify UOG
This commit is contained in:
@@ -21,11 +21,7 @@ namespace OpenRA.Orders
|
|||||||
{
|
{
|
||||||
var underCursor = world.FindUnitsAtMouse(mi.Location)
|
var underCursor = world.FindUnitsAtMouse(mi.Location)
|
||||||
.Where(a => a.HasTrait<ITargetable>())
|
.Where(a => a.HasTrait<ITargetable>())
|
||||||
.OrderByDescending(
|
.OrderByDescending(a => a.SelectionPriority())
|
||||||
a =>
|
|
||||||
a.Info.Traits.Contains<SelectableInfo>()
|
|
||||||
? a.Info.Traits.Get<SelectableInfo>().Priority
|
|
||||||
: int.MinValue)
|
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
var orders = world.Selection.Actors
|
var orders = world.Selection.Actors
|
||||||
@@ -55,7 +51,7 @@ namespace OpenRA.Orders
|
|||||||
|
|
||||||
var underCursor = world.FindUnitsAtMouse(mi.Location)
|
var underCursor = world.FindUnitsAtMouse(mi.Location)
|
||||||
.Where(a => a.HasTrait<ITargetable>())
|
.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();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any())
|
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