Remove ResupplyAircraft and AllowYieldingReservation

The few extra things those two activities did can be done
in Resupply, making them redundant.
This commit is contained in:
reaperrr
2019-04-22 20:12:21 +02:00
committed by Paul Chote
parent 4a06c66dbd
commit bc0d8ca015
9 changed files with 22 additions and 94 deletions

View File

@@ -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<Aircraft>();
}
public override Activity Tick(Actor self)
{
aircraft.AllowYieldingReservation();
return NextActivity;
}
}
}

View File

@@ -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<Aircraft>();
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;
}
}
}

View File

@@ -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;
}

View File

@@ -95,7 +95,17 @@ namespace OpenRA.Mods.Common.Activities
notifyResupply.ResupplyTick(host.Actor, self, activeResupplyTypes);
if (activeResupplyTypes == 0)
{
var aircraft = self.TraitOrDefault<Aircraft>();
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;
}

View File

@@ -63,7 +63,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="Activities\Air\AllowYieldingReservation.cs" />
<Compile Include="Activities\Air\FallToEarth.cs" />
<Compile Include="Activities\Air\Fly.cs" />
<Compile Include="Activities\Air\FlyAttack.cs" />
@@ -76,7 +75,6 @@
<Compile Include="Activities\Air\HeliFlyCircle.cs" />
<Compile Include="Activities\Air\HeliLand.cs" />
<Compile Include="Activities\Air\Land.cs" />
<Compile Include="Activities\Air\ResupplyAircraft.cs" />
<Compile Include="Activities\Air\ReturnToBase.cs" />
<Compile Include="Activities\Air\TakeOff.cs" />
<Compile Include="Activities\Attack.cs" />

View File

@@ -19,19 +19,19 @@ namespace OpenRA.Mods.Common.Scripting
[ScriptPropertyGroup("Movement")]
public class AircraftProperties : ScriptActorProperties, Requires<AircraftInfo>
{
readonly AircraftInfo aircraftInfo;
readonly Aircraft aircraft;
public AircraftProperties(ScriptContext context, Actor self)
: base(context, self)
{
aircraftInfo = self.Info.TraitInfo<AircraftInfo>();
aircraft = self.Trait<Aircraft>();
}
[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));
}
}
}

View File

@@ -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;
}
}

View File

@@ -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.

View File

@@ -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;