Simplify Fly interface.
This commit is contained in:
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
new FacingInit(64)
|
new FacingInit(64)
|
||||||
});
|
});
|
||||||
|
|
||||||
a.QueueActivity(Fly.ToCell(self.Location + new CVec(9, 0)));
|
a.QueueActivity(new Fly(a, Target.FromCell(self.Location + new CVec(9, 0))));
|
||||||
a.QueueActivity(new Land(Target.FromActor(self)));
|
a.QueueActivity(new Land(Target.FromActor(self)));
|
||||||
a.QueueActivity(new CallFunc(() =>
|
a.QueueActivity(new CallFunc(() =>
|
||||||
{
|
{
|
||||||
@@ -71,7 +71,8 @@ namespace OpenRA.Mods.Cnc
|
|||||||
self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit));
|
self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit));
|
||||||
Sound.PlayNotification(self.Owner, "Speech", (Info as ProductionAirdropInfo).ReadyAudio, self.Owner.Country.Race);
|
Sound.PlayNotification(self.Owner, "Speech", (Info as ProductionAirdropInfo).ReadyAudio, self.Owner.Country.Race);
|
||||||
}));
|
}));
|
||||||
a.QueueActivity(Fly.ToCell(endPos));
|
|
||||||
|
a.QueueActivity(new Fly(a, Target.FromCell(endPos)));
|
||||||
a.QueueActivity(new RemoveSelf());
|
a.QueueActivity(new RemoveSelf());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,13 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
public class Fly : Activity
|
public class Fly : Activity
|
||||||
{
|
{
|
||||||
readonly WPos pos;
|
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)
|
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);
|
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)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (IsCanceled)
|
if (IsCanceled)
|
||||||
@@ -49,7 +51,6 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
if (d.HorizontalLengthSquared < 91022)
|
if (d.HorizontalLengthSquared < 91022)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
var plane = self.Trait<Plane>();
|
|
||||||
var desiredFacing = Util.GetFacing(d, plane.Facing);
|
var desiredFacing = Util.GetFacing(d, plane.Facing);
|
||||||
|
|
||||||
// Don't turn until we've reached the cruise altitude
|
// Don't turn until we've reached the cruise altitude
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
if (IsCanceled)
|
if (IsCanceled)
|
||||||
return NextActivity;
|
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);
|
inner = Util.RunActivity(self, inner);
|
||||||
|
|||||||
@@ -24,10 +24,12 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
{
|
{
|
||||||
public readonly PlaneInfo Info;
|
public readonly PlaneInfo Info;
|
||||||
[Sync] public WPos RTBPathHash;
|
[Sync] public WPos RTBPathHash;
|
||||||
|
Actor self;
|
||||||
|
|
||||||
public Plane(ActorInitializer init, PlaneInfo info)
|
public Plane(ActorInitializer init, PlaneInfo info)
|
||||||
: base(init, info)
|
: base(init, info)
|
||||||
{
|
{
|
||||||
|
self = init.self;
|
||||||
Info = info;
|
Info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,10 +50,11 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
{
|
{
|
||||||
UnReserve();
|
UnReserve();
|
||||||
|
|
||||||
var target = self.World.ClampToWorld(order.TargetLocation);
|
var cell = self.World.ClampToWorld(order.TargetLocation);
|
||||||
self.SetTargetLine(Target.FromCell(target), Color.Green);
|
var t = Target.FromCell(cell);
|
||||||
|
self.SetTargetLine(t, Color.Green);
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(Fly.ToCell(target));
|
self.QueueActivity(new Fly(self, t));
|
||||||
self.QueueActivity(new FlyCircle());
|
self.QueueActivity(new FlyCircle());
|
||||||
}
|
}
|
||||||
else if (order.OrderString == "Enter")
|
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, int nearEnough) { return new Fly(self, Target.FromCell(cell)); }
|
||||||
public Activity MoveTo(CPos cell, Actor ignoredActor) { return Fly.ToCell(cell); }
|
public Activity MoveTo(CPos cell, Actor ignoredActor) { return new Fly(self, Target.FromCell(cell)); }
|
||||||
public Activity MoveWithinRange(Target target, WRange range) { return Fly.ToPos(target.CenterPosition); }
|
public Activity MoveWithinRange(Target target, WRange range) { return new Fly(self, target); }
|
||||||
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.QueueActivity(Fly.ToCell(someBuilding.Location));
|
self.QueueActivity(new Fly(self, Target.FromActor(someBuilding)));
|
||||||
self.QueueActivity(new FlyCircle());
|
self.QueueActivity(new FlyCircle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,15 +110,15 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
|
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
if (nearestAfld != null)
|
if (nearestAfld != null)
|
||||||
return Util.SequenceActivities(Fly.ToCell(nearestAfld.Location), new FlyCircle());
|
return Util.SequenceActivities(new Fly(self, Target.FromActor(nearestAfld)), new FlyCircle());
|
||||||
else
|
else
|
||||||
return new FlyCircle();
|
return new FlyCircle();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Util.SequenceActivities(
|
return Util.SequenceActivities(
|
||||||
Fly.ToPos(w1),
|
new Fly(self, Target.FromPos(w1)),
|
||||||
Fly.ToPos(w2),
|
new Fly(self, Target.FromPos(w2)),
|
||||||
Fly.ToPos(w3),
|
new Fly(self, Target.FromPos(w3)),
|
||||||
new Land(Target.FromActor(dest)),
|
new Land(Target.FromActor(dest)),
|
||||||
NextActivity);
|
NextActivity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
new FacingInit(Traits.Util.GetFacing(waypoints[1] - waypoints[0], 0))
|
new FacingInit(Traits.Util.GetFacing(waypoints[1] - waypoints[0], 0))
|
||||||
});
|
});
|
||||||
foreach (var waypoint in waypoints)
|
foreach (var waypoint in waypoints)
|
||||||
m.QueueActivity(Fly.ToCell(waypoint));
|
m.QueueActivity(new Fly(m, Target.FromCell(waypoint)));
|
||||||
m.QueueActivity(new RemoveSelf());
|
m.QueueActivity(new RemoveSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.RA.Missions
|
|||||||
});
|
});
|
||||||
|
|
||||||
badger.Trait<AttackBomber>().SetTarget(location.CenterPosition);
|
badger.Trait<AttackBomber>().SetTarget(location.CenterPosition);
|
||||||
badger.QueueActivity(Fly.ToCell(location));
|
badger.QueueActivity(new Fly(badger, Target.FromCell(location)));
|
||||||
badger.QueueActivity(new FlyOffMap());
|
badger.QueueActivity(new FlyOffMap());
|
||||||
badger.QueueActivity(new RemoveSelf());
|
badger.QueueActivity(new RemoveSelf());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ namespace OpenRA.Mods.RA.Scripting
|
|||||||
[LuaGlobal]
|
[LuaGlobal]
|
||||||
public void FlyToPos(Actor actor, WPos pos)
|
public void FlyToPos(Actor actor, WPos pos)
|
||||||
{
|
{
|
||||||
actor.QueueActivity(Fly.ToPos(pos));
|
actor.QueueActivity(new Fly(actor, Target.FromPos(pos)));
|
||||||
}
|
}
|
||||||
|
|
||||||
[LuaGlobal]
|
[LuaGlobal]
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (flare != null)
|
if (flare != null)
|
||||||
a.QueueActivity(new CallFunc(() => flare.Destroy()));
|
a.QueueActivity(new CallFunc(() => flare.Destroy()));
|
||||||
|
|
||||||
a.QueueActivity(Fly.ToPos(finishEdge + spawnOffset));
|
a.QueueActivity(new Fly(a, Target.FromPos(finishEdge + spawnOffset)));
|
||||||
a.QueueActivity(new RemoveSelf());
|
a.QueueActivity(new RemoveSelf());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA
|
|||||||
});
|
});
|
||||||
|
|
||||||
plane.CancelActivity();
|
plane.CancelActivity();
|
||||||
plane.QueueActivity(Fly.ToCell(order.TargetLocation));
|
plane.QueueActivity(new Fly(plane, Target.FromCell(order.TargetLocation)));
|
||||||
plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w =>
|
plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w =>
|
||||||
{
|
{
|
||||||
var camera = w.CreateActor("camera", new TypeDictionary
|
var camera = w.CreateActor("camera", new TypeDictionary
|
||||||
|
|||||||
Reference in New Issue
Block a user