Remove RepairBuildings from Aircraft

Require them to use Repairable trait instead.
This commit is contained in:
reaperrr
2017-11-13 23:25:23 +01:00
committed by Paul Chote
parent ed7d12506d
commit 139d5efba8
9 changed files with 69 additions and 10 deletions

View File

@@ -19,6 +19,7 @@ namespace OpenRA.Mods.Common.Activities
public class HeliReturnToBase : Activity
{
readonly Aircraft aircraft;
readonly RepairableInfo repairableInfo;
readonly bool alwaysLand;
readonly bool abortOnResupply;
Actor dest;
@@ -26,6 +27,7 @@ namespace OpenRA.Mods.Common.Activities
public HeliReturnToBase(Actor self, bool abortOnResupply, Actor dest = null, bool alwaysLand = true)
{
aircraft = self.Trait<Aircraft>();
repairableInfo = self.Info.TraitInfoOrDefault<RepairableInfo>();
this.alwaysLand = alwaysLand;
this.abortOnResupply = abortOnResupply;
this.dest = dest;
@@ -114,7 +116,7 @@ namespace OpenRA.Mods.Common.Activities
if (alwaysLand)
return true;
if (aircraft.Info.RepairBuildings.Contains(dest.Info.Name) && self.GetDamageState() != DamageState.Undamaged)
if (repairableInfo != null && repairableInfo.RepairBuildings.Contains(dest.Info.Name) && self.GetDamageState() != DamageState.Undamaged)
return true;
return aircraft.Info.RearmBuildings.Contains(dest.Info.Name) && self.TraitsImplementing<AmmoPool>()

View File

@@ -22,6 +22,7 @@ namespace OpenRA.Mods.Common.Activities
{
readonly Aircraft aircraft;
readonly AircraftInfo aircraftInfo;
readonly RepairableInfo repairableInfo;
readonly bool alwaysLand;
readonly bool abortOnResupply;
bool isCalculated;
@@ -35,6 +36,7 @@ namespace OpenRA.Mods.Common.Activities
this.abortOnResupply = abortOnResupply;
aircraft = self.Trait<Aircraft>();
aircraftInfo = self.Info.TraitInfo<AircraftInfo>();
repairableInfo = self.Info.TraitInfoOrDefault<RepairableInfo>();
}
public static Actor ChooseResupplier(Actor self, bool unreservedOnly)
@@ -104,7 +106,7 @@ namespace OpenRA.Mods.Common.Activities
if (alwaysLand)
return true;
if (aircraftInfo.RepairBuildings.Contains(dest.Info.Name) && self.GetDamageState() != DamageState.Undamaged)
if (repairableInfo != null && repairableInfo.RepairBuildings.Contains(dest.Info.Name) && self.GetDamageState() != DamageState.Undamaged)
return true;
return aircraftInfo.RearmBuildings.Contains(dest.Info.Name) && self.TraitsImplementing<AmmoPool>()

View File

@@ -929,6 +929,7 @@
<Compile Include="UpdateRules\Rules\20180923\MergeRearmAndRepairAnimation.cs" />
<Compile Include="UpdateRules\Rules\20180923\LowPowerSlowdownToModifier.cs" />
<Compile Include="UpdateRules\Rules\20180923\RemoveHealthPercentageRing.cs" />
<Compile Include="UpdateRules\Rules\20180923\RemoveRepairBuildingsFromAircraft.cs" />
<Compile Include="Traits\Player\PlayerResources.cs" />
<Compile Include="UtilityCommands\DumpSequenceSheetsCommand.cs" />
<Compile Include="Traits\Render\WithBuildingRepairDecoration.cs" />

View File

@@ -36,9 +36,6 @@ namespace OpenRA.Mods.Common.Traits
[Desc("The speed at which the aircraft is repulsed from other aircraft. Specify -1 for normal movement speed.")]
public readonly int RepulsionSpeed = -1;
[ActorReference]
public readonly HashSet<string> RepairBuildings = new HashSet<string> { };
[ActorReference]
public readonly HashSet<string> RearmBuildings = new HashSet<string> { };
@@ -157,6 +154,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly AircraftInfo Info;
readonly Actor self;
RepairableInfo repairableInfo;
ConditionManager conditionManager;
IDisposable reservation;
IEnumerable<int> speedModifiers;
@@ -212,6 +210,7 @@ namespace OpenRA.Mods.Common.Traits
protected virtual void Created(Actor self)
{
repairableInfo = self.Info.TraitInfoOrDefault<RepairableInfo>();
conditionManager = self.TraitOrDefault<ConditionManager>();
speedModifiers = self.TraitsImplementing<ISpeedModifier>().ToArray().Select(sm => sm.GetSpeedModifier());
cachedPosition = self.CenterPosition;
@@ -452,7 +451,7 @@ namespace OpenRA.Mods.Common.Traits
return false;
return Info.RearmBuildings.Contains(a.Info.Name)
|| Info.RepairBuildings.Contains(a.Info.Name);
|| (repairableInfo != null && repairableInfo.RepairBuildings.Contains(a.Info.Name));
}
public int MovementSpeed
@@ -492,7 +491,7 @@ namespace OpenRA.Mods.Common.Traits
yield return new Rearm(self, a, WDist.Zero);
// The ResupplyAircraft activity guarantees that we're on the helipad
if (Info.RepairBuildings.Contains(name))
if (repairableInfo != null && repairableInfo.RepairBuildings.Contains(name))
yield return new Repair(self, a, WDist.Zero);
}

View File

@@ -0,0 +1,50 @@
#region Copyright & License Information
/*
* Copyright 2007-2018 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.Collections.Generic;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
public class RemoveRepairBuildingsFromAircraft : UpdateRule
{
public override string Name { get { return "Removed RepairBuildings from Aircraft"; } }
public override string Description
{
get
{
return "Removed RepairBuildings from Aircraft in favor of using Repairable instead.";
}
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
// Aircraft isn't conditional or otherwise supports multiple traits, so LastChildMatching is fine.
var aircraftNode = actorNode.LastChildMatching("Aircraft");
if (aircraftNode != null)
{
var repairBuildings = aircraftNode.LastChildMatching("RepairBuildings");
if (repairBuildings != null)
{
var repariableNode = new MiniYamlNode("Repairable", "");
repairBuildings.MoveAndRenameNode(aircraftNode, repariableNode, "RepairBuildings");
var voice = aircraftNode.LastChildMatching("Voice");
if (voice != null)
repariableNode.AddNode(voice);
actorNode.AddNode(repariableNode);
}
}
yield break;
}
}
}

View File

@@ -99,6 +99,7 @@ namespace OpenRA.Mods.Common.UpdateRules
new ChangeTakeOffSoundAndLandingSound(),
new RemoveHealthPercentageRing(),
new RenameCrateActionNotification(),
new RemoveRepairBuildingsFromAircraft(),
})
};

View File

@@ -306,8 +306,9 @@
WithSpriteControlGroupDecoration:
Selectable:
Bounds: 24,24
Aircraft:
Repairable:
RepairBuildings: hpad
Aircraft:
LandWhenIdle: false
AirborneCondition: airborne
CruisingCondition: cruising

View File

@@ -526,7 +526,6 @@
Selectable:
Bounds: 24,24
Aircraft:
RepairBuildings: fix
AirborneCondition: airborne
Targetable@GROUND:
TargetTypes: Ground, Repair, Vehicle
@@ -573,6 +572,8 @@
^Plane:
Inherits: ^NeutralPlane
Inherits@2: ^GainsExperience
Repairable:
RepairBuildings: fix
^Helicopter:
Inherits: ^Plane

View File

@@ -821,9 +821,11 @@
WithTextControlGroupDecoration:
SelectionDecorations:
Palette: pips
Repairable:
RepairBuildings: gadept
Voice: Move
Aircraft:
AirborneCondition: airborne
RepairBuildings: gadept
LandWhenIdle: false
Voice: Move
IdealSeparation: 853