Simplify Fly interface.
This commit is contained in:
@@ -16,8 +16,13 @@ namespace OpenRA.Mods.RA.Air
|
||||
public class Fly : Activity
|
||||
{
|
||||
readonly WPos pos;
|
||||
readonly Plane plane;
|
||||
|
||||
Fly(WPos pos) { this.pos = pos; }
|
||||
public Fly(Actor self, Target t)
|
||||
{
|
||||
plane = self.Trait<Plane>();
|
||||
pos = t.CenterPosition;
|
||||
}
|
||||
|
||||
public static void FlyToward(Actor self, Plane plane, int desiredFacing, WRange desiredAltitude)
|
||||
{
|
||||
@@ -36,9 +41,6 @@ namespace OpenRA.Mods.RA.Air
|
||||
plane.SetPosition(self, plane.CenterPosition + move);
|
||||
}
|
||||
|
||||
public static Fly ToPos(WPos pos) { return new Fly(pos); }
|
||||
public static Fly ToCell(CPos pos) { return new Fly(pos.CenterPosition); }
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled)
|
||||
@@ -49,7 +51,6 @@ namespace OpenRA.Mods.RA.Air
|
||||
if (d.HorizontalLengthSquared < 91022)
|
||||
return NextActivity;
|
||||
|
||||
var plane = self.Trait<Plane>();
|
||||
var desiredFacing = Util.GetFacing(d, plane.Facing);
|
||||
|
||||
// Don't turn until we've reached the cruise altitude
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
if (IsCanceled)
|
||||
return NextActivity;
|
||||
|
||||
inner = Util.SequenceActivities(Fly.ToPos(target.CenterPosition), new FlyTimed(50));
|
||||
inner = Util.SequenceActivities(new Fly(self, target), new FlyTimed(50));
|
||||
}
|
||||
|
||||
inner = Util.RunActivity(self, inner);
|
||||
|
||||
@@ -24,10 +24,12 @@ namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
public readonly PlaneInfo Info;
|
||||
[Sync] public WPos RTBPathHash;
|
||||
Actor self;
|
||||
|
||||
public Plane(ActorInitializer init, PlaneInfo info)
|
||||
: base(init, info)
|
||||
{
|
||||
self = init.self;
|
||||
Info = info;
|
||||
}
|
||||
|
||||
@@ -48,10 +50,11 @@ namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
UnReserve();
|
||||
|
||||
var target = self.World.ClampToWorld(order.TargetLocation);
|
||||
self.SetTargetLine(Target.FromCell(target), Color.Green);
|
||||
var cell = self.World.ClampToWorld(order.TargetLocation);
|
||||
var t = Target.FromCell(cell);
|
||||
self.SetTargetLine(t, Color.Green);
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(Fly.ToCell(target));
|
||||
self.QueueActivity(new Fly(self, t));
|
||||
self.QueueActivity(new FlyCircle());
|
||||
}
|
||||
else if (order.OrderString == "Enter")
|
||||
@@ -89,9 +92,9 @@ namespace OpenRA.Mods.RA.Air
|
||||
}
|
||||
}
|
||||
|
||||
public Activity MoveTo(CPos cell, int nearEnough) { return Fly.ToCell(cell); }
|
||||
public Activity MoveTo(CPos cell, Actor ignoredActor) { return Fly.ToCell(cell); }
|
||||
public Activity MoveWithinRange(Target target, WRange range) { return Fly.ToPos(target.CenterPosition); }
|
||||
public Activity MoveTo(CPos cell, int nearEnough) { return new Fly(self, Target.FromCell(cell)); }
|
||||
public Activity MoveTo(CPos cell, Actor ignoredActor) { return new Fly(self, Target.FromCell(cell)); }
|
||||
public Activity MoveWithinRange(Target target, WRange range) { return new Fly(self, target); }
|
||||
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
return;
|
||||
}
|
||||
|
||||
self.QueueActivity(Fly.ToCell(someBuilding.Location));
|
||||
self.QueueActivity(new Fly(self, Target.FromActor(someBuilding)));
|
||||
self.QueueActivity(new FlyCircle());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,15 +110,15 @@ namespace OpenRA.Mods.RA.Air
|
||||
|
||||
self.CancelActivity();
|
||||
if (nearestAfld != null)
|
||||
return Util.SequenceActivities(Fly.ToCell(nearestAfld.Location), new FlyCircle());
|
||||
return Util.SequenceActivities(new Fly(self, Target.FromActor(nearestAfld)), new FlyCircle());
|
||||
else
|
||||
return new FlyCircle();
|
||||
}
|
||||
|
||||
return Util.SequenceActivities(
|
||||
Fly.ToPos(w1),
|
||||
Fly.ToPos(w2),
|
||||
Fly.ToPos(w3),
|
||||
new Fly(self, Target.FromPos(w1)),
|
||||
new Fly(self, Target.FromPos(w2)),
|
||||
new Fly(self, Target.FromPos(w3)),
|
||||
new Land(Target.FromActor(dest)),
|
||||
NextActivity);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user