Begin to unhack unit movement/cursors; Flying units no longer show move-blocked cursor on water

This commit is contained in:
Paul Chote
2009-12-21 03:09:47 -08:00
parent 7fa1da0d7d
commit 7aea135113
9 changed files with 46 additions and 15 deletions

View File

@@ -32,7 +32,7 @@ namespace OpenRa.Game.Traits
if (underCursor != null
&& underCursor.Owner == self.Owner
&& underCursor.traits.Contains<AcceptsOre>() && !IsEmpty)
return Order.DeliverOre(self, underCursor);
return Order.Enter(self, underCursor);
if (underCursor == null && Rules.Map.ContainsResource(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.Harvest());
}
else if (order.OrderString == "DeliverOre")
else if (order.OrderString == "Enter")
{
self.CancelActivity();
self.QueueActivity(new Traits.Activities.DeliverOre(order.TargetActor));

View File

@@ -4,7 +4,7 @@ using OpenRa.Game.GameRules;
namespace OpenRa.Game.Traits
{
class Helicopter : ITick, IOrder
class Helicopter : ITick, IOrder, IMovement
{
public int2 targetLocation;
@@ -74,5 +74,14 @@ namespace OpenRa.Game.Traits
/* todo: bob slightly when hovering */
}
public UnitMovementType GetMovementType()
{
return UnitMovementType.Fly;
}
public bool CanEnterCell(int2 location)
{
return true; // Planes can go anywhere (?)
}
}
}

View File

@@ -5,7 +5,7 @@ using OpenRa.Game.GameRules;
namespace OpenRa.Game.Traits
{
class Mobile : IOrder, IOccupySpace
class Mobile : IOrder, IOccupySpace, IMovement
{
readonly Actor self;
@@ -74,11 +74,16 @@ namespace OpenRa.Game.Traits
case "Ship":
return UnitMovementType.Float;
case "Plane":
return UnitMovementType.Track; // FIXME: remove this when planes actually fly.
return UnitMovementType.Fly;
default:
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()
{

View File

@@ -6,7 +6,7 @@ using OpenRa.Game.Traits.Activities;
namespace OpenRa.Game.Traits
{
class Plane : IOrder
class Plane : IOrder, IMovement
{
public Plane(Actor self)
{
@@ -19,7 +19,7 @@ namespace OpenRa.Game.Traits
return Order.Move(self, xy);
if (underCursor.Info == Rules.UnitInfo["AFLD"]
&& underCursor.Owner == self.Owner)
return Order.DeliverOre(self, underCursor); /* brutal hack */
return Order.Enter(self, underCursor);
return null;
}
@@ -31,11 +31,21 @@ namespace OpenRa.Game.Traits
self.QueueActivity(new Circle(order.TargetLocation));
}
if (order.OrderString == "DeliverOre")
if (order.OrderString == "Enter")
{
self.CancelActivity();
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 (?)
}
}
}

View File

@@ -29,4 +29,9 @@ namespace OpenRa.Game.Traits
interface ISpeedModifier { float GetSpeedModifier(); }
interface IPips { IEnumerable<PipType> GetPips(); }
interface ITags { IEnumerable<TagType> GetTags(); }
interface IMovement
{
UnitMovementType GetMovementType();
bool CanEnterCell(int2 location);
}
}