diff --git a/OpenRA.Mods.Common/Activities/EnterTransport.cs b/OpenRA.Mods.Common/Activities/EnterTransport.cs index 6fc335ab5d..6f803d2fa3 100644 --- a/OpenRA.Mods.Common/Activities/EnterTransport.cs +++ b/OpenRA.Mods.Common/Activities/EnterTransport.cs @@ -80,57 +80,4 @@ namespace OpenRA.Mods.Common.Activities base.Cancel(self, keepQueue); } } - - class EnterTransports : Activity - { - readonly string type; - readonly Passenger passenger; - - public EnterTransports(Actor self, Target primaryTarget) - { - passenger = self.Trait(); - if (primaryTarget.Type == TargetType.Actor) - type = primaryTarget.Actor.Info.Name; - - QueueChild(self, new EnterTransport(self, primaryTarget)); - } - - public override Activity Tick(Actor self) - { - if (ChildActivity != null) - { - ChildActivity = ActivityUtils.RunActivity(self, ChildActivity); - if (ChildActivity != null) - return this; - } - - // Try and find a new transport nearby - if (IsCanceling || string.IsNullOrEmpty(type)) - return NextActivity; - - Func isValidTransport = a => - { - var c = a.TraitOrDefault(); - return c != null && c.Info.Types.Contains(passenger.Info.CargoType) && - (c.Unloading || c.CanLoad(a, self)); - }; - - var candidates = self.World.FindActorsInCircle(self.CenterPosition, passenger.Info.AlternateTransportScanRange) - .Where(isValidTransport) - .ToList(); - - // Prefer transports of the same type as the primary - var transport = candidates.Where(a => a.Info.Name == type).ClosestTo(self); - if (transport == null) - transport = candidates.ClosestTo(self); - - if (transport != null) - { - QueueChild(self, ActivityUtils.RunActivity(self, new EnterTransport(self, Target.FromActor(transport))), true); - return this; - } - - return NextActivity; - } - } } diff --git a/OpenRA.Mods.Common/Orders/EnterTransportTargeter.cs b/OpenRA.Mods.Common/Orders/EnterTransportTargeter.cs deleted file mode 100644 index 4235f93a88..0000000000 --- a/OpenRA.Mods.Common/Orders/EnterTransportTargeter.cs +++ /dev/null @@ -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; -using OpenRA.Mods.Common.Traits; -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Orders -{ - public class EnterTransportTargeter : EnterAlliedActorTargeter - { - readonly AlternateTransportsMode mode; - - public EnterTransportTargeter(string order, int priority, - Func canTarget, Func useEnterCursor, - AlternateTransportsMode mode) - : base(order, priority, canTarget, useEnterCursor) { this.mode = mode; } - - public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor) - { - switch (mode) - { - case AlternateTransportsMode.None: - break; - case AlternateTransportsMode.Force: - if (modifiers.HasModifier(TargetModifiers.ForceMove)) - return false; - break; - case AlternateTransportsMode.Default: - if (!modifiers.HasModifier(TargetModifiers.ForceMove)) - return false; - break; - case AlternateTransportsMode.Always: - return false; - } - - return base.CanTargetActor(self, target, modifiers, ref cursor); - } - } -} diff --git a/OpenRA.Mods.Common/Orders/EnterTransportsTargeter.cs b/OpenRA.Mods.Common/Orders/EnterTransportsTargeter.cs deleted file mode 100644 index ae71531cf7..0000000000 --- a/OpenRA.Mods.Common/Orders/EnterTransportsTargeter.cs +++ /dev/null @@ -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; -using OpenRA.Mods.Common.Traits; -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Orders -{ - public class EnterTransportsTargeter : EnterAlliedActorTargeter - { - readonly AlternateTransportsMode mode; - - public EnterTransportsTargeter(string order, int priority, - Func canTarget, Func useEnterCursor, - AlternateTransportsMode mode) - : base(order, priority, canTarget, useEnterCursor) { this.mode = mode; } - - public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor) - { - switch (mode) - { - case AlternateTransportsMode.None: - return false; - case AlternateTransportsMode.Force: - if (!modifiers.HasModifier(TargetModifiers.ForceMove)) - return false; - break; - case AlternateTransportsMode.Default: - if (modifiers.HasModifier(TargetModifiers.ForceMove)) - return false; - break; - case AlternateTransportsMode.Always: - break; - } - - return base.CanTargetActor(self, target, modifiers, ref cursor); - } - } -} diff --git a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoPassenger.cs b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoPassenger.cs index e3defb21c7..f9bfce1477 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoPassenger.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/TransformsIntoPassenger.cs @@ -26,11 +26,6 @@ namespace OpenRA.Mods.Common.Traits public readonly string CargoType = null; public readonly int Weight = 1; - [Desc("Use to set when to use alternate transports (Never, Force, Default, Always).", - "Force - use force move modifier (Alt) to enable.", - "Default - use force move modifier (Alt) to disable.")] - public readonly AlternateTransportsMode AlternateTransportsMode = AlternateTransportsMode.Force; - [VoiceReference] public readonly string Voice = "Action"; @@ -39,20 +34,10 @@ namespace OpenRA.Mods.Common.Traits public class TransformsIntoPassenger : ConditionalTrait, IIssueOrder, IResolveOrder, IOrderVoice { - readonly IOrderTargeter[] orders; Transforms[] transforms; public TransformsIntoPassenger(TransformsIntoPassengerInfo info) - : base(info) - { - Func canTarget = IsCorrectCargoType; - Func useEnterCursor = CanEnter; - orders = new EnterAlliedActorTargeter[] - { - new EnterTransportTargeter("EnterTransport", 5, canTarget, useEnterCursor, Info.AlternateTransportsMode), - new EnterTransportsTargeter("EnterTransports", 5, canTarget, useEnterCursor, Info.AlternateTransportsMode) - }; - } + : base(info) { } protected override void Created(Actor self) { @@ -64,13 +49,14 @@ namespace OpenRA.Mods.Common.Traits { get { - return !IsTraitDisabled ? orders : Enumerable.Empty(); + if (!IsTraitDisabled) + yield return new EnterAlliedActorTargeter("EnterTransport", 5, IsCorrectCargoType, CanEnter); } } Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) { - if (order.OrderID == "EnterTransport" || order.OrderID == "EnterTransports") + if (order.OrderID == "EnterTransport") return new Order(order.OrderID, self, target, queued); return null; @@ -96,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits if (IsTraitDisabled) return; - if (order.OrderString != "EnterTransport" && order.OrderString != "EnterTransports") + if (order.OrderString != "EnterTransport") return; // Enter orders are only valid for own/allied actors, @@ -130,7 +116,7 @@ namespace OpenRA.Mods.Common.Traits if (IsTraitDisabled) return null; - if (order.OrderString != "EnterTransport" && order.OrderString != "EnterTransports") + if (order.OrderString != "EnterTransport") return null; if (order.Target.Type != TargetType.Actor || !CanEnter(order.Target.Actor)) diff --git a/OpenRA.Mods.Common/Traits/Passenger.cs b/OpenRA.Mods.Common/Traits/Passenger.cs index 3f8e884d2a..3c8c7c3dc2 100644 --- a/OpenRA.Mods.Common/Traits/Passenger.cs +++ b/OpenRA.Mods.Common/Traits/Passenger.cs @@ -18,8 +18,6 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - public enum AlternateTransportsMode { None, Force, Default, Always } - [Desc("This actor can enter Cargo actors.")] public class PassengerInfo : ITraitInfo { @@ -27,14 +25,6 @@ namespace OpenRA.Mods.Common.Traits public readonly PipType PipType = PipType.Green; public readonly int Weight = 1; - [Desc("Use to set when to use alternate transports (Never, Force, Default, Always).", - "Force - use force move modifier (Alt) to enable.", - "Default - use force move modifier (Alt) to disable.")] - public readonly AlternateTransportsMode AlternateTransportsMode = AlternateTransportsMode.Force; - - [Desc("Range from self for looking for an alternate transport (default: 5.5 cells).")] - public readonly WDist AlternateTransportScanRange = WDist.FromCells(11) / 2; - [GrantedConditionReference] [Desc("The condition to grant to when this actor is loaded inside any transport.")] public readonly string CargoCondition = null; @@ -64,18 +54,17 @@ namespace OpenRA.Mods.Common.Traits public Passenger(PassengerInfo info) { Info = info; - Func canTarget = IsCorrectCargoType; - Func useEnterCursor = CanEnter; - Orders = new EnterAlliedActorTargeter[] - { - new EnterTransportTargeter("EnterTransport", 5, canTarget, useEnterCursor, Info.AlternateTransportsMode), - new EnterTransportsTargeter("EnterTransports", 5, canTarget, useEnterCursor, Info.AlternateTransportsMode) - }; } public Cargo ReservedCargo { get; private set; } - public IEnumerable Orders { get; private set; } + IEnumerable IIssueOrder.Orders + { + get + { + yield return new EnterAlliedActorTargeter("EnterTransport", 5, IsCorrectCargoType, CanEnter); + } + } void INotifyCreated.Created(Actor self) { @@ -84,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) { - if (order.OrderID == "EnterTransport" || order.OrderID == "EnterTransports") + if (order.OrderID == "EnterTransport") return new Order(order.OrderID, self, target, queued); return null; @@ -108,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits public string VoicePhraseForOrder(Actor self, Order order) { - if (order.OrderString != "EnterTransport" && order.OrderString != "EnterTransports") + if (order.OrderString != "EnterTransport") return null; if (order.Target.Type != TargetType.Actor || !CanEnter(order.Target.Actor)) @@ -141,7 +130,7 @@ namespace OpenRA.Mods.Common.Traits public void ResolveOrder(Actor self, Order order) { - if (order.OrderString != "EnterTransport" && order.OrderString != "EnterTransports") + if (order.OrderString != "EnterTransport") return; // Enter orders are only valid for own/allied actors, @@ -160,10 +149,7 @@ namespace OpenRA.Mods.Common.Traits self.CancelActivity(); self.SetTargetLine(order.Target, Color.Green); - if (order.OrderString == "EnterTransports") - self.QueueActivity(new EnterTransports(self, order.Target)); - else - self.QueueActivity(new EnterTransport(self, order.Target)); + self.QueueActivity(new EnterTransport(self, order.Target)); } public bool Reserve(Actor self, Cargo cargo) diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index 0017c2650e..cf399d63b8 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -1212,7 +1212,7 @@ Container@PLAYER_WIDGETS: Background: chrome-button-background DisableKeySound: true TooltipText: Force Move - TooltipDesc: Selected units will move to the desired location\n - Default activity for the target is suppressed\n - Vehicles will attempt to crush enemies at the target location\n - Units entering transports will consider nearby alternatives\n\nLeft-click icon then right-click on target.\nHold {(Alt)} to activate temporarily while commanding units. + TooltipDesc: Selected units will move to the desired location\n - Default activity for the target is suppressed\n - Vehicles will attempt to crush enemies at the target location\n\nLeft-click icon then right-click on target.\nHold {(Alt)} to activate temporarily while commanding units. TooltipContainer: TOOLTIP_CONTAINER TooltipTemplate: BUTTON_WITH_DESC_HIGHLIGHT_TOOLTIP_FACTIONSUFFIX Children: diff --git a/mods/ra/chrome/ingame-player.yaml b/mods/ra/chrome/ingame-player.yaml index 6dabfd3705..a1141bd6e4 100644 --- a/mods/ra/chrome/ingame-player.yaml +++ b/mods/ra/chrome/ingame-player.yaml @@ -73,7 +73,7 @@ Container@PLAYER_WIDGETS: Background: command-button DisableKeySound: true TooltipText: Force Move - TooltipDesc: Selected units will move to the desired location\n - Default activity for the target is suppressed\n - Vehicles will attempt to crush enemies at the target location\n - Units entering transports will consider nearby alternatives\n - Chrono Tanks will teleport towards the target location\n\nLeft-click icon then right-click on target.\nHold {(Alt)} to activate temporarily while commanding units. + TooltipDesc: Selected units will move to the desired location\n - Default activity for the target is suppressed\n - Vehicles will attempt to crush enemies at the target location\n - Chrono Tanks will teleport towards the target location\n\nLeft-click icon then right-click on target.\nHold {(Alt)} to activate temporarily while commanding units. TooltipContainer: TOOLTIP_CONTAINER TooltipTemplate: BUTTON_WITH_DESC_HIGHLIGHT_TOOLTIP Children: diff --git a/mods/ts/chrome/ingame-player.yaml b/mods/ts/chrome/ingame-player.yaml index 275d3eb52f..5d4c87f01c 100644 --- a/mods/ts/chrome/ingame-player.yaml +++ b/mods/ts/chrome/ingame-player.yaml @@ -61,7 +61,7 @@ Container@PLAYER_WIDGETS: Background: DisableKeySound: true TooltipText: Force Move - TooltipDesc: Selected units will move to the desired location\n - Default activity for the target is suppressed\n - Vehicles will attempt to crush enemies at the target location\n - Deployed units will undeploy and move to the target location\n - Units entering transports will consider nearby alternatives\n - Carryalls will not release their cargo at the target location\n\nLeft-click icon then right-click on target.\nHold {(Alt)} to activate temporarily while commanding units. + TooltipDesc: Selected units will move to the desired location\n - Default activity for the target is suppressed\n - Vehicles will attempt to crush enemies at the target location\n - Deployed units will undeploy and move to the target location\n - Carryalls will not release their cargo at the target location\n\nLeft-click icon then right-click on target.\nHold {(Alt)} to activate temporarily while commanding units. TooltipContainer: TOOLTIP_CONTAINER TooltipTemplate: BUTTON_WITH_DESC_HIGHLIGHT_TOOLTIP Children: