Merge pull request #8987 from Mailaender/spiceblooms

Added spice blooms
This commit is contained in:
reaperrr
2015-10-16 19:38:21 +02:00
12 changed files with 217 additions and 45 deletions

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
public void Seed(Actor self)
{
var cell = RandomWalk(self.Location, self.World.SharedRandom)
var cell = Util.RandomWalk(self.Location, self.World.SharedRandom)
.Take(info.MaxRange)
.SkipWhile(p => resLayer.GetResource(p) == resourceType && resLayer.IsFull(p))
.Cast<CPos?>().FirstOrDefault();
@@ -71,20 +71,5 @@ namespace OpenRA.Mods.Common.Traits
if (cell != null && resLayer.CanSpawnResourceAt(resourceType, cell.Value))
resLayer.AddResource(resourceType, cell.Value, 1);
}
static IEnumerable<CPos> RandomWalk(CPos p, MersenneTwister r)
{
for (;;)
{
var dx = r.Next(-1, 2);
var dy = r.Next(-1, 2);
if (dx == 0 && dy == 0)
continue;
p += new CVec(dx, dy);
yield return p;
}
}
}
}

View File

@@ -18,9 +18,14 @@ namespace OpenRA.Mods.Common.Traits
public class ThrowsShrapnelInfo : ITraitInfo, IRulesetLoaded
{
[WeaponReference, FieldLoader.Require]
public string[] Weapons = { };
public int[] Pieces = { 3, 10 };
public WDist[] Range = { WDist.FromCells(2), WDist.FromCells(5) };
[Desc("The weapons used for shrapnel.")]
public readonly string[] Weapons = { };
[Desc("The amount of pieces of shrapnel to expel. Two values indicate a range.")]
public readonly int[] Pieces = { 3, 10 };
[Desc("The minimum and maximum distances the shrapnel may travel.")]
public readonly WDist[] Range = { WDist.FromCells(2), WDist.FromCells(5) };
public WeaponInfo[] WeaponInfos { get; private set; }