diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index f41e09dee1..7965e8cdbe 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -114,7 +114,6 @@ - diff --git a/OpenRA.Game/Traits/World/ResourceLayer.cs b/OpenRA.Game/Traits/World/ResourceLayer.cs index 6f389afcd3..784fc1f385 100644 --- a/OpenRA.Game/Traits/World/ResourceLayer.cs +++ b/OpenRA.Game/Traits/World/ResourceLayer.cs @@ -159,7 +159,7 @@ namespace OpenRA.Traits ++content[i, j].density; } - public void Spread(ResourceTypeInfo info, Random r, float chance) + public void Spread(ResourceTypeInfo info) { var map = w.Map; @@ -170,7 +170,6 @@ namespace OpenRA.Traits for (int j = minj; j < maxj; j++) for (int i = mini; i < maxi; i++) if (content[i,j].type == null - && r.NextDouble() < chance && GetAdjacentCellsWith(info, i,j ) > 0 && w.IsCellBuildable(new int2(i, j), UnitMovementType.Wheel)) growMask[i, j] = true; diff --git a/OpenRA.Game/Traits/World/ResourceType.cs b/OpenRA.Game/Traits/World/ResourceType.cs index 6c98f0a8ea..79a1e25e92 100644 --- a/OpenRA.Game/Traits/World/ResourceType.cs +++ b/OpenRA.Game/Traits/World/ResourceType.cs @@ -19,7 +19,7 @@ #endregion using OpenRA.Graphics; -using System.Collections.Generic; + namespace OpenRA.Traits { public class ResourceTypeInfo : ITraitInfo @@ -27,13 +27,41 @@ namespace OpenRA.Traits public readonly int[] Overlays = { }; public readonly string[] SpriteNames = { }; public readonly string Palette = "terrain"; + public readonly int ValuePerUnit = 0; public readonly string Name = null; + public readonly float GrowthInterval = 0; + public readonly float SpreadInterval = 0; + public Sprite[][] Sprites; - public object Create(Actor self) { return new ResourceType(); } + public object Create(Actor self) { return new ResourceType(this); } } - class ResourceType { } + class ResourceType : ITick + { + int growthTicks; + int spreadTicks; + ResourceTypeInfo info; + + public ResourceType(ResourceTypeInfo info) { this.info = info; } + + public void Tick(Actor self) + { + if (info.GrowthInterval != 0 && --growthTicks <= 0) + { + growthTicks = (int)(info.GrowthInterval * 25 * 60); + self.World.WorldActor.traits.Get().Grow(info); + self.World.Minimap.InvalidateOre(); + } + + if (info.SpreadInterval != 0 && --spreadTicks <= 0) + { + spreadTicks = (int)(info.SpreadInterval * 25 * 60); + self.World.WorldActor.traits.Get().Spread(info); + self.World.Minimap.InvalidateOre(); + } + } + } } diff --git a/mods/cnc/compat.yaml b/mods/cnc/compat.yaml index 010c119e6d..44b1266e79 100644 --- a/mods/cnc/compat.yaml +++ b/mods/cnc/compat.yaml @@ -38,4 +38,5 @@ MINE: RenderBuilding: Palette: terrain SeedsOre: + ResourceType: Tiberium -Selectable: diff --git a/mods/cnc/system.yaml b/mods/cnc/system.yaml index 0dd0e95844..9f3af4c520 100644 --- a/mods/cnc/system.yaml +++ b/mods/cnc/system.yaml @@ -153,11 +153,6 @@ World: B: 0 A: 180 ShroudPalette: - OreGrowth: - Interval: .3 - Chance: .02 - Spreads: yes - Grows: yes Country@gdi: Name: GDI Race: gdi @@ -173,3 +168,5 @@ World: SpriteNames: ti1,ti2,ti3,ti4,ti5,ti6,ti7,ti8,ti9,ti10,ti11,ti12 ValuePerUnit: 30 Name: Tiberium + GrowthInterval: .1 + SpreadInterval: .1 diff --git a/mods/ra/rules.yaml b/mods/ra/rules.yaml index a1c1bdee32..90d0da1f4b 100644 --- a/mods/ra/rules.yaml +++ b/mods/ra/rules.yaml @@ -184,11 +184,6 @@ World: B: 0 A: 180 ShroudPalette: - OreGrowth: - Interval: .3 - Chance: .02 - Spreads: yes - Grows: yes Country@0: Name: England Race: allies @@ -241,6 +236,8 @@ World: SpriteNames: gold01,gold02,gold03,gold04 ValuePerUnit: 30 Name: Ore + GrowthInterval: .3 + SpreadInterval: .7 ResourceType@gem: Overlays: 9,10,11,12 Palette: terrain