diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs
index 318120d691..f114ab494b 100644
--- a/OpenRa.Game/Chrome.cs
+++ b/OpenRa.Game/Chrome.cs
@@ -481,9 +481,7 @@ namespace OpenRa.Game
}
void TickPaletteAnimation()
- {
- Log.Write("{0} {1} {2} {3}", paletteAnimationFrame, paletteOrigin.X, paletteAnimating, paletteOpen);
-
+ {
if (!paletteAnimating)
return;
diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj
index 14c7838ece..d3d3fc46b2 100644
--- a/OpenRa.Game/OpenRa.Game.csproj
+++ b/OpenRa.Game/OpenRa.Game.csproj
@@ -227,6 +227,7 @@
+
diff --git a/OpenRa.Game/Player.cs b/OpenRa.Game/Player.cs
index b4ff66fe75..79006dbff5 100644
--- a/OpenRa.Game/Player.cs
+++ b/OpenRa.Game/Player.cs
@@ -130,6 +130,7 @@ namespace OpenRa.Game
{
UpdatePower();
UpdateOreCapacity();
+ Shroud.Tick();
foreach (var sp in SupportPowers.Values)
sp.Tick();
diff --git a/OpenRa.Game/Shroud.cs b/OpenRa.Game/Shroud.cs
index 697e774406..6ee7456142 100644
--- a/OpenRa.Game/Shroud.cs
+++ b/OpenRa.Game/Shroud.cs
@@ -4,12 +4,14 @@ using System.Linq;
using System.Text;
using IjwFramework.Types;
using OpenRa.Game.Graphics;
+using OpenRa.Game.Traits;
namespace OpenRa.Game
{
class Shroud
{
bool[,] explored = new bool[128, 128];
+ int[,] gapField = new int[128, 128];
Sprite[] shadowBits = SpriteSheetBuilder.LoadAllSprites("shadow");
Sprite[,] sprites = new Sprite[128, 128];
bool dirty;
@@ -21,9 +23,35 @@ namespace OpenRa.Game
set { hasGPS = value; dirty = true;}
}
+ public void Tick()
+ {
+ // This is probably slow
+ bool[,] gapActive = new bool[128, 128];
+ foreach (var a in Game.world.Actors.Where(a => a.traits.Contains()))
+ {
+ foreach (var t in a.traits.Get().GetShroudedTiles())
+ gapActive[t.X, t.Y] = true;
+ }
+
+ for (int j = 1; j < 127; j++)
+ for (int i = 1; i < 127; i++)
+ {
+ if (gapField[i, j] > 0 && !gapActive[i, j]) /*0 >= --gapField[i, j]*/
+ {
+ gapField[i, j] = 0;
+ dirty = true;
+ }
+ if (gapActive[i, j] && 0 == gapField[i, j]++)
+ dirty = true;
+ }
+ }
+
public bool IsExplored(int2 xy) { return IsExplored(xy.X, xy.Y); }
public bool IsExplored(int x, int y)
{
+ if (gapField[ x, y ] >= Rules.General.GapRegenInterval * 25 * 60)
+ return false;
+
if (hasGPS)
return true;
@@ -33,8 +61,10 @@ namespace OpenRa.Game
public void Explore(Actor a)
{
foreach (var t in Game.FindTilesInCircle((1f / Game.CellSize * a.CenterLocation).ToInt2(), a.Info.Sight))
+ {
explored[t.X, t.Y] = true;
-
+ gapField[t.X, t.Y] = 0;
+ }
dirty = true;
}
diff --git a/OpenRa.Game/Traits/GeneratesGap.cs b/OpenRa.Game/Traits/GeneratesGap.cs
new file mode 100644
index 0000000000..5dcdf3c4f6
--- /dev/null
+++ b/OpenRa.Game/Traits/GeneratesGap.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using OpenRa.FileFormats;
+using OpenRa.Game.Support;
+using OpenRa.Game.Traits;
+
+namespace OpenRa.Game.Traits
+{
+ class GeneratesGap
+ {
+ Actor self;
+ public GeneratesGap(Actor self)
+ {
+ this.self = self;
+ }
+
+ public IEnumerableGetShroudedTiles()
+ {
+ // Gap Generator building; powered down
+ if (self.traits.Contains() && self.traits.Get().Disabled)
+ yield break;
+
+ // It won't let me return Game.FindTilesInCircle directly...?
+ foreach (var t in Game.FindTilesInCircle(self.Location, Rules.General.GapRadius))
+ yield return t;
+ }
+ }
+}
diff --git a/units.ini b/units.ini
index 4e22c79415..089a0be145 100644
--- a/units.ini
+++ b/units.ini
@@ -77,7 +77,7 @@ Voice=VehicleVoice
LongDesc=Hides nearby units on the enemy's minimap.\n Unarmed
[MGG]
Description=Mobile Gap Generator
-Traits=Unit, Mobile, RenderUnitSpinner, Repairable, Chronoshiftable, Passenger, IronCurtainable
+Traits=Unit, Mobile, RenderUnitSpinner, Repairable, Chronoshiftable, Passenger, IronCurtainable, GeneratesGap
PrimaryOffset=0,6,0,-3
SelectionPriority=3
Voice=VehicleVoice
@@ -303,7 +303,7 @@ SelectionPriority=3
LongDesc=Teleports a unit from one place \nto another, for a limited time.\n Special Ability: Chronoshift
[GAP]
Description=Gap Generator
-Traits=Building, RenderBuilding, IronCurtainable
+Traits=Building, RenderBuilding, IronCurtainable, GeneratesGap
Dimensions=1,2
Footprint=_ x
SelectionPriority=3