Remove AlternateTransportsMode.
This conflicts with undeploy orders and has been largely superseded by queued enter orders.
This commit is contained in:
@@ -80,57 +80,4 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
base.Cancel(self, keepQueue);
|
base.Cancel(self, keepQueue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class EnterTransports : Activity
|
|
||||||
{
|
|
||||||
readonly string type;
|
|
||||||
readonly Passenger passenger;
|
|
||||||
|
|
||||||
public EnterTransports(Actor self, Target primaryTarget)
|
|
||||||
{
|
|
||||||
passenger = self.Trait<Passenger>();
|
|
||||||
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<Actor, bool> isValidTransport = a =>
|
|
||||||
{
|
|
||||||
var c = a.TraitOrDefault<Cargo>();
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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<CargoInfo>
|
|
||||||
{
|
|
||||||
readonly AlternateTransportsMode mode;
|
|
||||||
|
|
||||||
public EnterTransportTargeter(string order, int priority,
|
|
||||||
Func<Actor, bool> canTarget, Func<Actor, bool> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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<CargoInfo>
|
|
||||||
{
|
|
||||||
readonly AlternateTransportsMode mode;
|
|
||||||
|
|
||||||
public EnterTransportsTargeter(string order, int priority,
|
|
||||||
Func<Actor, bool> canTarget, Func<Actor, bool> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,11 +26,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly string CargoType = null;
|
public readonly string CargoType = null;
|
||||||
public readonly int Weight = 1;
|
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]
|
[VoiceReference]
|
||||||
public readonly string Voice = "Action";
|
public readonly string Voice = "Action";
|
||||||
|
|
||||||
@@ -39,20 +34,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public class TransformsIntoPassenger : ConditionalTrait<TransformsIntoPassengerInfo>, IIssueOrder, IResolveOrder, IOrderVoice
|
public class TransformsIntoPassenger : ConditionalTrait<TransformsIntoPassengerInfo>, IIssueOrder, IResolveOrder, IOrderVoice
|
||||||
{
|
{
|
||||||
readonly IOrderTargeter[] orders;
|
|
||||||
Transforms[] transforms;
|
Transforms[] transforms;
|
||||||
|
|
||||||
public TransformsIntoPassenger(TransformsIntoPassengerInfo info)
|
public TransformsIntoPassenger(TransformsIntoPassengerInfo info)
|
||||||
: base(info)
|
: base(info) { }
|
||||||
{
|
|
||||||
Func<Actor, bool> canTarget = IsCorrectCargoType;
|
|
||||||
Func<Actor, bool> useEnterCursor = CanEnter;
|
|
||||||
orders = new EnterAlliedActorTargeter<CargoInfo>[]
|
|
||||||
{
|
|
||||||
new EnterTransportTargeter("EnterTransport", 5, canTarget, useEnterCursor, Info.AlternateTransportsMode),
|
|
||||||
new EnterTransportsTargeter("EnterTransports", 5, canTarget, useEnterCursor, Info.AlternateTransportsMode)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
@@ -64,13 +49,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return !IsTraitDisabled ? orders : Enumerable.Empty<IOrderTargeter>();
|
if (!IsTraitDisabled)
|
||||||
|
yield return new EnterAlliedActorTargeter<CargoInfo>("EnterTransport", 5, IsCorrectCargoType, CanEnter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
|
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 new Order(order.OrderID, self, target, queued);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -96,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (IsTraitDisabled)
|
if (IsTraitDisabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (order.OrderString != "EnterTransport" && order.OrderString != "EnterTransports")
|
if (order.OrderString != "EnterTransport")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Enter orders are only valid for own/allied actors,
|
// Enter orders are only valid for own/allied actors,
|
||||||
@@ -130,7 +116,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (IsTraitDisabled)
|
if (IsTraitDisabled)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (order.OrderString != "EnterTransport" && order.OrderString != "EnterTransports")
|
if (order.OrderString != "EnterTransport")
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (order.Target.Type != TargetType.Actor || !CanEnter(order.Target.Actor))
|
if (order.Target.Type != TargetType.Actor || !CanEnter(order.Target.Actor))
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
public enum AlternateTransportsMode { None, Force, Default, Always }
|
|
||||||
|
|
||||||
[Desc("This actor can enter Cargo actors.")]
|
[Desc("This actor can enter Cargo actors.")]
|
||||||
public class PassengerInfo : ITraitInfo
|
public class PassengerInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
@@ -27,14 +25,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly PipType PipType = PipType.Green;
|
public readonly PipType PipType = PipType.Green;
|
||||||
public readonly int Weight = 1;
|
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]
|
[GrantedConditionReference]
|
||||||
[Desc("The condition to grant to when this actor is loaded inside any transport.")]
|
[Desc("The condition to grant to when this actor is loaded inside any transport.")]
|
||||||
public readonly string CargoCondition = null;
|
public readonly string CargoCondition = null;
|
||||||
@@ -64,18 +54,17 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public Passenger(PassengerInfo info)
|
public Passenger(PassengerInfo info)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
Func<Actor, bool> canTarget = IsCorrectCargoType;
|
|
||||||
Func<Actor, bool> useEnterCursor = CanEnter;
|
|
||||||
Orders = new EnterAlliedActorTargeter<CargoInfo>[]
|
|
||||||
{
|
|
||||||
new EnterTransportTargeter("EnterTransport", 5, canTarget, useEnterCursor, Info.AlternateTransportsMode),
|
|
||||||
new EnterTransportsTargeter("EnterTransports", 5, canTarget, useEnterCursor, Info.AlternateTransportsMode)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cargo ReservedCargo { get; private set; }
|
public Cargo ReservedCargo { get; private set; }
|
||||||
|
|
||||||
public IEnumerable<IOrderTargeter> Orders { get; private set; }
|
IEnumerable<IOrderTargeter> IIssueOrder.Orders
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
yield return new EnterAlliedActorTargeter<CargoInfo>("EnterTransport", 5, IsCorrectCargoType, CanEnter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
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)
|
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 new Order(order.OrderID, self, target, queued);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -108,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public string VoicePhraseForOrder(Actor self, Order order)
|
public string VoicePhraseForOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
if (order.OrderString != "EnterTransport" && order.OrderString != "EnterTransports")
|
if (order.OrderString != "EnterTransport")
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (order.Target.Type != TargetType.Actor || !CanEnter(order.Target.Actor))
|
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)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
if (order.OrderString != "EnterTransport" && order.OrderString != "EnterTransports")
|
if (order.OrderString != "EnterTransport")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Enter orders are only valid for own/allied actors,
|
// Enter orders are only valid for own/allied actors,
|
||||||
@@ -160,10 +149,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Green);
|
self.SetTargetLine(order.Target, Color.Green);
|
||||||
if (order.OrderString == "EnterTransports")
|
self.QueueActivity(new EnterTransport(self, order.Target));
|
||||||
self.QueueActivity(new EnterTransports(self, order.Target));
|
|
||||||
else
|
|
||||||
self.QueueActivity(new EnterTransport(self, order.Target));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Reserve(Actor self, Cargo cargo)
|
public bool Reserve(Actor self, Cargo cargo)
|
||||||
|
|||||||
@@ -1212,7 +1212,7 @@ Container@PLAYER_WIDGETS:
|
|||||||
Background: chrome-button-background
|
Background: chrome-button-background
|
||||||
DisableKeySound: true
|
DisableKeySound: true
|
||||||
TooltipText: Force Move
|
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
|
TooltipContainer: TOOLTIP_CONTAINER
|
||||||
TooltipTemplate: BUTTON_WITH_DESC_HIGHLIGHT_TOOLTIP_FACTIONSUFFIX
|
TooltipTemplate: BUTTON_WITH_DESC_HIGHLIGHT_TOOLTIP_FACTIONSUFFIX
|
||||||
Children:
|
Children:
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ Container@PLAYER_WIDGETS:
|
|||||||
Background: command-button
|
Background: command-button
|
||||||
DisableKeySound: true
|
DisableKeySound: true
|
||||||
TooltipText: Force Move
|
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
|
TooltipContainer: TOOLTIP_CONTAINER
|
||||||
TooltipTemplate: BUTTON_WITH_DESC_HIGHLIGHT_TOOLTIP
|
TooltipTemplate: BUTTON_WITH_DESC_HIGHLIGHT_TOOLTIP
|
||||||
Children:
|
Children:
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ Container@PLAYER_WIDGETS:
|
|||||||
Background:
|
Background:
|
||||||
DisableKeySound: true
|
DisableKeySound: true
|
||||||
TooltipText: Force Move
|
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
|
TooltipContainer: TOOLTIP_CONTAINER
|
||||||
TooltipTemplate: BUTTON_WITH_DESC_HIGHLIGHT_TOOLTIP
|
TooltipTemplate: BUTTON_WITH_DESC_HIGHLIGHT_TOOLTIP
|
||||||
Children:
|
Children:
|
||||||
|
|||||||
Reference in New Issue
Block a user