Convert Drag to world coords.

This commit is contained in:
Paul Chote
2013-07-06 19:55:16 +12:00
parent 7f25573cfa
commit 0fdffd7b6a
8 changed files with 40 additions and 28 deletions

View File

@@ -15,25 +15,25 @@ namespace OpenRA.Mods.RA.Move
{
public class Drag : Activity
{
PPos endLocation;
PPos startLocation;
WPos start, end;
int length;
int ticks = 0;
public Drag(PPos start, PPos end, int length)
public Drag(WPos start, WPos end, int length)
{
startLocation = start;
endLocation = end;
this.start = start;
this.end = end;
this.length = length;
}
public override Activity Tick( Actor self )
{
var mobile = self.Trait<Mobile>();
mobile.PxPosition = length > 1
? PPos.Lerp(startLocation, endLocation, ticks, length - 1)
: endLocation;
var pos = length > 1
? WPos.Lerp(start, end, ticks, length - 1)
: end;
mobile.PxPosition = PPos.FromWPos(pos);
if (++ticks >= length)
{
mobile.IsMoving = false;
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Move
public override IEnumerable<Target> GetTargets( Actor self )
{
yield return Target.FromPos(endLocation);
yield return Target.FromPos(PPos.FromWPos(end));
}
// Cannot be cancelled