Replaced Canceled state with Canceling state.

This commit is contained in:
tovl
2019-03-03 01:57:17 +01:00
committed by Paul Chote
parent 8191a6566b
commit a17cd0fa06
43 changed files with 74 additions and 108 deletions

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Activities namespace OpenRA.Activities
{ {
public enum ActivityState { Queued, Active, Done, Canceled } public enum ActivityState { Queued, Active, Canceling, Done }
/* /*
* Activities are actions carried out by actors during each tick. * Activities are actions carried out by actors during each tick.
@@ -99,7 +99,7 @@ namespace OpenRA.Activities
{ {
get get
{ {
return childActivity != null && childActivity.State != ActivityState.Done ? childActivity : null; return childActivity != null && childActivity.State < ActivityState.Done ? childActivity : null;
} }
set set
@@ -153,7 +153,7 @@ namespace OpenRA.Activities
} }
public bool IsInterruptible { get; protected set; } public bool IsInterruptible { get; protected set; }
public bool IsCanceled { get { return State == ActivityState.Canceled; } } public bool IsCanceling { get { return State == ActivityState.Canceling; } }
public Activity() public Activity()
{ {
@@ -179,8 +179,7 @@ namespace OpenRA.Activities
if (ParentActivity != null && ParentActivity != ret) if (ParentActivity != null && ParentActivity != ret)
ParentActivity.ChildActivity = ret; ParentActivity.ChildActivity = ret;
if (State != ActivityState.Canceled) State = ActivityState.Done;
State = ActivityState.Done;
OnLastRun(self); OnLastRun(self);
} }
@@ -220,16 +219,16 @@ namespace OpenRA.Activities
public virtual bool Cancel(Actor self, bool keepQueue = false) public virtual bool Cancel(Actor self, bool keepQueue = false)
{ {
if (!keepQueue)
NextInQueue = null;
if (!IsInterruptible) if (!IsInterruptible)
return false; return false;
if (ChildActivity != null && !ChildActivity.Cancel(self)) if (ChildActivity != null)
return false; ChildActivity.Cancel(self);
if (!keepQueue) State = ActivityState.Canceling;
NextActivity = null;
State = ActivityState.Canceled;
return true; return true;
} }

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
if (rearmableInfo != null && ammoPools.Any(p => p.Info.Name == info.AmmoPoolName && !p.HasAmmo())) if (rearmableInfo != null && ammoPools.Any(p => p.Info.Name == info.AmmoPoolName && !p.HasAmmo()))

View File

@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Cnc.Activities
return this; return this;
} }
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
bool targetIsHiddenActor; bool targetIsHiddenActor;

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Cnc.Traits
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled || !target.IsValidFor(self)) if (IsCanceling || !target.IsValidFor(self))
return NextActivity; return NextActivity;
if (attack.IsTraitDisabled) if (attack.IsTraitDisabled)

View File

@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Cnc.Traits
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled || !attack.CanAttack(self, target)) if (IsCanceling || !attack.CanAttack(self, target))
return NextActivity; return NextActivity;
if (attack.charges == 0) if (attack.charges == 0)
@@ -120,7 +120,7 @@ namespace OpenRA.Mods.Cnc.Traits
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled || !attack.CanAttack(self, target)) if (IsCanceling || !attack.CanAttack(self, target))
return NextActivity; return NextActivity;
if (attack.charges == 0) if (attack.charges == 0)

View File

@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Activities
if (aircraft.ForceLanding) if (aircraft.ForceLanding)
Cancel(self); Cancel(self);
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
bool targetIsHiddenActor; bool targetIsHiddenActor;

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Activities
if (aircraft.ForceLanding) if (aircraft.ForceLanding)
Cancel(self); Cancel(self);
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
bool targetIsHiddenActor; bool targetIsHiddenActor;

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Activities
return NextActivity; return NextActivity;
} }
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
if (remainingTicks > 0) if (remainingTicks > 0)

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Activities
if (aircraft.ForceLanding) if (aircraft.ForceLanding)
Cancel(self); Cancel(self);
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
bool targetIsHiddenActor; bool targetIsHiddenActor;

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Activities
return NextActivity; return NextActivity;
} }
if (IsCanceled || !self.World.Map.Contains(self.Location)) if (IsCanceling || !self.World.Map.Contains(self.Location))
return NextActivity; return NextActivity;
Fly.FlyToward(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude); Fly.FlyToward(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude);

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Activities
return NextActivity; return NextActivity;
} }
if (IsCanceled || remainingTicks-- == 0) if (IsCanceling || remainingTicks-- == 0)
return NextActivity; return NextActivity;
Fly.FlyToward(self, aircraft, aircraft.Facing, cruiseAltitude); Fly.FlyToward(self, aircraft, aircraft.Facing, cruiseAltitude);

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Activities
if (aircraft.ForceLanding) if (aircraft.ForceLanding)
Cancel(self); Cancel(self);
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
bool targetIsHiddenActor; bool targetIsHiddenActor;

View File

@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Activities
if (aircraft.ForceLanding) if (aircraft.ForceLanding)
Cancel(self); Cancel(self);
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
bool targetIsHiddenActor; bool targetIsHiddenActor;
@@ -156,7 +156,7 @@ namespace OpenRA.Mods.Common.Activities
{ {
var activity = base.Tick(self); var activity = base.Tick(self);
if (activity == null && !IsCanceled && info.LandWhenIdle) if (activity == null && !IsCanceling && info.LandWhenIdle)
{ {
if (info.TurnToLand) if (info.TurnToLand)
self.QueueActivity(new Turn(self, info.InitialFacing)); self.QueueActivity(new Turn(self, info.InitialFacing));

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Activities
return NextActivity; return NextActivity;
} }
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
if (HeliFly.AdjustAltitude(self, aircraft, aircraft.Info.CruiseAltitude)) if (HeliFly.AdjustAltitude(self, aircraft, aircraft.Info.CruiseAltitude))

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
if (requireSpace && !aircraft.CanLand(self.Location)) if (requireSpace && !aircraft.CanLand(self.Location))

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Activities
if (aircraft.ForceLanding) if (aircraft.ForceLanding)
return NextActivity; return NextActivity;
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
if (dest == null || dest.IsDead || !Reservable.IsAvailableFor(dest, self)) if (dest == null || dest.IsDead || !Reservable.IsAvailableFor(dest, self))

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Activities
if (!target.IsValidFor(self)) if (!target.IsValidFor(self))
Cancel(self); Cancel(self);
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
if (!soundPlayed && aircraft.Info.LandingSounds.Length > 0 && !self.IsAtGroundLevel()) if (!soundPlayed && aircraft.Info.LandingSounds.Length > 0 && !self.IsAtGroundLevel())

View File

@@ -51,11 +51,8 @@ namespace OpenRA.Mods.Common.Activities
} }
// Conditional fixes being able to stop aircraft from resupplying. // Conditional fixes being able to stop aircraft from resupplying.
if (IsCanceled && NextInQueue == null) if (IsCanceling && NextInQueue == null)
{ return new ResupplyAircraft(self);
OnFirstRun(self);
return this;
}
return NextActivity; return NextActivity;
} }

View File

@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Activities
if (aircraft.ForceLanding) if (aircraft.ForceLanding)
return NextActivity; return NextActivity;
if (IsCanceled || self.IsDead) if (IsCanceling || self.IsDead)
return NextActivity; return NextActivity;
if (!isCalculated) if (!isCalculated)

View File

@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
bool targetIsHiddenActor; bool targetIsHiddenActor;
@@ -145,7 +145,7 @@ namespace OpenRA.Mods.Common.Activities
protected virtual AttackStatus TickAttack(Actor self, AttackFrontal attack) protected virtual AttackStatus TickAttack(Actor self, AttackFrontal attack)
{ {
if (IsCanceled) if (IsCanceling)
return AttackStatus.UnableToAttack; return AttackStatus.UnableToAttack;
if (!target.IsValidFor(self)) if (!target.IsValidFor(self))

View File

@@ -83,7 +83,7 @@ namespace OpenRA.Mods.Common.Activities
return this; return this;
} }
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
if ((carryall.State == Carryall.CarryallState.Idle || carryall.Carryable.IsDead) && state != DeliveryState.TakeOff) if ((carryall.State == Carryall.CarryallState.Idle || carryall.Carryable.IsDead) && state != DeliveryState.TakeOff)
@@ -208,8 +208,8 @@ namespace OpenRA.Mods.Common.Activities
public override bool Cancel(Actor self, bool keepQueue = false) public override bool Cancel(Actor self, bool keepQueue = false)
{ {
if (!IsCanceled && innerActivity != null && !innerActivity.Cancel(self)) if (!IsCanceling && innerActivity != null)
return false; innerActivity.Cancel(self);
return base.Cancel(self); return base.Cancel(self);
} }

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Activities
} }
// Without this, turn for facing deploy angle will be canceled and immediately deploy! // Without this, turn for facing deploy angle will be canceled and immediately deploy!
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
if (IsInterruptible) if (IsInterruptible)

View File

@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Common.Activities
useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self); useLastVisibleTarget = targetIsHiddenActor || !target.IsValidFor(self);
// Cancel immediately if the target died while we were entering it // Cancel immediately if the target died while we were entering it
if (!IsCanceled && useLastVisibleTarget && lastState == EnterState.Entering) if (!IsCanceling && useLastVisibleTarget && lastState == EnterState.Entering)
Cancel(self, true); Cancel(self, true);
TickInner(self, target, useLastVisibleTarget); TickInner(self, target, useLastVisibleTarget);
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Activities
{ {
// NOTE: We can safely cancel in this case because we know the // NOTE: We can safely cancel in this case because we know the
// actor has finished any in-progress move activities // actor has finished any in-progress move activities
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
// Lost track of the target // Lost track of the target
@@ -134,7 +134,7 @@ namespace OpenRA.Mods.Common.Activities
// Subclasses can cancel the activity during TryStartEnter // Subclasses can cancel the activity during TryStartEnter
// Return immediately to avoid an extra tick's delay // Return immediately to avoid an extra tick's delay
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
lastState = EnterState.Waiting; lastState = EnterState.Waiting;
@@ -145,7 +145,7 @@ namespace OpenRA.Mods.Common.Activities
{ {
// Check that we reached the requested position // Check that we reached the requested position
var targetPos = target.Positions.PositionClosestTo(self.CenterPosition); var targetPos = target.Positions.PositionClosestTo(self.CenterPosition);
if (!IsCanceled && self.CenterPosition == targetPos && target.Type == TargetType.Actor) if (!IsCanceling && self.CenterPosition == targetPos && target.Type == TargetType.Actor)
OnEnterComplete(self, target.Actor); OnEnterComplete(self, target.Actor);
lastState = EnterState.Exiting; lastState = EnterState.Exiting;
@@ -164,8 +164,8 @@ namespace OpenRA.Mods.Common.Activities
{ {
OnCancel(self); OnCancel(self);
if (!IsCanceled && moveActivity != null && !moveActivity.Cancel(self)) if (!IsCanceling && moveActivity != null)
return false; moveActivity.Cancel(self);
return base.Cancel(self, keepQueue); return base.Cancel(self, keepQueue);
} }

View File

@@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Activities
} }
// Try and find a new transport nearby // Try and find a new transport nearby
if (IsCanceled || string.IsNullOrEmpty(type)) if (IsCanceling || string.IsNullOrEmpty(type))
return NextActivity; return NextActivity;
Func<Actor, bool> isValidTransport = a => Func<Actor, bool> isValidTransport = a =>
@@ -135,8 +135,8 @@ namespace OpenRA.Mods.Common.Activities
public override bool Cancel(Actor self, bool keepQueue = false) public override bool Cancel(Actor self, bool keepQueue = false)
{ {
if (!IsCanceled && enterTransport != null && !enterTransport.Cancel(self)) if (!IsCanceling && enterTransport != null)
return false; enterTransport.Cancel(self);
return base.Cancel(self, keepQueue); return base.Cancel(self, keepQueue);
} }

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
if (harv.IsFull) if (harv.IsFull)

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled) if (IsCanceling)
{ {
claimLayer.RemoveClaim(self); claimLayer.RemoveClaim(self);
return NextActivity; return NextActivity;

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
var target = targets.ClosestTo(self); var target = targets.ClosestTo(self);

View File

@@ -48,8 +48,8 @@ namespace OpenRA.Mods.Common.Activities
public override bool Cancel(Actor self, bool keepQueue = false) public override bool Cancel(Actor self, bool keepQueue = false)
{ {
if (!IsCanceled && inner != null && !inner.Cancel(self)) if (!IsCanceling && inner != null)
return false; inner.Cancel(self);
return base.Cancel(self, keepQueue); return base.Cancel(self, keepQueue);
} }

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
bool targetIsHiddenActor; bool targetIsHiddenActor;

View File

@@ -144,37 +144,9 @@ namespace OpenRA.Mods.Common.Activities
} }
} }
public override bool Cancel(Actor self, bool keepQueue = false)
{
if (ChildActivity == null)
return base.Cancel(self, keepQueue);
// Although MoveFirstHalf and MoveSecondHalf can't be interrupted,
// we prevent them from moving forever by removing the path.
if (path != null)
path.Clear();
// Remove queued activities
if (!keepQueue && NextInQueue != null)
NextInQueue = null;
// In current implementation, ChildActivity can be Turn, MoveFirstHalf and MoveSecondHalf.
// Turn may be interrupted freely while they are turning.
// Unlike Turn, MoveFirstHalf and MoveSecondHalf are not Interruptable, but clearing the
// path guarantees that they will return as soon as possible, once the actor is back in a
// valid position.
// This means that it is safe to unconditionally return true, which avoids breaking parent
// activities that rely on cancellation succeeding (but not necessarily immediately)
ChildActivity.Cancel(self, false);
return true;
}
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
// ChildActivity is the top priority, unlike other activities. // Let the child be run so that units will not end up in an odd place.
// Even if this activity is canceled, we must let the child be run so that units
// will not end up in an odd place.
if (ChildActivity != null) if (ChildActivity != null)
{ {
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity); ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
@@ -187,7 +159,7 @@ namespace OpenRA.Mods.Common.Activities
// If the actor is inside a tunnel then we must let them move // If the actor is inside a tunnel then we must let them move
// all the way through before moving to the next activity // all the way through before moving to the next activity
if (IsCanceled && self.Location.Layer != CustomMovementLayerType.Tunnel) if (IsCanceling && self.Location.Layer != CustomMovementLayerType.Tunnel)
return NextActivity; return NextActivity;
if (mobile.IsTraitDisabled || mobile.IsTraitPaused) if (mobile.IsTraitDisabled || mobile.IsTraitPaused)
@@ -440,7 +412,7 @@ namespace OpenRA.Mods.Common.Activities
var fromSubcellOffset = map.Grid.OffsetOfSubCell(mobile.FromSubCell); var fromSubcellOffset = map.Grid.OffsetOfSubCell(mobile.FromSubCell);
var toSubcellOffset = map.Grid.OffsetOfSubCell(mobile.ToSubCell); var toSubcellOffset = map.Grid.OffsetOfSubCell(mobile.ToSubCell);
if (!IsCanceled || self.Location.Layer == CustomMovementLayerType.Tunnel) if (!IsCanceling || self.Location.Layer == CustomMovementLayerType.Tunnel)
{ {
var nextCell = parent.PopPath(self); var nextCell = parent.PopPath(self);
if (nextCell != null) if (nextCell != null)

View File

@@ -115,7 +115,7 @@ namespace OpenRA.Mods.Common.Activities
{ {
// We are done here if the order was cancelled for any // We are done here if the order was cancelled for any
// reason except the target moving. // reason except the target moving.
if (IsCanceled || !repath || !targetIsValid) if (IsCanceling || !repath || !targetIsValid)
return NextActivity; return NextActivity;
// Target has moved, and MoveAdjacentTo is still valid. // Target has moved, and MoveAdjacentTo is still valid.
@@ -169,8 +169,8 @@ namespace OpenRA.Mods.Common.Activities
public override bool Cancel(Actor self, bool keepQueue = false) public override bool Cancel(Actor self, bool keepQueue = false)
{ {
if (!IsCanceled && inner != null && !inner.Cancel(self)) if (!IsCanceling && inner != null)
return false; inner.Cancel(self);
return base.Cancel(self); return base.Cancel(self);
} }

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Activities
return this; return this;
} }
if (IsCanceled || target.Type == TargetType.Invalid) if (IsCanceling || target.Type == TargetType.Invalid)
return NextActivity; return NextActivity;
if (mobile.IsTraitDisabled || mobile.IsTraitPaused) if (mobile.IsTraitDisabled || mobile.IsTraitPaused)

View File

@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Activities
if (cargo != carryall.Carryable) if (cargo != carryall.Carryable)
return NextActivity; return NextActivity;
if (cargo.IsDead || IsCanceled || carryable.IsTraitDisabled || !cargo.AppearsFriendlyTo(self)) if (cargo.IsDead || IsCanceling || carryable.IsTraitDisabled || !cargo.AppearsFriendlyTo(self))
{ {
carryall.UnreserveCarryable(self); carryall.UnreserveCarryable(self);
return NextActivity; return NextActivity;
@@ -161,8 +161,8 @@ namespace OpenRA.Mods.Common.Activities
public override bool Cancel(Actor self, bool keepQueue = false) public override bool Cancel(Actor self, bool keepQueue = false)
{ {
if (!IsCanceled && innerActivity != null && !innerActivity.Cancel(self)) if (!IsCanceling && innerActivity != null)
return false; innerActivity.Cancel(self);
return base.Cancel(self, keepQueue); return base.Cancel(self, keepQueue);
} }

View File

@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
if (host.Type == TargetType.Invalid) if (host.Type == TargetType.Invalid)

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Activities
{ {
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled) return NextActivity; if (IsCanceling) return NextActivity;
self.Dispose(); self.Dispose();
return null; return null;
} }

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled) if (IsCanceling)
{ {
if (remainingTicks-- == 0) if (remainingTicks-- == 0)
return NextActivity; return NextActivity;

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled) if (IsCanceling)
return NextActivity; return NextActivity;
if (ChildActivity != null) if (ChildActivity != null)
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Activities
protected override void OnLastRun(Actor self) protected override void OnLastRun(Actor self)
{ {
if (!IsCanceled) if (!IsCanceling)
DoTransform(self); DoTransform(self);
} }

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsInterruptible && IsCanceled) if (IsInterruptible && IsCanceling)
return NextActivity; return NextActivity;
if (disablable != null && disablable.IsTraitDisabled) if (disablable != null && disablable.IsTraitDisabled)

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
cargo.Unloading = false; cargo.Unloading = false;
if (IsCanceled || cargo.IsEmpty(self)) if (IsCanceling || cargo.IsEmpty(self))
return NextActivity; return NextActivity;
foreach (var inu in notifiers) foreach (var inu in notifiers)

View File

@@ -43,8 +43,8 @@ namespace OpenRA.Mods.Common.Activities
public override bool Cancel(Actor self, bool keepQueue = false) public override bool Cancel(Actor self, bool keepQueue = false)
{ {
if (!IsCanceled && inner != null && !inner.Cancel(self)) if (!IsCanceling && inner != null)
return false; inner.Cancel(self);
return base.Cancel(self, keepQueue); return base.Cancel(self, keepQueue);
} }

View File

@@ -45,9 +45,7 @@ namespace OpenRA.Mods.Common.Activities
public override bool Cancel(Actor self, bool keepQueue = false) public override bool Cancel(Actor self, bool keepQueue = false)
{ {
if (!base.Cancel(self, keepQueue)) base.Cancel(self, keepQueue);
return false;
Dispose(); Dispose();
return true; return true;
} }

View File

@@ -176,7 +176,7 @@ namespace OpenRA.Mods.Common.Traits
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled) if (IsCanceling)
{ {
// Cancel the requested target, but keep firing on it while in range // Cancel the requested target, but keep firing on it while in range
attack.opportunityTarget = attack.requestedTarget; attack.opportunityTarget = attack.requestedTarget;

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits
// This activity can't move to reacquire hidden targets, so use the // This activity can't move to reacquire hidden targets, so use the
// Recalculate overload that invalidates hidden targets. // Recalculate overload that invalidates hidden targets.
target = target.RecalculateInvalidatingHiddenTargets(self.Owner); target = target.RecalculateInvalidatingHiddenTargets(self.Owner);
if (IsCanceled || !target.IsValidFor(self) || !attack.IsReachableTarget(target, allowMove)) if (IsCanceling || !target.IsValidFor(self) || !attack.IsReachableTarget(target, allowMove))
return NextActivity; return NextActivity;
attack.DoAttack(self, target); attack.DoAttack(self, target);