diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 035a52e565..9f2faa50ec 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -161,6 +161,8 @@ namespace OpenRA.Traits Activity MoveTo(CPos cell, Actor ignoredActor); Activity MoveWithinRange(Target target, WRange range); Activity MoveFollow(Actor self, Target target, WRange range); + Activity MoveIntoWorld(Actor self, CPos cell); + Activity VisualMove(Actor self, WPos fromPos, WPos toPos); CPos NearestMoveableCell(CPos target); bool IsMoving { get; set; } } diff --git a/OpenRA.Mods.RA/Air/Helicopter.cs b/OpenRA.Mods.RA/Air/Helicopter.cs index d1687f109a..8996daec2b 100755 --- a/OpenRA.Mods.RA/Air/Helicopter.cs +++ b/OpenRA.Mods.RA/Air/Helicopter.cs @@ -159,5 +159,16 @@ namespace OpenRA.Mods.RA.Air public Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange) { return new HeliFly(self, target, minRange, maxRange); } public Activity MoveFollow(Actor self, Target target, WRange range) { return new Follow(self, target, range); } public CPos NearestMoveableCell(CPos cell) { return cell; } + + public Activity MoveIntoWorld(Actor self, CPos cell) + { + return new HeliFly(self, Target.FromCell(cell)); + } + + public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) + { + // TODO: Ignore repulsion when moving + return Util.SequenceActivities(new CallFunc(() => SetVisualPosition(self, fromPos)), new HeliFly(self, Target.FromPos(toPos))); + } } } diff --git a/OpenRA.Mods.RA/Air/Plane.cs b/OpenRA.Mods.RA/Air/Plane.cs index 07e15802b0..a154ecc6be 100755 --- a/OpenRA.Mods.RA/Air/Plane.cs +++ b/OpenRA.Mods.RA/Air/Plane.cs @@ -100,5 +100,8 @@ namespace OpenRA.Mods.RA.Air public Activity MoveWithinRange(Target target, WRange minRange, WRange maxRange) { return Util.SequenceActivities(new Fly(self, target, minRange, maxRange), new FlyCircle()); } public Activity MoveFollow(Actor self, Target target, WRange range) { return new FlyFollow(self, target, range); } public CPos NearestMoveableCell(CPos cell) { return cell; } + + public Activity MoveIntoWorld(Actor self, CPos cell) { return new Fly(self, Target.FromCell(cell)); } + public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) { return Util.SequenceActivities(new CallFunc(() => SetVisualPosition(self, fromPos)), new Fly(self, Target.FromPos(toPos))); } } } diff --git a/OpenRA.Mods.RA/Move/Mobile.cs b/OpenRA.Mods.RA/Move/Mobile.cs index b281669538..01696b4b17 100755 --- a/OpenRA.Mods.RA/Move/Mobile.cs +++ b/OpenRA.Mods.RA/Move/Mobile.cs @@ -548,5 +548,31 @@ namespace OpenRA.Mods.RA.Move if (self.IsIdle && self.AppearsFriendlyTo(blocking)) Nudge(self, blocking, true); } + + public Activity MoveIntoWorld(Actor self, CPos cell) + { + var pos = self.CenterPosition; + + // Reserve the exit cell + SetPosition(self, cell); + SetVisualPosition(self, pos); + + // Animate transition + var to = cell.CenterPosition; + var speed = MovementSpeedForCell(self, cell); + var length = speed > 0 ? (to - pos).Length / speed : 0; + + var facing = Util.GetFacing(to - pos, Facing); + return Util.SequenceActivities(new Turn(facing), new Drag(pos, to, length)); + } + + public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) + { + var speed = MovementSpeedForCell(self, self.Location); + var length = speed > 0 ? (toPos - fromPos).Length / speed : 0; + + var facing = Util.GetFacing(toPos - fromPos, Facing); + return Util.SequenceActivities(new Turn(facing), new Drag(fromPos, toPos, length)); + } } }