Ensure that we never tick an activity before calling OnFirstRun
This commit is contained in:
@@ -83,6 +83,7 @@ namespace OpenRA.Activities
|
|||||||
public bool ChildHasPriority { get; protected set; }
|
public bool ChildHasPriority { get; protected set; }
|
||||||
public bool IsCanceling { get { return State == ActivityState.Canceling; } }
|
public bool IsCanceling { get { return State == ActivityState.Canceling; } }
|
||||||
bool finishing;
|
bool finishing;
|
||||||
|
bool firstRunCompleted;
|
||||||
bool lastRun;
|
bool lastRun;
|
||||||
|
|
||||||
public Activity()
|
public Activity()
|
||||||
@@ -99,9 +100,13 @@ namespace OpenRA.Activities
|
|||||||
if (State == ActivityState.Queued)
|
if (State == ActivityState.Queued)
|
||||||
{
|
{
|
||||||
OnFirstRun(self);
|
OnFirstRun(self);
|
||||||
|
firstRunCompleted = true;
|
||||||
State = ActivityState.Active;
|
State = ActivityState.Active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!firstRunCompleted)
|
||||||
|
throw new InvalidOperationException("Actor {0} attempted to tick activity {1} before running its OnFirstRun method.".F(self, GetType()));
|
||||||
|
|
||||||
// Only run the parent tick when the child is done.
|
// Only run the parent tick when the child is done.
|
||||||
// We must always let the child finish on its own before continuing.
|
// We must always let the child finish on its own before continuing.
|
||||||
if (ChildHasPriority)
|
if (ChildHasPriority)
|
||||||
|
|||||||
Reference in New Issue
Block a user