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)