diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 172d6395f5..a625a5e030 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -143,6 +143,13 @@ namespace OpenRA.Traits void SetVisualPosition(Actor self, WPos pos); } + public interface IMove + { + Activity MoveTo(CPos cell, int nearEnough); + Activity MoveTo(CPos cell, Actor ignoredActor); + Activity MoveWithinRange(Target target, WRange range); + } + public interface INotifyBlockingMove { void OnNotifyBlockingMove(Actor self, Actor blocking); } public interface IFacing diff --git a/OpenRA.Mods.RA/Air/Helicopter.cs b/OpenRA.Mods.RA/Air/Helicopter.cs index 33c5a2d89e..f83dbe344b 100755 --- a/OpenRA.Mods.RA/Air/Helicopter.cs +++ b/OpenRA.Mods.RA/Air/Helicopter.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Air public override object Create(ActorInitializer init) { return new Helicopter(init, this); } } - class Helicopter : Aircraft, ITick, IResolveOrder + class Helicopter : Aircraft, ITick, IResolveOrder, IMove { public HelicopterInfo Info; bool firstTick = true; @@ -149,5 +149,9 @@ namespace OpenRA.Mods.RA.Air return (d * 1024 * 8) / (int)distSq; } + + public Activity MoveTo(CPos cell, int nearEnough) { return new HeliFly(cell); } + public Activity MoveTo(CPos cell, Actor ignoredActor) { return new HeliFly(cell); } + public Activity MoveWithinRange(Target target, WRange range) { return new HeliFly(target.CenterPosition); } } } diff --git a/OpenRA.Mods.RA/Air/Plane.cs b/OpenRA.Mods.RA/Air/Plane.cs index 9c90191f72..4fc91ed44d 100755 --- a/OpenRA.Mods.RA/Air/Plane.cs +++ b/OpenRA.Mods.RA/Air/Plane.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Air public override object Create(ActorInitializer init) { return new Plane(init, this); } } - public class Plane : Aircraft, IResolveOrder, ITick, ISync + public class Plane : Aircraft, IResolveOrder, IMove, ITick, ISync { public readonly PlaneInfo Info; [Sync] public WPos RTBPathHash; @@ -89,5 +89,9 @@ namespace OpenRA.Mods.RA.Air UnReserve(); } } + + public Activity MoveTo(CPos cell, int nearEnough) { return Fly.ToCell(cell); } + public Activity MoveTo(CPos cell, Actor ignoredActor) { return Fly.ToCell(cell); } + public Activity MoveWithinRange(Target target, WRange range) { return Fly.ToPos(target.CenterPosition); } } } diff --git a/OpenRA.Mods.RA/Move/Mobile.cs b/OpenRA.Mods.RA/Move/Mobile.cs index 86ef2231a8..0da1ec50b1 100755 --- a/OpenRA.Mods.RA/Move/Mobile.cs +++ b/OpenRA.Mods.RA/Move/Mobile.cs @@ -144,7 +144,7 @@ namespace OpenRA.Mods.RA.Move public int GetInitialFacing() { return InitialFacing; } } - public class Mobile : IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IFacing, ISync + public class Mobile : IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove, IFacing, ISync { public readonly Actor self; public readonly MobileInfo Info; diff --git a/OpenRA.Mods.RA/Production.cs b/OpenRA.Mods.RA/Production.cs index ad6c8241e3..dd9108fb18 100755 --- a/OpenRA.Mods.RA/Production.cs +++ b/OpenRA.Mods.RA/Production.cs @@ -94,19 +94,11 @@ namespace OpenRA.Mods.RA if (rp == null) return exitLocation; - var mobile = newUnit.TraitOrDefault(); - if (mobile != null) + var move = newUnit.TraitOrDefault(); + if (move != null) { newUnit.QueueActivity(new AttackMove.AttackMoveActivity( - newUnit, mobile.MoveTo(rp.rallyPoint, rp.nearEnough))); - return rp.rallyPoint; - } - - // TODO: don't talk about HeliFly here. - var helicopter = newUnit.TraitOrDefault(); - if (helicopter != null) - { - newUnit.QueueActivity(new HeliFly(rp.rallyPoint)); + newUnit, move.MoveTo(rp.rallyPoint, rp.nearEnough))); return rp.rallyPoint; }