add IHasLocation
This commit is contained in:
@@ -16,11 +16,11 @@ namespace OpenRA.Traits.Activities
|
||||
{
|
||||
IActivity NextActivity { get; set; }
|
||||
|
||||
float2 endLocation;
|
||||
float2 startLocation;
|
||||
int2 endLocation;
|
||||
int2 startLocation;
|
||||
int length;
|
||||
|
||||
public Drag(float2 start, float2 end, int length)
|
||||
public Drag(int2 start, int2 end, int length)
|
||||
{
|
||||
startLocation = start;
|
||||
endLocation = end;
|
||||
@@ -29,15 +29,16 @@ namespace OpenRA.Traits.Activities
|
||||
|
||||
int ticks = 0;
|
||||
public IActivity Tick( Actor self )
|
||||
{
|
||||
self.CenterLocation = float2.Lerp(startLocation, endLocation, (float)ticks/(length-1));
|
||||
{
|
||||
var mobile = self.Trait<Mobile>();
|
||||
mobile.PxPosition = int2.Lerp(startLocation, endLocation, ticks, length - 1);
|
||||
|
||||
if (++ticks >= length)
|
||||
{
|
||||
self.Trait<Mobile>().IsMoving = false;
|
||||
mobile.IsMoving = false;
|
||||
return NextActivity;
|
||||
}
|
||||
self.Trait<Mobile>().IsMoving = true;
|
||||
mobile.IsMoving = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user