Remove health bar rendering duplication.
This commit is contained in:
@@ -194,31 +194,6 @@ namespace OpenRA.Graphics
|
|||||||
foreach (var r in g)
|
foreach (var r in g)
|
||||||
r.RenderDebugGeometry(this);
|
r.RenderDebugGeometry(this);
|
||||||
|
|
||||||
if (World.Type == WorldType.Regular)
|
|
||||||
{
|
|
||||||
foreach (var g in World.ScreenMap.ActorsInBox(Viewport.TopLeft, Viewport.BottomRight)
|
|
||||||
.Where(a =>
|
|
||||||
!a.Disposed &&
|
|
||||||
!World.Selection.Contains(a) &&
|
|
||||||
a.Info.HasTraitInfo<SelectableInfo>() &&
|
|
||||||
!World.FogObscures(a)))
|
|
||||||
{
|
|
||||||
if (Game.Settings.Game.StatusBars == StatusBarsType.Standard)
|
|
||||||
new SelectionBarsRenderable(g, false, false).Render(this);
|
|
||||||
|
|
||||||
if (Game.Settings.Game.StatusBars == StatusBarsType.AlwaysShow)
|
|
||||||
new SelectionBarsRenderable(g, true, true).Render(this);
|
|
||||||
|
|
||||||
if (Game.Settings.Game.StatusBars == StatusBarsType.DamageShow)
|
|
||||||
{
|
|
||||||
if (g.GetDamageState() != DamageState.Undamaged)
|
|
||||||
new SelectionBarsRenderable(g, true, true).Render(this);
|
|
||||||
else
|
|
||||||
new SelectionBarsRenderable(g, false, true).Render(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Game.Renderer.Flush();
|
Game.Renderer.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
public int[] SelectionBoxBounds { get { return VisualBounds; } }
|
public int[] SelectionBoxBounds { get { return VisualBounds; } }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SelectionDecorations : IRenderAboveShroudWhenSelected, ITick
|
public class SelectionDecorations : IRenderAboveShroud, ITick
|
||||||
{
|
{
|
||||||
// depends on the order of pips in TraitsInterfaces.cs!
|
// depends on the order of pips in TraitsInterfaces.cs!
|
||||||
static readonly string[] PipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray", "pip-blue", "pip-ammo", "pip-ammoempty" };
|
static readonly string[] PipStrings = { "pip-empty", "pip-green", "pip-yellow", "pip-red", "pip-gray", "pip-blue", "pip-ammo", "pip-ammoempty" };
|
||||||
@@ -73,18 +73,36 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<IRenderable> IRenderAboveShroudWhenSelected.RenderAboveShroud(Actor self, WorldRenderer wr)
|
IEnumerable<IRenderable> IRenderAboveShroud.RenderAboveShroud(Actor self, WorldRenderer wr)
|
||||||
{
|
{
|
||||||
if (self.World.FogObscures(self))
|
if (self.World.FogObscures(self))
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
if (Info.RenderSelectionBox)
|
var selected = self.World.Selection.Contains(self);
|
||||||
|
var regularWorld = self.World.Type == WorldType.Regular;
|
||||||
|
var statusBars = Game.Settings.Game.StatusBars;
|
||||||
|
|
||||||
|
// Health bars are shown when:
|
||||||
|
// * actor is selected
|
||||||
|
// * status bar preference is set to "always show"
|
||||||
|
// * status bar preference is set to "when damaged" and actor is damaged
|
||||||
|
var displayHealth = selected || (regularWorld && statusBars == StatusBarsType.AlwaysShow)
|
||||||
|
|| (regularWorld && statusBars == StatusBarsType.DamageShow && self.GetDamageState() != DamageState.Undamaged);
|
||||||
|
|
||||||
|
// Extra bars are shown when:
|
||||||
|
// * actor is selected
|
||||||
|
// * status bar preference is set to "always show"
|
||||||
|
// * status bar preference is set to "when damaged"
|
||||||
|
var displayExtra = selected || (regularWorld && statusBars != StatusBarsType.Standard);
|
||||||
|
|
||||||
|
if (Info.RenderSelectionBox && selected)
|
||||||
yield return new SelectionBoxRenderable(self, Info.SelectionBoxColor);
|
yield return new SelectionBoxRenderable(self, Info.SelectionBoxColor);
|
||||||
|
|
||||||
if (Info.RenderSelectionBars)
|
if (Info.RenderSelectionBars && (displayHealth || displayExtra))
|
||||||
yield return new SelectionBarsRenderable(self, true, true);
|
yield return new SelectionBarsRenderable(self, displayHealth, displayExtra);
|
||||||
|
|
||||||
if (!self.Owner.IsAlliedWith(wr.World.RenderPlayer))
|
// Target lines and pips are always only displayed for selected allied actors
|
||||||
|
if (!selected || !self.Owner.IsAlliedWith(wr.World.RenderPlayer))
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
if (self.World.LocalPlayer != null && self.World.LocalPlayer.PlayerActor.Trait<DeveloperMode>().PathDebug)
|
if (self.World.LocalPlayer != null && self.World.LocalPlayer.PlayerActor.Trait<DeveloperMode>().PathDebug)
|
||||||
|
|||||||
Reference in New Issue
Block a user