moved a query where it belongs

This commit is contained in:
Chris Forbes
2009-12-08 20:13:59 +13:00
parent 2c4b29bd51
commit 4528ee4910
2 changed files with 17 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
using OpenRa.Game.GameRules;
using System.Linq;
namespace OpenRa.Game.Traits
{
@@ -55,9 +56,23 @@ namespace OpenRa.Game.Traits
{
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 Game.FindAdjacentTile( self, producee.WaterBound ?
return FindAdjacentTile( self, producee.WaterBound ?
UnitMovementType.Float : UnitMovementType.Wheel); /* hackety hack */
}