Add IMove.MoveIntoWorld and IMove.VisualMove.
This commit is contained in:
@@ -161,6 +161,8 @@ namespace OpenRA.Traits
|
|||||||
Activity MoveTo(CPos cell, Actor ignoredActor);
|
Activity MoveTo(CPos cell, Actor ignoredActor);
|
||||||
Activity MoveWithinRange(Target target, WRange range);
|
Activity MoveWithinRange(Target target, WRange range);
|
||||||
Activity MoveFollow(Actor self, 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);
|
CPos NearestMoveableCell(CPos target);
|
||||||
bool IsMoving { get; set; }
|
bool IsMoving { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 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 Activity MoveFollow(Actor self, Target target, WRange range) { return new Follow(self, target, range); }
|
||||||
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
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)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 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 Activity MoveFollow(Actor self, Target target, WRange range) { return new FlyFollow(self, target, range); }
|
||||||
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
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))); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -548,5 +548,31 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
if (self.IsIdle && self.AppearsFriendlyTo(blocking))
|
if (self.IsIdle && self.AppearsFriendlyTo(blocking))
|
||||||
Nudge(self, blocking, true);
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user