Add some basic safeguards around RenderPlayer.set.

This commit is contained in:
Paul Chote
2018-05-28 12:01:23 +00:00
committed by reaperrr
parent 3a1857886a
commit ebf3ec0e90
4 changed files with 43 additions and 5 deletions

View File

@@ -68,6 +68,20 @@ namespace OpenRA
public Shroud Shroud;
public World World { get; private set; }
readonly bool inMissionMap;
readonly IUnlocksRenderPlayer[] unlockRenderPlayer;
public bool UnlockedRenderPlayer
{
get
{
if (unlockRenderPlayer.Any(x => x.RenderPlayerUnlocked))
return true;
return WinState != WinState.Undefined && !inMissionMap;
}
}
readonly StanceColors stanceColors;
static FactionInfo ChooseFaction(World world, string name, bool requireSelectable = true)
@@ -105,6 +119,8 @@ namespace OpenRA
InternalName = pr.Name;
PlayerReference = pr;
inMissionMap = world.Map.Visibility.HasFlag(MapVisibility.MissionSelector);
// Real player or host-created bot
if (client != null)
{
@@ -156,6 +172,8 @@ namespace OpenRA
stanceColors.Allies = ChromeMetrics.Get<Color>("PlayerStanceColorAllies");
stanceColors.Enemies = ChromeMetrics.Get<Color>("PlayerStanceColorEnemies");
stanceColors.Neutrals = ChromeMetrics.Get<Color>("PlayerStanceColorNeutrals");
unlockRenderPlayer = PlayerActor.TraitsImplementing<IUnlocksRenderPlayer>().ToArray();
}
public override string ToString()