@@ -18,13 +18,8 @@ namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
public readonly float2 Pos;
|
||||
|
||||
private Fly( float2 pos )
|
||||
{
|
||||
this.Pos = pos;
|
||||
}
|
||||
|
||||
public static Fly ToPx( float2 px ) { return new Fly( px ); }
|
||||
public static Fly ToCell( int2 pos ) { return new Fly( Util.CenterOfCell( pos ) ); }
|
||||
public Fly(float2 pos) { Pos = pos; }
|
||||
public Fly(int2 pos) { Pos = Util.CenterOfCell(pos); }
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
{
|
||||
@@ -62,7 +57,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
var aircraft = self.Trait<Aircraft>();
|
||||
var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
|
||||
var angle = aircraft.Facing / 128f * Math.PI;
|
||||
aircraft.center += speed * -float2.FromAngle((float)angle);
|
||||
self.CenterLocation += speed * -float2.FromAngle((float)angle);
|
||||
aircraft.Location = Util.CellContaining(self.CenterLocation);
|
||||
aircraft.Altitude += Math.Sign(desiredAltitude - aircraft.Altitude);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
return NextActivity;
|
||||
|
||||
return Util.SequenceActivities(
|
||||
Fly.ToPx(Target.CenterLocation),
|
||||
new Fly(Target.CenterLocation),
|
||||
new FlyTimed(50),
|
||||
this);
|
||||
}
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
if( IsCanceled ) return NextActivity;
|
||||
|
||||
return Util.SequenceActivities(
|
||||
Fly.ToPx(Util.CenterOfCell(Target)),
|
||||
new Fly(Util.CenterOfCell(Target)),
|
||||
new FlyTimed(50),
|
||||
this);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
var rawSpeed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
|
||||
|
||||
if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize))
|
||||
aircraft.center += (rawSpeed / dist.Length) * dist;
|
||||
self.CenterLocation += (rawSpeed / dist.Length) * dist;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
var dist = Dest - self.CenterLocation;
|
||||
if (float2.WithinEpsilon(float2.Zero, dist, 2))
|
||||
{
|
||||
aircraft.center = Dest;
|
||||
self.CenterLocation = Dest;
|
||||
aircraft.Location = Util.CellContaining(self.CenterLocation);
|
||||
return NextActivity;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
aircraft.ROT);
|
||||
|
||||
var rawSpeed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
|
||||
aircraft.center += (rawSpeed / dist.Length) * dist;
|
||||
self.CenterLocation += (rawSpeed / dist.Length) * dist;
|
||||
aircraft.Location = Util.CellContaining(self.CenterLocation);
|
||||
|
||||
return this;
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
|
||||
var angle = aircraft.Facing / 128f * Math.PI;
|
||||
|
||||
aircraft.center += speed * -float2.FromAngle((float)angle);
|
||||
self.CenterLocation += speed * -float2.FromAngle((float)angle);
|
||||
aircraft.Location = Util.CellContaining(self.CenterLocation);
|
||||
|
||||
return this;
|
||||
|
||||
@@ -17,15 +17,15 @@ namespace OpenRA.Mods.RA.Activities
|
||||
class Leap : CancelableActivity
|
||||
{
|
||||
Target target;
|
||||
int2 initialLocation;
|
||||
float2 initialLocation;
|
||||
float t;
|
||||
|
||||
const int delay = 6;
|
||||
int moveFraction;
|
||||
|
||||
public Leap(Actor self, Target target)
|
||||
{
|
||||
this.target = target;
|
||||
initialLocation = self.Trait<Mobile>().PxPosition;
|
||||
initialLocation = self.CenterLocation;
|
||||
|
||||
self.Trait<RenderInfantry>().Attacking(self);
|
||||
Sound.Play("dogg5p.aud", self.CenterLocation);
|
||||
@@ -33,16 +33,16 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
public override IActivity Tick(Actor self)
|
||||
{
|
||||
if( moveFraction == 0 && IsCanceled ) return NextActivity;
|
||||
if( t == 0 && IsCanceled ) return NextActivity;
|
||||
if (!target.IsValid) return NextActivity;
|
||||
|
||||
self.Trait<AttackLeap>().IsLeaping = true;
|
||||
var mobile = self.Trait<Mobile>();
|
||||
++moveFraction;
|
||||
|
||||
mobile.PxPosition = int2.Lerp(initialLocation, target.PxPosition, moveFraction, delay);
|
||||
t += (1f / delay);
|
||||
|
||||
if (moveFraction >= delay)
|
||||
self.CenterLocation = float2.Lerp(initialLocation, target.CenterLocation, t);
|
||||
|
||||
if (t >= 1f)
|
||||
{
|
||||
self.TraitsImplementing<IMove>().FirstOrDefault()
|
||||
.SetPosition(self, Util.CellContaining(target.CenterLocation));
|
||||
|
||||
@@ -92,9 +92,9 @@ namespace OpenRA.Mods.RA.Activities
|
||||
Calculate(self);
|
||||
|
||||
return Util.SequenceActivities(
|
||||
Fly.ToPx(w1),
|
||||
Fly.ToPx(w2),
|
||||
Fly.ToPx(w3),
|
||||
new Fly(w1),
|
||||
new Fly(w2),
|
||||
new Fly(w3),
|
||||
new Land(Target.FromActor(dest)),
|
||||
NextActivity);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user