More shroud refactoring.

This introduces a hash on Shroud which ShroudRenderer
can observe, removing the need to explicitly twiddle
a dirty flag between objects.

Shroud disabling is now done via RenderPlayer, so
enabling the cheat or winning/losing will now give
vis equivalent to an observer.
This commit is contained in:
Paul Chote
2013-04-10 20:27:33 +12:00
parent ca8dbce0ef
commit 248e815d99
9 changed files with 169 additions and 168 deletions

View File

@@ -18,14 +18,10 @@ namespace OpenRA.Graphics
Map map; Map map;
Sprite[] shadowBits = Game.modData.SpriteLoader.LoadAllSprites("shadow"); Sprite[] shadowBits = Game.modData.SpriteLoader.LoadAllSprites("shadow");
Sprite[,] sprites, fogSprites; Sprite[,] sprites, fogSprites;
int shroudHash;
public ShroudRenderer(World world) bool initializePalettes = true;
{ PaletteReference fogPalette, shroudPalette;
this.map = world.Map;
sprites = new Sprite[map.MapSize.X, map.MapSize.Y];
fogSprites = new Sprite[map.MapSize.X, map.MapSize.Y];
}
static readonly byte[][] SpecialShroudTiles = static readonly byte[][] SpecialShroudTiles =
{ {
@@ -47,6 +43,17 @@ namespace OpenRA.Graphics
new byte[] { 46 }, new byte[] { 46 },
}; };
public ShroudRenderer(World world)
{
this.map = world.Map;
sprites = new Sprite[map.MapSize.X, map.MapSize.Y];
fogSprites = new Sprite[map.MapSize.X, map.MapSize.Y];
// Force update on first render
shroudHash = -1;
}
Sprite ChooseShroud(Shroud s, int i, int j) Sprite ChooseShroud(Shroud s, int i, int j)
{ {
if (!s.IsExplored(i, j)) if (!s.IsExplored(i, j))
@@ -96,18 +103,14 @@ namespace OpenRA.Graphics
return shadowBits[SpecialShroudTiles[u ^ uSides][v]]; return shadowBits[SpecialShroudTiles[u ^ uSides][v]];
} }
bool initializePalettes = true; void GenerateSprites(Shroud shroud)
PaletteReference fogPalette, shroudPalette;
internal void Draw(WorldRenderer wr, Player renderPlayer)
{ {
if (initializePalettes) var hash = shroud != null ? shroud.Hash : 0;
{ if (shroudHash == hash)
fogPalette = wr.Palette("fog"); return;
shroudPalette = wr.Palette("shroud");
initializePalettes = false;
}
if (renderPlayer == null) shroudHash = hash;
if (shroud == null)
{ {
// Players with no shroud see the whole map so we only need to set the edges // Players with no shroud see the whole map so we only need to set the edges
var b = map.Bounds; var b = map.Bounds;
@@ -133,16 +136,27 @@ namespace OpenRA.Graphics
} }
else else
{ {
renderPlayer.Shroud.dirty = false; for (int i = map.Bounds.Left; i < map.Bounds.Right; i++)
for (int j = map.Bounds.Top; j < map.Bounds.Bottom; j++)
sprites[i, j] = ChooseShroud(shroud, i, j);
for (int i = map.Bounds.Left; i < map.Bounds.Right; i++) for (int i = map.Bounds.Left; i < map.Bounds.Right; i++)
for (int j = map.Bounds.Top; j < map.Bounds.Bottom; j++) for (int j = map.Bounds.Top; j < map.Bounds.Bottom; j++)
sprites[i, j] = ChooseShroud(renderPlayer.Shroud, i, j); fogSprites[i, j] = ChooseFog(shroud, i, j);
for (int i = map.Bounds.Left; i < map.Bounds.Right; i++)
for (int j = map.Bounds.Top; j < map.Bounds.Bottom; j++)
fogSprites[i, j] = ChooseFog(renderPlayer.Shroud, i, j);
} }
}
internal void Draw(WorldRenderer wr, Shroud shroud)
{
if (initializePalettes)
{
fogPalette = wr.Palette("fog");
shroudPalette = wr.Palette("shroud");
initializePalettes = false;
}
GenerateSprites(shroud);
var clipRect = Game.viewport.WorldBounds(wr.world); var clipRect = Game.viewport.WorldBounds(wr.world);
DrawShroud(wr, clipRect, sprites, shroudPalette); DrawShroud(wr, clipRect, sprites, shroudPalette);
if (wr.world.WorldActor.HasTrait<Fog>()) if (wr.world.WorldActor.HasTrait<Fog>())

View File

@@ -127,7 +127,8 @@ namespace OpenRA.Graphics
if (world.OrderGenerator != null) if (world.OrderGenerator != null)
world.OrderGenerator.RenderAfterWorld(this, world); world.OrderGenerator.RenderAfterWorld(this, world);
shroudRenderer.Draw(this, world.RenderPlayer); var renderShroud = world.RenderPlayer != null ? world.RenderPlayer.Shroud : null;
shroudRenderer.Draw(this, renderShroud);
Game.Renderer.DisableScissor(); Game.Renderer.DisableScissor();
foreach (var g in world.Selection.Actors.Where(a => !a.Destroyed) foreach (var g in world.Selection.Actors.Where(a => !a.Destroyed)

View File

@@ -77,7 +77,7 @@ namespace OpenRA
} }
PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) }); PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) });
Shroud = PlayerActor.Trait<Shroud>(); Shroud = PlayerActor.Trait<Shroud>();
Shroud.Owner = this;
// Enable the bot logic on the host // Enable the bot logic on the host
IsBot = botType != null; IsBot = botType != null;
if (IsBot && Game.IsHost) if (IsBot && Game.IsHost)

