moved a query where it belongs
This commit is contained in:
@@ -243,20 +243,6 @@ namespace OpenRa.Game
|
|||||||
public static Random SharedRandom = new Random(0); /* for things that require sync */
|
public static Random SharedRandom = new Random(0); /* for things that require sync */
|
||||||
public static Random CosmeticRandom = new Random(); /* for things that are just fluff */
|
public static Random CosmeticRandom = new Random(); /* for things that are just fluff */
|
||||||
|
|
||||||
public 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 (IsCellBuildable(new int2(i, j), umt))
|
|
||||||
return new int2(i, j);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool CanPlaceBuilding(BuildingInfo building, int2 xy, Actor toIgnore, bool adjust)
|
public static bool CanPlaceBuilding(BuildingInfo building, int2 xy, Actor toIgnore, bool adjust)
|
||||||
{
|
{
|
||||||
return !Footprint.Tiles(building, xy, adjust).Any(
|
return !Footprint.Tiles(building, xy, adjust).Any(
|
||||||
@@ -267,7 +253,7 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
public static bool IsCloseEnoughToBase(Player p, BuildingInfo bi, int2 position)
|
public static bool IsCloseEnoughToBase(Player p, BuildingInfo bi, int2 position)
|
||||||
{
|
{
|
||||||
var maxDistance = bi.Adjacent + 2; /* real-ra is weird. this is 1 GAP. */
|
var maxDistance = bi.Adjacent + 1;
|
||||||
|
|
||||||
var search = new PathSearch()
|
var search = new PathSearch()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using OpenRa.Game.GameRules;
|
using OpenRa.Game.GameRules;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace OpenRa.Game.Traits
|
namespace OpenRa.Game.Traits
|
||||||
{
|
{
|
||||||
@@ -55,9 +56,23 @@ namespace OpenRa.Game.Traits
|
|||||||
{
|
{
|
||||||
public ProductionSurround( Actor self ) : base( self ) { }
|
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 )
|
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 */
|
UnitMovementType.Float : UnitMovementType.Wheel); /* hackety hack */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user