Make PlayerRelationShipColor static

This commit is contained in:
Gustas
2023-06-11 17:09:29 +03:00
committed by Matthias Mailänder
parent fa0254cb27
commit 34262fb33c
6 changed files with 10 additions and 29 deletions

View File

@@ -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<FactionInfo> factionInfos, MersenneTwister playerRandom, bool requireSelectable = true)
{
var selectableFactions = factionInfos
@@ -221,11 +211,6 @@ namespace OpenRA
logic.Activate(this);
}
stanceColors.Self = ChromeMetrics.Get<Color>("PlayerStanceColorSelf");
stanceColors.Allies = ChromeMetrics.Get<Color>("PlayerStanceColorAllies");
stanceColors.Enemies = ChromeMetrics.Get<Color>("PlayerStanceColorEnemies");
stanceColors.Neutrals = ChromeMetrics.Get<Color>("PlayerStanceColorNeutrals");
unlockRenderPlayer = PlayerActor.TraitsImplementing<IUnlocksRenderPlayer>().ToArray();
notifyDisconnected = PlayerActor.TraitsImplementing<INotifyPlayerDisconnected>().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<Color>("PlayerStanceColorSelf");
if (apparentOwner.IsAlliedWith(player))
return stanceColors.Allies;
return ChromeMetrics.Get<Color>("PlayerStanceColorAllies");
if (!apparentOwner.NonCombatant)
return stanceColors.Enemies;
return ChromeMetrics.Get<Color>("PlayerStanceColorEnemies");
}
return stanceColors.Neutrals;
return ChromeMetrics.Get<Color>("PlayerStanceColorNeutrals");
}
internal void PlayerDisconnected(Player p)

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);