diff --git a/OpenRA.Mods.Common/Activities/Air/HeliReturnToBase.cs b/OpenRA.Mods.Common/Activities/Air/HeliReturnToBase.cs index 054375f9af..2a21b505f9 100644 --- a/OpenRA.Mods.Common/Activities/Air/HeliReturnToBase.cs +++ b/OpenRA.Mods.Common/Activities/Air/HeliReturnToBase.cs @@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Activities if (alwaysLand) return true; - if (repairableInfo != null && repairableInfo.RepairBuildings.Contains(dest.Info.Name) && self.GetDamageState() != DamageState.Undamaged) + if (repairableInfo != null && repairableInfo.RepairActors.Contains(dest.Info.Name) && self.GetDamageState() != DamageState.Undamaged) return true; return rearmable != null && rearmable.Info.RearmActors.Contains(dest.Info.Name) diff --git a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs index 089c62798a..11dee24742 100644 --- a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs +++ b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs @@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Activities if (alwaysLand) return true; - if (repairableInfo != null && repairableInfo.RepairBuildings.Contains(dest.Info.Name) && self.GetDamageState() != DamageState.Undamaged) + if (repairableInfo != null && repairableInfo.RepairActors.Contains(dest.Info.Name) && self.GetDamageState() != DamageState.Undamaged) return true; return rearmable != null && rearmable.Info.RearmActors.Contains(dest.Info.Name) diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 094d4416b8..5097dab1a7 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -953,6 +953,7 @@ + diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 11cdaba5a1..fdaedc333d 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -472,7 +472,7 @@ namespace OpenRA.Mods.Common.Traits return false; return (rearmableInfo != null && rearmableInfo.RearmActors.Contains(a.Info.Name)) - || (repairableInfo != null && repairableInfo.RepairBuildings.Contains(a.Info.Name)); + || (repairableInfo != null && repairableInfo.RepairActors.Contains(a.Info.Name)); } public int MovementSpeed @@ -512,7 +512,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 (repairableInfo != null && repairableInfo.RepairBuildings.Contains(name)) + if (repairableInfo != null && repairableInfo.RepairActors.Contains(name)) yield return new Repair(self, a, WDist.Zero); } diff --git a/OpenRA.Mods.Common/Traits/Repairable.cs b/OpenRA.Mods.Common/Traits/Repairable.cs index db138e9a6b..859d2efc81 100644 --- a/OpenRA.Mods.Common/Traits/Repairable.cs +++ b/OpenRA.Mods.Common/Traits/Repairable.cs @@ -20,19 +20,20 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("This actor can be sent to a structure for repairs.")] - class RepairableInfo : ITraitInfo, Requires, Requires + public class RepairableInfo : ITraitInfo, Requires, Requires { - public readonly HashSet RepairBuildings = new HashSet { "fix" }; + [FieldLoader.Require] + [ActorReference] public readonly HashSet RepairActors = new HashSet { }; [VoiceReference] public readonly string Voice = "Action"; - [Desc("The amount the unit will be repaired at each step. Use -1 for fallback behavior where HpPerStep from RepairUnit trait will be used.")] + [Desc("The amount the unit will be repaired at each step. Use -1 for fallback behavior where HpPerStep from RepairsUnits trait will be used.")] public readonly int HpPerStep = -1; public virtual object Create(ActorInitializer init) { return new Repairable(init.Self, this); } } - class Repairable : IIssueOrder, IResolveOrder, IOrderVoice, INotifyCreated + public class Repairable : IIssueOrder, IResolveOrder, IOrderVoice, INotifyCreated { public readonly RepairableInfo Info; readonly IHealth health; @@ -69,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits bool CanRepairAt(Actor target) { - return Info.RepairBuildings.Contains(target.Info.Name); + return Info.RepairActors.Contains(target.Info.Name); } bool CanRearmAt(Actor target) @@ -155,7 +156,7 @@ namespace OpenRA.Mods.Common.Traits var repairBuilding = self.World.ActorsWithTrait() .Where(a => !a.Actor.IsDead && a.Actor.IsInWorld && a.Actor.Owner.IsAlliedWith(self.Owner) && - Info.RepairBuildings.Contains(a.Actor.Info.Name)) + Info.RepairActors.Contains(a.Actor.Info.Name)) .OrderBy(p => (self.Location - p.Actor.Location).LengthSquared); // Worst case FirstOrDefault() will return a TraitPair, which is OK. diff --git a/OpenRA.Mods.Common/Traits/RepairableNear.cs b/OpenRA.Mods.Common/Traits/RepairableNear.cs index b79c0d7d24..976394968a 100644 --- a/OpenRA.Mods.Common/Traits/RepairableNear.cs +++ b/OpenRA.Mods.Common/Traits/RepairableNear.cs @@ -20,7 +20,9 @@ namespace OpenRA.Mods.Common.Traits { class RepairableNearInfo : ITraitInfo, Requires, Requires { - [ActorReference] public readonly HashSet Buildings = new HashSet { "spen", "syrd" }; + [FieldLoader.Require] + [ActorReference] public readonly HashSet RepairActors = new HashSet { }; + public readonly WDist CloseEnough = WDist.FromCells(4); [VoiceReference] public readonly string Voice = "Action"; @@ -59,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits bool CanRepairAt(Actor target) { - return info.Buildings.Contains(target.Info.Name); + return info.RepairActors.Contains(target.Info.Name); } bool ShouldRepair() @@ -96,7 +98,7 @@ namespace OpenRA.Mods.Common.Traits var repairBuilding = self.World.ActorsWithTrait() .Where(a => !a.Actor.IsDead && a.Actor.IsInWorld && a.Actor.Owner.IsAlliedWith(self.Owner) && - info.Buildings.Contains(a.Actor.Info.Name)) + info.RepairActors.Contains(a.Actor.Info.Name)) .OrderBy(p => (self.Location - p.Actor.Location).LengthSquared); // Worst case FirstOrDefault() will return a TraitPair, which is OK. diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20190106/StreamlineRepairableTraits.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20190106/StreamlineRepairableTraits.cs new file mode 100644 index 0000000000..a8d2fb81a0 --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/20190106/StreamlineRepairableTraits.cs @@ -0,0 +1,56 @@ +#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.Collections.Generic; + +namespace OpenRA.Mods.Common.UpdateRules.Rules +{ + public class StreamlineRepairableTraits : UpdateRule + { + public override string Name { get { return "Streamline RepairableNear and Repairable"; } } + public override string Description + { + get + { + return "Renamed Repairable.RepairBuildings and RepairableNear.Buildings to RepairActors,\n" + + "for consistency with RearmActors (and since repairing at other actors should already be possible).\n" + + "Additionally, removed internal 'fix' and 'spen, syrd' default values."; + } + } + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + // Repairable isn't conditional or otherwise supports multiple traits, so LastChildMatching should be fine. + var repairableNode = actorNode.LastChildMatching("Repairable"); + if (repairableNode != null) + { + var repairBuildings = repairableNode.LastChildMatching("RepairBuildings"); + if (repairBuildings != null) + repairBuildings.RenameKey("RepairActors"); + else + repairableNode.AddNode(new MiniYamlNode("RepairActors", "fix")); + } + + // RepairableNear isn't conditional or otherwise supports multiple traits, so LastChildMatching should be fine. + var repairableNearNode = actorNode.LastChildMatching("RepairableNear"); + if (repairableNearNode != null) + { + var repairBuildings = repairableNearNode.LastChildMatching("Buildings"); + if (repairBuildings != null) + repairBuildings.RenameKey("RepairActors"); + else + repairableNearNode.AddNode(new MiniYamlNode("RepairActors", "spen, syrd")); + } + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index c4eea617ea..76adf67bd5 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -88,7 +88,6 @@ namespace OpenRA.Mods.Common.UpdateRules new UpdatePath("release-20181215", "playtest-20190106", new UpdateRule[] { - // Bleed only changes here new AddCarryableHarvester(), new RenameEditorTilesetFilter(), new DefineNotificationDefaults(), @@ -117,8 +116,10 @@ namespace OpenRA.Mods.Common.UpdateRules new UpdatePath("playtest-20190106", new UpdateRule[] { + // Bleed only changes here new RemoveAttackSuicides(), new MakeMobilePausableConditional(), + new StreamlineRepairableTraits(), }) }; diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 44240772d8..fd478d832a 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -258,6 +258,7 @@ Targetable: TargetTypes: Ground, Vehicle Repairable: + RepairActors: fix Passenger: CargoType: Vehicle ActorLostNotification: @@ -309,7 +310,7 @@ Selectable: Bounds: 24,24 Repairable: - RepairBuildings: hpad + RepairActors: hpad Aircraft: LandWhenIdle: false AirborneCondition: airborne diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index 9a9b567e2a..247f0935d2 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -188,7 +188,7 @@ HiddenUnderFog: ActorLostNotification: Repairable: - RepairBuildings: repair_pad + RepairActors: repair_pad Guard: Voice: Guard Guardable: diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 12d7a93715..572a68464d 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -259,6 +259,7 @@ Condition: damaged ValidDamageStates: Light, Medium, Heavy, Critical Repairable: + RepairActors: fix Chronoshiftable: Passenger: CargoType: Vehicle @@ -513,6 +514,7 @@ Types: Ship Chronoshiftable: RepairableNear: + RepairActors: spen, syrd GpsDot: String: Ship WithDamageOverlay: @@ -604,7 +606,7 @@ Inherits: ^NeutralPlane Inherits@2: ^GainsExperience Repairable: - RepairBuildings: fix + RepairActors: fix ^Helicopter: Inherits: ^Plane diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index fc6381497d..5e2baca8db 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -749,7 +749,7 @@ Condition: damaged ValidDamageStates: Light, Medium, Heavy, Critical Repairable: - RepairBuildings: gadept + RepairActors: gadept Voice: Move Passenger: CargoType: Vehicle @@ -841,7 +841,7 @@ SelectionDecorations: Palette: pips Repairable: - RepairBuildings: gadept + RepairActors: gadept Voice: Move Aircraft: AirborneCondition: airborne