Begin to unhack unit movement/cursors; Flying units no longer show move-blocked cursor on water
This commit is contained in:
@@ -128,11 +128,12 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
Cursor CursorForOrderString( string s, Actor a, int2 location )
|
Cursor CursorForOrderString( string s, Actor a, int2 location )
|
||||||
{
|
{
|
||||||
|
var movement = a.traits.WithInterface<IMovement>().FirstOrDefault();
|
||||||
switch( s )
|
switch( s )
|
||||||
{
|
{
|
||||||
case "Attack": return Cursor.Attack;
|
case "Attack": return Cursor.Attack;
|
||||||
case "Move":
|
case "Move":
|
||||||
if( Game.IsCellBuildable( location, a.Info.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel, a ) )
|
if (movement.CanEnterCell(location))
|
||||||
return Cursor.Move;
|
return Cursor.Move;
|
||||||
else
|
else
|
||||||
return Cursor.MoveBlocked;
|
return Cursor.MoveBlocked;
|
||||||
@@ -144,11 +145,11 @@ namespace OpenRa.Game
|
|||||||
return Cursor.DeployBlocked;
|
return Cursor.DeployBlocked;
|
||||||
case "ActivatePortableChronoshift": return Cursor.Deploy;
|
case "ActivatePortableChronoshift": return Cursor.Deploy;
|
||||||
case "UsePortableChronoshift":
|
case "UsePortableChronoshift":
|
||||||
if (Game.IsCellBuildable(location, a.Info.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel, a))
|
if (movement.CanEnterCell(location))
|
||||||
return Cursor.Chronoshift;
|
return Cursor.Chronoshift;
|
||||||
else
|
else
|
||||||
return Cursor.MoveBlocked;
|
return Cursor.MoveBlocked;
|
||||||
case "DeliverOre": return Cursor.Enter;
|
case "Enter": return Cursor.Enter;
|
||||||
case "Harvest": return Cursor.Attack; // TODO: special harvest cursor?
|
case "Harvest": return Cursor.Attack; // TODO: special harvest cursor?
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -169,9 +169,9 @@ namespace OpenRa.Game
|
|||||||
return new Order("PlaceBuilding", subject.PlayerActor, null, target, buildingName);
|
return new Order("PlaceBuilding", subject.PlayerActor, null, target, buildingName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Order DeliverOre(Actor subject, Actor target)
|
public static Order Enter(Actor subject, Actor target)
|
||||||
{
|
{
|
||||||
return new Order("DeliverOre", subject, target, int2.Zero, null);
|
return new Order("Enter", subject, target, int2.Zero, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Order Harvest(Actor subject, int2 target)
|
public static Order Harvest(Actor subject, int2 target)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace OpenRa.Game
|
|||||||
Track = 1,
|
Track = 1,
|
||||||
Wheel = 2,
|
Wheel = 2,
|
||||||
Float = 3,
|
Float = 3,
|
||||||
|
Fly = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TerrainMovementType : byte
|
enum TerrainMovementType : byte
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenRa.Game.Traits
|
|||||||
if (underCursor != null
|
if (underCursor != null
|
||||||
&& underCursor.Owner == self.Owner
|
&& underCursor.Owner == self.Owner
|
||||||
&& underCursor.traits.Contains<AcceptsOre>() && !IsEmpty)
|
&& underCursor.traits.Contains<AcceptsOre>() && !IsEmpty)
|
||||||
return Order.DeliverOre(self, underCursor);
|
return Order.Enter(self, underCursor);
|
||||||
|
|
||||||
if (underCursor == null && Rules.Map.ContainsResource(xy))
|
if (underCursor == null && Rules.Map.ContainsResource(xy))
|
||||||
return Order.Harvest(self, xy);
|
return Order.Harvest(self, xy);
|
||||||
@@ -48,7 +48,7 @@ namespace OpenRa.Game.Traits
|
|||||||
self.QueueActivity(new Traits.Activities.Move(order.TargetLocation, 0));
|
self.QueueActivity(new Traits.Activities.Move(order.TargetLocation, 0));
|
||||||
self.QueueActivity(new Traits.Activities.Harvest());
|
self.QueueActivity(new Traits.Activities.Harvest());
|
||||||
}
|
}
|
||||||
else if (order.OrderString == "DeliverOre")
|
else if (order.OrderString == "Enter")
|
||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(new Traits.Activities.DeliverOre(order.TargetActor));
|
self.QueueActivity(new Traits.Activities.DeliverOre(order.TargetActor));
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using OpenRa.Game.GameRules;
|
|||||||
|
|
||||||
namespace OpenRa.Game.Traits
|
namespace OpenRa.Game.Traits
|
||||||
{
|
{
|
||||||
class Helicopter : ITick, IOrder
|
class Helicopter : ITick, IOrder, IMovement
|
||||||
{
|
{
|
||||||
public int2 targetLocation;
|
public int2 targetLocation;
|
||||||
|
|
||||||
@@ -74,5 +74,14 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
/* todo: bob slightly when hovering */
|
/* todo: bob slightly when hovering */
|
||||||
}
|
}
|
||||||
|
public UnitMovementType GetMovementType()
|
||||||
|
{
|
||||||
|
return UnitMovementType.Fly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanEnterCell(int2 location)
|
||||||
|
{
|
||||||
|
return true; // Planes can go anywhere (?)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using OpenRa.Game.GameRules;
|
|||||||
|
|
||||||
namespace OpenRa.Game.Traits
|
namespace OpenRa.Game.Traits
|
||||||
{
|
{
|
||||||
class Mobile : IOrder, IOccupySpace
|
class Mobile : IOrder, IOccupySpace, IMovement
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
|
|
||||||
@@ -74,12 +74,17 @@ namespace OpenRa.Game.Traits
|
|||||||
case "Ship":
|
case "Ship":
|
||||||
return UnitMovementType.Float;
|
return UnitMovementType.Float;
|
||||||
case "Plane":
|
case "Plane":
|
||||||
return UnitMovementType.Track; // FIXME: remove this when planes actually fly.
|
return UnitMovementType.Fly;
|
||||||
default:
|
default:
|
||||||
throw new InvalidOperationException("GetMovementType on unit that shouldn't be aable to move.");
|
throw new InvalidOperationException("GetMovementType on unit that shouldn't be aable to move.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanEnterCell(int2 location)
|
||||||
|
{
|
||||||
|
return Game.IsCellBuildable( location, GetMovementType(), self );
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<int2> GetCurrentPath()
|
public IEnumerable<int2> GetCurrentPath()
|
||||||
{
|
{
|
||||||
var move = self.GetCurrentActivity() as Activities.Move;
|
var move = self.GetCurrentActivity() as Activities.Move;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using OpenRa.Game.Traits.Activities;
|
|||||||
|
|
||||||
namespace OpenRa.Game.Traits
|
namespace OpenRa.Game.Traits
|
||||||
{
|
{
|
||||||
class Plane : IOrder
|
class Plane : IOrder, IMovement
|
||||||
{
|
{
|
||||||
public Plane(Actor self)
|
public Plane(Actor self)
|
||||||
{
|
{
|
||||||
@@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits
|
|||||||
return Order.Move(self, xy);
|
return Order.Move(self, xy);
|
||||||
if (underCursor.Info == Rules.UnitInfo["AFLD"]
|
if (underCursor.Info == Rules.UnitInfo["AFLD"]
|
||||||
&& underCursor.Owner == self.Owner)
|
&& underCursor.Owner == self.Owner)
|
||||||
return Order.DeliverOre(self, underCursor); /* brutal hack */
|
return Order.Enter(self, underCursor);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,11 +31,21 @@ namespace OpenRa.Game.Traits
|
|||||||
self.QueueActivity(new Circle(order.TargetLocation));
|
self.QueueActivity(new Circle(order.TargetLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (order.OrderString == "DeliverOre")
|
if (order.OrderString == "Enter")
|
||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(new ReturnToBase(self, order.TargetActor.CenterLocation));
|
self.QueueActivity(new ReturnToBase(self, order.TargetActor.CenterLocation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UnitMovementType GetMovementType()
|
||||||
|
{
|
||||||
|
return UnitMovementType.Fly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CanEnterCell(int2 location)
|
||||||
|
{
|
||||||
|
return true; // Planes can go anywhere (?)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,4 +29,9 @@ namespace OpenRa.Game.Traits
|
|||||||
interface ISpeedModifier { float GetSpeedModifier(); }
|
interface ISpeedModifier { float GetSpeedModifier(); }
|
||||||
interface IPips { IEnumerable<PipType> GetPips(); }
|
interface IPips { IEnumerable<PipType> GetPips(); }
|
||||||
interface ITags { IEnumerable<TagType> GetTags(); }
|
interface ITags { IEnumerable<TagType> GetTags(); }
|
||||||
|
interface IMovement
|
||||||
|
{
|
||||||
|
UnitMovementType GetMovementType();
|
||||||
|
bool CanEnterCell(int2 location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace OpenRa.Game
|
|||||||
case "Move":
|
case "Move":
|
||||||
case "Attack":
|
case "Attack":
|
||||||
case "DeployMcv":
|
case "DeployMcv":
|
||||||
case "DeliverOre":
|
case "Enter":
|
||||||
case "Harvest":
|
case "Harvest":
|
||||||
case "SetRallyPoint":
|
case "SetRallyPoint":
|
||||||
case "StartProduction":
|
case "StartProduction":
|
||||||
|
|||||||
Reference in New Issue
Block a user