diff --git a/OpenRA.Mods.Common/Activities/Move/Move.cs b/OpenRA.Mods.Common/Activities/Move/Move.cs
index 7645e843d0..904361a8f8 100644
--- a/OpenRA.Mods.Common/Activities/Move/Move.cs
+++ b/OpenRA.Mods.Common/Activities/Move/Move.cs
@@ -190,7 +190,7 @@ namespace OpenRA.Mods.Common.Activities
if (IsCanceled && self.Location.Layer != CustomMovementLayerType.Tunnel)
return NextActivity;
- if (mobile.IsTraitDisabled)
+ if (mobile.IsTraitDisabled || mobile.IsTraitPaused)
return this;
if (destination == mobile.ToCell)
diff --git a/OpenRA.Mods.Common/Activities/Move/VisualMoveIntoTarget.cs b/OpenRA.Mods.Common/Activities/Move/VisualMoveIntoTarget.cs
index 48b93d7259..2c3f8d3fa8 100644
--- a/OpenRA.Mods.Common/Activities/Move/VisualMoveIntoTarget.cs
+++ b/OpenRA.Mods.Common/Activities/Move/VisualMoveIntoTarget.cs
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Activities
if (IsCanceled || target.Type == TargetType.Invalid)
return NextActivity;
- if (mobile.IsTraitDisabled)
+ if (mobile.IsTraitDisabled || mobile.IsTraitPaused)
return this;
var currentPos = self.CenterPosition;
diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
index ec1a6608b1..4e63c0ac96 100644
--- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
+++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
@@ -594,6 +594,7 @@
+
diff --git a/OpenRA.Mods.Common/Scripting/Properties/MobileProperties.cs b/OpenRA.Mods.Common/Scripting/Properties/MobileProperties.cs
index 0a43e63ac9..43780fa60a 100644
--- a/OpenRA.Mods.Common/Scripting/Properties/MobileProperties.cs
+++ b/OpenRA.Mods.Common/Scripting/Properties/MobileProperties.cs
@@ -64,6 +64,6 @@ namespace OpenRA.Mods.Common.Scripting
}
[Desc("Whether the actor can move (false if immobilized).")]
- public bool IsMobile { get { return !mobile.IsTraitDisabled; } }
+ public bool IsMobile { get { return !mobile.IsTraitDisabled && !mobile.IsTraitPaused; } }
}
}
diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs
index 150f198739..6c3f3b8906 100644
--- a/OpenRA.Mods.Common/Traits/Mobile.cs
+++ b/OpenRA.Mods.Common/Traits/Mobile.cs
@@ -21,7 +21,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Unit is able to move.")]
- public class MobileInfo : ConditionalTraitInfo, IMoveInfo, IPositionableInfo, IFacingInfo, IActorPreviewInitInfo,
+ public class MobileInfo : PausableConditionalTraitInfo, IMoveInfo, IPositionableInfo, IFacingInfo, IActorPreviewInitInfo,
IEditorActorOptions
{
[Desc("Which Locomotor does this trait use. Must be defined on the World actor.")]
@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
- public class Mobile : ConditionalTrait, INotifyCreated, IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove,
+ public class Mobile : PausableConditionalTrait, IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove,
IFacing, IDeathActorInitModifier, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyBlockingMove, IActorPreviewInitModifier, INotifyBecomingIdle
{
readonly Actor self;
@@ -220,7 +220,7 @@ namespace OpenRA.Mods.Common.Traits
public void Nudge(Actor self, Actor nudger, bool force)
{
- if (IsTraitDisabled)
+ if (IsTraitDisabled || IsTraitPaused)
return;
// Initial fairly braindead implementation.
@@ -683,7 +683,14 @@ namespace OpenRA.Mods.Common.Traits
Nudge(self, blocking, true);
}
- IEnumerable IIssueOrder.Orders { get { yield return new MoveOrderTargeter(self, this); } }
+ IEnumerable IIssueOrder.Orders
+ {
+ get
+ {
+ if (!IsTraitDisabled)
+ yield return new MoveOrderTargeter(self, this);
+ }
+ }
// Note: Returns a valid order even if the unit can't move to the target
Order IIssueOrder.IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
@@ -696,6 +703,9 @@ namespace OpenRA.Mods.Common.Traits
void IResolveOrder.ResolveOrder(Actor self, Order order)
{
+ if (IsTraitDisabled)
+ return;
+
if (order.OrderString == "Move")
{
var cell = self.World.Map.Clamp(this.self.World.Map.CellContaining(order.Target.CenterPosition));
@@ -718,6 +728,9 @@ namespace OpenRA.Mods.Common.Traits
string IOrderVoice.VoicePhraseForOrder(Actor self, Order order)
{
+ if (IsTraitDisabled)
+ return null;
+
switch (order.OrderString)
{
case "Move":
@@ -770,7 +783,7 @@ namespace OpenRA.Mods.Common.Traits
cursor = self.World.Map.Contains(location) ?
(self.World.Map.GetTerrainInfo(location).CustomCursor ?? mobile.Info.Cursor) : mobile.Info.BlockedCursor;
- if (mobile.IsTraitDisabled
+ if (mobile.IsTraitPaused
|| (!explored && !locomotorInfo.MoveIntoShroud)
|| (explored && locomotorInfo.MovementCostForCell(self.World, location) == int.MaxValue))
cursor = mobile.Info.BlockedCursor;
diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20181215/MakeMobilePausableConditional.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20181215/MakeMobilePausableConditional.cs
new file mode 100644
index 0000000000..1c93c6ea19
--- /dev/null
+++ b/OpenRA.Mods.Common/UpdateRules/Rules/20181215/MakeMobilePausableConditional.cs
@@ -0,0 +1,54 @@
+#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;
+using System.Linq;
+
+namespace OpenRA.Mods.Common.UpdateRules.Rules
+{
+ public class MakeMobilePausableConditional : UpdateRule
+ {
+ public override string Name { get { return "Change Mobile>RequiresCondition to PauseOnCondition"; } }
+ public override string Description
+ {
+ get
+ {
+ return "Mobile is now a PausableConditionalTrait instead of a ConditionalTrait.\n" +
+ "RequiresCondition is changed to PauseOnCondition.";
+ }
+ }
+
+ bool displayedMessage;
+ public override IEnumerable AfterUpdate(ModData modData)
+ {
+ var message = "You may want to update the result of PauseOnCondition, as this update\n" +
+ "just adds ! prefix to RequiresCondition's value to reverse it.";
+
+ if (!displayedMessage)
+ yield return message;
+
+ displayedMessage = true;
+ }
+
+ public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode)
+ {
+ foreach (var node in actorNode.ChildrenMatching("Mobile").Where(t => t.ChildrenMatching("RequiresCondition").Any()))
+ {
+ var rc = node.LastChildMatching("RequiresCondition");
+
+ rc.ReplaceValue("!(" + rc.Value.Value + ")");
+ rc.RenameKey("PauseOnCondition");
+ }
+
+ yield break;
+ }
+ }
+}
diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs
index 023e2e87c6..c4eea617ea 100644
--- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs
+++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs
@@ -118,6 +118,7 @@ namespace OpenRA.Mods.Common.UpdateRules
new UpdatePath("playtest-20190106", new UpdateRule[]
{
new RemoveAttackSuicides(),
+ new MakeMobilePausableConditional(),
})
};
diff --git a/mods/cnc/rules/ships.yaml b/mods/cnc/rules/ships.yaml
index efb86a856f..c8caa8244b 100644
--- a/mods/cnc/rules/ships.yaml
+++ b/mods/cnc/rules/ships.yaml
@@ -64,7 +64,7 @@ LST:
InitialFacing: 0
TurnSpeed: 4
Speed: 142
- RequiresCondition: !notmobile
+ PauseOnCondition: notmobile
Health:
HP: 40000
Armor:
diff --git a/mods/cnc/rules/vehicles.yaml b/mods/cnc/rules/vehicles.yaml
index 845d4fe524..41b31b3b79 100644
--- a/mods/cnc/rules/vehicles.yaml
+++ b/mods/cnc/rules/vehicles.yaml
@@ -109,7 +109,7 @@ APC:
Mobile:
TurnSpeed: 5
Speed: 132
- RequiresCondition: !notmobile
+ PauseOnCondition: notmobile
Health:
HP: 19000
Repairable:
diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml
index 4ac0d3f8cc..9a9b567e2a 100644
--- a/mods/d2k/rules/defaults.yaml
+++ b/mods/d2k/rules/defaults.yaml
@@ -174,7 +174,7 @@
Mobile:
TurnSpeed: 5
Locomotor: vehicle
- RequiresCondition: !notmobile
+ PauseOnCondition: notmobile
SelectionDecorations:
WithSpriteControlGroupDecoration:
Selectable:
diff --git a/mods/d2k/rules/vehicles.yaml b/mods/d2k/rules/vehicles.yaml
index 3793771f03..2cfb7dcd50 100644
--- a/mods/d2k/rules/vehicles.yaml
+++ b/mods/d2k/rules/vehicles.yaml
@@ -343,7 +343,8 @@ devastator:
TurnSpeed: 3
Speed: 31
Locomotor: devastator
- RequiresCondition: !overload && !notmobile
+ RequiresCondition: !overload
+ PauseOnCondition: notmobile
AutoCarryable:
RequiresCondition: !overload
RevealsShroud:
diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml
index cf1debc15c..0a2bdf0c1d 100644
--- a/mods/ra/rules/defaults.yaml
+++ b/mods/ra/rules/defaults.yaml
@@ -242,7 +242,7 @@
DrawLineToTarget:
UpdatesPlayerStatistics:
Mobile:
- RequiresCondition: !being-captured
+ PauseOnCondition: being-captured
Locomotor: wheeled
TurnSpeed: 5
SelectionDecorations:
diff --git a/mods/ra/rules/infantry.yaml b/mods/ra/rules/infantry.yaml
index 0cbeb271e2..fdc580bda8 100644
--- a/mods/ra/rules/infantry.yaml
+++ b/mods/ra/rules/infantry.yaml
@@ -22,7 +22,7 @@ DOG:
Mobile:
Speed: 99
Voice: Move
- RequiresCondition: !attack-cooldown && !eating
+ PauseOnCondition: attack-cooldown || eating
Guard:
Voice: Move
Passenger:
diff --git a/mods/ra/rules/ships.yaml b/mods/ra/rules/ships.yaml
index 30a7b0a453..5f352e359a 100644
--- a/mods/ra/rules/ships.yaml
+++ b/mods/ra/rules/ships.yaml
@@ -275,7 +275,7 @@ LST:
Mobile:
Locomotor: lcraft
Speed: 113
- RequiresCondition: !notmobile
+ PauseOnCondition: notmobile
RevealsShroud:
Range: 6c0
RevealGeneratedShroud: False
diff --git a/mods/ra/rules/vehicles.yaml b/mods/ra/rules/vehicles.yaml
index f4dc8b2b08..aae775c5f5 100644
--- a/mods/ra/rules/vehicles.yaml
+++ b/mods/ra/rules/vehicles.yaml
@@ -399,7 +399,7 @@ JEEP:
Mobile:
TurnSpeed: 10
Speed: 170
- RequiresCondition: !notmobile && !being-captured
+ PauseOnCondition: notmobile || being-captured
RevealsShroud:
Range: 8c0
RevealGeneratedShroud: False
@@ -444,7 +444,7 @@ APC:
Type: Heavy
Mobile:
Speed: 142
- RequiresCondition: !notmobile && !being-captured
+ PauseOnCondition: notmobile || being-captured
RevealsShroud:
Range: 5c0
RevealGeneratedShroud: False
@@ -802,7 +802,8 @@ QTNK:
Armor:
Type: Heavy
Mobile:
- RequiresCondition: !deployed && !being-captured
+ RequiresCondition: !deployed
+ PauseOnCondition: being-captured
Speed: 56
Chronoshiftable:
RequiresCondition: !deployed && !being-captured
@@ -842,7 +843,7 @@ STNK:
Mobile:
Speed: 142
Locomotor: heavywheeled
- RequiresCondition: !notmobile && !being-captured
+ PauseOnCondition: notmobile || being-captured
RevealsShroud:
Range: 7c0
RevealGeneratedShroud: False
diff --git a/mods/ts/rules/civilian-vehicles.yaml b/mods/ts/rules/civilian-vehicles.yaml
index 14c848a152..4a5e8697ab 100644
--- a/mods/ts/rules/civilian-vehicles.yaml
+++ b/mods/ts/rules/civilian-vehicles.yaml
@@ -97,7 +97,7 @@ BUS:
Mobile:
TurnSpeed: 5
Speed: 113
- RequiresCondition: !empdisable && !loading && !being-captured
+ PauseOnCondition: empdisable || loading || being-captured
Health:
HP: 10000
Armor:
@@ -123,7 +123,7 @@ PICK:
Mobile:
TurnSpeed: 5
Speed: 113
- RequiresCondition: !empdisable && !loading && !being-captured
+ PauseOnCondition: empdisable || loading || being-captured
Health:
HP: 10000
Armor:
@@ -149,7 +149,7 @@ CAR:
Mobile:
TurnSpeed: 5
Speed: 113
- RequiresCondition: !empdisable && !loading && !being-captured
+ PauseOnCondition: empdisable || loading || being-captured
Health:
HP: 10000
Armor:
@@ -175,7 +175,7 @@ WINI:
Mobile:
TurnSpeed: 5
Speed: 113
- RequiresCondition: !empdisable && !loading && !being-captured
+ PauseOnCondition: empdisable || loading || being-captured
Health:
HP: 20000
Armor:
diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml
index 353ecf5f15..fc6381497d 100644
--- a/mods/ts/rules/defaults.yaml
+++ b/mods/ts/rules/defaults.yaml
@@ -701,7 +701,7 @@
RequiresCondition: criticalspeed
Modifier: 50
Mobile:
- RequiresCondition: !empdisable
+ PauseOnCondition: empdisable
^CivilianInfantry:
Inherits@1: ^Infantry
@@ -728,7 +728,7 @@
Action: Kill
DrawLineToTarget:
Mobile:
- RequiresCondition: !empdisable && !being-captured
+ PauseOnCondition: empdisable || being-captured
Locomotor: wheeled
TurnSpeed: 5
Voice: Move
@@ -1066,7 +1066,7 @@
TurnSpeed: 5
Voice: Move
Speed: 113
- RequiresCondition: !empdisable
+ PauseOnCondition: empdisable
Locomotor: train
Cargo:
Types: Infantry
diff --git a/mods/ts/rules/gdi-vehicles.yaml b/mods/ts/rules/gdi-vehicles.yaml
index 40121bacf0..6aee65b3a5 100644
--- a/mods/ts/rules/gdi-vehicles.yaml
+++ b/mods/ts/rules/gdi-vehicles.yaml
@@ -15,7 +15,7 @@ APC:
Mobile:
TurnSpeed: 5
Speed: 113
- RequiresCondition: !empdisable && !loading && !being-captured
+ PauseOnCondition: empdisable || loading || being-captured
Locomotor: amphibious
Health:
HP: 20000
@@ -326,7 +326,8 @@ JUGG:
Mobile:
Speed: 71
TurnSpeed: 5
- RequiresCondition: !empdisable && undeployed && !being-captured
+ RequiresCondition: undeployed
+ PauseOnCondition: empdisable || being-captured
AlwaysConsiderTurnAsMove: true
RevealsShroud:
RequiresCondition: !inside-tunnel
diff --git a/mods/ts/rules/nod-vehicles.yaml b/mods/ts/rules/nod-vehicles.yaml
index 68226d1715..baae566c60 100644
--- a/mods/ts/rules/nod-vehicles.yaml
+++ b/mods/ts/rules/nod-vehicles.yaml
@@ -104,7 +104,8 @@ TTNK:
Mobile:
TurnSpeed: 5
Speed: 85
- RequiresCondition: !empdisable && undeployed && !being-captured
+ RequiresCondition: undeployed
+ PauseOnCondition: empdisable || being-captured
Health:
HP: 35000
Armor:
@@ -223,7 +224,8 @@ ART2:
Mobile:
Speed: 71
TurnSpeed: 2
- RequiresCondition: !empdisable && undeployed && !being-captured
+ RequiresCondition: undeployed
+ PauseOnCondition: empdisable || being-captured
RevealsShroud:
RequiresCondition: !inside-tunnel
Range: 9c0
@@ -378,7 +380,7 @@ SAPC:
Mobile:
TurnSpeed: 5
Speed: 71
- RequiresCondition: !empdisable && !loading && !being-captured
+ PauseOnCondition: empdisable || loading || being-captured
Locomotor: subterranean
Health:
HP: 17500
diff --git a/mods/ts/rules/shared-vehicles.yaml b/mods/ts/rules/shared-vehicles.yaml
index 192d51031f..1cc7f4fabc 100644
--- a/mods/ts/rules/shared-vehicles.yaml
+++ b/mods/ts/rules/shared-vehicles.yaml
@@ -124,7 +124,8 @@ LPST:
Mobile:
Speed: 85
TurnSpeed: 5
- RequiresCondition: !empdisable && undeployed && !being-captured
+ RequiresCondition: undeployed
+ PauseOnCondition: empdisable || being-captured
RevealsShroud:
RequiresCondition: !inside-tunnel && undeployed
Range: 10c0