shroud tidy up
This commit is contained in:
@@ -27,13 +27,11 @@ namespace OpenRa.Game
|
|||||||
dirty = true;
|
dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite ChooseShroud(int i, int j)
|
static readonly byte[] ShroudTiles =
|
||||||
{
|
{
|
||||||
// bits are for exploredness: left, right, up, down, self
|
|
||||||
var n = new[] {
|
|
||||||
0xf,0xf,0xf,0xf,
|
0xf,0xf,0xf,0xf,
|
||||||
0xf,0x0f,0x0f,0xf,
|
0xf,0xf,0xf,0xf,
|
||||||
0xf,0x0f,0x0f,0xf,
|
0xf,0xf,0xf,0xf,
|
||||||
0xf,0xf,0xf,0xf,
|
0xf,0xf,0xf,0xf,
|
||||||
0,7,13,0,
|
0,7,13,0,
|
||||||
14,6,12,4,
|
14,6,12,4,
|
||||||
@@ -41,6 +39,17 @@ namespace OpenRa.Game
|
|||||||
0,2,8,0,
|
0,2,8,0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static readonly byte[] ExtraShroudTiles =
|
||||||
|
{
|
||||||
|
46, 41, 42, 38,
|
||||||
|
43, 45, 39, 35,
|
||||||
|
40, 37, 44, 34,
|
||||||
|
36, 33, 32, 47,
|
||||||
|
};
|
||||||
|
|
||||||
|
Sprite ChooseShroud(int i, int j)
|
||||||
|
{
|
||||||
|
// bits are for exploredness: left, right, up, down, self
|
||||||
var v = 0;
|
var v = 0;
|
||||||
if (explored[i - 1, j]) v |= 1;
|
if (explored[i - 1, j]) v |= 1;
|
||||||
if (explored[i + 1, j]) v |= 2;
|
if (explored[i + 1, j]) v |= 2;
|
||||||
@@ -48,27 +57,17 @@ namespace OpenRa.Game
|
|||||||
if (explored[i, j + 1]) v |= 8;
|
if (explored[i, j + 1]) v |= 8;
|
||||||
if (explored[i, j]) v |= 16;
|
if (explored[i, j]) v |= 16;
|
||||||
|
|
||||||
var x = n[v];
|
var x = ShroudTiles[v];
|
||||||
|
if (x != 0)
|
||||||
|
return shadowBits[x];
|
||||||
|
|
||||||
if (x == 0)
|
|
||||||
{
|
|
||||||
// bits are for exploredness: TL, TR, BR, BL
|
// bits are for exploredness: TL, TR, BR, BL
|
||||||
var m = new[] {
|
|
||||||
46, 41, 42, 38,
|
|
||||||
43, 45, 39, 35,
|
|
||||||
40, 37, 44, 34,
|
|
||||||
36, 33, 32, 47,
|
|
||||||
};
|
|
||||||
|
|
||||||
var u = 0;
|
var u = 0;
|
||||||
if (explored[i - 1, j - 1]) u |= 1;
|
if (explored[i - 1, j - 1]) u |= 1;
|
||||||
if (explored[i + 1, j - 1]) u |= 2;
|
if (explored[i + 1, j - 1]) u |= 2;
|
||||||
if (explored[i + 1, j + 1]) u |= 4;
|
if (explored[i + 1, j + 1]) u |= 4;
|
||||||
if (explored[i - 1, j + 1]) u |= 8;
|
if (explored[i - 1, j + 1]) u |= 8;
|
||||||
return shadowBits[m[u]];
|
return shadowBits[ExtraShroudTiles[u]];
|
||||||
}
|
|
||||||
|
|
||||||
return shadowBits[x];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(SpriteRenderer r)
|
public void Draw(SpriteRenderer r)
|
||||||
|
|||||||
Reference in New Issue
Block a user