Make Mobile a PausableConditionalTrait
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -594,6 +594,7 @@
|
||||
<Compile Include="Traits\World\WeatherOverlay.cs" />
|
||||
<Compile Include="Traits\World\ActorSpawnManager.cs" />
|
||||
<Compile Include="Traits\ActorSpawner.cs" />
|
||||
<Compile Include="UpdateRules\Rules\20181215\MakeMobilePausableConditional.cs" />
|
||||
<Compile Include="UpdateRules\Rules\20181215\RemoveAttackIgnoresVisibility.cs" />
|
||||
<Compile Include="UpdateRules\Rules\20181215\RemoveAttackSuicides.cs" />
|
||||
<Compile Include="UpdateRules\Rules\20181215\RemovedDemolishLocking.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; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<MobileInfo>, INotifyCreated, IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove,
|
||||
public class Mobile : PausableConditionalTrait<MobileInfo>, 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<IOrderTargeter> IIssueOrder.Orders { get { yield return new MoveOrderTargeter(self, this); } }
|
||||
IEnumerable<IOrderTargeter> 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;
|
||||
|
||||
@@ -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<string> 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<string> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,6 +118,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
||||
new UpdatePath("playtest-20190106", new UpdateRule[]
|
||||
{
|
||||
new RemoveAttackSuicides(),
|
||||
new MakeMobilePausableConditional(),
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ LST:
|
||||
InitialFacing: 0
|
||||
TurnSpeed: 4
|
||||
Speed: 142
|
||||
RequiresCondition: !notmobile
|
||||
PauseOnCondition: notmobile
|
||||
Health:
|
||||
HP: 40000
|
||||
Armor:
|
||||
|
||||
@@ -109,7 +109,7 @@ APC:
|
||||
Mobile:
|
||||
TurnSpeed: 5
|
||||
Speed: 132
|
||||
RequiresCondition: !notmobile
|
||||
PauseOnCondition: notmobile
|
||||
Health:
|
||||
HP: 19000
|
||||
Repairable:
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
Mobile:
|
||||
TurnSpeed: 5
|
||||
Locomotor: vehicle
|
||||
RequiresCondition: !notmobile
|
||||
PauseOnCondition: notmobile
|
||||
SelectionDecorations:
|
||||
WithSpriteControlGroupDecoration:
|
||||
Selectable:
|
||||
|
||||
@@ -343,7 +343,8 @@ devastator:
|
||||
TurnSpeed: 3
|
||||
Speed: 31
|
||||
Locomotor: devastator
|
||||
RequiresCondition: !overload && !notmobile
|
||||
RequiresCondition: !overload
|
||||
PauseOnCondition: notmobile
|
||||
AutoCarryable:
|
||||
RequiresCondition: !overload
|
||||
RevealsShroud:
|
||||
|
||||
@@ -242,7 +242,7 @@
|
||||
DrawLineToTarget:
|
||||
UpdatesPlayerStatistics:
|
||||
Mobile:
|
||||
RequiresCondition: !being-captured
|
||||
PauseOnCondition: being-captured
|
||||
Locomotor: wheeled
|
||||
TurnSpeed: 5
|
||||
SelectionDecorations:
|
||||
|
||||
@@ -22,7 +22,7 @@ DOG:
|
||||
Mobile:
|
||||
Speed: 99
|
||||
Voice: Move
|
||||
RequiresCondition: !attack-cooldown && !eating
|
||||
PauseOnCondition: attack-cooldown || eating
|
||||
Guard:
|
||||
Voice: Move
|
||||
Passenger:
|
||||
|
||||
@@ -275,7 +275,7 @@ LST:
|
||||
Mobile:
|
||||
Locomotor: lcraft
|
||||
Speed: 113
|
||||
RequiresCondition: !notmobile
|
||||
PauseOnCondition: notmobile
|
||||
RevealsShroud:
|
||||
Range: 6c0
|
||||
RevealGeneratedShroud: False
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user