View File

@@ -32,29 +32,24 @@ namespace OpenRA.Traits
public void Tick(Actor self) public void Tick(Actor self)
{ {
// TODO: don't tick all the time. // TODO: don't tick all the time.
if(self.Owner == null) return; if (self.Owner == null)
return;
if (previousLocation != self.Location && v != null) { var shrouds = self.World.ActorsWithTrait<Shroud>().Select(s => s.Actor.Owner.Shroud);
if (previousLocation != self.Location && v != null)
{
previousLocation = self.Location; previousLocation = self.Location;
var shrouds = self.World.ActorsWithTrait<Shroud>().Select(s => s.Actor.Owner.Shroud); foreach (var shroud in shrouds)
foreach (var shroud in shrouds) {
shroud.UnhideActor(self, v, Info.Range); shroud.UnhideActor(self, v, Info.Range);
} }
}
if (!self.TraitsImplementing<IDisable>().Any(d => d.Disabled)) { if (!self.TraitsImplementing<IDisable>().Any(d => d.Disabled))
var shrouds = self.World.ActorsWithTrait<Shroud>().Select(s => s.Actor.Owner.Shroud); foreach (var shroud in shrouds)
foreach (var shroud in shrouds) {
shroud.HideActor(self, Info.Range); shroud.HideActor(self, Info.Range);
} else
} foreach (var shroud in shrouds)
else {
var shrouds = self.World.ActorsWithTrait<Shroud>().Select(s => s.Actor.Owner.Shroud);
foreach (var shroud in shrouds) {
shroud.UnhideActor(self, v, Info.Range); shroud.UnhideActor(self, v, Info.Range);
}
}
v = new Shroud.ActorVisibility { v = new Shroud.ActorVisibility {
vis = Shroud.GetVisOrigins(self).ToArray() vis = Shroud.GetVisOrigins(self).ToArray()

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Traits
case "DevShroudDisable": case "DevShroudDisable":
{ {
DisableShroud ^= true; DisableShroud ^= true;
self.Owner.Shroud.Disabled = DisableShroud; self.World.RenderPlayer = DisableShroud ? null : self.Owner;
break; break;
} }
case "DevPathDebug": case "DevPathDebug":

View File

@@ -12,62 +12,70 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.Graphics;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {
public class ShroudInfo : ITraitInfo public class ShroudInfo : ITraitInfo
{ {
public object Create(ActorInitializer init) { return new Shroud(init.world); } public object Create(ActorInitializer init) { return new Shroud(init.self); }
} }
public class Shroud : ISync public class Shroud
{ {
Map map; Map map;
Actor self;
[Sync] public Player Owner; int[,] visibleCells;
public int[,] visibleCells; bool[,] exploredCells;
public bool[,] exploredCells; bool[,] foggedCells;
public bool[,] foggedCells;
public Rectangle? exploredBounds; public Rectangle ExploredBounds { get; private set; }
bool disabled = false;
public bool dirty = true; public int Hash { get; private set; }
[Sync] public bool Disabled
public Shroud(Actor self)
{ {
get { return disabled; } this.self = self;
set { disabled = value; Dirty(); } map = self.World.Map;
}
public Rectangle? Bounds
{
get { return Disabled ? null : exploredBounds; }
}
public Action Dirty = () => { };
public Shroud(World world)
{
map = world.Map;
visibleCells = new int[map.MapSize.X, map.MapSize.Y]; visibleCells = new int[map.MapSize.X, map.MapSize.Y];
exploredCells = new bool[map.MapSize.X, map.MapSize.Y]; exploredCells = new bool[map.MapSize.X, map.MapSize.Y];
foggedCells = new bool[map.MapSize.X, map.MapSize.Y]; foggedCells = new bool[map.MapSize.X, map.MapSize.Y];
world.ActorAdded += AddActor; self.World.ActorAdded += AddActor;
world.ActorRemoved += RemoveActor; self.World.ActorRemoved += RemoveActor;
Dirty += () => dirty = true; }
void Invalidate()
{
Hash = Sync.hash_player(self.Owner) + self.World.FrameNumber * 3;
} }
// cache of positions that were added, so no matter what crazy trait code does, it // cache of positions that were added, so no matter what crazy trait code does, it
// can't make us invalid. // can't make us invalid.
public class ActorVisibility { [Sync] public int range; [Sync] public CPos[] vis; } public class ActorVisibility
{
[Sync] public int range;
[Sync] public CPos[] vis;
}
public Dictionary<Actor, ActorVisibility> vis = new Dictionary<Actor, ActorVisibility>(); public Dictionary<Actor, ActorVisibility> vis = new Dictionary<Actor, ActorVisibility>();
static IEnumerable<CPos> FindVisibleTiles(World world, CPos a, int r) static IEnumerable<CPos> FindVisibleTiles(World world, CPos a, int r)
{ {
var min = a - new CVec(r, r); var min = a - new CVec(r, r);
var max = a + new CVec(r, r); var max = a + new CVec(r, r);
if (min.X < world.Map.Bounds.Left - 1) min = new CPos(world.Map.Bounds.Left - 1, min.Y); if (min.X < world.Map.Bounds.Left - 1)
if (min.Y < world.Map.Bounds.Top - 1) min = new CPos(min.X, world.Map.Bounds.Top - 1); min = new CPos(world.Map.Bounds.Left - 1, min.Y);
if (max.X > world.Map.Bounds.Right) max = new CPos(world.Map.Bounds.Right, max.Y);
if (max.Y > world.Map.Bounds.Bottom) max = new CPos(max.X, world.Map.Bounds.Bottom); if (min.Y < world.Map.Bounds.Top - 1)
min = new CPos(min.X, world.Map.Bounds.Top - 1);
if (max.X > world.Map.Bounds.Right)
max = new CPos(world.Map.Bounds.Right, max.Y);
if (max.Y > world.Map.Bounds.Bottom)
max = new CPos(max.X, world.Map.Bounds.Bottom);
for (var j = min.Y; j <= max.Y; j++) for (var j = min.Y; j <= max.Y; j++)
for (var i = min.X; i <= max.X; i++) for (var i = min.X; i <= max.X; i++)
@@ -77,13 +85,12 @@ namespace OpenRA.Traits
public void AddActor(Actor a) public void AddActor(Actor a)
{ {
if (!a.HasTrait<RevealsShroud>()) return; if (!a.HasTrait<RevealsShroud>() || !a.Owner.IsAlliedWith(self.Owner))
if (a.Owner == null || Owner == null) return; return;
if(a.Owner.Stances[Owner] != Stance.Ally) return;
ActorVisibility v = a.Sight; ActorVisibility v = a.Sight;
if (v.range == 0)
if (v.range == 0) return; // don't bother for things that can't see return;
foreach (var p in v.vis) foreach (var p in v.vis)
{ {
@@ -95,17 +102,16 @@ namespace OpenRA.Traits
} }
var box = new Rectangle(p.X - v.range, p.Y - v.range, 2 * v.range + 1, 2 * v.range + 1); var box = new Rectangle(p.X - v.range, p.Y - v.range, 2 * v.range + 1, 2 * v.range + 1);
exploredBounds = (exploredBounds.HasValue) ? Rectangle.Union(exploredBounds.Value, box) : box; ExploredBounds = Rectangle.Union(ExploredBounds, box);
} }
if (!Disabled) Invalidate();
Dirty();
} }
public void HideActor(Actor a, int range) public void HideActor(Actor a, int range)
{ {
if (a.Owner.World.LocalPlayer == null if (a.Owner.IsAlliedWith(self.Owner))
|| a.Owner.Stances[a.Owner.World.LocalPlayer] == Stance.Ally) return; return;
var v = new ActorVisibility var v = new ActorVisibility
{ {
@@ -116,34 +122,33 @@ namespace OpenRA.Traits
foreach (var q in FindVisibleTiles(a.World, p, range)) foreach (var q in FindVisibleTiles(a.World, p, range))
foggedCells[q.X, q.Y] = visibleCells[q.X, q.Y] > 0; foggedCells[q.X, q.Y] = visibleCells[q.X, q.Y] > 0;
if (!Disabled) Invalidate();
Dirty();
} }
public void UnhideActor(Actor a, ActorVisibility v, int range) { public void UnhideActor(Actor a, ActorVisibility v, int range)
if (a.Owner.World.LocalPlayer == null {
|| a.Owner.Stances[a.Owner.World.LocalPlayer] == Stance.Ally) return; if (a.Owner.IsAlliedWith(self.Owner) || v == null)
if (v == null)
return; return;
foreach (var p in v.vis) foreach (var p in v.vis)
foreach (var q in FindVisibleTiles(a.World, p, range)) foreach (var q in FindVisibleTiles(a.World, p, range))
foggedCells[q.X, q.Y] = exploredCells[q.X, q.Y]; foggedCells[q.X, q.Y] = exploredCells[q.X, q.Y];
if (!Disabled) Invalidate();
Dirty();
} }
public void MergeShroud(Shroud s) { public void MergeShroud(Shroud s)
for (int i = map.Bounds.Left; i < map.Bounds.Right; i++) { {
for (int j = map.Bounds.Top; j < map.Bounds.Bottom; j++) { for (int i = map.Bounds.Left; i < map.Bounds.Right; i++)
{
for (int j = map.Bounds.Top; j < map.Bounds.Bottom; j++)
{
if (s.exploredCells[i,j] == true) if (s.exploredCells[i,j] == true)
exploredCells[i, j] = true; exploredCells[i, j] = true;
if (s.foggedCells[i,j] == true) if (s.foggedCells[i,j] == true)
foggedCells[i, j] = true; foggedCells[i, j] = true;
} }
exploredBounds = Rectangle.Union(exploredBounds.Value, s.exploredBounds.Value); ExploredBounds = Rectangle.Union(ExploredBounds, s.ExploredBounds);
} }
} }
@@ -159,6 +164,7 @@ namespace OpenRA.Traits
foreach (var a in toRemove) foreach (var a in toRemove)
RemoveActor(a); RemoveActor(a);
} }
// Is now our ally; add unit vis // Is now our ally; add unit vis
if (newStance == Stance.Ally) if (newStance == Stance.Ally)
foreach (var a in w.Actors.Where( a => a.Owner == player )) foreach (var a in w.Actors.Where( a => a.Owner == player ))
@@ -170,7 +176,8 @@ namespace OpenRA.Traits
int seen = 0; int seen = 0;
for (int i = map.Bounds.Left; i < map.Bounds.Right; i++) for (int i = map.Bounds.Left; i < map.Bounds.Right; i++)
for (int j = map.Bounds.Top; j < map.Bounds.Bottom; j++) for (int j = map.Bounds.Top; j < map.Bounds.Bottom; j++)
if(foggedCells[i, j]) seen++; if (foggedCells[i, j])
seen++;
return seen; return seen;
} }
@@ -189,34 +196,33 @@ namespace OpenRA.Traits
public void RemoveActor(Actor a) public void RemoveActor(Actor a)
{ {
if (!a.HasTrait<RevealsShroud>())return;
if (a.Owner == null || Owner == null) return;
ActorVisibility v = a.Sight; ActorVisibility v = a.Sight;
if (!a.Owner.IsAlliedWith(self.Owner))
if(a.Owner.Stances[Owner] != Stance.Ally) { {
if (a.HasTrait<CreatesShroud>()) { if (a.HasTrait<CreatesShroud>())
foreach (var p in v.vis) foreach (var p in v.vis)
foreach (var q in FindVisibleTiles(a.World, p, v.range)) foreach (var q in FindVisibleTiles(a.World, p, v.range))
foggedCells[q.X, q.Y] = exploredCells[q.X, q.Y]; foggedCells[q.X, q.Y] = exploredCells[q.X, q.Y];
}
return; return;
} }
if (!a.HasTrait<RevealsShroud>())
return;
foreach (var p in v.vis) foreach (var p in v.vis)
foreach (var q in FindVisibleTiles(a.World, p, v.range)) foreach (var q in FindVisibleTiles(a.World, p, v.range))
--visibleCells[q.X, q.Y]; --visibleCells[q.X, q.Y];
if (!Disabled) Invalidate();
Dirty();
} }
public void UpdateActor(Actor a) public void UpdateActor(Actor a)
{ {
if (a.Owner.World.LocalPlayer == null if (!a.Owner.IsAlliedWith(self.Owner))
|| a.Owner.Stances[a.Owner.World.LocalPlayer] != Stance.Ally) return; return;
RemoveActor(a); AddActor(a); RemoveActor(a);
AddActor(a);
} }
public void Explore(World world, CPos center, int range) public void Explore(World world, CPos center, int range)
@@ -227,10 +233,9 @@ namespace OpenRA.Traits
} }
var box = new Rectangle(center.X - range, center.Y - range, 2 * range + 1, 2 * range + 1); var box = new Rectangle(center.X - range, center.Y - range, 2 * range + 1, 2 * range + 1);
exploredBounds = (exploredBounds.HasValue) ? Rectangle.Union(exploredBounds.Value, box) : box; ExploredBounds = Rectangle.Union(ExploredBounds, box);
if (!Disabled) Invalidate();
Dirty();
} }
public void ExploreAll(World world) public void ExploreAll(World world)
@@ -241,10 +246,9 @@ namespace OpenRA.Traits
foggedCells[i, j] = true; foggedCells[i, j] = true;
} }
} }
exploredBounds = world.Map.Bounds; ExploredBounds = world.Map.Bounds;
if (!Disabled) Invalidate();
Dirty();
} }
public void ResetExploration() public void ResetExploration()
@@ -257,8 +261,7 @@ namespace OpenRA.Traits
for (var i = 0; i <= foggedCells.GetUpperBound(0); i++) for (var i = 0; i <= foggedCells.GetUpperBound(0); i++)
foggedCells[i, j] = visibleCells[i, j] > 0; foggedCells[i, j] = visibleCells[i, j] > 0;
if (!Disabled) Invalidate();
Dirty();
} }
public bool IsExplored(CPos xy) { return IsExplored(xy.X, xy.Y); } public bool IsExplored(CPos xy) { return IsExplored(xy.X, xy.Y); }
@@ -267,26 +270,17 @@ namespace OpenRA.Traits
if (!map.IsInMap(x, y)) if (!map.IsInMap(x, y))
return false; return false;
if (Disabled)
return true;
return foggedCells[x,y]; return foggedCells[x,y];
} }
public bool IsExplored(Actor a) public bool IsExplored(Actor a)
{ {
if (Owner == null)
return true;
return GetVisOrigins(a).Any(o => IsExplored(o)); return GetVisOrigins(a).Any(o => IsExplored(o));
} }
public bool IsVisible(CPos xy) { return IsVisible(xy.X, xy.Y); } public bool IsVisible(CPos xy) { return IsVisible(xy.X, xy.Y); }
public bool IsVisible(int x, int y) public bool IsVisible(int x, int y)
{ {
if (Disabled)
return true;
// Visibility is allowed to extend beyond the map cordon so that // Visibility is allowed to extend beyond the map cordon so that
// the fog tiles are not visible at the edge of the world // the fog tiles are not visible at the edge of the world
if (x < 0 || x >= map.MapSize.X || y < 0 || y >= map.MapSize.Y) if (x < 0 || x >= map.MapSize.X || y < 0 || y >= map.MapSize.Y)
@@ -298,15 +292,14 @@ namespace OpenRA.Traits
// Actors are hidden under shroud, but not under fog by default // Actors are hidden under shroud, but not under fog by default
public bool IsVisible(Actor a) public bool IsVisible(Actor a)
{ {
// I need to pass in the current shroud, otherwise we're just checking that true==true if (a.TraitsImplementing<IVisibilityModifier>().Any(t => !t.IsVisible(a, self.Owner)))
if (a.TraitsImplementing<IVisibilityModifier>().Any(t => !t.IsVisible(a, Owner)))
return false; return false;
return Disabled || a.Owner.Stances[Owner] == Stance.Ally || IsExplored(a); return a.Owner.IsAlliedWith(self.Owner) || IsExplored(a);
} }
public bool IsTargetable(Actor a) { public bool IsTargetable(Actor a) {
if (a.TraitsImplementing<IVisibilityModifier>().Any(t => !t.IsVisible(a, Owner))) if (a.TraitsImplementing<IVisibilityModifier>().Any(t => !t.IsVisible(a, self.Owner)))
return false; return false;
return GetVisOrigins(a).Any(o => IsVisible(o)); return GetVisOrigins(a).Any(o => IsVisible(o));

View File

@@ -41,26 +41,24 @@ 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 bool Observer { get { return LocalPlayer == null; } }
Player renderPlayer; public Player RenderPlayer;
public Player RenderPlayer 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 ShroudObscures(Actor a) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(a); }
public bool ShroudObscures(CPos p) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(p); }
public Rectangle? VisibleBounds
{ {
get { return renderPlayer; } get
set
{ {
renderPlayer = value; if (RenderPlayer == null)
if (renderPlayer != null) return null;
renderPlayer.Shroud.Dirty();
return RenderPlayer.Shroud.ExploredBounds;
} }
} }
public Rectangle? VisibleBounds { get { return renderPlayer != null ? renderPlayer.Shroud.Bounds : null; } }
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 ShroudObscures(Actor a) { return renderPlayer != null && !renderPlayer.Shroud.IsExplored(a); }
public bool ShroudObscures(CPos p) { return renderPlayer != null && !renderPlayer.Shroud.IsExplored(p); }
public void SetLocalPlayer(string pr) public void SetLocalPlayer(string pr)
{ {
if (orderManager.Connection is ReplayConnection) if (orderManager.Connection is ReplayConnection)

View File

@@ -62,9 +62,9 @@ namespace OpenRA.Mods.RA
foreach (var a in self.World.Actors.Where(a => a.Owner == self.Owner)) foreach (var a in self.World.Actors.Where(a => a.Owner == self.Owner))
a.Kill(a); a.Kill(a);
self.Owner.Shroud.Disabled = true;
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))
@@ -79,9 +79,9 @@ namespace OpenRA.Mods.RA
self.Owner.WinState = WinState.Won; self.Owner.WinState = WinState.Won;
Game.Debug("{0} is victorious.".F(self.Owner.PlayerName)); Game.Debug("{0} is victorious.".F(self.Owner.PlayerName));
self.Owner.Shroud.Disabled = true;
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));
} }
} }

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
private bool teamChat = false; private bool teamChat = false;
internal bool TeamChat internal bool TeamChat
{ {
get { return World.Observer ? false : teamChat; } get { return World.LocalPlayer == null ? false : teamChat; }
set { teamChat = value; } set { teamChat = value; }
} }