Move ChildActivity handling into base Activity class.
This commit is contained in:
@@ -41,11 +41,13 @@ namespace OpenRA.Activities
|
||||
public Activity NextActivity { get; protected set; }
|
||||
|
||||
public bool IsInterruptible { get; protected set; }
|
||||
public bool ChildHasPriority { get; protected set; }
|
||||
public bool IsCanceling { get { return State == ActivityState.Canceling; } }
|
||||
|
||||
public Activity()
|
||||
{
|
||||
IsInterruptible = true;
|
||||
ChildHasPriority = true;
|
||||
}
|
||||
|
||||
public Activity TickOuter(Actor self)
|
||||
@@ -59,7 +61,18 @@ namespace OpenRA.Activities
|
||||
State = ActivityState.Active;
|
||||
}
|
||||
|
||||
if (ChildHasPriority)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
var ret = Tick(self);
|
||||
|
||||
if (ChildActivity != null && ChildActivity.State == ActivityState.Queued)
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
|
||||
if (ret != this)
|
||||
{
|
||||
State = ActivityState.Done;
|
||||
@@ -113,20 +126,20 @@ namespace OpenRA.Activities
|
||||
State = ActivityState.Canceling;
|
||||
}
|
||||
|
||||
public virtual void Queue(Actor self, Activity activity)
|
||||
public void Queue(Activity activity)
|
||||
{
|
||||
if (NextActivity != null)
|
||||
NextActivity.Queue(self, activity);
|
||||
NextActivity.Queue(activity);
|
||||
else
|
||||
NextActivity = activity;
|
||||
}
|
||||
|
||||
public virtual void QueueChild(Actor self, Activity activity, bool pretick = false)
|
||||
public void QueueChild(Activity activity)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
ChildActivity.Queue(self, activity);
|
||||
ChildActivity.Queue(activity);
|
||||
else
|
||||
ChildActivity = pretick ? ActivityUtils.RunActivity(self, activity) : activity;
|
||||
ChildActivity = activity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -187,15 +200,4 @@ namespace OpenRA.Activities
|
||||
yield return a;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ActivityExts
|
||||
{
|
||||
public static IEnumerable<Target> GetTargetQueue(this Actor self)
|
||||
{
|
||||
return self.CurrentActivity
|
||||
.Iterate(u => u.NextActivity)
|
||||
.TakeWhile(u => u != null)
|
||||
.SelectMany(u => u.GetTargets(self));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace OpenRA
|
||||
if (CurrentActivity == null)
|
||||
CurrentActivity = nextActivity;
|
||||
else
|
||||
CurrentActivity.Queue(this, nextActivity);
|
||||
CurrentActivity.Queue(nextActivity);
|
||||
}
|
||||
|
||||
public void CancelActivity()
|
||||
|
||||
@@ -51,10 +51,10 @@ namespace OpenRA.Traits
|
||||
return act;
|
||||
}
|
||||
|
||||
public static Activity SequenceActivities(Actor self, params Activity[] acts)
|
||||
public static Activity SequenceActivities(params Activity[] acts)
|
||||
{
|
||||
return acts.Reverse().Aggregate(
|
||||
(next, a) => { a.Queue(self, next); return a; });
|
||||
(next, a) => { a.Queue(next); return a; });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,19 +72,10 @@ 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)
|
||||
if (canceled || jumpComplete)
|
||||
return NextActivity;
|
||||
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
return this;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,13 +102,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;
|
||||
}
|
||||
|
||||
// Refuse to take off if it would land immediately again.
|
||||
if (aircraft.ForceLanding)
|
||||
Cancel(self);
|
||||
@@ -125,7 +118,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (aircraft.Info.CanHover && !skipHeightAdjustment && dat != aircraft.Info.CruiseAltitude)
|
||||
{
|
||||
if (dat <= aircraft.LandAltitude)
|
||||
QueueChild(self, new TakeOff(self, target), true);
|
||||
QueueChild(new TakeOff(self, target));
|
||||
else
|
||||
VerticalTakeOffOrLandTick(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude);
|
||||
|
||||
@@ -136,7 +129,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
}
|
||||
else if (dat <= aircraft.LandAltitude)
|
||||
{
|
||||
QueueChild(self, new TakeOff(self, target), true);
|
||||
QueueChild(new TakeOff(self, target));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,13 +65,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;
|
||||
}
|
||||
|
||||
// Refuse to take off if it would land immediately again.
|
||||
if (aircraft.ForceLanding)
|
||||
Cancel(self);
|
||||
@@ -121,7 +114,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// If all valid weapons have depleted their ammo and Rearmable trait exists, return to RearmActor to reload and then resume the activity
|
||||
if (rearmable != null && !useLastVisibleTarget && attackAircraft.Armaments.All(x => x.IsTraitPaused || !x.Weapon.IsValidAgainst(target, self.World, self)))
|
||||
{
|
||||
QueueChild(self, new ReturnToBase(self, aircraft.Info.AbortOnResupply), true);
|
||||
QueueChild(new ReturnToBase(self, aircraft.Info.AbortOnResupply));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -139,7 +132,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
}
|
||||
|
||||
// Fly towards the last known position
|
||||
QueueChild(self, new Fly(self, target, WDist.Zero, lastVisibleMaximumRange, checkTarget.CenterPosition, Color.Red), true);
|
||||
QueueChild(new Fly(self, target, WDist.Zero, lastVisibleMaximumRange, checkTarget.CenterPosition, Color.Red));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -148,21 +141,21 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var isAirborne = self.World.Map.DistanceAboveTerrain(pos).Length >= aircraft.Info.MinAirborneAltitude;
|
||||
|
||||
if (!isAirborne)
|
||||
QueueChild(self, new TakeOff(self), true);
|
||||
QueueChild(new TakeOff(self));
|
||||
|
||||
if (attackAircraft.Info.AttackType == AirAttackType.Strafe)
|
||||
{
|
||||
if (target.IsInRange(pos, attackAircraft.GetMinimumRange()))
|
||||
QueueChild(self, new FlyTimed(ticksUntilTurn, self), true);
|
||||
QueueChild(new FlyTimed(ticksUntilTurn, self));
|
||||
|
||||
QueueChild(self, new Fly(self, target, target.CenterPosition, Color.Red), true);
|
||||
QueueChild(self, new FlyTimed(ticksUntilTurn, self));
|
||||
QueueChild(new Fly(self, target, target.CenterPosition, Color.Red));
|
||||
QueueChild(new FlyTimed(ticksUntilTurn, self));
|
||||
}
|
||||
else
|
||||
{
|
||||
var minimumRange = attackAircraft.GetMinimumRangeVersusTarget(target);
|
||||
if (!target.IsInRange(pos, lastVisibleMaximumRange) || target.IsInRange(pos, minimumRange))
|
||||
QueueChild(self, new Fly(self, target, minimumRange, lastVisibleMaximumRange, target.CenterPosition, Color.Red), true);
|
||||
QueueChild(new Fly(self, target, minimumRange, lastVisibleMaximumRange, target.CenterPosition, Color.Red));
|
||||
else if (isAirborne) // Don't use 'else' to avoid conflict with TakeOff
|
||||
Fly.VerticalTakeOffOrLandTick(self, aircraft, desiredFacing, aircraft.Info.CruiseAltitude);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
// Refuse to take off if it would land immediately again.
|
||||
if (aircraft.ForceLanding)
|
||||
Cancel(self);
|
||||
@@ -96,7 +89,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
}
|
||||
|
||||
wasMovingWithinRange = true;
|
||||
QueueChild(self, aircraft.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, targetLineColor), true);
|
||||
QueueChild(aircraft.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, targetLineColor));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,13 +73,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)
|
||||
{
|
||||
if (landingInitiated)
|
||||
@@ -94,7 +87,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var dat = self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition);
|
||||
if (dat > aircraft.LandAltitude && dat < aircraft.Info.CruiseAltitude)
|
||||
{
|
||||
QueueChild(self, new TakeOff(self), true);
|
||||
QueueChild(new TakeOff(self));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -125,7 +118,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (!newLocation.HasValue)
|
||||
{
|
||||
Cancel(self, true);
|
||||
QueueChild(self, aircraft.MoveTo(landingCell, 0), true);
|
||||
QueueChild(aircraft.MoveTo(landingCell, 0));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -140,10 +133,10 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// Move towards landing location
|
||||
if (aircraft.Info.VTOL && (pos - targetPosition).HorizontalLengthSquared != 0)
|
||||
{
|
||||
QueueChild(self, new Fly(self, Target.FromPos(targetPosition)), true);
|
||||
QueueChild(new Fly(self, Target.FromPos(targetPosition)));
|
||||
|
||||
if (desiredFacing != -1)
|
||||
QueueChild(self, new Turn(self, desiredFacing));
|
||||
QueueChild(new Turn(self, desiredFacing));
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -199,11 +192,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
turnRadius = Fly.CalculateTurnRadius(aircraft.Info.Speed, aircraft.Info.TurnSpeed);
|
||||
|
||||
// Move along approach trajectory.
|
||||
QueueChild(self, new Fly(self, Target.FromPos(w1), WDist.Zero, new WDist(turnRadius * 3)), true);
|
||||
QueueChild(self, new Fly(self, Target.FromPos(w2)), true);
|
||||
QueueChild(new Fly(self, Target.FromPos(w1), WDist.Zero, new WDist(turnRadius * 3)));
|
||||
QueueChild(new Fly(self, Target.FromPos(w2)));
|
||||
|
||||
// Fix a problem when the airplane is sent to land near the landing cell
|
||||
QueueChild(self, new Fly(self, Target.FromPos(w3), WDist.Zero, new WDist(turnRadius / 2)), true);
|
||||
QueueChild(new Fly(self, Target.FromPos(w3), WDist.Zero, new WDist(turnRadius / 2)));
|
||||
finishedApproach = true;
|
||||
return this;
|
||||
}
|
||||
@@ -216,9 +209,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
// Maintain holding pattern.
|
||||
if (aircraft.Info.CanHover)
|
||||
QueueChild(self, new Wait(25), true);
|
||||
QueueChild(new Wait(25));
|
||||
else
|
||||
QueueChild(self, new FlyCircle(self, 25), true);
|
||||
QueueChild(new FlyCircle(self, 25));
|
||||
|
||||
self.NotifyBlocker(blockingCells);
|
||||
finishedApproach = false;
|
||||
|
||||
@@ -68,13 +68,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;
|
||||
}
|
||||
|
||||
// Refuse to take off if it would land immediately again.
|
||||
// Special case: Don't kill other deploy hotkey activities.
|
||||
if (aircraft.ForceLanding)
|
||||
@@ -113,15 +106,14 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var randomPosition = WVec.FromPDF(self.World.SharedRandom, 2) * distanceLength / 1024;
|
||||
var target = Target.FromPos(nearestResupplier.CenterPosition + randomPosition);
|
||||
|
||||
QueueChild(self, new Fly(self, target, WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green), true);
|
||||
QueueChild(new Fly(self, target, WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
QueueChild(self, new Fly(self, Target.FromActor(nearestResupplier), WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green),
|
||||
true);
|
||||
QueueChild(self, new FlyCircle(self, aircraft.Info.NumberOfTicksToVerifyAvailableAirport), true);
|
||||
QueueChild(new Fly(self, Target.FromActor(nearestResupplier), WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green));
|
||||
QueueChild(new FlyCircle(self, aircraft.Info.NumberOfTicksToVerifyAvailableAirport));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -140,13 +132,13 @@ namespace OpenRA.Mods.Common.Activities
|
||||
facing = 192;
|
||||
|
||||
aircraft.MakeReservation(dest);
|
||||
QueueChild(self, new Land(self, Target.FromActor(dest), offset, facing), true);
|
||||
QueueChild(self, new Resupply(self, dest, WDist.Zero), true);
|
||||
QueueChild(new Land(self, Target.FromActor(dest), offset, facing));
|
||||
QueueChild(new Resupply(self, dest, WDist.Zero));
|
||||
if (aircraft.Info.TakeOffOnResupply && !alwaysLand)
|
||||
QueueChild(self, new TakeOff(self));
|
||||
QueueChild(new TakeOff(self));
|
||||
}
|
||||
else
|
||||
QueueChild(self, new Fly(self, Target.FromActor(dest)), true);
|
||||
QueueChild(new Fly(self, Target.FromActor(dest)));
|
||||
|
||||
resupplied = true;
|
||||
return this;
|
||||
|
||||
@@ -64,13 +64,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;
|
||||
}
|
||||
|
||||
// Refuse to take off if it would land immediately again.
|
||||
if (aircraft.ForceLanding)
|
||||
{
|
||||
@@ -100,7 +93,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (!aircraft.Info.VTOL && assignTargetOnFirstRun)
|
||||
return NextActivity;
|
||||
|
||||
QueueChild(self, new AttackMoveActivity(self, () => move.MoveToTarget(self, target)), true);
|
||||
QueueChild(new AttackMoveActivity(self, () => move.MoveToTarget(self, target)));
|
||||
moveToRallyPoint = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -85,12 +85,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
return this;
|
||||
}
|
||||
|
||||
if (IsCanceling)
|
||||
return NextActivity;
|
||||
|
||||
@@ -135,7 +129,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// Move towards the last known position
|
||||
wasMovingWithinRange = true;
|
||||
QueueChild(self, move.MoveWithinRange(target, WDist.Zero, lastVisibleMaximumRange, checkTarget.CenterPosition, Color.Red), true);
|
||||
QueueChild(move.MoveWithinRange(target, WDist.Zero, lastVisibleMaximumRange, checkTarget.CenterPosition, Color.Red));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -178,7 +172,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var sightRange = rs != null ? rs.Range : WDist.FromCells(2);
|
||||
|
||||
attackStatus |= AttackStatus.NeedsToMove;
|
||||
QueueChild(self, move.MoveWithinRange(target, sightRange, target.CenterPosition, Color.Red), true);
|
||||
QueueChild(move.MoveWithinRange(target, sightRange, target.CenterPosition, Color.Red));
|
||||
return AttackStatus.NeedsToMove;
|
||||
}
|
||||
|
||||
@@ -203,7 +197,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
attackStatus |= AttackStatus.NeedsToMove;
|
||||
var checkTarget = useLastVisibleTarget ? lastVisibleTarget : target;
|
||||
QueueChild(self, move.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, Color.Red), true);
|
||||
QueueChild(move.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, Color.Red));
|
||||
return AttackStatus.NeedsToMove;
|
||||
}
|
||||
|
||||
@@ -211,7 +205,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
var desiredFacing = (attack.GetTargetPosition(pos, target) - pos).Yaw.Facing;
|
||||
attackStatus |= AttackStatus.NeedsToTurn;
|
||||
QueueChild(self, new Turn(self, desiredFacing), true);
|
||||
QueueChild(new Turn(self, desiredFacing));
|
||||
return AttackStatus.NeedsToTurn;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,13 +39,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 || isDocking)
|
||||
return NextActivity;
|
||||
|
||||
@@ -56,7 +49,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// No refineries exist; check again after delay defined in Harvester.
|
||||
if (harv.LinkedProc == null)
|
||||
{
|
||||
QueueChild(self, new Wait(harv.Info.SearchForDeliveryBuildingDelay), true);
|
||||
QueueChild(new Wait(harv.Info.SearchForDeliveryBuildingDelay));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -69,13 +62,13 @@ namespace OpenRA.Mods.Common.Activities
|
||||
foreach (var n in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||
n.MovingToRefinery(self, proc, new FindAndDeliverResources(self));
|
||||
|
||||
QueueChild(self, movement.MoveTo(proc.Location + iao.DeliveryOffset, 0), true);
|
||||
QueueChild(movement.MoveTo(proc.Location + iao.DeliveryOffset, 0));
|
||||
return this;
|
||||
}
|
||||
|
||||
if (!isDocking)
|
||||
{
|
||||
QueueChild(self, new Wait(10), true);
|
||||
QueueChild(new Wait(10));
|
||||
isDocking = true;
|
||||
iao.OnDock(self, this);
|
||||
return this;
|
||||
|
||||
@@ -44,20 +44,14 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (assignTargetOnFirstRun)
|
||||
destination = Target.FromCell(self.World, self.Location);
|
||||
|
||||
QueueChild(self, new Land(self, destination, deliverRange), true);
|
||||
QueueChild(self, new Wait(carryall.Info.BeforeUnloadDelay, false), true);
|
||||
QueueChild(self, new ReleaseUnit(self));
|
||||
QueueChild(self, new TakeOff(self));
|
||||
QueueChild(new Land(self, destination, deliverRange));
|
||||
QueueChild(new Wait(carryall.Info.BeforeUnloadDelay, false));
|
||||
QueueChild(new ReleaseUnit(self));
|
||||
QueueChild(new TakeOff(self));
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
@@ -33,22 +33,15 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
// Turn to the required facing.
|
||||
if (deploy.DeployState == DeployState.Undeployed && deploy.Info.Facing != -1 && canTurn && !moving)
|
||||
QueueChild(self, new Turn(self, deploy.Info.Facing));
|
||||
QueueChild(new Turn(self, deploy.Info.Facing));
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
if (IsCanceling || initiated || (deploy.DeployState != DeployState.Deployed && moving))
|
||||
return NextActivity;
|
||||
|
||||
QueueChild(self, new DeployInner(self, deploy), true);
|
||||
QueueChild(new DeployInner(self, deploy));
|
||||
|
||||
initiated = true;
|
||||
return this;
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
move = self.Trait<IMove>();
|
||||
this.target = target;
|
||||
this.targetLineColor = targetLineColor;
|
||||
ChildHasPriority = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -80,12 +81,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// We need to wait for movement to finish before transitioning to
|
||||
// the next state or next activity
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
// Note that lastState refers to what we have just *finished* doing
|
||||
switch (lastState)
|
||||
@@ -106,7 +104,7 @@ 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(self, move.MoveToTarget(self, target, initialTargetPosition), true);
|
||||
QueueChild(move.MoveToTarget(self, target, initialTargetPosition));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -119,7 +117,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (TryStartEnter(self, target.Actor))
|
||||
{
|
||||
lastState = EnterState.Entering;
|
||||
QueueChild(self, move.MoveIntoTarget(self, target), true);
|
||||
QueueChild(move.MoveIntoTarget(self, target));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -139,7 +137,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
OnEnterComplete(self, target.Actor);
|
||||
|
||||
lastState = EnterState.Exiting;
|
||||
QueueChild(self, move.MoveIntoWorld(self, self.Location), true);
|
||||
QueueChild(move.MoveIntoWorld(self, self.Location));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,26 +65,19 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// We have to make sure the actual "harvest" order is not skipped if a third order is queued,
|
||||
// so we keep deliveredLoad false.
|
||||
if (harv.IsFull)
|
||||
QueueChild(self, new DeliverResources(self), true);
|
||||
QueueChild(new DeliverResources(self));
|
||||
}
|
||||
|
||||
// If an explicit "deliver" order is given, the harvester goes immediately to the refinery.
|
||||
if (deliverActor != null)
|
||||
{
|
||||
QueueChild(self, new DeliverResources(self, deliverActor), true);
|
||||
QueueChild(new DeliverResources(self, deliverActor));
|
||||
hasDeliveredLoad = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
if (IsCanceling)
|
||||
return NextActivity;
|
||||
|
||||
@@ -102,7 +95,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// Are we full or have nothing more to gather? Deliver resources.
|
||||
if (harv.IsFull || (!harv.IsEmpty && harv.LastSearchFailed))
|
||||
{
|
||||
QueueChild(self, new DeliverResources(self), true);
|
||||
QueueChild(new DeliverResources(self));
|
||||
hasDeliveredLoad = true;
|
||||
return this;
|
||||
}
|
||||
@@ -110,7 +103,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// After a failed search, wait and sit still for a bit before searching again.
|
||||
if (harv.LastSearchFailed && !hasWaited)
|
||||
{
|
||||
QueueChild(self, new Wait(harv.Info.WaitDuration), true);
|
||||
QueueChild(new Wait(harv.Info.WaitDuration));
|
||||
hasWaited = true;
|
||||
return this;
|
||||
}
|
||||
@@ -147,7 +140,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var unblockCell = deliveryLoc + harv.Info.UnblockCell;
|
||||
var moveTo = mobile.NearestMoveableCell(unblockCell, 1, 5);
|
||||
self.SetTargetLine(Target.FromCell(self.World, moveTo), Color.Green, false);
|
||||
QueueChild(self, mobile.MoveTo(moveTo, 1), true);
|
||||
QueueChild(mobile.MoveTo(moveTo, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +148,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
}
|
||||
|
||||
// If we get here, our search for resources was successful. Commence harvesting.
|
||||
QueueChild(self, new HarvestResource(self, closestHarvestableCell.Value), true);
|
||||
QueueChild(new HarvestResource(self, closestHarvestableCell.Value));
|
||||
lastHarvestedCell = closestHarvestableCell.Value;
|
||||
hasHarvestedCell = true;
|
||||
return this;
|
||||
|
||||
@@ -49,13 +49,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 || harv.IsFull)
|
||||
return NextActivity;
|
||||
|
||||
@@ -66,7 +59,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
n.MovingToResources(self, targetCell, new FindAndDeliverResources(self));
|
||||
|
||||
self.SetTargetLine(Target.FromCell(self.World, targetCell), Color.Red, false);
|
||||
QueueChild(self, move.MoveTo(targetCell, 2), true);
|
||||
QueueChild(move.MoveTo(targetCell, 2));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -80,7 +73,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var desired = body.QuantizeFacing(current, harvInfo.HarvestFacings);
|
||||
if (desired != current)
|
||||
{
|
||||
QueueChild(self, new Turn(self, desired), true);
|
||||
QueueChild(new Turn(self, desired));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -94,7 +87,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
foreach (var t in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||
t.Harvested(self, resource);
|
||||
|
||||
QueueChild(self, new Wait(harvInfo.BaleLoadDelay), true);
|
||||
QueueChild(new Wait(harvInfo.BaleLoadDelay));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
switch (dockingState)
|
||||
{
|
||||
case DockingState.Wait:
|
||||
@@ -61,9 +54,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
case DockingState.Turn:
|
||||
dockingState = DockingState.Dock;
|
||||
QueueChild(self, new Turn(self, DockAngle), true);
|
||||
QueueChild(new Turn(self, DockAngle));
|
||||
if (IsDragRequired)
|
||||
QueueChild(self, new Drag(self, StartDrag, EndDrag, DragLength));
|
||||
QueueChild(new Drag(self, StartDrag, EndDrag, DragLength));
|
||||
return this;
|
||||
|
||||
case DockingState.Dock:
|
||||
@@ -90,7 +83,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
Harv.LastLinkedProc = Harv.LinkedProc;
|
||||
Harv.LinkProc(self, null);
|
||||
if (IsDragRequired)
|
||||
QueueChild(self, new Drag(self, EndDrag, StartDrag, DragLength), true);
|
||||
QueueChild(new Drag(self, EndDrag, StartDrag, DragLength));
|
||||
|
||||
dockingState = DockingState.Finished;
|
||||
return this;
|
||||
|
||||
@@ -33,13 +33,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;
|
||||
|
||||
@@ -47,8 +40,8 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (target == null)
|
||||
return this;
|
||||
|
||||
QueueChild(self, new AttackMoveActivity(self, () => move.MoveTo(target.Location, 2)), true);
|
||||
QueueChild(self, new Wait(25));
|
||||
QueueChild(new AttackMoveActivity(self, () => move.MoveTo(target.Location, 2)));
|
||||
QueueChild(new Wait(25));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -56,13 +56,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 (cargo != carryall.Carryable)
|
||||
return NextActivity;
|
||||
|
||||
@@ -86,7 +79,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
switch (state)
|
||||
{
|
||||
case PickupState.Intercept:
|
||||
QueueChild(self, movement.MoveWithinRange(Target.FromActor(cargo), WDist.FromCells(4), targetLineColor: Color.Yellow), true);
|
||||
QueueChild(movement.MoveWithinRange(Target.FromActor(cargo), WDist.FromCells(4), targetLineColor: Color.Yellow));
|
||||
state = PickupState.LockCarryable;
|
||||
return this;
|
||||
|
||||
@@ -101,15 +94,15 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
// Land at the target location
|
||||
var localOffset = carryall.OffsetForCarryable(self, cargo).Rotate(carryableBody.QuantizeOrientation(self, cargo.Orientation));
|
||||
QueueChild(self, new Land(self, Target.FromActor(cargo), -carryableBody.LocalToWorld(localOffset), carryableFacing.Facing), true);
|
||||
QueueChild(new Land(self, Target.FromActor(cargo), -carryableBody.LocalToWorld(localOffset), carryableFacing.Facing));
|
||||
|
||||
// Pause briefly before attachment for visual effect
|
||||
if (delay > 0)
|
||||
QueueChild(self, new Wait(delay, false));
|
||||
QueueChild(new Wait(delay, false));
|
||||
|
||||
// Remove our carryable from world
|
||||
QueueChild(self, new CallFunc(() => Attach(self)));
|
||||
QueueChild(self, new TakeOff(self));
|
||||
QueueChild(new CallFunc(() => Attach(self)));
|
||||
QueueChild(new TakeOff(self));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,19 +75,12 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
// HACK: If the activity is cancelled while we're already resupplying (or about to start resupplying),
|
||||
// move actor outside the resupplier footprint
|
||||
// TODO: This check is nowhere near robust enough, and should be rewritten
|
||||
if (IsCanceling && host.IsInRange(self.CenterPosition, closeEnough))
|
||||
{
|
||||
QueueChild(self, self.Trait<IMove>().MoveToTarget(self, host), true);
|
||||
QueueChild(self.Trait<IMove>().MoveToTarget(self, host));
|
||||
foreach (var notifyResupply in notifyResupplies)
|
||||
notifyResupply.ResupplyTick(host.Actor, self, ResupplyType.None);
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@ namespace OpenRA.Mods.Common.Activities
|
||||
protected override void OnFirstRun(Actor self)
|
||||
{
|
||||
if (self.Info.HasTraitInfo<IFacingInfo>())
|
||||
QueueChild(self, new Turn(self, Facing));
|
||||
QueueChild(new Turn(self, Facing));
|
||||
|
||||
if (self.Info.HasTraitInfo<AircraftInfo>())
|
||||
QueueChild(self, new Land(self));
|
||||
QueueChild(new Land(self));
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
@@ -48,12 +48,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (IsCanceling)
|
||||
return NextActivity;
|
||||
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ActivityUtils.RunActivity(self, ChildActivity);
|
||||
return this;
|
||||
}
|
||||
|
||||
// Prevent deployment in bogus locations
|
||||
var transforms = self.TraitOrDefault<Transforms>();
|
||||
if (transforms != null && !transforms.CanDeploy())
|
||||
@@ -72,7 +66,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
IsInterruptible = false;
|
||||
|
||||
// Wait forever
|
||||
QueueChild(self, new WaitFor(() => false));
|
||||
QueueChild(new WaitFor(() => false));
|
||||
makeAnimation.Reverse(self, () => DoTransform(self));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -77,27 +77,20 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (aircraft != null)
|
||||
{
|
||||
// Queue the activity even if already landed in case self.Location != destination
|
||||
QueueChild(self, new Land(self, destination, unloadRange));
|
||||
QueueChild(new Land(self, destination, unloadRange));
|
||||
takeOffAfterUnload = !aircraft.AtLandAltitude;
|
||||
}
|
||||
else
|
||||
{
|
||||
var cell = self.World.Map.Clamp(this.self.World.Map.CellContaining(destination.CenterPosition));
|
||||
QueueChild(self, new Move(self, cell, unloadRange));
|
||||
QueueChild(new Move(self, cell, unloadRange));
|
||||
}
|
||||
|
||||
QueueChild(self, new Wait(cargo.Info.BeforeUnloadDelay));
|
||||
QueueChild(new Wait(cargo.Info.BeforeUnloadDelay));
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
if (IsCanceling || cargo.IsEmpty(self))
|
||||
return NextActivity;
|
||||
|
||||
@@ -113,7 +106,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (exitSubCell == null)
|
||||
{
|
||||
self.NotifyBlocker(BlockedExitCells(actor));
|
||||
QueueChild(self, new Wait(10), true);
|
||||
QueueChild(new Wait(10));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -138,10 +131,10 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
Cancel(self, true);
|
||||
if (cargo.Info.AfterUnloadDelay > 0)
|
||||
QueueChild(self, new Wait(cargo.Info.AfterUnloadDelay, false), true);
|
||||
QueueChild(new Wait(cargo.Info.AfterUnloadDelay, false));
|
||||
|
||||
if (takeOffAfterUnload)
|
||||
QueueChild(self, new TakeOff(self), true);
|
||||
QueueChild(new TakeOff(self));
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
@@ -28,18 +27,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
protected override void OnFirstRun(Actor self)
|
||||
{
|
||||
QueueChild(self, inner);
|
||||
QueueChild(inner);
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
if (transportable != null)
|
||||
transportable.MovementCancelled(self);
|
||||
|
||||
|
||||
@@ -861,7 +861,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos)
|
||||
{
|
||||
// TODO: Ignore repulsion when moving
|
||||
return ActivityUtils.SequenceActivities(self,
|
||||
return ActivityUtils.SequenceActivities(
|
||||
new CallFunc(() => SetVisualPosition(self, fromPos)),
|
||||
new Fly(self, Target.FromPos(toPos)));
|
||||
}
|
||||
|
||||
@@ -257,13 +257,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
if (IsCanceling)
|
||||
{
|
||||
// Cancel the requested target, but keep firing on it while in range
|
||||
@@ -362,7 +355,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
wasMovingWithinRange = true;
|
||||
QueueChild(self, move.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, Color.Red), true);
|
||||
QueueChild(move.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, Color.Red));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -164,9 +164,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
if (!preventDock)
|
||||
{
|
||||
dockOrder.QueueChild(self, new CallFunc(() => dockedHarv = harv, false));
|
||||
dockOrder.QueueChild(self, DockSequence(harv, self));
|
||||
dockOrder.QueueChild(self, new CallFunc(() => dockedHarv = null, false));
|
||||
dockOrder.QueueChild(new CallFunc(() => dockedHarv = harv, false));
|
||||
dockOrder.QueueChild(DockSequence(harv, self));
|
||||
dockOrder.QueueChild(new CallFunc(() => dockedHarv = null, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!order.Queued && activity.NextActivity != null)
|
||||
activity.NextActivity.Cancel(self);
|
||||
|
||||
activity.Queue(self, new IssueOrderAfterTransform(order.OrderString, order.Target));
|
||||
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target));
|
||||
|
||||
if (currentTransform == null)
|
||||
self.QueueActivity(order.Queued, activity);
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!order.Queued && activity.NextActivity != null)
|
||||
activity.NextActivity.Cancel(self);
|
||||
|
||||
activity.Queue(self, new IssueOrderAfterTransform(order.OrderString, order.Target));
|
||||
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target));
|
||||
|
||||
if (currentTransform == null)
|
||||
self.QueueActivity(order.Queued, activity);
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!order.Queued && activity.NextActivity != null)
|
||||
activity.NextActivity.Cancel(self);
|
||||
|
||||
activity.Queue(self, new IssueOrderAfterTransform("Move", order.Target));
|
||||
activity.Queue(new IssueOrderAfterTransform("Move", order.Target));
|
||||
|
||||
if (currentTransform == null)
|
||||
self.QueueActivity(order.Queued, activity);
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!order.Queued && activity.NextActivity != null)
|
||||
activity.NextActivity.Cancel(self);
|
||||
|
||||
activity.Queue(self, new IssueOrderAfterTransform(order.OrderString, order.Target));
|
||||
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target));
|
||||
|
||||
if (currentTransform == null)
|
||||
self.QueueActivity(order.Queued, activity);
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!order.Queued && activity.NextActivity != null)
|
||||
activity.NextActivity.Cancel(self);
|
||||
|
||||
activity.Queue(self, new IssueOrderAfterTransform(order.OrderString, order.Target));
|
||||
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target));
|
||||
|
||||
if (currentTransform == null)
|
||||
self.QueueActivity(order.Queued, activity);
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return moveInner;
|
||||
|
||||
var activity = new DeployForGrantedCondition(self, this, true);
|
||||
activity.Queue(self, moveInner);
|
||||
activity.Queue(moveInner);
|
||||
return activity;
|
||||
}
|
||||
|
||||
|
||||
@@ -322,7 +322,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var notifyBlocking = new CallFunc(() => self.NotifyBlocker(cellInfo.Cell));
|
||||
var waitFor = new WaitFor(() => CanEnterCell(cellInfo.Cell));
|
||||
var move = new Move(self, cellInfo.Cell);
|
||||
self.QueueActivity(ActivityUtils.SequenceActivities(self, notifyBlocking, waitFor, move));
|
||||
self.QueueActivity(ActivityUtils.SequenceActivities(notifyBlocking, waitFor, move));
|
||||
|
||||
Log.Write("debug", "OnNudge (notify next blocking actor, wait and move) #{0} from {1} to {2}",
|
||||
self.ActorID, self.Location, cellInfo.Cell);
|
||||
@@ -691,7 +691,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var delta = toPos - fromPos;
|
||||
var facing = delta.HorizontalLengthSquared != 0 ? delta.Yaw.Facing : Facing;
|
||||
return ActivityUtils.SequenceActivities(self, new Turn(self, facing), new Drag(self, fromPos, toPos, length));
|
||||
return ActivityUtils.SequenceActivities(new Turn(self, facing), new Drag(self, fromPos, toPos, length));
|
||||
}
|
||||
|
||||
CPos? ClosestGroundCell()
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
self.CancelActivity();
|
||||
|
||||
self.SetTargetLine(order.Target, Color.Green);
|
||||
var activities = ActivityUtils.SequenceActivities(self,
|
||||
var activities = ActivityUtils.SequenceActivities(
|
||||
movement.MoveToTarget(self, order.Target, targetLineColor: Color.Green),
|
||||
new CallFunc(() => AfterReachActivities(self, order, movement)));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user