diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index 20ba3c35fe..7df35e0128 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -37,14 +37,6 @@ namespace OpenRA public class Player : IScriptBindable, IScriptNotifyBind, ILuaTableBinding, ILuaEqualityBinding, ILuaToStringBinding { - struct StanceColors - { - public Color Self; - public Color Allies; - public Color Enemies; - public Color Neutrals; - } - public readonly Actor PlayerActor; public readonly Color Color; @@ -101,8 +93,6 @@ namespace OpenRA } } - readonly StanceColors stanceColors; - public static FactionInfo ResolveFaction(string factionName, IEnumerable factionInfos, MersenneTwister playerRandom, bool requireSelectable = true) { var selectableFactions = factionInfos @@ -221,11 +211,6 @@ namespace OpenRA logic.Activate(this); } - stanceColors.Self = ChromeMetrics.Get("PlayerStanceColorSelf"); - stanceColors.Allies = ChromeMetrics.Get("PlayerStanceColorAllies"); - stanceColors.Enemies = ChromeMetrics.Get("PlayerStanceColorEnemies"); - stanceColors.Neutrals = ChromeMetrics.Get("PlayerStanceColorNeutrals"); - unlockRenderPlayer = PlayerActor.TraitsImplementing().ToArray(); notifyDisconnected = PlayerActor.TraitsImplementing().ToArray(); } @@ -259,7 +244,7 @@ namespace OpenRA return RelationshipWith(p) == PlayerRelationship.Ally; } - public Color PlayerRelationshipColor(Actor a) + public static Color PlayerRelationshipColor(Actor a) { var renderPlayer = a.World.RenderPlayer; var player = renderPlayer ?? a.World.LocalPlayer; @@ -271,16 +256,16 @@ namespace OpenRA apparentOwner = effectiveOwner.Owner; if (apparentOwner == player) - return stanceColors.Self; + return ChromeMetrics.Get("PlayerStanceColorSelf"); if (apparentOwner.IsAlliedWith(player)) - return stanceColors.Allies; + return ChromeMetrics.Get("PlayerStanceColorAllies"); if (!apparentOwner.NonCombatant) - return stanceColors.Enemies; + return ChromeMetrics.Get("PlayerStanceColorEnemies"); } - return stanceColors.Neutrals; + return ChromeMetrics.Get("PlayerStanceColorNeutrals"); } internal void PlayerDisconnected(Player p) diff --git a/OpenRA.Mods.Cnc/Traits/Disguise.cs b/OpenRA.Mods.Cnc/Traits/Disguise.cs index fd2478a571..dd5c0c7817 100644 --- a/OpenRA.Mods.Cnc/Traits/Disguise.cs +++ b/OpenRA.Mods.Cnc/Traits/Disguise.cs @@ -163,7 +163,7 @@ namespace OpenRA.Mods.Cnc.Traits if (!Disguised || self.Owner.IsAlliedWith(self.World.RenderPlayer)) return color; - return Game.Settings.Game.UsePlayerStanceColors ? AsPlayer.PlayerRelationshipColor(self) : AsPlayer.Color; + return Game.Settings.Game.UsePlayerStanceColors ? Player.PlayerRelationshipColor(self) : AsPlayer.Color; } public void DisguiseAs(Actor target) diff --git a/OpenRA.Mods.Common/Graphics/IsometricSelectionBarsAnnotationRenderable.cs b/OpenRA.Mods.Common/Graphics/IsometricSelectionBarsAnnotationRenderable.cs index b9e24790c7..3a73b43e80 100644 --- a/OpenRA.Mods.Common/Graphics/IsometricSelectionBarsAnnotationRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/IsometricSelectionBarsAnnotationRenderable.cs @@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.Graphics Color GetHealthColor(IHealth health) { if (Game.Settings.Game.UsePlayerStanceColors) - return actor.Owner.PlayerRelationshipColor(actor); + return Player.PlayerRelationshipColor(actor); return health.DamageState == DamageState.Critical ? Color.Red : health.DamageState == DamageState.Heavy ? Color.Yellow : Color.LimeGreen; diff --git a/OpenRA.Mods.Common/Graphics/SelectionBarsAnnotationRenderable.cs b/OpenRA.Mods.Common/Graphics/SelectionBarsAnnotationRenderable.cs index 1be1ace602..79a81564a9 100644 --- a/OpenRA.Mods.Common/Graphics/SelectionBarsAnnotationRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/SelectionBarsAnnotationRenderable.cs @@ -84,7 +84,7 @@ namespace OpenRA.Mods.Common.Graphics Color GetHealthColor(IHealth health) { if (Game.Settings.Game.UsePlayerStanceColors) - return actor.Owner.PlayerRelationshipColor(actor); + return Player.PlayerRelationshipColor(actor); return health.DamageState == DamageState.Critical ? Color.Red : health.DamageState == DamageState.Heavy ? Color.Yellow : Color.LimeGreen; diff --git a/OpenRA.Mods.Common/Traits/Radar/AppearsOnRadar.cs b/OpenRA.Mods.Common/Traits/Radar/AppearsOnRadar.cs index 1de8c48551..8fdf20c8ad 100644 --- a/OpenRA.Mods.Common/Traits/Radar/AppearsOnRadar.cs +++ b/OpenRA.Mods.Common/Traits/Radar/AppearsOnRadar.cs @@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits.Radar if (IsTraitDisabled || (viewer != null && !Info.ValidRelationships.HasRelationship(self.Owner.RelationshipWith(viewer)))) return; - var color = Game.Settings.Game.UsePlayerStanceColors ? self.Owner.PlayerRelationshipColor(self) : self.Owner.Color; + var color = Game.Settings.Game.UsePlayerStanceColors ? Player.PlayerRelationshipColor(self) : self.Owner.Color; if (modifier != null) color = modifier.RadarColorOverride(self, color); diff --git a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs index c234ad1a29..c78bba496c 100644 --- a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs @@ -61,11 +61,7 @@ namespace OpenRA.Mods.Common.Widgets var time = WidgetUtils.FormatTime(p.RemainingTicks, false, self.World.Timestep); var text = TranslationProvider.GetString(Format, Translation.Arguments("player", self.Owner.PlayerName, "support-power", p.Name, "time", time)); - var playerColor = self.Owner.Color; - - if (Game.Settings.Game.UsePlayerStanceColors) - playerColor = self.Owner.PlayerRelationshipColor(self); - + var playerColor = Game.Settings.Game.UsePlayerStanceColors ? Player.PlayerRelationshipColor(self) : self.Owner.Color; var color = !p.Ready || Game.LocalTick % 50 < 25 ? playerColor : Color.White; return (text, color);