split various flying behaviors into own files

This commit is contained in:
Chris Forbes
2009-12-28 09:05:13 +13:00
parent b7bac5bd16
commit 1afe170d6d
9 changed files with 222 additions and 182 deletions

View File

@@ -57,34 +57,4 @@ namespace OpenRa.Game.Traits
yield return (true) ? TagType.Primary : TagType.None;
}
}
class ProductionSurround : Production
{
public ProductionSurround( Actor self ) : base( self ) { }
static int2? FindAdjacentTile(Actor a, UnitMovementType umt)
{
var tiles = Footprint.Tiles(a, a.traits.Get<Traits.Building>());
var min = tiles.Aggregate(int2.Min) - new int2(1, 1);
var max = tiles.Aggregate(int2.Max) + new int2(1, 1);
for (var j = min.Y; j <= max.Y; j++)
for (var i = min.X; i <= max.X; i++)
if (Game.IsCellBuildable(new int2(i, j), umt))
return new int2(i, j);
return null;
}
public override int2? CreationLocation( Actor self, UnitInfo producee )
{
return FindAdjacentTile( self, producee.WaterBound ?
UnitMovementType.Float : UnitMovementType.Wheel); /* hackety hack */
}
public override int CreationFacing( Actor self, Actor newUnit )
{
return Util.GetFacing( newUnit.CenterLocation - self.CenterLocation, 128 );
}
}
}