Simply the localplayer hack, and prevent vis dirtying when shroud is disabled.

This commit is contained in:
Paul Chote
2010-11-26 21:05:20 +13:00
parent 1d81e71bcb
commit 3b0810a096

View File

@@ -31,13 +31,13 @@ namespace OpenRA.Traits
bool disabled = false; bool disabled = false;
public bool Disabled public bool Disabled
{ {
get { return disabled; } get { return disabled || world.LocalPlayer == null; }
set { disabled = value; Dirty(); } set { disabled = value; Dirty(); }
} }
public Rectangle? Bounds public Rectangle? Bounds
{ {
get { return !disabled ? exploredBounds : null; } get { return Disabled ? null : exploredBounds; }
} }
public event Action Dirty = () => { }; public event Action Dirty = () => { };
@@ -108,6 +108,7 @@ namespace OpenRA.Traits
vis[a] = v; vis[a] = v;
if (!Disabled)
Dirty(); Dirty();
} }
@@ -152,6 +153,7 @@ namespace OpenRA.Traits
vis.Remove(a); vis.Remove(a);
if (!Disabled)
Dirty(); Dirty();
} }
@@ -171,6 +173,7 @@ 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 = (exploredBounds.HasValue) ? Rectangle.Union(exploredBounds.Value, box) : box;
if (!Disabled)
Dirty(); Dirty();
} }
@@ -181,6 +184,7 @@ namespace OpenRA.Traits
exploredCells[i, j] = true; exploredCells[i, j] = true;
exploredBounds = world.Map.Bounds; exploredBounds = world.Map.Bounds;
if (!Disabled)
Dirty(); Dirty();
} }
@@ -190,6 +194,7 @@ namespace OpenRA.Traits
for (var i = 0; i <= exploredCells.GetUpperBound(0); i++) for (var i = 0; i <= exploredCells.GetUpperBound(0); i++)
exploredCells[i, j] = visibleCells[i, j] > 0; exploredCells[i, j] = visibleCells[i, j] > 0;
if (!Disabled)
Dirty(); Dirty();
} }
@@ -199,7 +204,7 @@ namespace OpenRA.Traits
if (!map.IsInMap(x, y)) if (!map.IsInMap(x, y))
return false; return false;
if (disabled || world.LocalPlayer == null) if (Disabled)
return true; return true;
return exploredCells[x,y]; return exploredCells[x,y];
@@ -208,7 +213,7 @@ namespace OpenRA.Traits
public bool IsVisible(int2 xy) { return IsVisible(xy.X, xy.Y); } public bool IsVisible(int2 xy) { return IsVisible(xy.X, xy.Y); }
public bool IsVisible(int x, int y) public bool IsVisible(int x, int y)
{ {
if (disabled || world.LocalPlayer == null) if (Disabled)
return true; return true;
return visibleCells[x,y] != 0; return visibleCells[x,y] != 0;
@@ -220,7 +225,7 @@ namespace OpenRA.Traits
if (a.TraitsImplementing<IVisibilityModifier>().Any(t => !t.IsVisible(a))) if (a.TraitsImplementing<IVisibilityModifier>().Any(t => !t.IsVisible(a)))
return false; return false;
return disabled || a.Owner == a.World.LocalPlayer || GetVisOrigins(a).Any(o => IsExplored(o)); return Disabled || a.Owner == a.World.LocalPlayer || GetVisOrigins(a).Any(o => IsExplored(o));
} }
} }
} }