> For the complete documentation index, see [llms.txt](https://morningheartgames.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://morningheartgames.gitbook.io/docs/gameplay-ability-toolkit/demo-details/arena.md).

# Arena Technical Notes

> Online doc: <https://morningheartgames.gitbook.io/docs/gameplay-ability-toolkit/demo/arena-1?fallback=true>

These notes describe what ships in `GameplayAbilityToolkit/Demo/Arena/` and how the slice is assembled. Use the [Arena Demo](/docs/gameplay-ability-toolkit/try-it/arena.md) page first if you want controls and a player-facing overview.

## Slice Summary

Arena is a complete top-down combat slice:

* Player controller with WASD movement and mouse aim.
* Light combo, heavy attack, dodge, warcry, firebolt, flamethrower, and meteor.
* Enemies, boss, waves, pickups, win/lose flow, HUD, event log, cues, and debug overlays.
* Committed ScriptableObject assets, prefabs, scenes, VFX, SFX, and CC0 art sources.

## How To Inspect The Slice

Use this order when reading the demo in Unity:

1. Open `Scenes/Training.unity` and play each ability without enemy pressure.
2. Open `Scenes/Arena.unity` and play one wave.
3. Stop Play Mode.
4. Inspect `ArenaDemoBootstrap` and `GameplayCueManager` in the scene.
5. Open `Prefabs/Actors/Player.prefab`.
6. Open `Abilities/GA_*` assets.
7. Open referenced `Effects/GE_*` assets.
8. Open `Prefabs/UI/ArenaHUD.prefab`.
9. Read the relevant runtime scripts under `Scripts/`.

This order follows the runtime path from scene services to actor ownership, authored data, feedback, and manual verification.

## Content Inventory

Everything below is committed under `GameplayAbilityToolkit/Demo/Arena/`.

| Area               | Contents                                                                                                                   |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------- |
| `Attributes/`      | `ASDef_Arena`, `AS_Arena`, boss variants; Health, Mana, Stamina, MoveSpeed, AttackSpeed.                                   |
| `Tags/`            | `ArenaTags` with `Ability.*`, `State.*`, `Effect.*`, `Combo.*`, and `Cue.*`.                                               |
| `Effects/`         | Light/heavy damage, burn, pickups, mana/stamina costs, flamethrower ticks, haste, hit-react, invulnerability, enemy melee. |
| `Abilities/`       | `GA_LightAttack`, `GA_HeavyAttack`, `GA_Dodge`, `GA_Warcry`, `GA_Firebolt`, `GA_Flamethrower`, `GA_Meteor`.                |
| `Inputs/`          | `ArenaInputs` logical input library.                                                                                       |
| `Cues/`            | `ArenaCueLibrary` mapping cue tags to particle prefabs.                                                                    |
| `Resources/`       | `GASConfiguration` wiring tags, inputs, cues, and defaults.                                                                |
| `Prefabs/Actors/`  | Player and training dummy.                                                                                                 |
| `Prefabs/Enemies/` | Fodder and boss enemies with ASC, hurtbox, AI, and death handling.                                                         |
| `Prefabs/VFX/`     | Gameplay cue prefabs.                                                                                                      |
| `Scenes/`          | `Arena.unity` and `Training.unity`.                                                                                        |
| `Scripts/`         | Runtime gameplay components and ability logic.                                                                             |

## Scene Composition

| Scene            | Key objects                                                                                    | Purpose                                                |
| ---------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| `Training.unity` | `ArenaDemoBootstrap`, `GameplayCueManager`, training dummies, mechanic pads, camera, HUD       | Isolated ability verification and tuning.              |
| `Arena.unity`    | `ArenaDemoBootstrap`, `GameplayCueManager`, `ArenaWaveManager`, arena environment, camera, HUD | Full wave loop with enemy pressure and result screens. |

The player and HUD are prefab-driven so the two scenes share the same core setup.

### Scene-Level Services

| Object                              | Responsibility                                                 |
| ----------------------------------- | -------------------------------------------------------------- |
| `ArenaDemoBootstrap`                | Applies the demo GAS configuration for the scene.              |
| `GameplayCueManager`                | Routes cue tags to cue prefabs.                                |
| `ArenaWaveManager`                  | Owns wave spawning and victory progression in the Arena scene. |
| `Main Camera` with `ArenaCameraRig` | Follows the active player target.                              |

### Actor-Level Services

The player and enemies own gameplay through components on their prefabs:

| Component                  | Responsibility                                              |
| -------------------------- | ----------------------------------------------------------- |
| `AbilitySystemComponent`   | Runtime owner for attributes, effects, tags, and abilities. |
| `ArenaInitialAbilities`    | Grants the player ability assets at startup.                |
| `ArenaKeyboardInputSource` | Converts Unity keys into logical toolkit input events.      |
| `ArenaPlayerController`    | Movement and mouse-facing control outside the toolkit.      |
| `ArenaEnemyAI`             | Enemy movement, attack timing, and hit reaction state.      |
| `ArenaActorDeath`          | Death rule and cleanup when Health reaches zero.            |

## Runtime Composition

```mermaid
flowchart LR
    Input["ArenaKeyboardInputSource"]
    ASC["Player AbilitySystemComponent"]
    Abilities["GA_* ability assets"]
    Effects["GE_* effect assets"]
    Cues["ArenaCueLibrary"]
    HUD["ArenaHudPresenter and GASEventLog"]
    Enemies["Enemy ASCs"]

    Input --> ASC
    Abilities --> ASC
    ASC --> Effects
    Effects --> Enemies
    Effects --> Cues
    ASC --> HUD
    Enemies --> HUD
```

## Data Flow

```mermaid
flowchart TD
    Config["GASConfiguration"]
    Tags["ArenaTags"]
    Inputs["ArenaInputs"]
    Cues["ArenaCueLibrary"]
    Player["Player prefab with ASC"]
    Abilities["GA_* assets"]
    Effects["GE_* assets"]
    Runtime["Runtime subsystems"]
    HUD["ArenaHUD and event log"]

    Config --> Tags
    Config --> Inputs
    Config --> Cues
    Player --> Abilities
    Abilities --> Effects
    Player --> Runtime
    Effects --> Runtime
    Runtime --> HUD
```

The important boundary is that authored assets describe rules, while the ASC and runtime subsystems own current actor state.

## Core Gameplay Rules

| Rule         | Implementation                                                    |
| ------------ | ----------------------------------------------------------------- |
| Light combo  | Runtime state machine, combo window tag, timed hit windows.       |
| Heavy attack | Stamina cost, cooldown, stagger effect.                           |
| Dodge        | Movement burst plus duration effect granting invulnerability.     |
| Firebolt     | Projectile moving through world contact and applying effects.     |
| Meteor       | Ground AoE after telegraph delay.                                 |
| Flamethrower | Held channel with periodic damage and mana drain.                 |
| Warcry       | Duration self-buff modifying AttackSpeed.                         |
| Burn         | Periodic stacking duration effect.                                |
| Pickups      | Instant recovery effects.                                         |
| Death        | Health reaching zero adds dead state and removes/ends actor flow. |

## Ability Implementation Map

| Ability           | Definition/runtime file                                         | Primary assets to inspect                                                                |
| ----------------- | --------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| Light/heavy melee | `ArenaMeleeAbilityDefinition.cs`, `ArenaMeleeAbilityRuntime.cs` | `GA_LightAttack`, `GA_HeavyAttack`, `GE_LightDamage`, `GE_HeavyDamage`, `GE_HitReact`    |
| Dodge             | `ArenaDodgeAbilityDefinition.cs`, `ArenaDodgeAbilityRuntime.cs` | `GA_Dodge`, `GE_Invuln`                                                                  |
| Firebolt          | `ArenaFireboltAbilityDefinition.cs`                             | `GA_Firebolt`, `FireboltProjectile.prefab`, `GE_FireboltImpact`, `GE_Burn`               |
| Flamethrower      | `ArenaFlamethrowerAbilityDefinition.cs`                         | `GA_Flamethrower`, `GE_FlamethrowerTick`, `GE_FlamethrowerManaTick`, `GE_Burn`           |
| Meteor            | `ArenaMeteorAbilityDefinition.cs`                               | `GA_Meteor`, `MeteorGroundTargeter.prefab`, `MeteorProjectile.prefab`, `GE_MeteorImpact` |
| Warcry            | `ArenaBuffAbilityDefinition.cs`                                 | `GA_Warcry`, `GE_Haste`                                                                  |

Use this table to move between Inspector data and C# behavior without guessing which file owns a rule.

## Presentation Layer

Presentation feedback is intentionally part of the slice:

* `ArenaHudPresenter` renders HP, Mana, Stamina, wave/enemy counters, current target, and cooldown icons.
* `GASEventLog` streams ability, effect, stack, tag, failure, and cue events.
* `ArenaParticleCue` turns cue tags into pooled particle feedback.
* Hit and death feedback include flash, knockback, procedural WAV cues, and camera shake.
* `ArenaResultScreen` handles victory, defeat, and retry.

The presentation layer listens to runtime state; ability logic should not need one-off VFX code.

## Editor Debugging

Add `ArenaDebugDraw` to a scene root if you need Scene view overlays.

It can visualize:

* Melee hitboxes.
* Enemy attack ranges.
* Projectile and meteor radii.
* Player tags such as invulnerability.
* Combo windows.

Use overlays to verify target geometry before changing damage numbers or cooldowns.

## Verification

Use `Training.unity` for isolated checks and `Arena.unity` for pressure checks. The practical gameplay checks include:

* Attribute damage.
* Hitbox active windows.
* In-range and out-of-range melee.
* Combo chaining.
* Dodge invulnerability.
* Warcry buff and cooldown.
* Projectile impact.
* Meteor radius filtering.
* Regen and pickups.
* Flamethrower channel and release.
* Enemy melee.
* Death at 0 HP.

Add `ArenaDebugDraw` to a scene root when tuning hitboxes, projectile ranges, meteor radii, enemy attack ranges, or invulnerability windows.

If behavior changes after tuning content, check whether the intended gameplay rule changed or whether only presentation changed. Presentation-only changes should not require ability or effect rules to change.

## Dependencies

Arena has zero paid dependencies.

Runtime references:

* `GameplayAbilityToolkit.Core`
* `GameplayAbilityToolkit.UI`
* `Unity.TextMeshPro`
* `UnityEngine.UI`

Animation uses the built-in Unity Playables driver. It does not require Animancer or GameCreator.

## Asset Sources

* Quaternius character and animation assets are CC0.
* Kenney Modular Dungeon Kit assets are CC0 and live under `Art/External/KenneyModularDungeonKit/` with source/license notes.
* VFX are self-made Shuriken particle cues.
* Audio cues are procedural assets with source notes in `Art/Audio/SOURCE.md`.
* Third-party art sources are summarized in `../../../THIRD_PARTY_NOTICES.md`.

## Intentional Scope

Arena is a gameplay framework demonstration, not a full game template. It intentionally excludes:

* Networking, replication, and prediction.
* Save/load.
* Equipment and inventory systems.
* DOTS/Jobs conversion.
* Third-party integrations.

Those systems can be built on top of the toolkit, but they are not part of this demo slice.

## Recommended Extension Exercises

Use these exercises when adapting Arena to your own project:

| Exercise                       | Start from                                                                    |
| ------------------------------ | ----------------------------------------------------------------------------- |
| Add a new projectile ability   | `GA_Firebolt` and `ArenaFireboltAbilityDefinition.cs`                         |
| Add a new self-buff            | `GA_Warcry`, `GE_Haste`, and `ArenaBuffAbilityDefinition.cs`                  |
| Add a new enemy type           | `Prefabs/Enemies/Fodder.prefab`, `ArenaMonsterDefinition`, and `ArenaEnemyAI` |
| Add a status effect UI chip    | `GE_Burn`, `ArenaHudPresenter`, and `ArenaCueLibrary`                         |
| Add a manual verification note | This document and the relevant `Scripts/` entry point                         |

Keep each exercise small: one asset, one runtime rule, one visible result, one verification.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://morningheartgames.gitbook.io/docs/gameplay-ability-toolkit/demo-details/arena.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
