Move ChildActivity handling into base Activity class.
This commit is contained in:
@@ -39,12 +39,6 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
return this;
|
||||
}
|
||||
|
||||
if (IsCanceling)
|
||||
return NextActivity;
|
||||
|
||||
@@ -59,16 +53,16 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
return NextActivity;
|
||||
|
||||
// Add a CloseEnough range of 512 to the Rearm/Repair activities in order to ensure that we're at the host actor
|
||||
QueueChild(self, new MoveAdjacentTo(self, Target.FromActor(rearmTarget)), true);
|
||||
QueueChild(self, movement.MoveTo(self.World.Map.CellContaining(rearmTarget.CenterPosition), rearmTarget));
|
||||
QueueChild(self, new Resupply(self, rearmTarget, new WDist(512)));
|
||||
QueueChild(new MoveAdjacentTo(self, Target.FromActor(rearmTarget)));
|
||||
QueueChild(movement.MoveTo(self.World.Map.CellContaining(rearmTarget.CenterPosition), rearmTarget));
|
||||
QueueChild(new Resupply(self, rearmTarget, new WDist(512)));
|
||||
return this;
|
||||
}
|
||||
|
||||
if ((minefield == null || minefield.Contains(self.Location)) && ShouldLayMine(self, self.Location))
|
||||
{
|
||||
LayMine(self);
|
||||
QueueChild(self, new Wait(20), true); // A little wait after placing each mine, for show
|
||||
QueueChild(new Wait(20)); // A little wait after placing each mine, for show
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -80,7 +74,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
var p = minefield.Random(self.World.SharedRandom);
|
||||
if (ShouldLayMine(self, p))
|
||||
{
|
||||
QueueChild(self, movement.MoveTo(p, 0), true);
|
||||
QueueChild(movement.MoveTo(p, 0));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,18 +72,9 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (canceled)
|
||||
return NextActivity;
|
||||
|
||||
// Correct the visual position after we jumped
|
||||
if (jumpComplete)
|
||||
{
|
||||
if (ChildActivity == null)
|
||||
return NextActivity;
|
||||
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
return this;
|
||||
}
|
||||
if (canceled || jumpComplete)
|
||||
return NextActivity;
|
||||
|
||||
if (target.Type != TargetType.Invalid)
|
||||
targetPosition = target.CenterPosition;
|
||||
@@ -106,9 +97,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
attack.DoAttack(self, target);
|
||||
|
||||
jumpComplete = true;
|
||||
QueueChild(self, mobile.VisualMove(self, position, self.World.Map.CenterOfSubCell(destinationCell, destinationSubCell)), true);
|
||||
|
||||
return this;
|
||||
QueueChild(mobile.VisualMove(self, position, self.World.Map.CenterOfSubCell(destinationCell, destinationSubCell)));
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
@@ -74,13 +74,6 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
// Run this even if the target became invalid to avoid visual glitches
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
return this;
|
||||
}
|
||||
|
||||
if (IsCanceling)
|
||||
return NextActivity;
|
||||
|
||||
@@ -114,7 +107,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
if (!allowMovement || lastVisibleMaxRange == WDist.Zero || lastVisibleMaxRange < lastVisibleMinRange)
|
||||
return NextActivity;
|
||||
|
||||
QueueChild(self, mobile.MoveWithinRange(target, lastVisibleMinRange, lastVisibleMaxRange, checkTarget.CenterPosition, Color.Red), true);
|
||||
QueueChild(mobile.MoveWithinRange(target, lastVisibleMinRange, lastVisibleMaxRange, checkTarget.CenterPosition, Color.Red));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -144,11 +137,11 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
var desiredFacing = (destination - origin).Yaw.Facing;
|
||||
if (mobile.Facing != desiredFacing)
|
||||
{
|
||||
QueueChild(self, new Turn(self, desiredFacing), true);
|
||||
QueueChild(new Turn(self, desiredFacing));
|
||||
return this;
|
||||
}
|
||||
|
||||
QueueChild(self, new Leap(self, target, mobile, targetMobile, info.Speed.Length, attack, edible), true);
|
||||
QueueChild(new Leap(self, target, mobile, targetMobile, info.Speed.Length, attack, edible));
|
||||
|
||||
// Re-queue the child activities to kill the target if it didn't die in one go
|
||||
return this;
|
||||
|
||||
@@ -96,13 +96,6 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
if (IsCanceling || !attack.CanAttack(self, target))
|
||||
return NextActivity;
|
||||
|
||||
@@ -115,8 +108,8 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
if (!string.IsNullOrEmpty(attack.info.ChargeAudio))
|
||||
Game.Sound.Play(SoundType.World, attack.info.ChargeAudio, self.CenterPosition);
|
||||
|
||||
QueueChild(self, new Wait(attack.info.InitialChargeDelay), true);
|
||||
QueueChild(self, new ChargeFire(attack, target));
|
||||
QueueChild(new Wait(attack.info.InitialChargeDelay));
|
||||
QueueChild(new ChargeFire(attack, target));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -154,13 +147,6 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
if (IsCanceling || !attack.CanAttack(self, target))
|
||||
return NextActivity;
|
||||
|
||||
@@ -169,7 +155,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
|
||||
attack.DoAttack(self, target);
|
||||
|
||||
QueueChild(self, new Wait(attack.info.ChargeDelay), true);
|
||||
QueueChild(new Wait(attack.info.ChargeDelay));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user