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 Activity NextActivity { get; protected set; }
|
||||||
|
|
||||||
public bool IsInterruptible { get; protected set; }
|
public bool IsInterruptible { 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; } }
|
||||||
|
|
||||||
public Activity()
|
public Activity()
|
||||||
{
|
{
|
||||||
IsInterruptible = true;
|
IsInterruptible = true;
|
||||||
|
ChildHasPriority = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Activity TickOuter(Actor self)
|
public Activity TickOuter(Actor self)
|
||||||
@@ -59,7 +61,18 @@ namespace OpenRA.Activities
|
|||||||
State = ActivityState.Active;
|
State = ActivityState.Active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ChildHasPriority)
|
||||||
|
{
|
||||||
|
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||||
|
if (ChildActivity != null)
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
var ret = Tick(self);
|
var ret = Tick(self);
|
||||||
|
|
||||||
|
if (ChildActivity != null && ChildActivity.State == ActivityState.Queued)
|
||||||
|
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||||
|
|
||||||
if (ret != this)
|
if (ret != this)
|
||||||
{
|
{
|
||||||
State = ActivityState.Done;
|
State = ActivityState.Done;
|
||||||
@@ -113,20 +126,20 @@ namespace OpenRA.Activities
|
|||||||
State = ActivityState.Canceling;
|
State = ActivityState.Canceling;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Queue(Actor self, Activity activity)
|
public void Queue(Activity activity)
|
||||||
{
|
{
|
||||||
if (NextActivity != null)
|
if (NextActivity != null)
|
||||||
NextActivity.Queue(self, activity);
|
NextActivity.Queue(activity);
|
||||||
else
|
else
|
||||||
NextActivity = activity;
|
NextActivity = activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void QueueChild(Actor self, Activity activity, bool pretick = false)
|
public void QueueChild(Activity activity)
|
||||||
{
|
{
|
||||||
if (ChildActivity != null)
|
if (ChildActivity != null)
|
||||||
ChildActivity.Queue(self, activity);
|
ChildActivity.Queue(activity);
|
||||||
else
|
else
|
||||||
ChildActivity = pretick ? ActivityUtils.RunActivity(self, activity) : activity;
|
ChildActivity = activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -187,15 +200,4 @@ namespace OpenRA.Activities
|
|||||||
yield return a;
|
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)
|
if (CurrentActivity == null)
|
||||||
CurrentActivity = nextActivity;
|
CurrentActivity = nextActivity;
|
||||||
else
|
else
|
||||||
CurrentActivity.Queue(this, nextActivity);
|
CurrentActivity.Queue(nextActivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CancelActivity()
|
public void CancelActivity()
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ namespace OpenRA.Traits
|
|||||||
return act;
|
return act;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Activity SequenceActivities(Actor self, params Activity[] acts)
|
public static Activity SequenceActivities(params Activity[] acts)
|
||||||
{
|
{
|
||||||
return acts.Reverse().Aggregate(
|
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)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ChildActivity != null)
|
|
||||||
{
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsCanceling)
|
if (IsCanceling)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
@@ -59,16 +53,16 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
// Add a CloseEnough range of 512 to the Rearm/Repair activities in order to ensure that we're at the host actor
|
// 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(new MoveAdjacentTo(self, Target.FromActor(rearmTarget)));
|
||||||
QueueChild(self, movement.MoveTo(self.World.Map.CellContaining(rearmTarget.CenterPosition), rearmTarget));
|
QueueChild(movement.MoveTo(self.World.Map.CellContaining(rearmTarget.CenterPosition), rearmTarget));
|
||||||
QueueChild(self, new Resupply(self, rearmTarget, new WDist(512)));
|
QueueChild(new Resupply(self, rearmTarget, new WDist(512)));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((minefield == null || minefield.Contains(self.Location)) && ShouldLayMine(self, self.Location))
|
if ((minefield == null || minefield.Contains(self.Location)) && ShouldLayMine(self, self.Location))
|
||||||
{
|
{
|
||||||
LayMine(self);
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +74,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
var p = minefield.Random(self.World.SharedRandom);
|
var p = minefield.Random(self.World.SharedRandom);
|
||||||
if (ShouldLayMine(self, p))
|
if (ShouldLayMine(self, p))
|
||||||
{
|
{
|
||||||
QueueChild(self, movement.MoveTo(p, 0), true);
|
QueueChild(movement.MoveTo(p, 0));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,18 +72,9 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (canceled)
|
|
||||||
return NextActivity;
|
|
||||||
|
|
||||||
// Correct the visual position after we jumped
|
// Correct the visual position after we jumped
|
||||||
if (jumpComplete)
|
if (canceled || jumpComplete)
|
||||||
{
|
return NextActivity;
|
||||||
if (ChildActivity == null)
|
|
||||||
return NextActivity;
|
|
||||||
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.Type != TargetType.Invalid)
|
if (target.Type != TargetType.Invalid)
|
||||||
targetPosition = target.CenterPosition;
|
targetPosition = target.CenterPosition;
|
||||||
@@ -106,9 +97,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
attack.DoAttack(self, target);
|
attack.DoAttack(self, target);
|
||||||
|
|
||||||
jumpComplete = true;
|
jumpComplete = true;
|
||||||
QueueChild(self, mobile.VisualMove(self, position, self.World.Map.CenterOfSubCell(destinationCell, destinationSubCell)), true);
|
QueueChild(mobile.VisualMove(self, position, self.World.Map.CenterOfSubCell(destinationCell, destinationSubCell)));
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -74,13 +74,6 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
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)
|
if (IsCanceling)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
@@ -114,7 +107,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
if (!allowMovement || lastVisibleMaxRange == WDist.Zero || lastVisibleMaxRange < lastVisibleMinRange)
|
if (!allowMovement || lastVisibleMaxRange == WDist.Zero || lastVisibleMaxRange < lastVisibleMinRange)
|
||||||
return NextActivity;
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,11 +137,11 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
var desiredFacing = (destination - origin).Yaw.Facing;
|
var desiredFacing = (destination - origin).Yaw.Facing;
|
||||||
if (mobile.Facing != desiredFacing)
|
if (mobile.Facing != desiredFacing)
|
||||||
{
|
{
|
||||||
QueueChild(self, new Turn(self, desiredFacing), true);
|
QueueChild(new Turn(self, desiredFacing));
|
||||||
return this;
|
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
|
// Re-queue the child activities to kill the target if it didn't die in one go
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -96,13 +96,6 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
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))
|
if (IsCanceling || !attack.CanAttack(self, target))
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
@@ -115,8 +108,8 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
if (!string.IsNullOrEmpty(attack.info.ChargeAudio))
|
if (!string.IsNullOrEmpty(attack.info.ChargeAudio))
|
||||||
Game.Sound.Play(SoundType.World, attack.info.ChargeAudio, self.CenterPosition);
|
Game.Sound.Play(SoundType.World, attack.info.ChargeAudio, self.CenterPosition);
|
||||||
|
|
||||||
QueueChild(self, new Wait(attack.info.InitialChargeDelay), true);
|
QueueChild(new Wait(attack.info.InitialChargeDelay));
|
||||||
QueueChild(self, new ChargeFire(attack, target));
|
QueueChild(new ChargeFire(attack, target));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,13 +147,6 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
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))
|
if (IsCanceling || !attack.CanAttack(self, target))
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
@@ -169,7 +155,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
attack.DoAttack(self, target);
|
attack.DoAttack(self, target);
|
||||||
|
|
||||||
QueueChild(self, new Wait(attack.info.ChargeDelay), true);
|
QueueChild(new Wait(attack.info.ChargeDelay));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,13 +102,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
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.
|
// Refuse to take off if it would land immediately again.
|
||||||
if (aircraft.ForceLanding)
|
if (aircraft.ForceLanding)
|
||||||
Cancel(self);
|
Cancel(self);
|
||||||
@@ -125,7 +118,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (aircraft.Info.CanHover && !skipHeightAdjustment && dat != aircraft.Info.CruiseAltitude)
|
if (aircraft.Info.CanHover && !skipHeightAdjustment && dat != aircraft.Info.CruiseAltitude)
|
||||||
{
|
{
|
||||||
if (dat <= aircraft.LandAltitude)
|
if (dat <= aircraft.LandAltitude)
|
||||||
QueueChild(self, new TakeOff(self, target), true);
|
QueueChild(new TakeOff(self, target));
|
||||||
else
|
else
|
||||||
VerticalTakeOffOrLandTick(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude);
|
VerticalTakeOffOrLandTick(self, aircraft, aircraft.Facing, aircraft.Info.CruiseAltitude);
|
||||||
|
|
||||||
@@ -136,7 +129,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
}
|
}
|
||||||
else if (dat <= aircraft.LandAltitude)
|
else if (dat <= aircraft.LandAltitude)
|
||||||
{
|
{
|
||||||
QueueChild(self, new TakeOff(self, target), true);
|
QueueChild(new TakeOff(self, target));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,13 +65,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
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.
|
// Refuse to take off if it would land immediately again.
|
||||||
if (aircraft.ForceLanding)
|
if (aircraft.ForceLanding)
|
||||||
Cancel(self);
|
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 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)))
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +132,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fly towards the last known position
|
// 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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,21 +141,21 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
var isAirborne = self.World.Map.DistanceAboveTerrain(pos).Length >= aircraft.Info.MinAirborneAltitude;
|
var isAirborne = self.World.Map.DistanceAboveTerrain(pos).Length >= aircraft.Info.MinAirborneAltitude;
|
||||||
|
|
||||||
if (!isAirborne)
|
if (!isAirborne)
|
||||||
QueueChild(self, new TakeOff(self), true);
|
QueueChild(new TakeOff(self));
|
||||||
|
|
||||||
if (attackAircraft.Info.AttackType == AirAttackType.Strafe)
|
if (attackAircraft.Info.AttackType == AirAttackType.Strafe)
|
||||||
{
|
{
|
||||||
if (target.IsInRange(pos, attackAircraft.GetMinimumRange()))
|
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(new Fly(self, target, target.CenterPosition, Color.Red));
|
||||||
QueueChild(self, new FlyTimed(ticksUntilTurn, self));
|
QueueChild(new FlyTimed(ticksUntilTurn, self));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var minimumRange = attackAircraft.GetMinimumRangeVersusTarget(target);
|
var minimumRange = attackAircraft.GetMinimumRangeVersusTarget(target);
|
||||||
if (!target.IsInRange(pos, lastVisibleMaximumRange) || target.IsInRange(pos, minimumRange))
|
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
|
else if (isAirborne) // Don't use 'else' to avoid conflict with TakeOff
|
||||||
Fly.VerticalTakeOffOrLandTick(self, aircraft, desiredFacing, aircraft.Info.CruiseAltitude);
|
Fly.VerticalTakeOffOrLandTick(self, aircraft, desiredFacing, aircraft.Info.CruiseAltitude);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,13 +47,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
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.
|
// Refuse to take off if it would land immediately again.
|
||||||
if (aircraft.ForceLanding)
|
if (aircraft.ForceLanding)
|
||||||
Cancel(self);
|
Cancel(self);
|
||||||
@@ -96,7 +89,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
}
|
}
|
||||||
|
|
||||||
wasMovingWithinRange = true;
|
wasMovingWithinRange = true;
|
||||||
QueueChild(self, aircraft.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, targetLineColor), true);
|
QueueChild(aircraft.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, targetLineColor));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,13 +73,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
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 (IsCanceling || target.Type == TargetType.Invalid)
|
||||||
{
|
{
|
||||||
if (landingInitiated)
|
if (landingInitiated)
|
||||||
@@ -94,7 +87,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
var dat = self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition);
|
var dat = self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition);
|
||||||
if (dat > aircraft.LandAltitude && dat < aircraft.Info.CruiseAltitude)
|
if (dat > aircraft.LandAltitude && dat < aircraft.Info.CruiseAltitude)
|
||||||
{
|
{
|
||||||
QueueChild(self, new TakeOff(self), true);
|
QueueChild(new TakeOff(self));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +118,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (!newLocation.HasValue)
|
if (!newLocation.HasValue)
|
||||||
{
|
{
|
||||||
Cancel(self, true);
|
Cancel(self, true);
|
||||||
QueueChild(self, aircraft.MoveTo(landingCell, 0), true);
|
QueueChild(aircraft.MoveTo(landingCell, 0));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,10 +133,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
// Move towards landing location
|
// Move towards landing location
|
||||||
if (aircraft.Info.VTOL && (pos - targetPosition).HorizontalLengthSquared != 0)
|
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)
|
if (desiredFacing != -1)
|
||||||
QueueChild(self, new Turn(self, desiredFacing));
|
QueueChild(new Turn(self, desiredFacing));
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -199,11 +192,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
turnRadius = Fly.CalculateTurnRadius(aircraft.Info.Speed, aircraft.Info.TurnSpeed);
|
turnRadius = Fly.CalculateTurnRadius(aircraft.Info.Speed, aircraft.Info.TurnSpeed);
|
||||||
|
|
||||||
// Move along approach trajectory.
|
// Move along approach trajectory.
|
||||||
QueueChild(self, new Fly(self, Target.FromPos(w1), WDist.Zero, new WDist(turnRadius * 3)), true);
|
QueueChild(new Fly(self, Target.FromPos(w1), WDist.Zero, new WDist(turnRadius * 3)));
|
||||||
QueueChild(self, new Fly(self, Target.FromPos(w2)), true);
|
QueueChild(new Fly(self, Target.FromPos(w2)));
|
||||||
|
|
||||||
// Fix a problem when the airplane is sent to land near the landing cell
|
// 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;
|
finishedApproach = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -216,9 +209,9 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
// Maintain holding pattern.
|
// Maintain holding pattern.
|
||||||
if (aircraft.Info.CanHover)
|
if (aircraft.Info.CanHover)
|
||||||
QueueChild(self, new Wait(25), true);
|
QueueChild(new Wait(25));
|
||||||
else
|
else
|
||||||
QueueChild(self, new FlyCircle(self, 25), true);
|
QueueChild(new FlyCircle(self, 25));
|
||||||
|
|
||||||
self.NotifyBlocker(blockingCells);
|
self.NotifyBlocker(blockingCells);
|
||||||
finishedApproach = false;
|
finishedApproach = false;
|
||||||
|
|||||||
@@ -68,13 +68,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
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.
|
// Refuse to take off if it would land immediately again.
|
||||||
// Special case: Don't kill other deploy hotkey activities.
|
// Special case: Don't kill other deploy hotkey activities.
|
||||||
if (aircraft.ForceLanding)
|
if (aircraft.ForceLanding)
|
||||||
@@ -113,15 +106,14 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
var randomPosition = WVec.FromPDF(self.World.SharedRandom, 2) * distanceLength / 1024;
|
var randomPosition = WVec.FromPDF(self.World.SharedRandom, 2) * distanceLength / 1024;
|
||||||
var target = Target.FromPos(nearestResupplier.CenterPosition + randomPosition);
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueChild(self, new Fly(self, Target.FromActor(nearestResupplier), WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green),
|
QueueChild(new Fly(self, Target.FromActor(nearestResupplier), WDist.Zero, aircraft.Info.WaitDistanceFromResupplyBase, targetLineColor: Color.Green));
|
||||||
true);
|
QueueChild(new FlyCircle(self, aircraft.Info.NumberOfTicksToVerifyAvailableAirport));
|
||||||
QueueChild(self, new FlyCircle(self, aircraft.Info.NumberOfTicksToVerifyAvailableAirport), true);
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,13 +132,13 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
facing = 192;
|
facing = 192;
|
||||||
|
|
||||||
aircraft.MakeReservation(dest);
|
aircraft.MakeReservation(dest);
|
||||||
QueueChild(self, new Land(self, Target.FromActor(dest), offset, facing), true);
|
QueueChild(new Land(self, Target.FromActor(dest), offset, facing));
|
||||||
QueueChild(self, new Resupply(self, dest, WDist.Zero), true);
|
QueueChild(new Resupply(self, dest, WDist.Zero));
|
||||||
if (aircraft.Info.TakeOffOnResupply && !alwaysLand)
|
if (aircraft.Info.TakeOffOnResupply && !alwaysLand)
|
||||||
QueueChild(self, new TakeOff(self));
|
QueueChild(new TakeOff(self));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
QueueChild(self, new Fly(self, Target.FromActor(dest)), true);
|
QueueChild(new Fly(self, Target.FromActor(dest)));
|
||||||
|
|
||||||
resupplied = true;
|
resupplied = true;
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -64,13 +64,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
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.
|
// Refuse to take off if it would land immediately again.
|
||||||
if (aircraft.ForceLanding)
|
if (aircraft.ForceLanding)
|
||||||
{
|
{
|
||||||
@@ -100,7 +93,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (!aircraft.Info.VTOL && assignTargetOnFirstRun)
|
if (!aircraft.Info.VTOL && assignTargetOnFirstRun)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
QueueChild(self, new AttackMoveActivity(self, () => move.MoveToTarget(self, target)), true);
|
QueueChild(new AttackMoveActivity(self, () => move.MoveToTarget(self, target)));
|
||||||
moveToRallyPoint = false;
|
moveToRallyPoint = false;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,12 +85,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ChildActivity != null)
|
|
||||||
{
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsCanceling)
|
if (IsCanceling)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
@@ -135,7 +129,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
// Move towards the last known position
|
// Move towards the last known position
|
||||||
wasMovingWithinRange = true;
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +172,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
var sightRange = rs != null ? rs.Range : WDist.FromCells(2);
|
var sightRange = rs != null ? rs.Range : WDist.FromCells(2);
|
||||||
|
|
||||||
attackStatus |= AttackStatus.NeedsToMove;
|
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;
|
return AttackStatus.NeedsToMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +197,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
attackStatus |= AttackStatus.NeedsToMove;
|
attackStatus |= AttackStatus.NeedsToMove;
|
||||||
var checkTarget = useLastVisibleTarget ? lastVisibleTarget : target;
|
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;
|
return AttackStatus.NeedsToMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,7 +205,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
var desiredFacing = (attack.GetTargetPosition(pos, target) - pos).Yaw.Facing;
|
var desiredFacing = (attack.GetTargetPosition(pos, target) - pos).Yaw.Facing;
|
||||||
attackStatus |= AttackStatus.NeedsToTurn;
|
attackStatus |= AttackStatus.NeedsToTurn;
|
||||||
QueueChild(self, new Turn(self, desiredFacing), true);
|
QueueChild(new Turn(self, desiredFacing));
|
||||||
return AttackStatus.NeedsToTurn;
|
return AttackStatus.NeedsToTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,13 +39,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ChildActivity != null)
|
|
||||||
{
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
if (ChildActivity != null)
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsCanceling || isDocking)
|
if (IsCanceling || isDocking)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
@@ -56,7 +49,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
// No refineries exist; check again after delay defined in Harvester.
|
// No refineries exist; check again after delay defined in Harvester.
|
||||||
if (harv.LinkedProc == null)
|
if (harv.LinkedProc == null)
|
||||||
{
|
{
|
||||||
QueueChild(self, new Wait(harv.Info.SearchForDeliveryBuildingDelay), true);
|
QueueChild(new Wait(harv.Info.SearchForDeliveryBuildingDelay));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,13 +62,13 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
foreach (var n in self.TraitsImplementing<INotifyHarvesterAction>())
|
foreach (var n in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||||
n.MovingToRefinery(self, proc, new FindAndDeliverResources(self));
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDocking)
|
if (!isDocking)
|
||||||
{
|
{
|
||||||
QueueChild(self, new Wait(10), true);
|
QueueChild(new Wait(10));
|
||||||
isDocking = true;
|
isDocking = true;
|
||||||
iao.OnDock(self, this);
|
iao.OnDock(self, this);
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -44,20 +44,14 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (assignTargetOnFirstRun)
|
if (assignTargetOnFirstRun)
|
||||||
destination = Target.FromCell(self.World, self.Location);
|
destination = Target.FromCell(self.World, self.Location);
|
||||||
|
|
||||||
QueueChild(self, new Land(self, destination, deliverRange), true);
|
QueueChild(new Land(self, destination, deliverRange));
|
||||||
QueueChild(self, new Wait(carryall.Info.BeforeUnloadDelay, false), true);
|
QueueChild(new Wait(carryall.Info.BeforeUnloadDelay, false));
|
||||||
QueueChild(self, new ReleaseUnit(self));
|
QueueChild(new ReleaseUnit(self));
|
||||||
QueueChild(self, new TakeOff(self));
|
QueueChild(new TakeOff(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ChildActivity != null)
|
|
||||||
{
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
if (ChildActivity != null)
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,22 +33,15 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
// Turn to the required facing.
|
// Turn to the required facing.
|
||||||
if (deploy.DeployState == DeployState.Undeployed && deploy.Info.Facing != -1 && canTurn && !moving)
|
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)
|
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))
|
if (IsCanceling || initiated || (deploy.DeployState != DeployState.Deployed && moving))
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
QueueChild(self, new DeployInner(self, deploy), true);
|
QueueChild(new DeployInner(self, deploy));
|
||||||
|
|
||||||
initiated = true;
|
initiated = true;
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
move = self.Trait<IMove>();
|
move = self.Trait<IMove>();
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.targetLineColor = targetLineColor;
|
this.targetLineColor = targetLineColor;
|
||||||
|
ChildHasPriority = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -80,12 +81,9 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
// We need to wait for movement to finish before transitioning to
|
// We need to wait for movement to finish before transitioning to
|
||||||
// the next state or next activity
|
// the next state or next activity
|
||||||
|
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||||
if (ChildActivity != null)
|
if (ChildActivity != null)
|
||||||
{
|
return this;
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
if (ChildActivity != null)
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note that lastState refers to what we have just *finished* doing
|
// Note that lastState refers to what we have just *finished* doing
|
||||||
switch (lastState)
|
switch (lastState)
|
||||||
@@ -106,7 +104,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
// Target lines are managed by this trait, so we do not pass targetLineColor
|
// Target lines are managed by this trait, so we do not pass targetLineColor
|
||||||
var initialTargetPosition = (useLastVisibleTarget ? lastVisibleTarget : target).CenterPosition;
|
var initialTargetPosition = (useLastVisibleTarget ? lastVisibleTarget : target).CenterPosition;
|
||||||
QueueChild(self, move.MoveToTarget(self, target, initialTargetPosition), true);
|
QueueChild(move.MoveToTarget(self, target, initialTargetPosition));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +117,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (TryStartEnter(self, target.Actor))
|
if (TryStartEnter(self, target.Actor))
|
||||||
{
|
{
|
||||||
lastState = EnterState.Entering;
|
lastState = EnterState.Entering;
|
||||||
QueueChild(self, move.MoveIntoTarget(self, target), true);
|
QueueChild(move.MoveIntoTarget(self, target));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +137,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
OnEnterComplete(self, target.Actor);
|
OnEnterComplete(self, target.Actor);
|
||||||
|
|
||||||
lastState = EnterState.Exiting;
|
lastState = EnterState.Exiting;
|
||||||
QueueChild(self, move.MoveIntoWorld(self, self.Location), true);
|
QueueChild(move.MoveIntoWorld(self, self.Location));
|
||||||
return this;
|
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,
|
// We have to make sure the actual "harvest" order is not skipped if a third order is queued,
|
||||||
// so we keep deliveredLoad false.
|
// so we keep deliveredLoad false.
|
||||||
if (harv.IsFull)
|
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 an explicit "deliver" order is given, the harvester goes immediately to the refinery.
|
||||||
if (deliverActor != null)
|
if (deliverActor != null)
|
||||||
{
|
{
|
||||||
QueueChild(self, new DeliverResources(self, deliverActor), true);
|
QueueChild(new DeliverResources(self, deliverActor));
|
||||||
hasDeliveredLoad = true;
|
hasDeliveredLoad = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ChildActivity != null)
|
|
||||||
{
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
if (ChildActivity != null)
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsCanceling)
|
if (IsCanceling)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
@@ -102,7 +95,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
// Are we full or have nothing more to gather? Deliver resources.
|
// Are we full or have nothing more to gather? Deliver resources.
|
||||||
if (harv.IsFull || (!harv.IsEmpty && harv.LastSearchFailed))
|
if (harv.IsFull || (!harv.IsEmpty && harv.LastSearchFailed))
|
||||||
{
|
{
|
||||||
QueueChild(self, new DeliverResources(self), true);
|
QueueChild(new DeliverResources(self));
|
||||||
hasDeliveredLoad = true;
|
hasDeliveredLoad = true;
|
||||||
return this;
|
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.
|
// After a failed search, wait and sit still for a bit before searching again.
|
||||||
if (harv.LastSearchFailed && !hasWaited)
|
if (harv.LastSearchFailed && !hasWaited)
|
||||||
{
|
{
|
||||||
QueueChild(self, new Wait(harv.Info.WaitDuration), true);
|
QueueChild(new Wait(harv.Info.WaitDuration));
|
||||||
hasWaited = true;
|
hasWaited = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -147,7 +140,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
var unblockCell = deliveryLoc + harv.Info.UnblockCell;
|
var unblockCell = deliveryLoc + harv.Info.UnblockCell;
|
||||||
var moveTo = mobile.NearestMoveableCell(unblockCell, 1, 5);
|
var moveTo = mobile.NearestMoveableCell(unblockCell, 1, 5);
|
||||||
self.SetTargetLine(Target.FromCell(self.World, moveTo), Color.Green, false);
|
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.
|
// 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;
|
lastHarvestedCell = closestHarvestableCell.Value;
|
||||||
hasHarvestedCell = true;
|
hasHarvestedCell = true;
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -49,13 +49,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ChildActivity != null)
|
|
||||||
{
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
if (ChildActivity != null)
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsCanceling || harv.IsFull)
|
if (IsCanceling || harv.IsFull)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
@@ -66,7 +59,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
n.MovingToResources(self, targetCell, new FindAndDeliverResources(self));
|
n.MovingToResources(self, targetCell, new FindAndDeliverResources(self));
|
||||||
|
|
||||||
self.SetTargetLine(Target.FromCell(self.World, targetCell), Color.Red, false);
|
self.SetTargetLine(Target.FromCell(self.World, targetCell), Color.Red, false);
|
||||||
QueueChild(self, move.MoveTo(targetCell, 2), true);
|
QueueChild(move.MoveTo(targetCell, 2));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +73,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
var desired = body.QuantizeFacing(current, harvInfo.HarvestFacings);
|
var desired = body.QuantizeFacing(current, harvInfo.HarvestFacings);
|
||||||
if (desired != current)
|
if (desired != current)
|
||||||
{
|
{
|
||||||
QueueChild(self, new Turn(self, desired), true);
|
QueueChild(new Turn(self, desired));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -94,7 +87,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
foreach (var t in self.TraitsImplementing<INotifyHarvesterAction>())
|
foreach (var t in self.TraitsImplementing<INotifyHarvesterAction>())
|
||||||
t.Harvested(self, resource);
|
t.Harvested(self, resource);
|
||||||
|
|
||||||
QueueChild(self, new Wait(harvInfo.BaleLoadDelay), true);
|
QueueChild(new Wait(harvInfo.BaleLoadDelay));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,13 +47,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ChildActivity != null)
|
|
||||||
{
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
if (ChildActivity != null)
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (dockingState)
|
switch (dockingState)
|
||||||
{
|
{
|
||||||
case DockingState.Wait:
|
case DockingState.Wait:
|
||||||
@@ -61,9 +54,9 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
case DockingState.Turn:
|
case DockingState.Turn:
|
||||||
dockingState = DockingState.Dock;
|
dockingState = DockingState.Dock;
|
||||||
QueueChild(self, new Turn(self, DockAngle), true);
|
QueueChild(new Turn(self, DockAngle));
|
||||||
if (IsDragRequired)
|
if (IsDragRequired)
|
||||||
QueueChild(self, new Drag(self, StartDrag, EndDrag, DragLength));
|
QueueChild(new Drag(self, StartDrag, EndDrag, DragLength));
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
case DockingState.Dock:
|
case DockingState.Dock:
|
||||||
@@ -90,7 +83,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
Harv.LastLinkedProc = Harv.LinkedProc;
|
Harv.LastLinkedProc = Harv.LinkedProc;
|
||||||
Harv.LinkProc(self, null);
|
Harv.LinkProc(self, null);
|
||||||
if (IsDragRequired)
|
if (IsDragRequired)
|
||||||
QueueChild(self, new Drag(self, EndDrag, StartDrag, DragLength), true);
|
QueueChild(new Drag(self, EndDrag, StartDrag, DragLength));
|
||||||
|
|
||||||
dockingState = DockingState.Finished;
|
dockingState = DockingState.Finished;
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -33,13 +33,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ChildActivity != null)
|
|
||||||
{
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
if (ChildActivity != null)
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsCanceling)
|
if (IsCanceling)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
@@ -47,8 +40,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (target == null)
|
if (target == null)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
QueueChild(self, new AttackMoveActivity(self, () => move.MoveTo(target.Location, 2)), true);
|
QueueChild(new AttackMoveActivity(self, () => move.MoveTo(target.Location, 2)));
|
||||||
QueueChild(self, new Wait(25));
|
QueueChild(new Wait(25));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,12 +33,13 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
conditionManager = self.TraitOrDefault<ConditionManager>();
|
conditionManager = self.TraitOrDefault<ConditionManager>();
|
||||||
attackMove = self.TraitOrDefault<AttackMove>();
|
attackMove = self.TraitOrDefault<AttackMove>();
|
||||||
isAssaultMove = assaultMoving;
|
isAssaultMove = assaultMoving;
|
||||||
|
ChildHasPriority = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnFirstRun(Actor self)
|
protected override void OnFirstRun(Actor self)
|
||||||
{
|
{
|
||||||
// Start moving.
|
// Start moving.
|
||||||
QueueChild(self, getInner());
|
QueueChild(getInner());
|
||||||
|
|
||||||
if (conditionManager == null || attackMove == null)
|
if (conditionManager == null || attackMove == null)
|
||||||
return;
|
return;
|
||||||
@@ -64,21 +65,18 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
foreach (var ab in attackBases)
|
foreach (var ab in attackBases)
|
||||||
{
|
{
|
||||||
var activity = ab.GetAttackActivity(self, target, true, false);
|
var activity = ab.GetAttackActivity(self, target, true, false);
|
||||||
QueueChild(self, activity);
|
QueueChild(activity);
|
||||||
ab.OnQueueAttackActivity(self, activity, target, true, false);
|
ab.OnQueueAttackActivity(self, activity, target, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure to continue moving when the attack activities have finished.
|
// Make sure to continue moving when the attack activities have finished.
|
||||||
QueueChild(self, getInner());
|
QueueChild(getInner());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||||
if (ChildActivity != null)
|
if (ChildActivity != null)
|
||||||
{
|
return this;
|
||||||
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
|
// 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.
|
// 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)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ChildActivity != null)
|
|
||||||
{
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
if (ChildActivity != null)
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsCanceling)
|
if (IsCanceling)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
@@ -90,7 +83,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
// Move into range
|
// Move into range
|
||||||
wasMovingWithinRange = true;
|
wasMovingWithinRange = true;
|
||||||
QueueChild(self, move.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, targetLineColor), true);
|
QueueChild(move.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, targetLineColor));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,17 +146,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
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
|
// If the actor is inside a tunnel then we must let them move
|
||||||
// all the way through before moving to the next activity
|
// all the way through before moving to the next activity
|
||||||
if (IsCanceling && self.Location.Layer != CustomMovementLayerType.Tunnel)
|
if (IsCanceling && self.Location.Layer != CustomMovementLayerType.Tunnel)
|
||||||
@@ -188,7 +177,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
path.Add(nextCell.Value.First);
|
path.Add(nextCell.Value.First);
|
||||||
|
|
||||||
QueueChild(self, new Turn(self, firstFacing), true);
|
QueueChild(new Turn(self, firstFacing));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +191,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
var to = Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) +
|
var to = Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) +
|
||||||
(map.Grid.OffsetOfSubCell(mobile.FromSubCell) + map.Grid.OffsetOfSubCell(mobile.ToSubCell)) / 2;
|
(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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,7 +324,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (ret == this)
|
if (ret == this)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
Queue(self, ret);
|
Queue(ret);
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
Mobile = self.Trait<Mobile>();
|
Mobile = self.Trait<Mobile>();
|
||||||
pathFinder = self.World.WorldActor.Trait<IPathFinder>();
|
pathFinder = self.World.WorldActor.Trait<IPathFinder>();
|
||||||
domainIndex = self.World.WorldActor.Trait<DomainIndex>();
|
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)
|
// 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
|
// 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)
|
protected override void OnFirstRun(Actor self)
|
||||||
{
|
{
|
||||||
QueueChild(self, Mobile.MoveTo(() => CalculatePathToTarget(self)));
|
QueueChild(Mobile.MoveTo(() => CalculatePathToTarget(self)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
@@ -116,7 +117,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
// Target has moved, and MoveAdjacentTo is still valid.
|
// Target has moved, and MoveAdjacentTo is still valid.
|
||||||
if (!IsCanceling && shouldRepath)
|
if (!IsCanceling && shouldRepath)
|
||||||
QueueChild(self, Mobile.MoveTo(() => CalculatePathToTarget(self)));
|
QueueChild(Mobile.MoveTo(() => CalculatePathToTarget(self)));
|
||||||
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||||
if (ChildActivity != null)
|
if (ChildActivity != null)
|
||||||
|
|||||||
@@ -37,13 +37,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
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 (IsCanceling || target.Type == TargetType.Invalid)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
@@ -64,7 +57,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
var turn = ActivityUtils.RunActivity(self, new Turn(self, facing));
|
var turn = ActivityUtils.RunActivity(self, new Turn(self, facing));
|
||||||
if (turn != null)
|
if (turn != null)
|
||||||
QueueChild(self, turn);
|
QueueChild(turn);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,13 +56,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ChildActivity != null)
|
|
||||||
{
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
if (ChildActivity != null)
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cargo != carryall.Carryable)
|
if (cargo != carryall.Carryable)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
@@ -86,7 +79,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case PickupState.Intercept:
|
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;
|
state = PickupState.LockCarryable;
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
@@ -101,15 +94,15 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
// Land at the target location
|
// Land at the target location
|
||||||
var localOffset = carryall.OffsetForCarryable(self, cargo).Rotate(carryableBody.QuantizeOrientation(self, cargo.Orientation));
|
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
|
// Pause briefly before attachment for visual effect
|
||||||
if (delay > 0)
|
if (delay > 0)
|
||||||
QueueChild(self, new Wait(delay, false));
|
QueueChild(new Wait(delay, false));
|
||||||
|
|
||||||
// Remove our carryable from world
|
// Remove our carryable from world
|
||||||
QueueChild(self, new CallFunc(() => Attach(self)));
|
QueueChild(new CallFunc(() => Attach(self)));
|
||||||
QueueChild(self, new TakeOff(self));
|
QueueChild(new TakeOff(self));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,19 +75,12 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
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),
|
// HACK: If the activity is cancelled while we're already resupplying (or about to start resupplying),
|
||||||
// move actor outside the resupplier footprint
|
// move actor outside the resupplier footprint
|
||||||
// TODO: This check is nowhere near robust enough, and should be rewritten
|
// TODO: This check is nowhere near robust enough, and should be rewritten
|
||||||
if (IsCanceling && host.IsInRange(self.CenterPosition, closeEnough))
|
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)
|
foreach (var notifyResupply in notifyResupplies)
|
||||||
notifyResupply.ResupplyTick(host.Actor, self, ResupplyType.None);
|
notifyResupply.ResupplyTick(host.Actor, self, ResupplyType.None);
|
||||||
|
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
protected override void OnFirstRun(Actor self)
|
protected override void OnFirstRun(Actor self)
|
||||||
{
|
{
|
||||||
if (self.Info.HasTraitInfo<IFacingInfo>())
|
if (self.Info.HasTraitInfo<IFacingInfo>())
|
||||||
QueueChild(self, new Turn(self, Facing));
|
QueueChild(new Turn(self, Facing));
|
||||||
|
|
||||||
if (self.Info.HasTraitInfo<AircraftInfo>())
|
if (self.Info.HasTraitInfo<AircraftInfo>())
|
||||||
QueueChild(self, new Land(self));
|
QueueChild(new Land(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
@@ -48,12 +48,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (IsCanceling)
|
if (IsCanceling)
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
if (ChildActivity != null)
|
|
||||||
{
|
|
||||||
ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prevent deployment in bogus locations
|
// Prevent deployment in bogus locations
|
||||||
var transforms = self.TraitOrDefault<Transforms>();
|
var transforms = self.TraitOrDefault<Transforms>();
|
||||||
if (transforms != null && !transforms.CanDeploy())
|
if (transforms != null && !transforms.CanDeploy())
|
||||||
@@ -72,7 +66,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
IsInterruptible = false;
|
IsInterruptible = false;
|
||||||
|
|
||||||
// Wait forever
|
// Wait forever
|
||||||
QueueChild(self, new WaitFor(() => false));
|
QueueChild(new WaitFor(() => false));
|
||||||
makeAnimation.Reverse(self, () => DoTransform(self));
|
makeAnimation.Reverse(self, () => DoTransform(self));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,27 +77,20 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (aircraft != null)
|
if (aircraft != null)
|
||||||
{
|
{
|
||||||
// Queue the activity even if already landed in case self.Location != destination
|
// 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;
|
takeOffAfterUnload = !aircraft.AtLandAltitude;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var cell = self.World.Map.Clamp(this.self.World.Map.CellContaining(destination.CenterPosition));
|
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)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ChildActivity != null)
|
|
||||||
{
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
if (ChildActivity != null)
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsCanceling || cargo.IsEmpty(self))
|
if (IsCanceling || cargo.IsEmpty(self))
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
|
|
||||||
@@ -113,7 +106,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (exitSubCell == null)
|
if (exitSubCell == null)
|
||||||
{
|
{
|
||||||
self.NotifyBlocker(BlockedExitCells(actor));
|
self.NotifyBlocker(BlockedExitCells(actor));
|
||||||
QueueChild(self, new Wait(10), true);
|
QueueChild(new Wait(10));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,10 +131,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
Cancel(self, true);
|
Cancel(self, true);
|
||||||
if (cargo.Info.AfterUnloadDelay > 0)
|
if (cargo.Info.AfterUnloadDelay > 0)
|
||||||
QueueChild(self, new Wait(cargo.Info.AfterUnloadDelay, false), true);
|
QueueChild(new Wait(cargo.Info.AfterUnloadDelay, false));
|
||||||
|
|
||||||
if (takeOffAfterUnload)
|
if (takeOffAfterUnload)
|
||||||
QueueChild(self, new TakeOff(self), true);
|
QueueChild(new TakeOff(self));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
using OpenRA.Activities;
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Activities
|
namespace OpenRA.Mods.Common.Activities
|
||||||
{
|
{
|
||||||
@@ -28,18 +27,11 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
protected override void OnFirstRun(Actor self)
|
protected override void OnFirstRun(Actor self)
|
||||||
{
|
{
|
||||||
QueueChild(self, inner);
|
QueueChild(inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ChildActivity != null)
|
|
||||||
{
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
if (ChildActivity != null)
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (transportable != null)
|
if (transportable != null)
|
||||||
transportable.MovementCancelled(self);
|
transportable.MovementCancelled(self);
|
||||||
|
|
||||||
|
|||||||
@@ -861,7 +861,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos)
|
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos)
|
||||||
{
|
{
|
||||||
// TODO: Ignore repulsion when moving
|
// TODO: Ignore repulsion when moving
|
||||||
return ActivityUtils.SequenceActivities(self,
|
return ActivityUtils.SequenceActivities(
|
||||||
new CallFunc(() => SetVisualPosition(self, fromPos)),
|
new CallFunc(() => SetVisualPosition(self, fromPos)),
|
||||||
new Fly(self, Target.FromPos(toPos)));
|
new Fly(self, Target.FromPos(toPos)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,13 +257,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public override Activity Tick(Actor self)
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (ChildActivity != null)
|
|
||||||
{
|
|
||||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
|
||||||
if (ChildActivity != null)
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsCanceling)
|
if (IsCanceling)
|
||||||
{
|
{
|
||||||
// Cancel the requested target, but keep firing on it while in range
|
// Cancel the requested target, but keep firing on it while in range
|
||||||
@@ -362,7 +355,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
wasMovingWithinRange = true;
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,9 +164,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
if (!preventDock)
|
if (!preventDock)
|
||||||
{
|
{
|
||||||
dockOrder.QueueChild(self, new CallFunc(() => dockedHarv = harv, false));
|
dockOrder.QueueChild(new CallFunc(() => dockedHarv = harv, false));
|
||||||
dockOrder.QueueChild(self, DockSequence(harv, self));
|
dockOrder.QueueChild(DockSequence(harv, self));
|
||||||
dockOrder.QueueChild(self, new CallFunc(() => dockedHarv = null, false));
|
dockOrder.QueueChild(new CallFunc(() => dockedHarv = null, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued && activity.NextActivity != null)
|
if (!order.Queued && activity.NextActivity != null)
|
||||||
activity.NextActivity.Cancel(self);
|
activity.NextActivity.Cancel(self);
|
||||||
|
|
||||||
activity.Queue(self, new IssueOrderAfterTransform(order.OrderString, order.Target));
|
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target));
|
||||||
|
|
||||||
if (currentTransform == null)
|
if (currentTransform == null)
|
||||||
self.QueueActivity(order.Queued, activity);
|
self.QueueActivity(order.Queued, activity);
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued && activity.NextActivity != null)
|
if (!order.Queued && activity.NextActivity != null)
|
||||||
activity.NextActivity.Cancel(self);
|
activity.NextActivity.Cancel(self);
|
||||||
|
|
||||||
activity.Queue(self, new IssueOrderAfterTransform(order.OrderString, order.Target));
|
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target));
|
||||||
|
|
||||||
if (currentTransform == null)
|
if (currentTransform == null)
|
||||||
self.QueueActivity(order.Queued, activity);
|
self.QueueActivity(order.Queued, activity);
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued && activity.NextActivity != null)
|
if (!order.Queued && activity.NextActivity != null)
|
||||||
activity.NextActivity.Cancel(self);
|
activity.NextActivity.Cancel(self);
|
||||||
|
|
||||||
activity.Queue(self, new IssueOrderAfterTransform("Move", order.Target));
|
activity.Queue(new IssueOrderAfterTransform("Move", order.Target));
|
||||||
|
|
||||||
if (currentTransform == null)
|
if (currentTransform == null)
|
||||||
self.QueueActivity(order.Queued, activity);
|
self.QueueActivity(order.Queued, activity);
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued && activity.NextActivity != null)
|
if (!order.Queued && activity.NextActivity != null)
|
||||||
activity.NextActivity.Cancel(self);
|
activity.NextActivity.Cancel(self);
|
||||||
|
|
||||||
activity.Queue(self, new IssueOrderAfterTransform(order.OrderString, order.Target));
|
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target));
|
||||||
|
|
||||||
if (currentTransform == null)
|
if (currentTransform == null)
|
||||||
self.QueueActivity(order.Queued, activity);
|
self.QueueActivity(order.Queued, activity);
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!order.Queued && activity.NextActivity != null)
|
if (!order.Queued && activity.NextActivity != null)
|
||||||
activity.NextActivity.Cancel(self);
|
activity.NextActivity.Cancel(self);
|
||||||
|
|
||||||
activity.Queue(self, new IssueOrderAfterTransform(order.OrderString, order.Target));
|
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target));
|
||||||
|
|
||||||
if (currentTransform == null)
|
if (currentTransform == null)
|
||||||
self.QueueActivity(order.Queued, activity);
|
self.QueueActivity(order.Queued, activity);
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return moveInner;
|
return moveInner;
|
||||||
|
|
||||||
var activity = new DeployForGrantedCondition(self, this, true);
|
var activity = new DeployForGrantedCondition(self, this, true);
|
||||||
activity.Queue(self, moveInner);
|
activity.Queue(moveInner);
|
||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var notifyBlocking = new CallFunc(() => self.NotifyBlocker(cellInfo.Cell));
|
var notifyBlocking = new CallFunc(() => self.NotifyBlocker(cellInfo.Cell));
|
||||||
var waitFor = new WaitFor(() => CanEnterCell(cellInfo.Cell));
|
var waitFor = new WaitFor(() => CanEnterCell(cellInfo.Cell));
|
||||||
var move = new Move(self, 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}",
|
Log.Write("debug", "OnNudge (notify next blocking actor, wait and move) #{0} from {1} to {2}",
|
||||||
self.ActorID, self.Location, cellInfo.Cell);
|
self.ActorID, self.Location, cellInfo.Cell);
|
||||||
@@ -691,7 +691,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
var delta = toPos - fromPos;
|
var delta = toPos - fromPos;
|
||||||
var facing = delta.HorizontalLengthSquared != 0 ? delta.Yaw.Facing : Facing;
|
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()
|
CPos? ClosestGroundCell()
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(order.Target, Color.Green);
|
self.SetTargetLine(order.Target, Color.Green);
|
||||||
var activities = ActivityUtils.SequenceActivities(self,
|
var activities = ActivityUtils.SequenceActivities(
|
||||||
movement.MoveToTarget(self, order.Target, targetLineColor: Color.Green),
|
movement.MoveToTarget(self, order.Target, targetLineColor: Color.Green),
|
||||||
new CallFunc(() => AfterReachActivities(self, order, movement)));
|
new CallFunc(() => AfterReachActivities(self, order, movement)));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user