> 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.md).

# Delayed

The **Delayed** system is a lightweight Unity runtime utility for scheduling and managing actions that execute after a delay, over frames, under conditions, or immediately. It provides a unified interface to create time-based, frame-based, condition-based, and chained actions with full control over pausing, resuming, canceling, and repeating.

You never need to manually create a MonoBehaviour — the system initializes itself automatically on load. Managed automatically via `DelayedRunner`. Each frame, `Tick(deltaTime)` updates all actions and chains.

***

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

* `ImmediateAction` – executes on the current frame.
* `TimeBasedAction` – executes after a specified time or repeatedly at time intervals.
* `FrameBasedAction` – executes after a number of frames or repeatedly per frame interval.
* `ConditionBasedAction` – executes when or while one or multiple conditions are met.

Event-based and Define-based actions provide separate additional functionality, but are based on `ConditionBasedAction`.

***

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

The main `Delayed` class provides different types of methods to manage actions and chains.

#### Actions with ID

* `PauseWithID(id)` – Pauses the delayed action with the specified ID.
* `ResumeWithID(id)` – Resumes the delayed action with the specified ID.
* `CancelWithID(id)` – Cancels the delayed action with the specified ID.
* `GetWithID(id)` – Retrieves the delayed action with the specified ID.
* `HasWithID(id)` – Checks if there is a delayed action with the ID.

#### Actions with Tag

* `PauseWithTag(tag)` – Pauses all delayed actions with the specified tag.
* `ResumeWithTag(tag)` – Resumes all paused delayed actions with the specified tag.
* `CancelWithTag(tag)` – Cancels all delayed actions with the specified tag.
* `GetWithTag(tag)` – Retrieves all delayed actions with the specified tag.
* `HasWithTag(tag)` – Checks if there is at least one delayed action with the specified tag.

#### All Actions And Chains

* `PauseAll()` – Pauses all active delayed actions.
* `ResumeAll()` – Resumes all paused delayed actions.
* `CancelAll()` – Cancels all active delayed actions and chains.

***

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

The system provides runtime queries for monitoring actions:

* Active and paused actions: `ActiveActions`, `PausedActions`.
* Active and paused chains: `ActiveChains`, `PausedChains`.
* Counts: `ActiveActionsCount`, `PausedActionsCount`, `ActiveChainsCount`, `PausedChainsCount`.

***

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

* When `AutoRemoveCompleted` is `true` (default), completed actions or chains are automatically removed from the internal lists to avoid memory accumulation.
* When `AutoRemoveCompleted` is `false`, manual cleanup via `CleanupCompleted()` is required.
