diff --git a/OpenRa.Game/Traits/SeedsOre.cs b/OpenRa.Game/Traits/SeedsOre.cs index 046b061a9b..71292c2d98 100644 --- a/OpenRa.Game/Traits/SeedsOre.cs +++ b/OpenRa.Game/Traits/SeedsOre.cs @@ -1,19 +1,32 @@  namespace OpenRa.Traits { - class SeedsOreInfo : StatelessTraitInfo {} + class SeedsOreInfo : ITraitInfo + { + public readonly float Chance = .05f; + public readonly int Interval = 5; + + public object Create(Actor self) { return new SeedsOre(); } + } class SeedsOre : ITick { - const double OreSeedProbability = .05; // todo: push this out into rules + int ticks; 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); + if (--ticks <= 0) + { + var info = self.Info.Traits.Get(); + + 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; + } } } }