Add separate condition to mobile for disabling nudging only.
This commit is contained in:
@@ -53,6 +53,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Boolean expression defining the condition under which the regular (non-force) move cursor is disabled.")]
|
[Desc("Boolean expression defining the condition under which the regular (non-force) move cursor is disabled.")]
|
||||||
public readonly BooleanExpression RequireForceMoveCondition = null;
|
public readonly BooleanExpression RequireForceMoveCondition = null;
|
||||||
|
|
||||||
|
[ConsumedConditionReference]
|
||||||
|
[Desc("Boolean expression defining the condition under which this actor cannot be nudged by other actors.")]
|
||||||
|
public readonly BooleanExpression ImmovableCondition = null;
|
||||||
|
|
||||||
IEnumerable<object> IActorPreviewInitInfo.ActorPreviewInits(ActorInfo ai, ActorPreviewType type)
|
IEnumerable<object> IActorPreviewInitInfo.ActorPreviewInits(ActorInfo ai, ActorPreviewType type)
|
||||||
{
|
{
|
||||||
yield return new FacingInit(PreviewFacing);
|
yield return new FacingInit(PreviewFacing);
|
||||||
@@ -180,7 +184,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
INotifyMoving[] notifyMoving;
|
INotifyMoving[] notifyMoving;
|
||||||
INotifyFinishedMoving[] notifyFinishedMoving;
|
INotifyFinishedMoving[] notifyFinishedMoving;
|
||||||
IWrapMove[] moveWrappers;
|
IWrapMove[] moveWrappers;
|
||||||
public bool RequireForceMove;
|
bool requireForceMove;
|
||||||
|
|
||||||
|
public bool IsImmovable { get; private set; }
|
||||||
public bool TurnToMove;
|
public bool TurnToMove;
|
||||||
public bool IsBlocking { get; private set; }
|
public bool IsBlocking { get; private set; }
|
||||||
|
|
||||||
@@ -332,7 +338,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public void Nudge(Actor nudger)
|
public void Nudge(Actor nudger)
|
||||||
{
|
{
|
||||||
if (IsTraitDisabled || IsTraitPaused || RequireForceMove)
|
if (IsTraitDisabled || IsTraitPaused || IsImmovable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var cell = GetAdjacentCell(nudger.Location);
|
var cell = GetAdjacentCell(nudger.Location);
|
||||||
@@ -375,7 +381,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
var mobile = otherActor.TraitOrDefault<Mobile>();
|
var mobile = otherActor.TraitOrDefault<Mobile>();
|
||||||
if (mobile == null || mobile.IsTraitDisabled || mobile.IsTraitPaused || mobile.RequireForceMove)
|
if (mobile == null || mobile.IsTraitDisabled || mobile.IsTraitPaused || mobile.IsImmovable)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -857,11 +863,22 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
if (Info.RequireForceMoveCondition != null)
|
if (Info.RequireForceMoveCondition != null)
|
||||||
yield return new VariableObserver(RequireForceMoveConditionChanged, Info.RequireForceMoveCondition.Variables);
|
yield return new VariableObserver(RequireForceMoveConditionChanged, Info.RequireForceMoveCondition.Variables);
|
||||||
|
|
||||||
|
if (Info.ImmovableCondition != null)
|
||||||
|
yield return new VariableObserver(ImmovableConditionChanged, Info.ImmovableCondition.Variables);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequireForceMoveConditionChanged(Actor self, IReadOnlyDictionary<string, int> conditions)
|
void RequireForceMoveConditionChanged(Actor self, IReadOnlyDictionary<string, int> conditions)
|
||||||
{
|
{
|
||||||
RequireForceMove = Info.RequireForceMoveCondition.Evaluate(conditions);
|
requireForceMove = Info.RequireForceMoveCondition.Evaluate(conditions);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImmovableConditionChanged(Actor self, IReadOnlyDictionary<string, int> conditions)
|
||||||
|
{
|
||||||
|
var wasImmovable = IsImmovable;
|
||||||
|
IsImmovable = Info.ImmovableCondition.Evaluate(conditions);
|
||||||
|
if (wasImmovable != IsImmovable)
|
||||||
|
self.World.ActorMap.UpdateOccupiedCells(self.OccupiesSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<IOrderTargeter> IIssueOrder.Orders
|
IEnumerable<IOrderTargeter> IIssueOrder.Orders
|
||||||
@@ -957,7 +974,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||||
{
|
{
|
||||||
if (rejectMove || target.Type != TargetType.Terrain || (mobile.RequireForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
|
if (rejectMove || target.Type != TargetType.Terrain || (mobile.requireForceMove && !modifiers.HasModifier(TargetModifiers.ForceMove)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var location = self.World.Map.CellContaining(target.CenterPosition);
|
var location = self.World.Map.CellContaining(target.CenterPosition);
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.Owner.Stances[otherActor.Owner] == Stance.Ally)
|
self.Owner.Stances[otherActor.Owner] == Stance.Ally)
|
||||||
{
|
{
|
||||||
var mobile = otherActor.TraitOrDefault<Mobile>();
|
var mobile = otherActor.TraitOrDefault<Mobile>();
|
||||||
if (mobile != null && !mobile.IsTraitDisabled && !mobile.IsTraitPaused && !mobile.RequireForceMove)
|
if (mobile != null && !mobile.IsTraitDisabled && !mobile.IsTraitPaused && !mobile.IsImmovable)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,7 +487,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
var crushables = actor.TraitsImplementing<ICrushable>();
|
var crushables = actor.TraitsImplementing<ICrushable>();
|
||||||
var mobile = actor.OccupiesSpace as Mobile;
|
var mobile = actor.OccupiesSpace as Mobile;
|
||||||
var isMovable = mobile != null && !mobile.IsTraitDisabled && !mobile.IsTraitPaused && !mobile.RequireForceMove;
|
var isMovable = mobile != null && !mobile.IsTraitDisabled && !mobile.IsTraitPaused && !mobile.IsImmovable;
|
||||||
var isMoving = isMovable && mobile.CurrentMovementTypes.HasMovementType(MovementType.Horizontal);
|
var isMoving = isMovable && mobile.CurrentMovementTypes.HasMovementType(MovementType.Horizontal);
|
||||||
|
|
||||||
if (crushables.Any())
|
if (crushables.Any())
|
||||||
|
|||||||
@@ -332,6 +332,7 @@ JUGG:
|
|||||||
Mobile:
|
Mobile:
|
||||||
Speed: 71
|
Speed: 71
|
||||||
TurnSpeed: 5
|
TurnSpeed: 5
|
||||||
|
ImmovableCondition: !undeployed
|
||||||
RequireForceMoveCondition: !undeployed
|
RequireForceMoveCondition: !undeployed
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
RequiresCondition: !inside-tunnel
|
RequiresCondition: !inside-tunnel
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ TTNK:
|
|||||||
Mobile:
|
Mobile:
|
||||||
TurnSpeed: 5
|
TurnSpeed: 5
|
||||||
Speed: 85
|
Speed: 85
|
||||||
|
ImmovableCondition: !undeployed
|
||||||
RequireForceMoveCondition: !undeployed
|
RequireForceMoveCondition: !undeployed
|
||||||
Health:
|
Health:
|
||||||
HP: 35000
|
HP: 35000
|
||||||
@@ -232,6 +233,7 @@ ART2:
|
|||||||
Mobile:
|
Mobile:
|
||||||
Speed: 71
|
Speed: 71
|
||||||
TurnSpeed: 2
|
TurnSpeed: 2
|
||||||
|
ImmovableCondition: !undeployed
|
||||||
RequireForceMoveCondition: !undeployed
|
RequireForceMoveCondition: !undeployed
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
RequiresCondition: !inside-tunnel
|
RequiresCondition: !inside-tunnel
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ LPST:
|
|||||||
Mobile:
|
Mobile:
|
||||||
Speed: 85
|
Speed: 85
|
||||||
TurnSpeed: 5
|
TurnSpeed: 5
|
||||||
|
ImmovableCondition: !undeployed
|
||||||
RequireForceMoveCondition: !undeployed
|
RequireForceMoveCondition: !undeployed
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
RequiresCondition: !inside-tunnel && undeployed
|
RequiresCondition: !inside-tunnel && undeployed
|
||||||
|
|||||||
Reference in New Issue
Block a user