Make Tick return bool
This commit is contained in:
@@ -37,10 +37,10 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
this.minefield = minefield;
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
public override bool Tick(Actor self)
|
||||
{
|
||||
if (IsCanceling)
|
||||
return NextActivity;
|
||||
return true;
|
||||
|
||||
if (rearmableInfo != null && ammoPools.Any(p => p.Info.Name == info.AmmoPoolName && !p.HasAmmo()))
|
||||
{
|
||||
@@ -50,20 +50,20 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
.ClosestTo(self);
|
||||
|
||||
if (rearmTarget == null)
|
||||
return NextActivity;
|
||||
return true;
|
||||
|
||||
// Add a CloseEnough range of 512 to the Rearm/Repair activities in order to ensure that we're at the host actor
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((minefield == null || minefield.Contains(self.Location)) && ShouldLayMine(self, self.Location))
|
||||
{
|
||||
LayMine(self);
|
||||
QueueChild(new Wait(20)); // A little wait after placing each mine, for show
|
||||
return this;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (minefield != null && minefield.Length > 0)
|
||||
@@ -75,13 +75,13 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
if (ShouldLayMine(self, p))
|
||||
{
|
||||
QueueChild(movement.MoveTo(p, 0));
|
||||
return this;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Return somewhere likely to be safe (near rearm building) so we're not sitting out in the minefield.
|
||||
return NextActivity;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ShouldLayMine(Actor self, CPos p)
|
||||
|
||||
@@ -70,11 +70,11 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
attack.GrantLeapCondition(self);
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
public override bool Tick(Actor self)
|
||||
{
|
||||
// Correct the visual position after we jumped
|
||||
if (canceled || jumpComplete)
|
||||
return NextActivity;
|
||||
return true;
|
||||
|
||||
if (target.Type != TargetType.Invalid)
|
||||
targetPosition = target.CenterPosition;
|
||||
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
QueueChild(mobile.VisualMove(self, position, self.World.Map.CenterOfSubCell(destinationCell, destinationSubCell)));
|
||||
}
|
||||
|
||||
return this;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnLastRun(Actor self)
|
||||
|
||||
@@ -72,10 +72,10 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
attack.IsAiming = true;
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
public override bool Tick(Actor self)
|
||||
{
|
||||
if (IsCanceling)
|
||||
return NextActivity;
|
||||
return true;
|
||||
|
||||
bool targetIsHiddenActor;
|
||||
target = target.Recalculate(self.Owner, out targetIsHiddenActor);
|
||||
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
|
||||
// Target is hidden or dead, and we don't have a fallback position to move towards
|
||||
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
||||
return NextActivity;
|
||||
return true;
|
||||
|
||||
var pos = self.CenterPosition;
|
||||
var checkTarget = useLastVisibleTarget ? lastVisibleTarget : target;
|
||||
@@ -105,27 +105,27 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
if (!checkTarget.IsInRange(pos, lastVisibleMaxRange) || checkTarget.IsInRange(pos, lastVisibleMinRange))
|
||||
{
|
||||
if (!allowMovement || lastVisibleMaxRange == WDist.Zero || lastVisibleMaxRange < lastVisibleMinRange)
|
||||
return NextActivity;
|
||||
return true;
|
||||
|
||||
QueueChild(mobile.MoveWithinRange(target, lastVisibleMinRange, lastVisibleMaxRange, checkTarget.CenterPosition, Color.Red));
|
||||
return this;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ready to leap, but target isn't visible
|
||||
if (targetIsHiddenActor || target.Type != TargetType.Actor)
|
||||
return NextActivity;
|
||||
return true;
|
||||
|
||||
// Target is not valid
|
||||
if (!target.IsValidFor(self) || !attack.HasAnyValidWeapons(target))
|
||||
return NextActivity;
|
||||
return true;
|
||||
|
||||
var edible = target.Actor.TraitOrDefault<EdibleByLeap>();
|
||||
if (edible == null || !edible.CanLeap(self))
|
||||
return NextActivity;
|
||||
return true;
|
||||
|
||||
// Can't leap yet
|
||||
if (attack.Armaments.All(a => a.IsReloading))
|
||||
return this;
|
||||
return false;
|
||||
|
||||
// Use CenterOfSubCell with ToSubCell instead of target.Centerposition
|
||||
// to avoid continuous facing adjustments as the target moves
|
||||
@@ -138,13 +138,13 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
if (mobile.Facing != desiredFacing)
|
||||
{
|
||||
QueueChild(new Turn(self, desiredFacing));
|
||||
return this;
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnLastRun(Actor self)
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
IsInterruptible = false;
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
public override bool Tick(Actor self)
|
||||
{
|
||||
var pc = self.TraitOrDefault<PortableChrono>();
|
||||
if (teleporter == self && pc != null && (!pc.CanTeleport || IsCanceling))
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
if (killOnFailure)
|
||||
self.Kill(teleporter, killDamageTypes);
|
||||
|
||||
return NextActivity;
|
||||
return true;
|
||||
}
|
||||
|
||||
var bestCell = ChooseBestDestinationCell(self, destination);
|
||||
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
if (killOnFailure)
|
||||
self.Kill(teleporter, killDamageTypes);
|
||||
|
||||
return NextActivity;
|
||||
return true;
|
||||
}
|
||||
|
||||
destination = bestCell.Value;
|
||||
@@ -112,7 +112,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
building.PlayCustomAnimation(teleporter, "active");
|
||||
}
|
||||
|
||||
return NextActivity;
|
||||
return true;
|
||||
}
|
||||
|
||||
CPos? ChooseBestDestinationCell(Actor self, CPos destination)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
spriteOverlay = refinery.TraitOrDefault<WithDockingOverlay>();
|
||||
}
|
||||
|
||||
public override Activity OnStateDock(Actor self)
|
||||
public override void OnStateDock(Actor self)
|
||||
{
|
||||
body.Docked = true;
|
||||
|
||||
@@ -42,11 +42,9 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
}
|
||||
else
|
||||
dockingState = DockingState.Loop;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public override Activity OnStateUndock(Actor self)
|
||||
public override void OnStateUndock(Actor self)
|
||||
{
|
||||
dockingState = DockingState.Wait;
|
||||
|
||||
@@ -65,8 +63,6 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
dockingState = DockingState.Complete;
|
||||
body.Docked = false;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user