deploy mcv now requires clear space

This commit is contained in:
Chris Forbes
2009-11-01 21:29:05 +13:00
parent 98e64fc446
commit f4a5c9069b
7 changed files with 42 additions and 17 deletions

View File

@@ -156,9 +156,14 @@ namespace OpenRa.Game
}
public static bool IsCellBuildable(int2 a, UnitMovementType umt)
{
return IsCellBuildable(a, umt, null);
}
public static bool IsCellBuildable(int2 a, UnitMovementType umt, Actor toIgnore)
{
if (BuildingInfluence.GetBuildingAt(a) != null) return false;
if (UnitInfluence.GetUnitAt(a) != null) return false;
if (UnitInfluence.GetUnitAt(a) != null && UnitInfluence.GetUnitAt(a) != toIgnore) return false;
return map.IsInMap(a.X, a.Y) &&
TerrainCosts.Cost(umt,
@@ -246,6 +251,20 @@ namespace OpenRa.Game
return null;
}
public static bool CanPlaceBuilding(string name, int2 xy, Actor toIgnore)
{
var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo["fact"];
return !Footprint.Tiles(bi, xy).Any(
t => !Game.IsCellBuildable(t,
bi.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel,
toIgnore));
}
public static bool CanPlaceBuilding(string name, int2 xy)
{
return CanPlaceBuilding(name, xy, null);
}
public static void BuildUnit(Player player, string name)
{
var producerTypes = Rules.TechTree.UnitBuiltAt( Rules.UnitInfo[ name ] );