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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,4 +38,5 @@ MINE:
|
||||
RenderBuilding:
|
||||
Palette: terrain
|
||||
SeedsOre:
|
||||
ResourceType: Tiberium
|
||||
-Selectable:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user