Fix a dumb crash & avoid a trait lookup in DragHusk
This commit is contained in:
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
var to = Util.CenterOfCell(location);
|
var to = Util.CenterOfCell(location);
|
||||||
var length = (int)((to - PxPosition).Length * 3 / speed);
|
var length = (int)((to - PxPosition).Length * 3 / speed);
|
||||||
self.QueueActivity(new DragHusk(PxPosition, to, length));
|
self.QueueActivity(new DragHusk(PxPosition, to, length, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,26 +56,29 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
class DragHusk : Activity
|
class DragHusk : Activity
|
||||||
{
|
{
|
||||||
|
Husk husk;
|
||||||
int2 endLocation;
|
int2 endLocation;
|
||||||
int2 startLocation;
|
int2 startLocation;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
public DragHusk(int2 start, int2 end, int length)
|
public DragHusk(int2 start, int2 end, int length, Husk husk)
|
||||||
{
|
{
|
||||||
startLocation = start;
|
startLocation = start;
|
||||||
endLocation = end;
|
endLocation = end;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
|
this.husk = husk;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ticks = 0;
|
int ticks = 0;
|
||||||
public override Activity Tick( Actor self )
|
public override Activity Tick( Actor self )
|
||||||
{
|
{
|
||||||
var husk = self.Trait<Husk>();
|
if (ticks >= length || length <= 1)
|
||||||
husk.PxPosition = int2.Lerp(startLocation, endLocation, ticks, length - 1);
|
{
|
||||||
|
husk.PxPosition = endLocation;
|
||||||
if (++ticks >= length)
|
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
}
|
||||||
|
|
||||||
|
husk.PxPosition = int2.Lerp(startLocation, endLocation, ticks++, length - 1);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user