Add support for capture delays and conditions.
CaptureDelay is defined per-trait, and the shortest delay will be used if multiple traits are enabled. CapturingCondition and BeingCapturedCondition are global, and are granted when any capture is in progress. The capture period is defined from when the unit reaches the cell next to the target, and either starts to wait or enter the target through to when the capture succeeds or fails.
This commit is contained in:
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public abstract class Enter : Activity
|
||||
{
|
||||
public enum ReserveStatus { None, TooFar, Pending, Ready }
|
||||
enum EnterState { ApproachingOrEntering, Inside, Exiting, Done }
|
||||
enum EnterState { ApproachingOrEntering, WaitingToEnter, Inside, Exiting, Done }
|
||||
|
||||
readonly IMove move;
|
||||
readonly int maxTries = 0;
|
||||
@@ -58,6 +58,12 @@ namespace OpenRA.Mods.Common.Activities
|
||||
protected virtual void Unreserve(Actor self, bool abort) { }
|
||||
protected virtual void OnInside(Actor self) { }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the actor is ready to transition from approaching to entering the target.
|
||||
/// Return true to start entering, or false to wait in the WaitingToEnter state.
|
||||
/// </summary>
|
||||
protected virtual bool TryStartEnter(Actor self) { return true; }
|
||||
|
||||
protected bool TryGetAlternateTargetInCircle(
|
||||
Actor self, WDist radius, Action<Target> update, Func<Actor, bool> primaryFilter, Func<Actor, bool>[] preferenceFilters = null)
|
||||
{
|
||||
@@ -187,6 +193,10 @@ namespace OpenRA.Mods.Common.Activities
|
||||
break; // Reserved target -> start entering target
|
||||
}
|
||||
|
||||
// Can we enter yet?
|
||||
if (!TryStartEnter(self))
|
||||
return EnterState.WaitingToEnter;
|
||||
|
||||
// Entering
|
||||
isEnteringOrInside = true;
|
||||
savedPos = self.CenterPosition; // Save position of self, before entering, for returning on exit
|
||||
|
||||
Reference in New Issue
Block a user