664 fixed
This commit is contained in:
@@ -15,6 +15,7 @@ using OpenRA.FileFormats;
|
|||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Orders;
|
using OpenRA.Orders;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
@@ -144,11 +145,35 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
return world.FindUnits(a, b)
|
return world.FindUnits(a, b)
|
||||||
.Where( x => x.HasTrait<Selectable>() && world.LocalShroud.IsVisible(x) )
|
.Where( x => x.HasTrait<Selectable>() && world.LocalShroud.IsVisible(x) )
|
||||||
.GroupBy(x => (x.Owner == world.LocalPlayer) ? x.Info.Traits.Get<SelectableInfo>().Priority : 0)
|
.GroupBy(x => x.GetSelectionPriority())
|
||||||
.OrderByDescending(g => g.Key)
|
.OrderByDescending(g => g.Key)
|
||||||
.Select( g => g.AsEnumerable() )
|
.Select( g => g.AsEnumerable() )
|
||||||
.DefaultIfEmpty( NoActors )
|
.DefaultIfEmpty( NoActors )
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class PriorityExts
|
||||||
|
{
|
||||||
|
const int PriorityRange = 30;
|
||||||
|
|
||||||
|
public static int GetSelectionPriority(this Actor a)
|
||||||
|
{
|
||||||
|
var basePriority = a.Info.Traits.Get<SelectableInfo>().Priority;
|
||||||
|
var lp = a.World.LocalPlayer;
|
||||||
|
|
||||||
|
if (a.Owner == lp || lp == null)
|
||||||
|
return basePriority;
|
||||||
|
|
||||||
|
switch (lp.Stances[a.Owner])
|
||||||
|
{
|
||||||
|
case Stance.Ally: return basePriority - PriorityRange;
|
||||||
|
case Stance.Neutral: return basePriority - 2 * PriorityRange;
|
||||||
|
case Stance.Enemy: return basePriority - 3 * PriorityRange;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user