Allow GPS to be revoked

This commit is contained in:
Paul Chote
2010-01-08 21:24:52 +13:00
parent ad78ee6b6d
commit 0738c4ebe3
2 changed files with 24 additions and 29 deletions

View File

@@ -13,10 +13,21 @@ namespace OpenRa.Game
Sprite[] shadowBits = SpriteSheetBuilder.LoadAllSprites("shadow"); Sprite[] shadowBits = SpriteSheetBuilder.LoadAllSprites("shadow");
Sprite[,] sprites = new Sprite[128, 128]; Sprite[,] sprites = new Sprite[128, 128];
bool dirty; bool dirty;
bool hasGPS = false;
public bool IsExplored(int2 xy)
public bool HasGPS
{ {
return explored[ xy.X, xy.Y ]; get { return hasGPS; }
set { hasGPS = value; dirty = true;}
}
public bool IsExplored(int2 xy) { return IsExplored(xy.X, xy.Y); }
public bool IsExplored(int x, int y)
{
if (hasGPS)
return true;
return explored[ x, y ];
} }
public void Explore(Actor a) public void Explore(Actor a)
@@ -26,22 +37,6 @@ namespace OpenRa.Game
dirty = true; dirty = true;
} }
public void RevealAll()
{
for (int x = 0; x < 128; x++)
for (int y = 0; y < 128; y++)
explored[x, y] = true;
dirty = true;
}
public void HideAll()
{
for (int x = 0; x < 128; x++)
for (int y = 0; y < 128; y++)
explored[x, y] = false;
dirty = true;
}
static readonly byte[] ShroudTiles = static readonly byte[] ShroudTiles =
{ {
@@ -67,11 +62,11 @@ namespace OpenRa.Game
{ {
// bits are for exploredness: left, right, up, down, self // bits are for exploredness: left, right, up, down, self
var v = 0; var v = 0;
if (explored[i - 1, j]) v |= 1; if (IsExplored(i - 1, j)) v |= 1;
if (explored[i + 1, j]) v |= 2; if (IsExplored(i + 1, j)) v |= 2;
if (explored[i, j - 1]) v |= 4; if (IsExplored(i, j - 1)) v |= 4;
if (explored[i, j + 1]) v |= 8; if (IsExplored(i, j + 1)) v |= 8;
if (explored[i, j]) v |= 16; if (IsExplored(i, j)) v |= 16;
var x = ShroudTiles[v]; var x = ShroudTiles[v];
if (x != 0) if (x != 0)
@@ -79,10 +74,10 @@ namespace OpenRa.Game
// bits are for exploredness: TL, TR, BR, BL // bits are for exploredness: TL, TR, BR, BL
var u = 0; var u = 0;
if (explored[i - 1, j - 1]) u |= 1; if (IsExplored(i - 1, j - 1)) u |= 1;
if (explored[i + 1, j - 1]) u |= 2; if (IsExplored(i + 1, j - 1)) u |= 2;
if (explored[i + 1, j + 1]) u |= 4; if (IsExplored(i + 1, j + 1)) u |= 4;
if (explored[i - 1, j + 1]) u |= 8; if (IsExplored(i - 1, j + 1)) u |= 8;
return shadowBits[ExtraShroudTiles[u]]; return shadowBits[ExtraShroudTiles[u]];
} }

View File

@@ -17,7 +17,7 @@ namespace OpenRa.Game.Traits
if (fired && --revealTicks == 0) if (fired && --revealTicks == 0)
{ {
self.Owner.Shroud.RevealAll(); self.Owner.Shroud.HasGPS = true;
} }
} }
public void Activate(Actor self) public void Activate(Actor self)