Rename IMovement -> IMove; Move GetCurrentPath from Mobile to IMove and implement for aircraft; fix regressions in Helicopter (ITick) and remove unused cruft from Aircraft (IOccupySpace).
This commit is contained in:
@@ -64,7 +64,7 @@ namespace OpenRA
|
||||
if (voicedActor != null)
|
||||
{
|
||||
|
||||
if(voicedActor.traits.GetOrDefault<IMovement>().CanEnterCell(xy.ToInt2()))
|
||||
if(voicedActor.traits.GetOrDefault<IMove>().CanEnterCell(xy.ToInt2()))
|
||||
Sound.PlayVoice(isAttack ? "Attack" : "Move", voicedActor);
|
||||
|
||||
if (isMove)
|
||||
|
||||
@@ -236,18 +236,15 @@ namespace OpenRA.Graphics
|
||||
|
||||
if (Game.Settings.PathDebug)
|
||||
{
|
||||
var mobile = selectedUnit.traits.GetOrDefault<Mobile>();
|
||||
var mobile = selectedUnit.traits.WithInterface<IMove>().FirstOrDefault();
|
||||
if (mobile != null)
|
||||
{
|
||||
var path = mobile.GetCurrentPath();
|
||||
var start = selectedUnit.Location;
|
||||
var path = mobile.GetCurrentPath(selectedUnit);
|
||||
var start = selectedUnit.CenterLocation;
|
||||
|
||||
foreach (var step in path)
|
||||
{
|
||||
lineRenderer.DrawLine(
|
||||
Game.CellSize * start + new float2(12, 12),
|
||||
Game.CellSize * step + new float2(12, 12),
|
||||
Color.Red, Color.Red);
|
||||
lineRenderer.DrawLine(start, step, Color.Red, Color.Red);
|
||||
start = step;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace OpenRA.Orders
|
||||
case "Heal": return "heal";
|
||||
case "C4": return "c4";
|
||||
case "Move":
|
||||
if (a.traits.GetOrDefault<IMovement>().CanEnterCell(location))
|
||||
if (a.traits.GetOrDefault<IMove>().CanEnterCell(location))
|
||||
return "move";
|
||||
else
|
||||
return "move-blocked";
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Traits
|
||||
public object Create(ActorInitializer init) { return new Mobile(init); }
|
||||
}
|
||||
|
||||
public class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMovement
|
||||
public class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMove
|
||||
{
|
||||
readonly Actor self;
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace OpenRA.Traits
|
||||
{
|
||||
if (order.OrderString == "Move")
|
||||
{
|
||||
if (self.traits.GetOrDefault<IMovement>().CanEnterCell(order.TargetLocation))
|
||||
if (self.traits.GetOrDefault<IMove>().CanEnterCell(order.TargetLocation))
|
||||
{
|
||||
if( !order.Queued ) self.CancelActivity();
|
||||
self.QueueActivity(new Activities.Move(order.TargetLocation, 8));
|
||||
@@ -132,11 +132,12 @@ namespace OpenRA.Traits
|
||||
.GetCost(GetMovementType()) < float.PositiveInfinity;
|
||||
}
|
||||
|
||||
public IEnumerable<int2> GetCurrentPath()
|
||||
public IEnumerable<float2> GetCurrentPath(Actor self)
|
||||
{
|
||||
var move = self.GetCurrentActivity() as Activities.Move;
|
||||
if (move == null || move.path == null) return new int2[] { };
|
||||
return Enumerable.Reverse(move.path);
|
||||
if (move == null || move.path == null) return new float2[] { };
|
||||
|
||||
return Enumerable.Reverse(move.path).Select( c => Game.CellSize * c + new float2(12,12) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,10 +96,11 @@ namespace OpenRA.Traits
|
||||
public interface IPaletteModifier { void AdjustPalette(Bitmap b); }
|
||||
public interface IPips { IEnumerable<PipType> GetPips(Actor self); }
|
||||
public interface ITags { IEnumerable<TagType> GetTags(); }
|
||||
public interface IMovement
|
||||
public interface IMove
|
||||
{
|
||||
UnitMovementType GetMovementType();
|
||||
bool CanEnterCell(int2 location);
|
||||
IEnumerable<float2> GetCurrentPath(Actor self);
|
||||
}
|
||||
|
||||
public interface ICrushable
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA
|
||||
|
||||
public static bool IsActorCrushableByActor(this World world, Actor a, Actor b)
|
||||
{
|
||||
var movement = b.traits.GetOrDefault<IMovement>();
|
||||
var movement = b.traits.GetOrDefault<IMove>();
|
||||
return movement != null && world.IsActorCrushableByMovementType(a, movement.GetMovementType());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user