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