harvesting support in Map

This commit is contained in:
Chris Forbes
2009-11-03 18:10:09 +13:00
parent 2fe3618b23
commit 1cb3f1ee10

View File

@@ -116,12 +116,12 @@ namespace OpenRa.FileFormats
return MapTiles[i, j].overlay < overlayIsOre.Length;
}
bool ContainsOre(int i, int j)
public bool ContainsOre(int i, int j)
{
return HasOverlay(i,j) && overlayIsOre[MapTiles[i,j].overlay];
}
bool ContainsGem(int i, int j)
public bool ContainsGem(int i, int j)
{
return HasOverlay(i, j) && overlayIsGems[MapTiles[i, j].overlay];
}
@@ -129,6 +129,17 @@ namespace OpenRa.FileFormats
const float oreRate = .02f;
const float gemRate = .01f;
public bool Harvest(int2 p, out bool isGems) /* harvests one unit if possible */
{
isGems = ContainsGem(p.X, p.Y);
if (MapTiles[p.X, p.Y].density == 0) return false;
if (--MapTiles[p.X, p.Y].density == 0)
MapTiles[p.X, p.Y].overlay = 0xff;
return true;
}
public void GrowOre( Func<int2, bool> canSpreadIntoCell, Random r ) /* todo: deal with ore pits */
{
/* phase 1: grow into neighboring regions */