Move ChildActivity handling into base Activity class.
This commit is contained in:
@@ -33,12 +33,13 @@ namespace OpenRA.Mods.Common.Activities
|
||||
conditionManager = self.TraitOrDefault<ConditionManager>();
|
||||
attackMove = self.TraitOrDefault<AttackMove>();
|
||||
isAssaultMove = assaultMoving;
|
||||
ChildHasPriority = false;
|
||||
}
|
||||
|
||||
protected override void OnFirstRun(Actor self)
|
||||
{
|
||||
// Start moving.
|
||||
QueueChild(self, getInner());
|
||||
QueueChild(getInner());
|
||||
|
||||
if (conditionManager == null || attackMove == null)
|
||||
return;
|
||||
@@ -64,21 +65,18 @@ namespace OpenRA.Mods.Common.Activities
|
||||
foreach (var ab in attackBases)
|
||||
{
|
||||
var activity = ab.GetAttackActivity(self, target, true, false);
|
||||
QueueChild(self, activity);
|
||||
QueueChild(activity);
|
||||
ab.OnQueueAttackActivity(self, activity, target, true, false);
|
||||
}
|
||||
|
||||
// Make sure to continue moving when the attack activities have finished.
|
||||
QueueChild(self, getInner());
|
||||
QueueChild(getInner());
|
||||
}
|
||||
}
|
||||
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
return this;
|
||||
|
||||
// The last queued childactivity is guaranteed to be the inner move, so if we get here it means
|
||||
// we have reached our destination and there are no more enemies on our path.
|
||||
|
||||
@@ -47,13 +47,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
if (IsCanceling)
|
||||
return NextActivity;
|
||||
|
||||
@@ -90,7 +83,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// Move into range
|
||||
wasMovingWithinRange = true;
|
||||
QueueChild(self, move.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, targetLineColor), true);
|
||||
QueueChild(move.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, targetLineColor));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,17 +146,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
// Let the child be run so that units will not end up in an odd place.
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
|
||||
// Child activities such as Turn might have finished.
|
||||
// If we "return this" in this situation, the unit loses one tick and pauses movement briefly.
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
// If the actor is inside a tunnel then we must let them move
|
||||
// all the way through before moving to the next activity
|
||||
if (IsCanceling && self.Location.Layer != CustomMovementLayerType.Tunnel)
|
||||
@@ -188,7 +177,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
path.Add(nextCell.Value.First);
|
||||
|
||||
QueueChild(self, new Turn(self, firstFacing), true);
|
||||
QueueChild(new Turn(self, firstFacing));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -202,7 +191,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var to = Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) +
|
||||
(map.Grid.OffsetOfSubCell(mobile.FromSubCell) + map.Grid.OffsetOfSubCell(mobile.ToSubCell)) / 2;
|
||||
|
||||
QueueChild(self, new MoveFirstHalf(this, from, to, mobile.Facing, mobile.Facing, 0), true);
|
||||
QueueChild(new MoveFirstHalf(this, from, to, mobile.Facing, mobile.Facing, 0));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -335,7 +324,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (ret == this)
|
||||
return ret;
|
||||
|
||||
Queue(self, ret);
|
||||
Queue(ret);
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
Mobile = self.Trait<Mobile>();
|
||||
pathFinder = self.World.WorldActor.Trait<IPathFinder>();
|
||||
domainIndex = self.World.WorldActor.Trait<DomainIndex>();
|
||||
ChildHasPriority = false;
|
||||
|
||||
// The target may become hidden between the initial order request and the first tick (e.g. if queued)
|
||||
// Moving to any position (even if quite stale) is still better than immediately giving up
|
||||
@@ -81,7 +82,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
protected override void OnFirstRun(Actor self)
|
||||
{
|
||||
QueueChild(self, Mobile.MoveTo(() => CalculatePathToTarget(self)));
|
||||
QueueChild(Mobile.MoveTo(() => CalculatePathToTarget(self)));
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
@@ -116,7 +117,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// Target has moved, and MoveAdjacentTo is still valid.
|
||||
if (!IsCanceling && shouldRepath)
|
||||
QueueChild(self, Mobile.MoveTo(() => CalculatePathToTarget(self)));
|
||||
QueueChild(Mobile.MoveTo(() => CalculatePathToTarget(self)));
|
||||
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
|
||||
@@ -37,13 +37,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
if (IsCanceling || target.Type == TargetType.Invalid)
|
||||
return NextActivity;
|
||||
|
||||
@@ -64,7 +57,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
var turn = ActivityUtils.RunActivity(self, new Turn(self, facing));
|
||||
if (turn != null)
|
||||
QueueChild(self, turn);
|
||||
QueueChild(turn);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user