diff --git a/OpenRa.Game/Shroud.cs b/OpenRa.Game/Shroud.cs index 56cc9efb59..3761d54296 100644 --- a/OpenRa.Game/Shroud.cs +++ b/OpenRa.Game/Shroud.cs @@ -27,20 +27,29 @@ namespace OpenRa.Game dirty = true; } + static readonly byte[] ShroudTiles = + { + 0xf,0xf,0xf,0xf, + 0xf,0xf,0xf,0xf, + 0xf,0xf,0xf,0xf, + 0xf,0xf,0xf,0xf, + 0,7,13,0, + 14,6,12,4, + 11,3,9,1, + 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 n = new[] { - 0xf,0xf,0xf,0xf, - 0xf,0x0f,0x0f,0xf, - 0xf,0x0f,0x0f,0xf, - 0xf,0xf,0xf,0xf, - 0,7,13,0, - 14,6,12,4, - 11,3,9,1, - 0,2,8,0, - }; - var v = 0; if (explored[i - 1, j]) v |= 1; 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]) 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 - var m = new[] { - 46, 41, 42, 38, - 43, 45, 39, 35, - 40, 37, 44, 34, - 36, 33, 32, 47, - }; - - var u = 0; - if (explored[i - 1, j - 1]) u |= 1; - if (explored[i + 1, j - 1]) u |= 2; - if (explored[i + 1, j + 1]) u |= 4; - if (explored[i - 1, j + 1]) u |= 8; - return shadowBits[m[u]]; - } - - return shadowBits[x]; + // bits are for exploredness: TL, TR, BR, BL + var u = 0; + if (explored[i - 1, j - 1]) u |= 1; + if (explored[i + 1, j - 1]) u |= 2; + if (explored[i + 1, j + 1]) u |= 4; + if (explored[i - 1, j + 1]) u |= 8; + return shadowBits[ExtraShroudTiles[u]]; } public void Draw(SpriteRenderer r)