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:
Paul Chote
2018-10-06 21:37:47 +00:00
committed by abcdefg30
parent a53ef6e503
commit bab34252dd
4 changed files with 119 additions and 2 deletions

View File

@@ -38,6 +38,13 @@ namespace OpenRA.Mods.Common.Activities
return !actor.IsDead && !targetManager.BeingCaptured && targetManager.CanBeTargetedBy(actor, self, manager);
}
protected override bool TryStartEnter(Actor self)
{
// CanEnter is only called when the actor is ready to start entering the target.
// We can (ab)use this as a notification that the capture is starting.
return manager.StartCapture(self, actor, targetManager);
}
protected override void OnInside(Actor self)
{
if (!CanReserve(self))
@@ -94,6 +101,23 @@ namespace OpenRA.Mods.Common.Activities
});
}
protected override void OnLastRun(Actor self)
{
CancelCapture(self);
base.OnLastRun(self);
}
protected override void OnActorDispose(Actor self)
{
CancelCapture(self);
base.OnActorDispose(self);
}
void CancelCapture(Actor self)
{
manager.CancelCapture(self, actor, targetManager);
}
public override Activity Tick(Actor self)
{
if (!targetManager.CanBeTargetedBy(actor, self, manager))