Use footprints in GrantExternalConditionPower.

This commit is contained in:
Zimmermann Gyula
2018-05-22 06:30:22 +02:00
committed by atlimit8
parent 485faac294
commit 54bd0eb99d

View File

@@ -29,8 +29,13 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Duration of the condition (in ticks). Set to 0 for a permanent condition.")]
public readonly int Duration = 0;
[Desc("Cells - affects whole cells only")]
public readonly int Range = 1;
[FieldLoader.Require]
[Desc("Size of the footprint of the affected area.")]
public readonly CVec Dimensions = CVec.Zero;
[FieldLoader.Require]
[Desc("Actual footprint. Cells marked as x will be affected.")]
public readonly string Footprint = string.Empty;
[Desc("Sound to instantly play at the targeted area.")]
public readonly string OnFireSound = null;
@@ -88,8 +93,7 @@ namespace OpenRA.Mods.Common.Traits
public IEnumerable<Actor> UnitsInRange(CPos xy)
{
var range = info.Range;
var tiles = Self.World.Map.FindTilesInCircle(xy, range);
var tiles = CellsMatching(xy, info.Footprint, info.Dimensions);
var units = new List<Actor>();
foreach (var t in tiles)
units.AddRange(Self.World.ActorMap.GetActorsAt(t));
@@ -107,7 +111,8 @@ namespace OpenRA.Mods.Common.Traits
class SelectConditionTarget : OrderGenerator
{
readonly GrantExternalConditionPower power;
readonly int range;
readonly string footprint;
readonly CVec dimensions;
readonly Sprite tile;
readonly SupportPowerManager manager;
readonly string order;
@@ -121,7 +126,8 @@ namespace OpenRA.Mods.Common.Traits
this.manager = manager;
this.order = order;
this.power = power;
range = power.info.Range;
footprint = power.info.Footprint;
dimensions = power.info.Dimensions;
tile = world.Map.Rules.Sequences.GetSequence("overlay", "target-select").GetSprite(0);
}
@@ -157,7 +163,7 @@ namespace OpenRA.Mods.Common.Traits
var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos);
var pal = wr.Palette(TileSet.TerrainPaletteInternalName);
foreach (var t in world.Map.FindTilesInCircle(xy, range))
foreach (var t in power.CellsMatching(xy, footprint, dimensions))
yield return new SpriteRenderable(tile, wr.World.Map.CenterOfCell(t), WVec.Zero, -511, pal, 1f, true);
}