From 6ca51e47c1e2028a2bc00c1b2d15f7b852c1c1ac Mon Sep 17 00:00:00 2001 From: Curtis Shmyr Date: Sun, 10 May 2015 11:12:10 -0600 Subject: [PATCH] Give ally players a yellow hp bar for team health colors --- .../Graphics/SelectionBarsRenderable.cs | 26 +++++++++++++++---- OpenRA.Game/Player.cs | 2 +- .../LoadIngamePlayerOrObserverUILogic.cs | 1 + 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/OpenRA.Game/Graphics/SelectionBarsRenderable.cs b/OpenRA.Game/Graphics/SelectionBarsRenderable.cs index 9127ea3bae..4d86850a25 100644 --- a/OpenRA.Game/Graphics/SelectionBarsRenderable.cs +++ b/OpenRA.Game/Graphics/SelectionBarsRenderable.cs @@ -76,12 +76,28 @@ namespace OpenRA.Graphics Color GetHealthColor(Health health) { - if (Game.Settings.Game.TeamHealthColors) + var player = actor.World.RenderPlayer ?? actor.World.LocalPlayer; + + if (Game.Settings.Game.TeamHealthColors && player != null && !player.Spectating) { - var isAlly = actor.Owner.IsAlliedWith(actor.World.LocalPlayer) - || (actor.EffectiveOwner != null && actor.EffectiveOwner.Disguised - && actor.World.LocalPlayer.IsAlliedWith(actor.EffectiveOwner.Owner)); - return isAlly ? Color.LimeGreen : actor.Owner.NonCombatant ? Color.Tan : Color.Red; + var apparentOwner = actor.EffectiveOwner != null && actor.EffectiveOwner.Disguised + ? actor.EffectiveOwner.Owner + : actor.Owner; + + // For friendly spies, treat the unit's owner as the actual owner + if (actor.Owner.IsAlliedWith(actor.World.RenderPlayer)) + apparentOwner = actor.Owner; + + if (apparentOwner == player) + return Color.LimeGreen; + + if (apparentOwner.IsAlliedWith(player)) + return Color.Yellow; + + if (apparentOwner.NonCombatant) + return Color.Tan; + + return Color.Red; } else return health.DamageState == DamageState.Critical ? Color.Red : diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index 05a105bc6a..a4da8f438c 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -33,7 +33,6 @@ namespace OpenRA public readonly string InternalName; public readonly CountryInfo Country; public readonly bool NonCombatant = false; - public readonly bool Spectating = false; public readonly bool Playable = true; public readonly int ClientIndex; public readonly PlayerReference PlayerReference; @@ -45,6 +44,7 @@ namespace OpenRA public bool IsBot; public int SpawnPoint; public bool HasObjectives = false; + public bool Spectating; public Shroud Shroud; public World World { get; private set; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs index 7a7b6aa905..0120bf2fbb 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/LoadIngamePlayerOrObserverUILogic.cs @@ -35,6 +35,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (world.ObserveAfterWinOrLose && world.LocalPlayer.WinState != WinState.Undefined) Game.RunAfterTick(() => { + world.LocalPlayer.Spectating = true; playerRoot.RemoveChildren(); Game.LoadWidget(world, "OBSERVER_WIDGETS", playerRoot, new WidgetArgs()); });