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 Attack { get { return new Cursor("attack"); } }
|
||||||
public static Cursor Deploy { get { return new Cursor("deploy"); } }
|
public static Cursor Deploy { get { return new Cursor("deploy"); } }
|
||||||
public static Cursor Enter { get { return new Cursor("enter"); } }
|
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)
|
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 (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) &&
|
return map.IsInMap(a.X, a.Y) &&
|
||||||
TerrainCosts.Cost(umt,
|
TerrainCosts.Cost(umt,
|
||||||
@@ -246,6 +251,20 @@ namespace OpenRa.Game
|
|||||||
return null;
|
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)
|
public static void BuildUnit(Player player, string name)
|
||||||
{
|
{
|
||||||
var producerTypes = Rules.TechTree.UnitBuiltAt( Rules.UnitInfo[ name ] );
|
var producerTypes = Rules.TechTree.UnitBuiltAt( Rules.UnitInfo[ name ] );
|
||||||
|
|||||||
@@ -98,9 +98,10 @@ namespace OpenRa.Game
|
|||||||
isBlocked ? Cursor.MoveBlocked : Cursor.Move);
|
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)
|
public static Order PlaceBuilding(Player subject, int2 target, string buildingName)
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
if( lmb )
|
if( lmb )
|
||||||
{
|
{
|
||||||
// todo: check that space is free
|
|
||||||
var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[ Name ];
|
var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[ Name ];
|
||||||
if( Footprint.Tiles( bi, xy ).Any(
|
if( Footprint.Tiles( bi, xy ).Any(
|
||||||
t => !Game.IsCellBuildable( t,
|
t => !Game.IsCellBuildable( t,
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using OpenRa.Game.GameRules;
|
||||||
|
|
||||||
namespace OpenRa.Game.Traits
|
namespace OpenRa.Game.Traits
|
||||||
{
|
{
|
||||||
@@ -9,17 +10,16 @@ namespace OpenRa.Game.Traits
|
|||||||
{
|
{
|
||||||
public McvDeploy(Actor self)
|
public McvDeploy(Actor self)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Order Order(Actor self, int2 xy, bool lmb, Actor underCursor)
|
public Order Order(Actor self, int2 xy, bool lmb, Actor underCursor)
|
||||||
{
|
{
|
||||||
if( lmb ) return null;
|
if (lmb) return null;
|
||||||
|
|
||||||
// TODO: check that there's enough space at the destination.
|
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 );
|
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using OpenRa.Game.Traits;
|
using OpenRa.Game.Traits;
|
||||||
|
using OpenRa.Game.GameRules;
|
||||||
|
|
||||||
namespace OpenRa.Game
|
namespace OpenRa.Game
|
||||||
{
|
{
|
||||||
@@ -45,6 +46,10 @@ namespace OpenRa.Game
|
|||||||
}
|
}
|
||||||
case "DeployMcv":
|
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>();
|
var mobile = order.Subject.traits.Get<Mobile>();
|
||||||
mobile.QueueActivity( new Mobile.Turn( 96 ) );
|
mobile.QueueActivity( new Mobile.Turn( 96 ) );
|
||||||
mobile.QueueActivity( new Traits.Activities.DeployMcv() );
|
mobile.QueueActivity( new Traits.Activities.DeployMcv() );
|
||||||
|
|||||||
@@ -385,7 +385,7 @@
|
|||||||
<sequence name="heal-minimap" start="194" length="1" />
|
<sequence name="heal-minimap" start="194" length="1" />
|
||||||
<sequence name="attack2" start="195" length="8" x="12" y="12" />
|
<sequence name="attack2" start="195" length="8" x="12" y="12" />
|
||||||
<sequence name="attack2-minimap" start="203" length="8" />
|
<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="enter-blocked" start="212" length="1" />
|
||||||
<sequence name="repair2-blocked" start="213" length="1" />
|
<sequence name="repair2-blocked" start="213" length="1" />
|
||||||
<sequence name="ability-minimap" start="214" length="8" />
|
<sequence name="ability-minimap" start="214" length="8" />
|
||||||
|
|||||||
Reference in New Issue
Block a user