Make Tick return bool

This commit is contained in:
tovl
2019-05-14 21:13:25 +02:00
committed by teinarss
parent 09c1611239
commit 3790169db9
49 changed files with 328 additions and 318 deletions

View File

@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Activities
/// </summary>
protected virtual void OnEnterComplete(Actor self, Actor targetActor) { }
public override Activity Tick(Actor self)
public override bool Tick(Actor self)
{
// Update our view of the target
bool targetIsHiddenActor;
@@ -81,9 +81,8 @@ namespace OpenRA.Mods.Common.Activities
// We need to wait for movement to finish before transitioning to
// the next state or next activity
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
if (ChildActivity != null)
return this;
if (!TickChild(self))
return false;
// Note that lastState refers to what we have just *finished* doing
switch (lastState)
@@ -93,11 +92,11 @@ namespace OpenRA.Mods.Common.Activities
// NOTE: We can safely cancel in this case because we know the
// actor has finished any in-progress move activities
if (IsCanceling)
return NextActivity;
return true;
// Lost track of the target
if (useLastVisibleTarget && lastVisibleTarget.Type == TargetType.Invalid)
return NextActivity;
return true;
// We are not next to the target - lets fix that
if (target.Type != TargetType.Invalid && !move.CanEnterTargetNow(self, target))
@@ -105,28 +104,28 @@ namespace OpenRA.Mods.Common.Activities
// Target lines are managed by this trait, so we do not pass targetLineColor
var initialTargetPosition = (useLastVisibleTarget ? lastVisibleTarget : target).CenterPosition;
QueueChild(move.MoveToTarget(self, target, initialTargetPosition));
return this;
return false;
}
// We are next to where we thought the target should be, but it isn't here
// There's not much more we can do here
if (useLastVisibleTarget || target.Type != TargetType.Actor)
return NextActivity;
return true;
// Are we ready to move into the target?
if (TryStartEnter(self, target.Actor))
{
lastState = EnterState.Entering;
QueueChild(move.MoveIntoTarget(self, target));
return this;
return false;
}
// Subclasses can cancel the activity during TryStartEnter
// Return immediately to avoid an extra tick's delay
if (IsCanceling)
return NextActivity;
return true;
return this;
return false;
}
case EnterState.Entering:
@@ -138,14 +137,14 @@ namespace OpenRA.Mods.Common.Activities
lastState = EnterState.Exiting;
QueueChild(move.MoveIntoWorld(self, self.Location));
return this;
return false;
}
case EnterState.Exiting:
return NextActivity;
return true;
}
return this;
return false;
}
}
}