Skip to content

Commit

Permalink
Fix random placement of AssociateWithAirfieldActivity
Browse files Browse the repository at this point in the history
It doesn't belong to IMove, so it doesn't belong into that region.
Put it near ICreationActivity where it belongs.
  • Loading branch information
reaperrr authored and abcdefg30 committed Feb 6, 2022
1 parent 257ef95 commit 44fc4a1
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions OpenRA.Mods.Common/Traits/Air/Aircraft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -921,43 +921,6 @@ public Activity MoveFollow(Actor self, in Target target, WDist minRange, WDist m

public Activity ReturnToCell(Actor self) { return null; }

class AssociateWithAirfieldActivity : Activity
{
readonly Actor self;
readonly Aircraft aircraft;
readonly int delay;

public AssociateWithAirfieldActivity(Actor self, int delay = 0)
{
this.self = self;
aircraft = self.Trait<Aircraft>();
IsInterruptible = false;
this.delay = delay;
}

protected override void OnFirstRun(Actor self)
{
var host = aircraft.GetActorBelow();
if (host != null)
aircraft.MakeReservation(host);

if (delay > 0)
QueueChild(new Wait(delay));
}

public override bool Tick(Actor self)
{
if (!aircraft.Info.TakeOffOnCreation)
return true;

if (self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition).Length <= aircraft.LandAltitude.Length)
QueueChild(new TakeOff(self));

aircraft.UnReserve();
return true;
}
}

public Activity MoveToTarget(Actor self, in Target target,
WPos? initialTargetPosition = null, Color? targetLineColor = null)
{
Expand Down Expand Up @@ -1259,6 +1222,43 @@ Activity ICreationActivity.GetCreationActivity()
return new AssociateWithAirfieldActivity(self, creationActivityDelay);
}

class AssociateWithAirfieldActivity : Activity
{
readonly Actor self;
readonly Aircraft aircraft;
readonly int delay;

public AssociateWithAirfieldActivity(Actor self, int delay = 0)
{
this.self = self;
aircraft = self.Trait<Aircraft>();
IsInterruptible = false;
this.delay = delay;
}

protected override void OnFirstRun(Actor self)
{
var host = aircraft.GetActorBelow();
if (host != null)
aircraft.MakeReservation(host);

if (delay > 0)
QueueChild(new Wait(delay));
}

public override bool Tick(Actor self)
{
if (!aircraft.Info.TakeOffOnCreation)
return true;

if (self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition).Length <= aircraft.LandAltitude.Length)
QueueChild(new TakeOff(self));

aircraft.UnReserve();
return true;
}
}

public class AircraftMoveOrderTargeter : IOrderTargeter
{
readonly Aircraft aircraft;
Expand Down

0 comments on commit 44fc4a1

Please sign in to comment.