Add FirstNonEmptyBounds method for IDecorationBounds interface.
This provides a more efficient way of determining the bounds by avoiding LINQ. A helper that works directly on arrays prevents allocation of an enumerator when the collection is know to be an array.
This commit is contained in:
@@ -51,10 +51,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
// TODO: Integrate this with SelectionDecorations to unhardcode the *Renderable
|
||||
if (unit.Info.HasTraitInfo<SelectableInfo>())
|
||||
{
|
||||
var bounds = unit.TraitsImplementing<IDecorationBounds>()
|
||||
.Select(b => b.DecorationBounds(unit, worldRenderer))
|
||||
.FirstOrDefault(b => !b.IsEmpty);
|
||||
|
||||
var bounds = unit.TraitsImplementing<IDecorationBounds>().FirstNonEmptyBounds(unit, worldRenderer);
|
||||
new SelectionBarsRenderable(unit, bounds, true, true).Render(worldRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user