CanPlaceBuilding always takes topleft (instead of topleft when !adjust)

This commit is contained in:
Bob
2010-01-18 14:25:59 +13:00
parent 738d293b48
commit 4f60b2866b
4 changed files with 4 additions and 5 deletions

View File

@@ -29,7 +29,7 @@ namespace OpenRa.Orders
if (mi.Button == MouseButton.Left) if (mi.Button == MouseButton.Left)
{ {
var topLeft = xy - Footprint.AdjustForBuildingSize( BuildingInfo ); var topLeft = xy - Footprint.AdjustForBuildingSize( BuildingInfo );
if (!Game.world.CanPlaceBuilding( Building, BuildingInfo, xy, null, true) if (!Game.world.CanPlaceBuilding( Building, BuildingInfo, topLeft, null)
|| !Game.world.IsCloseEnoughToBase(Producer.Owner, Building, BuildingInfo, topLeft)) || !Game.world.IsCloseEnoughToBase(Producer.Owner, Building, BuildingInfo, topLeft))
{ {
Sound.Play("nodeply1.aud"); Sound.Play("nodeply1.aud");

View File

@@ -70,7 +70,7 @@ namespace OpenRa.Orders
return Cursor.MoveBlocked; return Cursor.MoveBlocked;
case "DeployMcv": case "DeployMcv":
var factBuildingInfo = Rules.ActorInfo["fact"].Traits.Get<BuildingInfo>(); var factBuildingInfo = Rules.ActorInfo["fact"].Traits.Get<BuildingInfo>();
if (Game.world.CanPlaceBuilding("fact", factBuildingInfo, a.Location - new int2(1, 1), a, false)) if (Game.world.CanPlaceBuilding("fact", factBuildingInfo, a.Location - new int2(1, 1), a))
return Cursor.Deploy; return Cursor.Deploy;
else else
return Cursor.DeployBlocked; return Cursor.DeployBlocked;

View File

@@ -25,7 +25,7 @@ namespace OpenRa.Traits
if( order.OrderString == "DeployMcv" ) if( order.OrderString == "DeployMcv" )
{ {
var factBuildingInfo = Rules.ActorInfo[ "fact" ].Traits.Get<BuildingInfo>(); var factBuildingInfo = Rules.ActorInfo[ "fact" ].Traits.Get<BuildingInfo>();
if( Game.world.CanPlaceBuilding( "fact", factBuildingInfo, self.Location - new int2( 1, 1 ), self, false ) ) if( Game.world.CanPlaceBuilding( "fact", factBuildingInfo, self.Location - new int2( 1, 1 ), self ) )
{ {
self.CancelActivity(); self.CancelActivity();
self.QueueActivity( new Turn( 96 ) ); self.QueueActivity( new Turn( 96 ) );

View File

@@ -99,9 +99,8 @@ namespace OpenRa
.FirstOrDefault(); .FirstOrDefault();
} }
public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 xy, Actor toIgnore, bool adjust) public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 topLeft, Actor toIgnore)
{ {
var topLeft = adjust ? xy - Footprint.AdjustForBuildingSize( building ) : xy;
return !Footprint.Tiles(name, building, topLeft).Any( return !Footprint.Tiles(name, building, topLeft).Any(
t => !world.Map.IsInMap(t.X, t.Y) || world.Map.ContainsResource(t) || !world.IsCellBuildable(t, t => !world.Map.IsInMap(t.X, t.Y) || world.Map.ContainsResource(t) || !world.IsCellBuildable(t,
building.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel, building.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel,