diff --git a/OpenRA.Game/VoiceExts.cs b/OpenRA.Game/VoiceExts.cs index 577e2d8c69..9cdc1ea884 100644 --- a/OpenRA.Game/VoiceExts.cs +++ b/OpenRA.Game/VoiceExts.cs @@ -63,12 +63,14 @@ namespace OpenRA continue; foreach (var voice in orderSubject.TraitsImplementing()) + { foreach (var v in orderSubject.TraitsImplementing()) { if (voice.PlayVoice(orderSubject, v.VoicePhraseForOrder(orderSubject, o), orderSubject.Owner.Faction.InternalName)) return; } + } } } } diff --git a/OpenRA.Mods.Common/Traits/RepairableNear.cs b/OpenRA.Mods.Common/Traits/RepairableNear.cs index 4de7aad94d..77dace723b 100644 --- a/OpenRA.Mods.Common/Traits/RepairableNear.cs +++ b/OpenRA.Mods.Common/Traits/RepairableNear.cs @@ -20,12 +20,13 @@ namespace OpenRA.Mods.Common.Traits class RepairableNearInfo : ITraitInfo, Requires, Requires { [ActorReference] public readonly HashSet Buildings = new HashSet { "spen", "syrd" }; - public readonly int CloseEnough = 4; /* cells */ + public readonly WDist CloseEnough = WDist.FromCells(4); + [VoiceReference] public readonly string Voice = "Action"; public object Create(ActorInitializer init) { return new RepairableNear(init.Self, this); } } - class RepairableNear : IIssueOrder, IResolveOrder + class RepairableNear : IIssueOrder, IResolveOrder, IOrderVoice { readonly Actor self; readonly RepairableNearInfo info; @@ -65,6 +66,11 @@ namespace OpenRA.Mods.Common.Traits return self.GetDamageState() > DamageState.Undamaged; } + public string VoicePhraseForOrder(Actor self, Order order) + { + return (order.OrderString == "RepairNear" && ShouldRepair()) ? info.Voice : null; + } + public void ResolveOrder(Actor self, Order order) { if (order.OrderString == "RepairNear" && CanRepairAt(order.TargetActor) && ShouldRepair()) @@ -72,7 +78,7 @@ namespace OpenRA.Mods.Common.Traits var target = Target.FromOrder(self.World, order); self.CancelActivity(); - self.QueueActivity(movement.MoveWithinRange(target, new WDist(1024 * info.CloseEnough))); + self.QueueActivity(movement.MoveWithinRange(target, info.CloseEnough)); self.QueueActivity(new Repair(order.TargetActor)); self.SetTargetLine(target, Color.Green, false); diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index f89b879feb..18a2847fa8 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -2683,6 +2683,17 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + // 'CloseEnough' on 'RepairableNear' uses WDist now + if (engineVersion < 20151214) + { + if (node.Key == "RepairableNear") + { + var ce = node.Value.Nodes.FirstOrDefault(n => n.Key == "CloseEnough"); + if (ce != null && !ce.Value.Value.Contains("c")) + ce.Value.Value = ce.Value.Value + "c0"; + } + } + UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } }