Allow cancelling an activity without aborting the entire queue

This commit is contained in:
Oliver Brakmann
2017-03-05 21:43:11 +01:00
committed by Paul Chote
parent 3111b2cf9b
commit f9951f76ca
11 changed files with 23 additions and 21 deletions

View File

@@ -201,7 +201,7 @@ namespace OpenRA.Activities
/// </summary>
protected virtual void OnLastRun(Actor self) { }
public virtual bool Cancel(Actor self)
public virtual bool Cancel(Actor self, bool keepQueue = false)
{
if (!IsInterruptible)
return false;
@@ -209,9 +209,11 @@ namespace OpenRA.Activities
if (ChildActivity != null && !ChildActivity.Cancel(self))
return false;
State = ActivityState.Canceled;
NextActivity = null;
if (!keepQueue)
NextActivity = null;
ChildActivity = null;
State = ActivityState.Canceled;
return true;
}

View File

@@ -207,7 +207,7 @@ namespace OpenRA.Mods.Common.Activities
});
}
public override bool Cancel(Actor self)
public override bool Cancel(Actor self, bool keepQueue = false)
{
if (!IsCanceled && innerActivity != null && !innerActivity.Cancel(self))
return false;

View File

@@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Activities
inner.Cancel(self);
}
public override bool Cancel(Actor self)
public override bool Cancel(Actor self, bool keepQueue = false)
{
AbortOrExit(self);
if (nextState < EnterState.Exiting)

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Activities
throw new InvalidOperationException("Invalid harvester dock state");
}
public override bool Cancel(Actor self)
public override bool Cancel(Actor self, bool keepQueue = false)
{
dockingState = DockingState.Undock;
return base.Cancel(self);

View File

@@ -46,12 +46,12 @@ namespace OpenRA.Mods.Common.Activities
return this;
}
public override bool Cancel(Actor self)
public override bool Cancel(Actor self, bool keepQueue = false)
{
if (!IsCanceled && inner != null && !inner.Cancel(self))
return false;
return base.Cancel(self);
return base.Cancel(self, keepQueue);
}
public override IEnumerable<Target> GetTargets(Actor self)

View File

@@ -334,9 +334,9 @@ namespace OpenRA.Mods.Common.Activities
}
}
public override bool Cancel(Actor self)
public override bool Cancel(Actor self, bool keepQueue = false)
{
Move.Cancel(self);
Move.Cancel(self, keepQueue);
return base.Cancel(self);
}

View File

@@ -161,7 +161,7 @@ namespace OpenRA.Mods.Common.Activities
return Target.None;
}
public override bool Cancel(Actor self)
public override bool Cancel(Actor self, bool keepQueue = false)
{
if (!IsCanceled && inner != null && !inner.Cancel(self))
return false;

View File

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

View File

@@ -30,9 +30,9 @@ namespace OpenRA.Mods.Common.Activities
return (remainingTicks-- == 0) ? NextActivity : this;
}
public override bool Cancel(Actor self)
public override bool Cancel(Actor self, bool keepQueue = false)
{
if (!base.Cancel(self))
if (!base.Cancel(self, keepQueue))
return false;
remainingTicks = 0;
@@ -56,9 +56,9 @@ namespace OpenRA.Mods.Common.Activities
return (f == null || f()) ? NextActivity : this;
}
public override bool Cancel(Actor self)
public override bool Cancel(Actor self, bool keepQueue = false)
{
if (!base.Cancel(self))
if (!base.Cancel(self, keepQueue))
return false;
f = null;

View File

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

View File

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