Fix shroud for observers observing a player after win/loss.

This commit is contained in:
Paul Chote
2013-04-10 22:33:58 +12:00
parent 707c86fbbb
commit 2c680a1831
2 changed files with 14 additions and 9 deletions

View File

@@ -42,7 +42,14 @@ namespace OpenRA
public void AddPlayer(Player p) { Players.Add(p); } public void AddPlayer(Player p) { Players.Add(p); }
public Player LocalPlayer { get; private set; } public Player LocalPlayer { get; private set; }
public Player RenderPlayer; Player renderPlayer;
public bool ObserveAfterWinOrLose;
public Player RenderPlayer
{
get { return renderPlayer == null || (ObserveAfterWinOrLose && renderPlayer.WinState != WinState.Undefined)? null : renderPlayer; }
set { renderPlayer = value; }
}
public bool FogObscures(Actor a) { return RenderPlayer != null && !RenderPlayer.Shroud.IsVisible(a); } public bool FogObscures(Actor a) { return RenderPlayer != null && !RenderPlayer.Shroud.IsVisible(a); }
public bool FogObscures(CPos p) { return RenderPlayer != null && !RenderPlayer.Shroud.IsVisible(p); } public bool FogObscures(CPos p) { return RenderPlayer != null && !RenderPlayer.Shroud.IsVisible(p); }
public bool ShroudObscures(Actor a) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(a); } public bool ShroudObscures(Actor a) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(a); }

View File

@@ -19,13 +19,17 @@ namespace OpenRA.Mods.RA
[Desc("Milliseconds")] [Desc("Milliseconds")]
public int NotificationDelay = 1500; public int NotificationDelay = 1500;
public object Create(ActorInitializer init) { return new ConquestVictoryConditions(this); } public object Create(ActorInitializer init) { return new ConquestVictoryConditions(init.world, this); }
} }
public class ConquestVictoryConditions : ITick, IResolveOrder public class ConquestVictoryConditions : ITick, IResolveOrder
{ {
ConquestVictoryConditionsInfo Info; ConquestVictoryConditionsInfo Info;
public ConquestVictoryConditions(ConquestVictoryConditionsInfo info) { Info = info; } public ConquestVictoryConditions(World world, ConquestVictoryConditionsInfo info)
{
world.ObserveAfterWinOrLose = true;
Info = info;
}
public void Tick(Actor self) public void Tick(Actor self)
{ {
@@ -63,14 +67,11 @@ namespace OpenRA.Mods.RA
a.Kill(a); a.Kill(a);
if (self.Owner == self.World.LocalPlayer) if (self.Owner == self.World.LocalPlayer)
{
self.World.RenderPlayer = null;
Game.RunAfterDelay(Info.NotificationDelay, () => Game.RunAfterDelay(Info.NotificationDelay, () =>
{ {
if (Game.IsCurrentWorld(self.World)) if (Game.IsCurrentWorld(self.World))
Sound.PlayNotification(self.Owner, "Speech", "Lose", self.Owner.Country.Race); Sound.PlayNotification(self.Owner, "Speech", "Lose", self.Owner.Country.Race);
}); });
}
} }
public void Win(Actor self) public void Win(Actor self)
@@ -80,10 +81,7 @@ namespace OpenRA.Mods.RA
Game.Debug("{0} is victorious.".F(self.Owner.PlayerName)); Game.Debug("{0} is victorious.".F(self.Owner.PlayerName));
if (self.Owner == self.World.LocalPlayer) if (self.Owner == self.World.LocalPlayer)
{
self.World.RenderPlayer = null;
Game.RunAfterDelay(Info.NotificationDelay, () => Sound.PlayNotification(self.Owner, "Speech", "Win", self.Owner.Country.Race)); Game.RunAfterDelay(Info.NotificationDelay, () => Sound.PlayNotification(self.Owner, "Speech", "Win", self.Owner.Country.Race));
}
} }
} }