Gap behaves like real-ra
This commit is contained in:
@@ -103,7 +103,7 @@ namespace OpenRa.Game.Graphics
|
|||||||
{
|
{
|
||||||
for (var y = 0; y < 128; y++)
|
for (var y = 0; y < 128; y++)
|
||||||
for (var x = 0; x < 128; x++)
|
for (var x = 0; x < 128; x++)
|
||||||
if (!Game.LocalPlayer.Shroud.IsExplored(new int2(x, y)))
|
if (!Game.LocalPlayer.Shroud.DisplayOnRadar(x,y))
|
||||||
*(c + (y * bitmapData.Stride >> 2) + x) = shroudColor.ToArgb();
|
*(c + (y * bitmapData.Stride >> 2) + x) = shroudColor.ToArgb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,15 @@ namespace OpenRa.Game
|
|||||||
class Shroud
|
class Shroud
|
||||||
{
|
{
|
||||||
bool[,] explored = new bool[128, 128];
|
bool[,] explored = new bool[128, 128];
|
||||||
int[,] gapField = new int[128, 128];
|
|
||||||
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;
|
bool hasGPS = false;
|
||||||
|
|
||||||
|
float gapOpaqueTicks = (int)(Rules.General.GapRegenInterval * 25 * 60);
|
||||||
|
int[,] gapField = new int[128, 128];
|
||||||
|
bool[,] gapActive = new bool[128, 128];
|
||||||
|
|
||||||
public bool HasGPS
|
public bool HasGPS
|
||||||
{
|
{
|
||||||
get { return hasGPS; }
|
get { return hasGPS; }
|
||||||
@@ -25,8 +28,8 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
public void Tick()
|
public void Tick()
|
||||||
{
|
{
|
||||||
// This is probably slow
|
// Clear active flags
|
||||||
bool[,] gapActive = new bool[128, 128];
|
gapActive = new bool[128, 128];
|
||||||
foreach (var a in Game.world.Actors.Where(a => a.traits.Contains<GeneratesGap>()))
|
foreach (var a in Game.world.Actors.Where(a => a.traits.Contains<GeneratesGap>()))
|
||||||
{
|
{
|
||||||
foreach (var t in a.traits.Get<GeneratesGap>().GetShroudedTiles())
|
foreach (var t in a.traits.Get<GeneratesGap>().GetShroudedTiles())
|
||||||
@@ -36,11 +39,17 @@ namespace OpenRa.Game
|
|||||||
for (int j = 1; j < 127; j++)
|
for (int j = 1; j < 127; j++)
|
||||||
for (int i = 1; i < 127; i++)
|
for (int i = 1; i < 127; i++)
|
||||||
{
|
{
|
||||||
if (gapField[i, j] > 0 && !gapActive[i, j]) /*0 >= --gapField[i, j]*/
|
if (gapField[i, j] > 0 && !gapActive[i, j])
|
||||||
{
|
{
|
||||||
|
// Convert gap to shroud
|
||||||
|
if (gapField[i, j] >= gapOpaqueTicks && explored[i, j])
|
||||||
|
explored[i, j] = false;
|
||||||
|
|
||||||
|
// Clear gap
|
||||||
gapField[i, j] = 0;
|
gapField[i, j] = 0;
|
||||||
dirty = true;
|
dirty = true;
|
||||||
}
|
}
|
||||||
|
// Increase gap tick; rerender if necessary
|
||||||
if (gapActive[i, j] && 0 == gapField[i, j]++)
|
if (gapActive[i, j] && 0 == gapField[i, j]++)
|
||||||
dirty = true;
|
dirty = true;
|
||||||
}
|
}
|
||||||
@@ -58,6 +67,15 @@ namespace OpenRa.Game
|
|||||||
return explored[ x, y ];
|
return explored[ x, y ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool DisplayOnRadar(int x, int y)
|
||||||
|
{
|
||||||
|
// Active gap is never shown on radar, even if a unit is in range
|
||||||
|
if (gapActive[x , y])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return IsExplored(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
public void Explore(Actor a)
|
public void Explore(Actor a)
|
||||||
{
|
{
|
||||||
foreach (var t in Game.FindTilesInCircle((1f / Game.CellSize * a.CenterLocation).ToInt2(), a.Info.Sight))
|
foreach (var t in Game.FindTilesInCircle((1f / Game.CellSize * a.CenterLocation).ToInt2(), a.Info.Sight))
|
||||||
@@ -68,6 +86,7 @@ namespace OpenRa.Game
|
|||||||
dirty = true;
|
dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static readonly byte[] ShroudTiles =
|
static readonly byte[] ShroudTiles =
|
||||||
{
|
{
|
||||||
0xf,0xf,0xf,0xf,
|
0xf,0xf,0xf,0xf,
|
||||||
|
|||||||
Reference in New Issue
Block a user