Select highest priority actor when not drag selecting.

This commit is contained in:
Paul Chote
2017-12-08 22:20:32 +00:00
committed by reaperrr
parent ff5b4b15b3
commit bf57eceeec

View File

@@ -323,12 +323,25 @@ namespace OpenRA.Mods.Common.Widgets
});
}
static IEnumerable<Actor> SelectHighestPriorityActorAtPoint(World world, int2 a)
{
var selected = world.ScreenMap.ActorsAtMouse(a)
.Where(x => x.Actor.Info.HasTraitInfo<SelectableInfo>() && (x.Actor.Owner.IsAlliedWith(world.RenderPlayer) || !world.FogObscures(x.Actor)))
.WithHighestSelectionPriority(a);
if (selected != null)
yield return selected;
}
static IEnumerable<Actor> 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<SelectableInfo>() && (x.Owner.IsAlliedWith(world.RenderPlayer) || !world.FogObscures(x)))