Remove RepairBuildings from Aircraft
Require them to use Repairable trait instead.
This commit is contained in:
@@ -19,6 +19,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
public class HeliReturnToBase : Activity
|
public class HeliReturnToBase : Activity
|
||||||
{
|
{
|
||||||
readonly Aircraft aircraft;
|
readonly Aircraft aircraft;
|
||||||
|
readonly RepairableInfo repairableInfo;
|
||||||
readonly bool alwaysLand;
|
readonly bool alwaysLand;
|
||||||
readonly bool abortOnResupply;
|
readonly bool abortOnResupply;
|
||||||
Actor dest;
|
Actor dest;
|
||||||
@@ -26,6 +27,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
public HeliReturnToBase(Actor self, bool abortOnResupply, Actor dest = null, bool alwaysLand = true)
|
public HeliReturnToBase(Actor self, bool abortOnResupply, Actor dest = null, bool alwaysLand = true)
|
||||||
{
|
{
|
||||||
aircraft = self.Trait<Aircraft>();
|
aircraft = self.Trait<Aircraft>();
|
||||||
|
repairableInfo = self.Info.TraitInfoOrDefault<RepairableInfo>();
|
||||||
this.alwaysLand = alwaysLand;
|
this.alwaysLand = alwaysLand;
|
||||||
this.abortOnResupply = abortOnResupply;
|
this.abortOnResupply = abortOnResupply;
|
||||||
this.dest = dest;
|
this.dest = dest;
|
||||||
@@ -114,7 +116,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (alwaysLand)
|
if (alwaysLand)
|
||||||
return true;
|
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 true;
|
||||||
|
|
||||||
return aircraft.Info.RearmBuildings.Contains(dest.Info.Name) && self.TraitsImplementing<AmmoPool>()
|
return aircraft.Info.RearmBuildings.Contains(dest.Info.Name) && self.TraitsImplementing<AmmoPool>()
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
readonly Aircraft aircraft;
|
readonly Aircraft aircraft;
|
||||||
readonly AircraftInfo aircraftInfo;
|
readonly AircraftInfo aircraftInfo;
|
||||||
|
readonly RepairableInfo repairableInfo;
|
||||||
readonly bool alwaysLand;
|
readonly bool alwaysLand;
|
||||||
readonly bool abortOnResupply;
|
readonly bool abortOnResupply;
|
||||||
bool isCalculated;
|
bool isCalculated;
|
||||||
@@ -35,6 +36,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
this.abortOnResupply = abortOnResupply;
|
this.abortOnResupply = abortOnResupply;
|
||||||
aircraft = self.Trait<Aircraft>();
|
aircraft = self.Trait<Aircraft>();
|
||||||
aircraftInfo = self.Info.TraitInfo<AircraftInfo>();
|
aircraftInfo = self.Info.TraitInfo<AircraftInfo>();
|
||||||
|
repairableInfo = self.Info.TraitInfoOrDefault<RepairableInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Actor ChooseResupplier(Actor self, bool unreservedOnly)
|
public static Actor ChooseResupplier(Actor self, bool unreservedOnly)
|
||||||
@@ -104,7 +106,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (alwaysLand)
|
if (alwaysLand)
|
||||||
return true;
|
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 true;
|
||||||
|
|
||||||
return aircraftInfo.RearmBuildings.Contains(dest.Info.Name) && self.TraitsImplementing<AmmoPool>()
|
return aircraftInfo.RearmBuildings.Contains(dest.Info.Name) && self.TraitsImplementing<AmmoPool>()
|
||||||
|
|||||||
@@ -929,6 +929,7 @@
|
|||||||
<Compile Include="UpdateRules\Rules\20180923\MergeRearmAndRepairAnimation.cs" />
|
<Compile Include="UpdateRules\Rules\20180923\MergeRearmAndRepairAnimation.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\20180923\LowPowerSlowdownToModifier.cs" />
|
<Compile Include="UpdateRules\Rules\20180923\LowPowerSlowdownToModifier.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\20180923\RemoveHealthPercentageRing.cs" />
|
<Compile Include="UpdateRules\Rules\20180923\RemoveHealthPercentageRing.cs" />
|
||||||
|
<Compile Include="UpdateRules\Rules\20180923\RemoveRepairBuildingsFromAircraft.cs" />
|
||||||
<Compile Include="Traits\Player\PlayerResources.cs" />
|
<Compile Include="Traits\Player\PlayerResources.cs" />
|
||||||
<Compile Include="UtilityCommands\DumpSequenceSheetsCommand.cs" />
|
<Compile Include="UtilityCommands\DumpSequenceSheetsCommand.cs" />
|
||||||
<Compile Include="Traits\Render\WithBuildingRepairDecoration.cs" />
|
<Compile Include="Traits\Render\WithBuildingRepairDecoration.cs" />
|
||||||
|
|||||||
@@ -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.")]
|
[Desc("The speed at which the aircraft is repulsed from other aircraft. Specify -1 for normal movement speed.")]
|
||||||
public readonly int RepulsionSpeed = -1;
|
public readonly int RepulsionSpeed = -1;
|
||||||
|
|
||||||
[ActorReference]
|
|
||||||
public readonly HashSet<string> RepairBuildings = new HashSet<string> { };
|
|
||||||
|
|
||||||
[ActorReference]
|
[ActorReference]
|
||||||
public readonly HashSet<string> RearmBuildings = new HashSet<string> { };
|
public readonly HashSet<string> RearmBuildings = new HashSet<string> { };
|
||||||
|
|
||||||
@@ -157,6 +154,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly AircraftInfo Info;
|
public readonly AircraftInfo Info;
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
|
|
||||||
|
RepairableInfo repairableInfo;
|
||||||
ConditionManager conditionManager;
|
ConditionManager conditionManager;
|
||||||
IDisposable reservation;
|
IDisposable reservation;
|
||||||
IEnumerable<int> speedModifiers;
|
IEnumerable<int> speedModifiers;
|
||||||
@@ -212,6 +210,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected virtual void Created(Actor self)
|
protected virtual void Created(Actor self)
|
||||||
{
|
{
|
||||||
|
repairableInfo = self.Info.TraitInfoOrDefault<RepairableInfo>();
|
||||||
conditionManager = self.TraitOrDefault<ConditionManager>();
|
conditionManager = self.TraitOrDefault<ConditionManager>();
|
||||||
speedModifiers = self.TraitsImplementing<ISpeedModifier>().ToArray().Select(sm => sm.GetSpeedModifier());
|
speedModifiers = self.TraitsImplementing<ISpeedModifier>().ToArray().Select(sm => sm.GetSpeedModifier());
|
||||||
cachedPosition = self.CenterPosition;
|
cachedPosition = self.CenterPosition;
|
||||||
@@ -452,7 +451,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
return Info.RearmBuildings.Contains(a.Info.Name)
|
return Info.RearmBuildings.Contains(a.Info.Name)
|
||||||
|| Info.RepairBuildings.Contains(a.Info.Name);
|
|| (repairableInfo != null && repairableInfo.RepairBuildings.Contains(a.Info.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int MovementSpeed
|
public int MovementSpeed
|
||||||
@@ -492,7 +491,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
yield return new Rearm(self, a, WDist.Zero);
|
yield return new Rearm(self, a, WDist.Zero);
|
||||||
|
|
||||||
// The ResupplyAircraft activity guarantees that we're on the helipad
|
// 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);
|
yield return new Repair(self, a, WDist.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -99,6 +99,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
|||||||
new ChangeTakeOffSoundAndLandingSound(),
|
new ChangeTakeOffSoundAndLandingSound(),
|
||||||
new RemoveHealthPercentageRing(),
|
new RemoveHealthPercentageRing(),
|
||||||
new RenameCrateActionNotification(),
|
new RenameCrateActionNotification(),
|
||||||
|
new RemoveRepairBuildingsFromAircraft(),
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -306,8 +306,9 @@
|
|||||||
WithSpriteControlGroupDecoration:
|
WithSpriteControlGroupDecoration:
|
||||||
Selectable:
|
Selectable:
|
||||||
Bounds: 24,24
|
Bounds: 24,24
|
||||||
Aircraft:
|
Repairable:
|
||||||
RepairBuildings: hpad
|
RepairBuildings: hpad
|
||||||
|
Aircraft:
|
||||||
LandWhenIdle: false
|
LandWhenIdle: false
|
||||||
AirborneCondition: airborne
|
AirborneCondition: airborne
|
||||||
CruisingCondition: cruising
|
CruisingCondition: cruising
|
||||||
|
|||||||
@@ -526,7 +526,6 @@
|
|||||||
Selectable:
|
Selectable:
|
||||||
Bounds: 24,24
|
Bounds: 24,24
|
||||||
Aircraft:
|
Aircraft:
|
||||||
RepairBuildings: fix
|
|
||||||
AirborneCondition: airborne
|
AirborneCondition: airborne
|
||||||
Targetable@GROUND:
|
Targetable@GROUND:
|
||||||
TargetTypes: Ground, Repair, Vehicle
|
TargetTypes: Ground, Repair, Vehicle
|
||||||
@@ -573,6 +572,8 @@
|
|||||||
^Plane:
|
^Plane:
|
||||||
Inherits: ^NeutralPlane
|
Inherits: ^NeutralPlane
|
||||||
Inherits@2: ^GainsExperience
|
Inherits@2: ^GainsExperience
|
||||||
|
Repairable:
|
||||||
|
RepairBuildings: fix
|
||||||
|
|
||||||
^Helicopter:
|
^Helicopter:
|
||||||
Inherits: ^Plane
|
Inherits: ^Plane
|
||||||
|
|||||||
@@ -821,9 +821,11 @@
|
|||||||
WithTextControlGroupDecoration:
|
WithTextControlGroupDecoration:
|
||||||
SelectionDecorations:
|
SelectionDecorations:
|
||||||
Palette: pips
|
Palette: pips
|
||||||
|
Repairable:
|
||||||
|
RepairBuildings: gadept
|
||||||
|
Voice: Move
|
||||||
Aircraft:
|
Aircraft:
|
||||||
AirborneCondition: airborne
|
AirborneCondition: airborne
|
||||||
RepairBuildings: gadept
|
|
||||||
LandWhenIdle: false
|
LandWhenIdle: false
|
||||||
Voice: Move
|
Voice: Move
|
||||||
IdealSeparation: 853
|
IdealSeparation: 853
|
||||||
|
|||||||
Reference in New Issue
Block a user