> For the complete documentation index, see [llms.txt](https://pahutyakv.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pahutyakv.gitbook.io/docs/delayed/delayed-action.md).

# Delayed Action

**DelayedAction** is the abstract base class for all delayed actions in the system. It provides the core behavior, lifecycle management, and event system that all specialized actions (Immediate, Time-based, Frame-based, Condition-based) inherit.

***

### <mark style="color:$success;">Properties</mark>

* `ID` – a unique identifier for the action.
* `Tag` – a tag for grouping actions.
* `Priority` - a execution priority for the action.
* `IsPaused` – true if the action is currently paused.
* `IsCompleted` – true if the action has finished or been canceled.
* `IsActive` – true if the action is active and not paused.
* `CurrentProgress` – current normalized progress of this action, from 0 to 1.

***

### <mark style="color:$success;">Methods</mark>

* `Pause() / Resume()` – temporarily suspend or resume execution.
* `Cancel()` – immediately stops the action and invokes the `OnCancel` event.
* `Loop(int times = -1)` - sets how many times the action should repeat after completion. Use `-1` for infinite looping.
* `WithID(string id)` - sets a custom identifier for the action.
* `WithTag(string tag)` - sets a custom tag for grouping actions.
* `WithPriority(int priority)` - sets a custom execution priority for the action.
* `WithStartDelay(float seconds)` - sets a delay before the action starts executing.
* `BindTo(GameObject target)` - binds an action to the target game object and cancels it when it is destroyed.

***

### <mark style="color:$success;">Events</mark>

<details>

<summary><strong>OnTick(Action&#x3C;float> callback)</strong></summary>

Fires each tick with normalized progress (0 → 1).

* **ImmediateAction:** always 1 (only executed once).
* **TimeBasedAction:** 0 at start, 1 after reaching the target time.
* **FrameBasedAction:** 0 at start, 1 after reaching the target number of frames.
* **ConditionBasedAction:** 0 if the condition is not met, 1 if it is met.

```csharp
action.OnTick(progress => Debug.Log("Progress: " + progress));
```

</details>

<details>

<summary><strong>OnComplete(Action / Action&#x3C;DelayedAction>)</strong></summary>

Fires when the action completes successfully.

```csharp
action.OnComplete(() => Debug.Log("Action completed!"));
```

</details>

<details>

<summary><strong>OnCancel(Action / Action&#x3C;DelayedAction>)</strong></summary>

Fires when the action is canceled before completion.

```csharp
action.OnCancel(() => Debug.Log("Action canceled!"));
```

</details>

***

### <mark style="color:$primary;">Notes</mark>

* `DelayedAction` is **never instantiated directly**; use one of the derived types (`ImmediateAction`, `TimeBasedAction`, `FrameBasedAction`, `ConditionBasedAction`).
* Works seamlessly with `DelayedChain` for sequential workflows.
* `BindTo` method adds a `DelayedBinder` component to the target object to bind to its lifecycle.
