mines seed ore
This commit is contained in:
@@ -161,6 +161,7 @@
|
||||
<Compile Include="Traits\RenderUnitRotor.cs" />
|
||||
<Compile Include="Traits\RenderUnitSpinner.cs" />
|
||||
<Compile Include="Traits\RenderUnitTurreted.cs" />
|
||||
<Compile Include="Traits\SeedsOre.cs" />
|
||||
<Compile Include="Traits\TraitsInterfaces.cs" />
|
||||
<Compile Include="Traits\Tree.cs" />
|
||||
<Compile Include="Traits\Turreted.cs" />
|
||||
|
||||
@@ -8,9 +8,19 @@ namespace OpenRa.Game
|
||||
{
|
||||
public static class Ore
|
||||
{
|
||||
/* todo: deal with ore pits */
|
||||
public static void AddOre(this Map map, int i, int j)
|
||||
{
|
||||
if (Rules.General.OreSpreads)
|
||||
if (map.ContainsOre(i, j) && map.MapTiles[i, j].density < 12)
|
||||
map.MapTiles[i, j].density++;
|
||||
else if (map.MapTiles[i, j].overlay == 0xff)
|
||||
{
|
||||
map.MapTiles[i, j].overlay = ChooseOre();
|
||||
map.MapTiles[i, j].density = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static bool CanSpreadInto(int i, int j)
|
||||
public static bool CanSpreadInto(int i, int j)
|
||||
{
|
||||
if (Game.BuildingInfluence.GetBuildingAt(new int2(i, j)) != null)
|
||||
return false;
|
||||
@@ -72,13 +82,6 @@ namespace OpenRa.Game
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<int2> AdjacentTiles(int2 p)
|
||||
{
|
||||
for (var u = -1; u < 2; u++)
|
||||
for (var v = -1; v < 2; v++)
|
||||
yield return new int2(u, v) + p;
|
||||
}
|
||||
|
||||
static byte GetOreDensity(this Map map, int i, int j)
|
||||
{
|
||||
int sum = 0;
|
||||
|
||||
23
OpenRa.Game/Traits/SeedsOre.cs
Normal file
23
OpenRa.Game/Traits/SeedsOre.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class SeedsOre : ITick
|
||||
{
|
||||
public SeedsOre( Actor self ) {}
|
||||
|
||||
const double OreSeedProbability = .05;
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
for (var j = -1; j < 2; j++)
|
||||
for (var i = -1; i < 2; i++)
|
||||
if (Game.SharedRandom.NextDouble() < OreSeedProbability)
|
||||
if (Ore.CanSpreadInto(self.Location.X + i, self.Location.Y + j))
|
||||
Rules.Map.AddOre(self.Location.X + i, self.Location.Y + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user