fix FACT space check on deploying mcv
This commit is contained in:
@@ -280,18 +280,18 @@ namespace OpenRa.Game
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool CanPlaceBuilding(string name, int2 xy, Actor toIgnore)
|
||||
public static bool CanPlaceBuilding(string name, int2 xy, Actor toIgnore, bool adjust)
|
||||
{
|
||||
var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo["fact"];
|
||||
return !Footprint.Tiles(bi, xy).Any(
|
||||
var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[name];
|
||||
return !Footprint.Tiles(bi, xy, adjust).Any(
|
||||
t => !Game.IsCellBuildable(t,
|
||||
bi.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel,
|
||||
toIgnore));
|
||||
}
|
||||
|
||||
public static bool CanPlaceBuilding(string name, int2 xy)
|
||||
public static bool CanPlaceBuilding(string name, int2 xy, bool adjust)
|
||||
{
|
||||
return CanPlaceBuilding(name, xy, null);
|
||||
return CanPlaceBuilding(name, xy, null, adjust);
|
||||
}
|
||||
|
||||
public static void BuildUnit(Player player, string name)
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace OpenRa.Game.GameRules
|
||||
return Tiles(unitInfo, position, true);
|
||||
}
|
||||
|
||||
static IEnumerable<int2> Tiles(UnitInfo unitInfo, int2 position, bool adjustForPlacement)
|
||||
public static IEnumerable<int2> Tiles(UnitInfo unitInfo, int2 position, bool adjustForPlacement)
|
||||
{
|
||||
var buildingInfo = unitInfo as UnitInfo.BuildingInfo;
|
||||
var dim = buildingInfo.Dimensions;
|
||||
|
||||
@@ -21,12 +21,10 @@ namespace OpenRa.Game
|
||||
{
|
||||
if( lmb )
|
||||
{
|
||||
var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[ Name ];
|
||||
if( Footprint.Tiles( bi, xy ).Any(
|
||||
t => !Game.IsCellBuildable( t,
|
||||
bi.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel ) ) )
|
||||
if (!Game.CanPlaceBuilding(Name, xy, true))
|
||||
yield break;
|
||||
|
||||
var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[Name];
|
||||
var maxDistance = bi.Adjacent + 2; /* real-ra is weird. this is 1 GAP. */
|
||||
if( !Footprint.Tiles( bi, xy ).Any(
|
||||
t => Game.GetDistanceToBase( t, Owner ) < maxDistance ) )
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRa.Game.Traits
|
||||
if (lmb) return null;
|
||||
|
||||
if (xy == self.Location)
|
||||
return OpenRa.Game.Order.DeployMcv(self, !Game.CanPlaceBuilding("fact", xy, self));
|
||||
return OpenRa.Game.Order.DeployMcv(self, !Game.CanPlaceBuilding("fact", xy - new int2(1,1), self, false));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace OpenRa.Game
|
||||
}
|
||||
case "DeployMcv":
|
||||
{
|
||||
if (!Game.CanPlaceBuilding("fact", order.Subject.Location, order.Subject))
|
||||
if (!Game.CanPlaceBuilding("fact", order.Subject.Location - new int2(1,1), order.Subject, false))
|
||||
break; /* throw the order on the floor */
|
||||
|
||||
var mobile = order.Subject.traits.Get<Mobile>();
|
||||
|
||||
Reference in New Issue
Block a user