Port to new traits model (untested)

This commit is contained in:
Paul Chote
2010-01-15 14:35:32 +13:00
parent 057dec41e4
commit 34f90aca3c
3 changed files with 62 additions and 48 deletions

View File

@@ -7,6 +7,12 @@ using OpenRa.Game.Traits;
namespace OpenRa.Game.Traits
{
class GeneratesGapInfo : ITraitInfo
{
public readonly int Range = 10;
public object Create(Actor self) { return new GeneratesGap(self); }
}
class GeneratesGap
{
Actor self;
@@ -17,12 +23,13 @@ namespace OpenRa.Game.Traits
public IEnumerable<int2>GetShroudedTiles()
{
int range = self.Info.Traits.Get<GeneratesGapInfo>().Range;
// Gap Generator building; powered down
if (self.traits.Contains<Building>() && self.traits.Get<Building>().Disabled)
yield break;
// It won't let me return Game.FindTilesInCircle directly...?
foreach (var t in Game.FindTilesInCircle(self.Location, Rules.General.GapRadius))
foreach (var t in Game.FindTilesInCircle(self.Location, range))
yield return t;
}
}