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

@@ -59,8 +59,6 @@ namespace OpenRA
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(Actor a) { if (a.Owner == a.World.LocalPlayer) dirty = true; }

View File

@@ -26,12 +26,12 @@ using System.Drawing;
namespace OpenRA.Traits
{
class ShroudInfo : ITraitInfo
public class ShroudInfo : ITraitInfo
{
public object Create(Actor self) { return new Shroud(self, this); }
}
class Shroud
public class Shroud
{
Map map;
@@ -124,5 +124,12 @@ namespace OpenRA.Traits
exploredBounds = exploredBounds.HasValue ?
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)
{
collector.Owner.Shroud.ResetExplored();
base.Activate(collector);
if (collector.Owner == collector.World.LocalPlayer)
collector.World.WorldActor.traits.Get<Shroud>().ResetExploration();
}
}
}