Clean up actor selection in WorldInteractionControllerWidget.
This commit is contained in:
@@ -206,5 +206,11 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Actor> ActorsInWorld()
|
||||||
|
{
|
||||||
|
return actors.SelectMany(a => a.Where(b => b.IsInWorld))
|
||||||
|
.Distinct();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,18 +209,20 @@ namespace OpenRA.Widgets
|
|||||||
}
|
}
|
||||||
else if (key == Game.Settings.Keys.SelectUnitsByTypeKey)
|
else if (key == Game.Settings.Keys.SelectUnitsByTypeKey)
|
||||||
{
|
{
|
||||||
var selectedTypes = World.Selection.Actors.Where(
|
var selectedTypes = World.Selection.Actors
|
||||||
x => x.Owner == World.RenderPlayer).Select(a => a.Info);
|
.Where(x => x.Owner == World.RenderPlayer)
|
||||||
|
.Select(a => a.Info);
|
||||||
|
|
||||||
Func<Actor, bool> cond = a => a.Owner == World.RenderPlayer && selectedTypes.Contains(a.Info);
|
Func<Actor, bool> cond = a => a.Owner == World.RenderPlayer && selectedTypes.Contains(a.Info);
|
||||||
var newSelection = SelectActorsInBox(
|
var tl = worldRenderer.Viewport.TopLeft;
|
||||||
World, worldRenderer.Viewport.TopLeft, worldRenderer.Viewport.BottomRight, cond);
|
var br = worldRenderer.Viewport.BottomRight;
|
||||||
|
var newSelection = SelectActorsInBox(World, tl, br, cond);
|
||||||
|
|
||||||
if (newSelection.Count() > selectedTypes.Count())
|
if (newSelection.Count() > selectedTypes.Count())
|
||||||
Game.Debug("Selected across screen");
|
Game.Debug("Selected across screen");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newSelection = World.ActorMap.ActorsInBox(
|
newSelection = World.ActorMap.ActorsInWorld().Where(cond);
|
||||||
World.Map.Bounds.TopLeftAsCPos().TopLeft,
|
|
||||||
World.Map.Bounds.BottomRightAsCPos().BottomRight).Where(cond);
|
|
||||||
Game.Debug("Selected across map");
|
Game.Debug("Selected across map");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user