Adds RallyPoint to Airfield, queues TakeOff
This commit is contained in:
@@ -87,6 +87,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
self.QueueActivity(new Turn(Info.InitialFacing));
|
||||
self.QueueActivity(new HeliLand(false));
|
||||
self.QueueActivity(new ResupplyAircraft());
|
||||
self.QueueActivity(new TakeOff());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,11 +117,11 @@ namespace OpenRA.Mods.RA.Air
|
||||
if (!self.HasTrait<FallsToEarth>()) // TODO: Aircraft husks don't properly unreserve.
|
||||
ReserveSpawnBuilding();
|
||||
|
||||
var afld = GetActorBelow();
|
||||
if (afld == null)
|
||||
var host = GetActorBelow();
|
||||
if (host == null)
|
||||
return;
|
||||
|
||||
self.QueueActivity(TakeOff(afld));
|
||||
self.QueueActivity(new TakeOff());
|
||||
}
|
||||
|
||||
// Repulsion only applies when we're flying!
|
||||
@@ -183,25 +184,5 @@ namespace OpenRA.Mods.RA.Air
|
||||
foreach (var b in base.GetResupplyActivities(a))
|
||||
yield return b;
|
||||
}
|
||||
|
||||
public Activity TakeOff(Actor a)
|
||||
{
|
||||
self.CancelActivity();
|
||||
if (Reservation != null)
|
||||
{
|
||||
Reservation.Dispose();
|
||||
Reservation = null;
|
||||
}
|
||||
|
||||
if (a != null)
|
||||
{
|
||||
if (a.HasTrait<RallyPoint>())
|
||||
return new HeliFly(self, Target.FromCell(a.Trait<RallyPoint>().rallyPoint));
|
||||
|
||||
return new HeliFly(self, Target.FromPos(a.CenterPosition));
|
||||
}
|
||||
|
||||
return new HeliFly(self, Target.FromPos(self.CenterPosition));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,12 @@ namespace OpenRA.Mods.RA.Air
|
||||
firstTick = false;
|
||||
if (!self.HasTrait<FallsToEarth>()) // TODO: Aircraft husks don't properly unreserve.
|
||||
ReserveSpawnBuilding();
|
||||
|
||||
var host = GetActorBelow();
|
||||
if (host == null)
|
||||
return;
|
||||
|
||||
self.QueueActivity(new TakeOff());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +92,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
self.SetTargetLine(Target.FromActor(airfield), Color.Green);
|
||||
self.QueueActivity(new ReturnToBase(self, airfield));
|
||||
self.QueueActivity(new ResupplyAircraft());
|
||||
self.QueueActivity(new TakeOff());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
40
OpenRA.Mods.RA/Air/TakeOff.cs
Normal file
40
OpenRA.Mods.RA/Air/TakeOff.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Air
|
||||
{
|
||||
public class TakeOff : Activity
|
||||
{
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
var aircraft = self.Trait<Aircraft>();
|
||||
|
||||
self.CancelActivity();
|
||||
|
||||
var reservation = aircraft.Reservation;
|
||||
if (reservation != null)
|
||||
{
|
||||
reservation.Dispose();
|
||||
reservation = null;
|
||||
}
|
||||
|
||||
var host = aircraft.GetActorBelow();
|
||||
var hasHost = host != null;
|
||||
var rp = hasHost ? host.TraitOrDefault<RallyPoint>() : null;
|
||||
|
||||
var destination = rp != null ? rp.rallyPoint :
|
||||
(hasHost ? host.CenterPosition.ToCPos() : self.CenterPosition.ToCPos());
|
||||
|
||||
return new AttackMove.AttackMoveActivity(self, self.Trait<IMove>().MoveTo(destination, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user