wire up hide-map crate properly

This commit is contained in:
Chris Forbes
2010-03-30 18:40:37 +13:00
parent a71ba665a7
commit c159300ecf
3 changed files with 11 additions and 5 deletions

View File

@@ -58,8 +58,6 @@ namespace OpenRA
bool IsExplored(int x, int y) { return shroud.exploredCells[x,y]; } bool IsExplored(int x, int y) { return shroud.exploredCells[x,y]; }
public bool DisplayOnRadar(int x, int y) { return IsExplored(x, y); } public bool DisplayOnRadar(int x, int y) { return IsExplored(x, y); }
public void ResetExplored() { } // todo
public void Explore(World w, int2 center, int range) { dirty = true; } public void Explore(World w, int2 center, int range) { dirty = true; }
public void Explore(Actor a) { if (a.Owner == a.World.LocalPlayer) dirty = true; } public void Explore(Actor a) { if (a.Owner == a.World.LocalPlayer) dirty = true; }

View File

@@ -26,12 +26,12 @@ using System.Drawing;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {
class ShroudInfo : ITraitInfo public class ShroudInfo : ITraitInfo
{ {
public object Create(Actor self) { return new Shroud(self, this); } public object Create(Actor self) { return new Shroud(self, this); }
} }
class Shroud public class Shroud
{ {
Map map; Map map;
@@ -124,5 +124,12 @@ namespace OpenRA.Traits
exploredBounds = exploredBounds.HasValue ? exploredBounds = exploredBounds.HasValue ?
Rectangle.Union(exploredBounds.Value, box) : box; Rectangle.Union(exploredBounds.Value, box) : box;
} }
public void ResetExploration() // for `hide map` crate
{
for (var j = 0; j <= exploredCells.GetUpperBound(1); j++)
for (var i = 0; i <= exploredCells.GetUpperBound(0); i++)
exploredCells[i, j] = visibleCells[i, j] > 0;
}
} }
} }

View File

@@ -34,8 +34,9 @@ namespace OpenRA.Mods.RA
public override void Activate(Actor collector) public override void Activate(Actor collector)
{ {
collector.Owner.Shroud.ResetExplored();
base.Activate(collector); base.Activate(collector);
if (collector.Owner == collector.World.LocalPlayer)
collector.World.WorldActor.traits.Get<Shroud>().ResetExploration();
} }
} }
} }