Add IMove.MoveIntoWorld and IMove.VisualMove.

This commit is contained in:
Paul Chote
2014-03-19 13:10:19 +13:00
parent 1f9dd53b4d
commit ac5a4589ea
4 changed files with 42 additions and 0 deletions

View File

@@ -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));
}
}
}