SeedsOre parameters in traitinfo
This commit is contained in:
@@ -1,19 +1,32 @@
|
|||||||
|
|
||||||
namespace OpenRa.Traits
|
namespace OpenRa.Traits
|
||||||
{
|
{
|
||||||
class SeedsOreInfo : StatelessTraitInfo<SeedsOre> {}
|
class SeedsOreInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public readonly float Chance = .05f;
|
||||||
|
public readonly int Interval = 5;
|
||||||
|
|
||||||
|
public object Create(Actor self) { return new SeedsOre(); }
|
||||||
|
}
|
||||||
|
|
||||||
class SeedsOre : ITick
|
class SeedsOre : ITick
|
||||||
{
|
{
|
||||||
const double OreSeedProbability = .05; // todo: push this out into rules
|
int ticks;
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
for (var j = -1; j < 2; j++)
|
if (--ticks <= 0)
|
||||||
for (var i = -1; i < 2; i++)
|
{
|
||||||
if (Game.SharedRandom.NextDouble() < OreSeedProbability)
|
var info = self.Info.Traits.Get<SeedsOreInfo>();
|
||||||
if (Ore.CanSpreadInto(self.Location.X + i, self.Location.Y + j))
|
|
||||||
Rules.Map.AddOre(self.Location.X + i, self.Location.Y + j);
|
for (var j = -1; j < 2; j++)
|
||||||
|
for (var i = -1; i < 2; i++)
|
||||||
|
if (Game.SharedRandom.NextDouble() < info.Chance)
|
||||||
|
if (Ore.CanSpreadInto(self.Location.X + i, self.Location.Y + j))
|
||||||
|
Rules.Map.AddOre(self.Location.X + i, self.Location.Y + j);
|
||||||
|
|
||||||
|
ticks = info.Interval;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user