deploy mcv now requires clear space
This commit is contained in:
@@ -25,5 +25,6 @@ namespace OpenRa.Game
|
||||
public static Cursor Attack { get { return new Cursor("attack"); } }
|
||||
public static Cursor Deploy { get { return new Cursor("deploy"); } }
|
||||
public static Cursor Enter { get { return new Cursor("enter"); } }
|
||||
public static Cursor DeployBlocked { get { return new Cursor("deploy-blocked"); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 ] );
|
||||
|
||||
@@ -98,9 +98,10 @@ namespace OpenRa.Game
|
||||
isBlocked ? Cursor.MoveBlocked : Cursor.Move);
|
||||
}
|
||||
|
||||
public static Order DeployMcv(Actor subject)
|
||||
public static Order DeployMcv(Actor subject, bool isBlocked)
|
||||
{
|
||||
return new Order(subject.Owner, "DeployMcv", subject, null, int2.Zero, null, Cursor.Deploy);
|
||||
return new Order(subject.Owner, "DeployMcv", subject, null, int2.Zero, isBlocked ? "nop" : null,
|
||||
isBlocked ? Cursor.DeployBlocked : Cursor.Deploy);
|
||||
}
|
||||
|
||||
public static Order PlaceBuilding(Player subject, int2 target, string buildingName)
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace OpenRa.Game
|
||||
{
|
||||
if( lmb )
|
||||
{
|
||||
// todo: check that space is free
|
||||
var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[ Name ];
|
||||
if( Footprint.Tiles( bi, xy ).Any(
|
||||
t => !Game.IsCellBuildable( t,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.GameRules;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
@@ -15,9 +16,8 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
if (lmb) return null;
|
||||
|
||||
// TODO: check that there's enough space at the destination.
|
||||
if (xy == self.Location)
|
||||
return OpenRa.Game.Order.DeployMcv( self );
|
||||
return OpenRa.Game.Order.DeployMcv(self, !Game.CanPlaceBuilding("fact", xy, self));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.Traits;
|
||||
using OpenRa.Game.GameRules;
|
||||
|
||||
namespace OpenRa.Game
|
||||
{
|
||||
@@ -45,6 +46,10 @@ namespace OpenRa.Game
|
||||
}
|
||||
case "DeployMcv":
|
||||
{
|
||||
var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo["fact"];
|
||||
if (!Game.CanPlaceBuilding("fact", order.Subject.Location, order.Subject))
|
||||
break; /* throw the order on the floor */
|
||||
|
||||
var mobile = order.Subject.traits.Get<Mobile>();
|
||||
mobile.QueueActivity( new Mobile.Turn( 96 ) );
|
||||
mobile.QueueActivity( new Traits.Activities.DeployMcv() );
|
||||
|
||||
@@ -385,7 +385,7 @@
|
||||
<sequence name="heal-minimap" start="194" length="1" />
|
||||
<sequence name="attack2" start="195" length="8" x="12" y="12" />
|
||||
<sequence name="attack2-minimap" start="203" length="8" />
|
||||
<sequence name="deploy-blocked" start="211" length="1" />
|
||||
<sequence name="deploy-blocked" start="211" length="1" x="12" y="12" />
|
||||
<sequence name="enter-blocked" start="212" length="1" />
|
||||
<sequence name="repair2-blocked" start="213" length="1" />
|
||||
<sequence name="ability-minimap" start="214" length="8" />
|
||||
|
||||
Reference in New Issue
Block a user