diff --git a/OpenRA.Mods.Common/Traits/Render/SelectionDecorationsBase.cs b/OpenRA.Mods.Common/Traits/Render/SelectionDecorationsBase.cs index b82c37f7f7d6..5f41b1af8f02 100644 --- a/OpenRA.Mods.Common/Traits/Render/SelectionDecorationsBase.cs +++ b/OpenRA.Mods.Common/Traits/Render/SelectionDecorationsBase.cs @@ -29,6 +29,8 @@ public abstract class SelectionDecorationsBase : ISelectionDecorations, IRenderA protected readonly SelectionDecorationsBaseInfo Info; + DeveloperMode developerMode; + public SelectionDecorationsBase(SelectionDecorationsBaseInfo info) { Info = info; @@ -69,7 +71,6 @@ IEnumerable IRenderAnnotations.RenderAnnotations(Actor self, WorldR IEnumerable DrawDecorations(Actor self, WorldRenderer wr) { var selected = self.World.Selection.Contains(self); - var rollover = self.World.Selection.RolloverContains(self); var regularWorld = self.World.Type == WorldType.Regular; var statusBars = Game.Settings.Game.StatusBars; @@ -77,13 +78,18 @@ IEnumerable DrawDecorations(Actor self, WorldRenderer wr) // * actor is selected / in active drag rectangle / under the mouse // * status bar preference is set to "always show" // * status bar preference is set to "when damaged" and actor is damaged - var displayHealth = selected || rollover || (regularWorld && statusBars == StatusBarsType.AlwaysShow) + var displayHealth = selected || (regularWorld && statusBars == StatusBarsType.AlwaysShow) || (regularWorld && statusBars == StatusBarsType.DamageShow && self.GetDamageState() != DamageState.Undamaged); // Extra bars are shown when: // * actor is selected / in active drag rectangle / under the mouse // * status bar preference is set to "always show" or "when damaged" - var displayExtra = selected || rollover || (regularWorld && statusBars != StatusBarsType.Standard); + var displayExtra = selected || (regularWorld && statusBars != StatusBarsType.Standard); + + // PERF: Only search rollover enumerable if needed. + if (!displayHealth || !displayExtra) + if (self.World.Selection.RolloverContains(self)) + displayHealth = displayExtra = true; if (selected) foreach (var r in RenderSelectionBox(self, wr, Info.SelectionBoxColor)) @@ -93,8 +99,14 @@ IEnumerable DrawDecorations(Actor self, WorldRenderer wr) foreach (var r in RenderSelectionBars(self, wr, displayHealth, displayExtra)) yield return r; - if (selected && self.World.LocalPlayer != null && self.World.LocalPlayer.PlayerActor.Trait().PathDebug) - yield return new TargetLineRenderable(ActivityTargetPath(self), Color.Green, 1, 2); + if (selected && self.World.LocalPlayer != null) + { + if (developerMode == null) + developerMode = self.World.LocalPlayer.PlayerActor.Trait(); + + if (developerMode.PathDebug) + yield return new TargetLineRenderable(ActivityTargetPath(self), Color.Green, 1, 2); + } // Hide decorations for spectators that zoom out further than the normal minimum level // This avoids graphical glitches with pip rows and icons overlapping the selection box