moved growth/spread control onto ResourceType
This commit is contained in:
@@ -114,7 +114,6 @@
|
||||
<Compile Include="Traits\World\ChoosePaletteOnSelect.cs" />
|
||||
<Compile Include="Traits\World\Country.cs" />
|
||||
<Compile Include="Traits\World\CrateSpawner.cs" />
|
||||
<Compile Include="Traits\World\OreGrowth.cs" />
|
||||
<Compile Include="Traits\OreRefinery.cs" />
|
||||
<Compile Include="Traits\Activities\Attack.cs" />
|
||||
<Compile Include="Traits\Activities\CallFunc.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;
|
||||
|
||||
@@ -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<ResourceLayer>().Grow(info);
|
||||
self.World.Minimap.InvalidateOre();
|
||||
}
|
||||
|
||||
if (info.SpreadInterval != 0 && --spreadTicks <= 0)
|
||||
{
|
||||
spreadTicks = (int)(info.SpreadInterval * 25 * 60);
|
||||
self.World.WorldActor.traits.Get<ResourceLayer>().Spread(info);
|
||||
self.World.Minimap.InvalidateOre();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user