Select highest priority actor when not drag selecting.
This commit is contained in:
@@ -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)
|
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)
|
// For dragboxes that are too small, shrink the dragbox to a single point (point b)
|
||||||
if ((a - b).Length <= Game.Settings.Game.SelectionDeadzone)
|
if ((a - b).Length <= Game.Settings.Game.SelectionDeadzone)
|
||||||
a = b;
|
a = b;
|
||||||
|
|
||||||
|
if (a == b)
|
||||||
|
return SelectHighestPriorityActorAtPoint(world, a);
|
||||||
|
|
||||||
return world.ScreenMap.ActorsInMouseBox(a, b)
|
return world.ScreenMap.ActorsInMouseBox(a, b)
|
||||||
.Select(x => x.Actor)
|
.Select(x => x.Actor)
|
||||||
.Where(x => x.Info.HasTraitInfo<SelectableInfo>() && (x.Owner.IsAlliedWith(world.RenderPlayer) || !world.FogObscures(x)))
|
.Where(x => x.Info.HasTraitInfo<SelectableInfo>() && (x.Owner.IsAlliedWith(world.RenderPlayer) || !world.FogObscures(x)))
|
||||||
|
|||||||
Reference in New Issue
Block a user