diff --git a/OpenRA.Mods.Common/Activities/Air/AllowYieldingReservation.cs b/OpenRA.Mods.Common/Activities/Air/AllowYieldingReservation.cs deleted file mode 100644 index ff57f1424b..0000000000 --- a/OpenRA.Mods.Common/Activities/Air/AllowYieldingReservation.cs +++ /dev/null @@ -1,32 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2019 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, either version 3 of - * the License, or (at your option) any later version. For more - * information, see COPYING. - */ -#endregion - -using OpenRA.Activities; -using OpenRA.Mods.Common.Traits; - -namespace OpenRA.Mods.Common.Activities -{ - public class AllowYieldingReservation : Activity - { - readonly Aircraft aircraft; - - public AllowYieldingReservation(Actor self) - { - aircraft = self.Trait(); - } - - public override Activity Tick(Actor self) - { - aircraft.AllowYieldingReservation(); - return NextActivity; - } - } -} diff --git a/OpenRA.Mods.Common/Activities/Air/ResupplyAircraft.cs b/OpenRA.Mods.Common/Activities/Air/ResupplyAircraft.cs deleted file mode 100644 index 66bf81eaf4..0000000000 --- a/OpenRA.Mods.Common/Activities/Air/ResupplyAircraft.cs +++ /dev/null @@ -1,48 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2019 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, either version 3 of - * the License, or (at your option) any later version. For more - * information, see COPYING. - */ -#endregion - -using System.Linq; -using OpenRA.Activities; -using OpenRA.Mods.Common.Traits; -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Activities -{ - public class ResupplyAircraft : Activity - { - public ResupplyAircraft(Actor self) { } - - protected override void OnFirstRun(Actor self) - { - var aircraft = self.Trait(); - var host = aircraft.GetActorBelow(); - - if (host == null) - return; - - QueueChild(self, new Resupply(self, host, WDist.Zero)); - QueueChild(self, new AllowYieldingReservation(self)); - if (aircraft.Info.TakeOffOnResupply) - QueueChild(self, new TakeOff(self, (a, b, c) => NextActivity == null && b.NextActivity == null)); - } - - public override Activity Tick(Actor self) - { - if (ChildActivity != null) - { - ChildActivity = ActivityUtils.RunActivity(self, ChildActivity); - return this; - } - - return NextActivity; - } - } -} diff --git a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs index d8748c626f..820c1431ff 100644 --- a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs +++ b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs @@ -235,7 +235,7 @@ namespace OpenRA.Mods.Common.Activities else QueueChild(self, new Land(self, Target.FromPos(dest.CenterPosition + offset), true, dest), true); - QueueChild(self, new ResupplyAircraft(self), true); + QueueChild(self, new Resupply(self, dest, WDist.Zero), true); resupplied = true; } diff --git a/OpenRA.Mods.Common/Activities/Resupply.cs b/OpenRA.Mods.Common/Activities/Resupply.cs index 0c66569885..0fb5500124 100644 --- a/OpenRA.Mods.Common/Activities/Resupply.cs +++ b/OpenRA.Mods.Common/Activities/Resupply.cs @@ -95,7 +95,17 @@ namespace OpenRA.Mods.Common.Activities notifyResupply.ResupplyTick(host.Actor, self, activeResupplyTypes); if (activeResupplyTypes == 0) + { + var aircraft = self.TraitOrDefault(); + if (aircraft != null) + { + aircraft.AllowYieldingReservation(); + if (aircraft.Info.TakeOffOnResupply) + Queue(self, new TakeOff(self, (a, b, c) => NextActivity == null && b.NextActivity == null)); + } + return NextActivity; + } return this; } diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 24f8c30dfa..9bd3fe4434 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -63,7 +63,6 @@ - @@ -76,7 +75,6 @@ - diff --git a/OpenRA.Mods.Common/Scripting/Properties/AircraftProperties.cs b/OpenRA.Mods.Common/Scripting/Properties/AircraftProperties.cs index 7fe6a44620..7f6a40be40 100644 --- a/OpenRA.Mods.Common/Scripting/Properties/AircraftProperties.cs +++ b/OpenRA.Mods.Common/Scripting/Properties/AircraftProperties.cs @@ -19,19 +19,19 @@ namespace OpenRA.Mods.Common.Scripting [ScriptPropertyGroup("Movement")] public class AircraftProperties : ScriptActorProperties, Requires { - readonly AircraftInfo aircraftInfo; + readonly Aircraft aircraft; public AircraftProperties(ScriptContext context, Actor self) : base(context, self) { - aircraftInfo = self.Info.TraitInfo(); + aircraft = self.Trait(); } [ScriptActorPropertyActivity] [Desc("Fly within the cell grid.")] public void Move(CPos cell) { - if (!aircraftInfo.CanHover) + if (!aircraft.Info.CanHover) Self.QueueActivity(new Fly(Self, Target.FromCell(Self.World, cell))); else Self.QueueActivity(new HeliFly(Self, Target.FromCell(Self.World, cell))); @@ -55,7 +55,10 @@ namespace OpenRA.Mods.Common.Scripting [Desc("Starts the resupplying activity when being on a host building.")] public void Resupply() { - Self.QueueActivity(new ResupplyAircraft(Self)); + var atLandAltitude = Self.World.Map.DistanceAboveTerrain(Self.CenterPosition) == aircraft.Info.LandAltitude; + var host = aircraft.GetActorBelow(); + if (atLandAltitude && host != null) + Self.QueueActivity(new Resupply(Self, host, WDist.Zero)); } } } diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 1b0bf97a3e..e4ea292997 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -595,7 +595,7 @@ namespace OpenRA.Mods.Common.Traits var atLandAltitude = self.World.Map.DistanceAboveTerrain(CenterPosition) == Info.LandAltitude; // Work-around to prevent players from accidentally canceling resupply by pressing 'Stop', - // by re-queueing ResupplyAircraft as long as resupply hasn't finished and aircraft is still on resupplier. + // by re-queueing Resupply as long as resupply hasn't finished and aircraft is still on resupplier. // TODO: Investigate moving this back to ResolveOrder's "Stop" handling, // once conflicts with other traits' "Stop" orders have been fixed. if (atLandAltitude) @@ -603,7 +603,7 @@ namespace OpenRA.Mods.Common.Traits var host = GetActorBelow(); if (host != null && (CanRearmAt(host) || CanRepairAt(host))) { - self.QueueActivity(new ResupplyAircraft(self)); + self.QueueActivity(new Resupply(self, host, WDist.Zero)); return; } } diff --git a/OpenRA.Mods.Common/Traits/Air/ReturnOnIdle.cs b/OpenRA.Mods.Common/Traits/Air/ReturnOnIdle.cs index 3400f95845..ddae658832 100644 --- a/OpenRA.Mods.Common/Traits/Air/ReturnOnIdle.cs +++ b/OpenRA.Mods.Common/Traits/Air/ReturnOnIdle.cs @@ -38,10 +38,7 @@ namespace OpenRA.Mods.Common.Traits var resupplier = ReturnToBase.ChooseResupplier(self, true); if (resupplier != null) - { self.QueueActivity(new ReturnToBase(self, aircraftInfo.AbortOnResupply, resupplier)); - self.QueueActivity(new ResupplyAircraft(self)); - } else { // nowhere to land, pick something friendly and circle over it. diff --git a/OpenRA.Mods.Common/Traits/BotModules/Squads/States/AirStates.cs b/OpenRA.Mods.Common/Traits/BotModules/Squads/States/AirStates.cs index 46424a0a32..4770c49e9c 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/Squads/States/AirStates.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/Squads/States/AirStates.cs @@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads var activity = a.CurrentActivity; var type = activity.GetType(); - if (type == typeof(Resupply) || type == typeof(ResupplyAircraft)) + if (type == typeof(Resupply)) return true; var next = activity.NextActivity; @@ -148,7 +148,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads return false; var nextType = next.GetType(); - if (nextType == typeof(Resupply) || nextType == typeof(ResupplyAircraft)) + if (nextType == typeof(Resupply)) return true; return false;