# cooperplease/pai-gow-civilization-official architecture

> Architecture diagram of the GitHub repository cooperplease/pai-gow-civilization-official, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cooperplease/pai-gow-civilization-official
- Repository: https://github.com/cooperplease/pai-gow-civilization-official

## Overview

This repository provides Yarn Spinner’s Unity runtime and editor integration, plus presentation add-ons. The principal workflow is to import Yarn assets into a project, run compiled dialogue, resolve localized lines and variables, dispatch commands, then present lines and options through Unity views. Source-index references establish several runtime and import relationships; unsampled subsystems are included where they represent substantial capabilities, but their internal wiring is not inferred. The README offers no capability detail beyond the project name and a design-document link.

Main entry points: [`Packages/dev.yarnspinner.unity/Runtime/DialogueRunner/DialogueRunner.cs`](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/DialogueRunner/DialogueRunner.cs) (Dialogue runner), [`Packages/dev.yarnspinner.unity/Runtime/Views/DialoguePresenterBase.cs`](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Views/DialoguePresenterBase.cs) (Presenter interface), [`Packages/dev.yarnspinner.unity/Editor/Importers/YarnProjectImporter.cs`](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Editor/Importers/YarnProjectImporter.cs) (Project importer), [`Packages/dev.yarnspinner.unity/Runtime/Storage/InMemoryVariableStorage.cs`](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Storage/InMemoryVariableStorage.cs) (Variable storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Editor authoring"]
  node_editor["Editor analysis<br/>[Analyser.cs]"]
  node_diagnostics["Action diagnostics<br/>[Diagnostics.cs]"]
  node_importer["Project importer"]
end

subgraph group_runtime["Dialogue runtime"]
  node_runner["Dialogue runner<br/>[DialogueRunner.cs]"]
  node_commands["Command dispatch<br/>[Actions.cs]"]
end

subgraph group_content["Content and state"]
  node_project["Yarn project<br/>[YarnProject.cs]"]
  node_storage[("Variable storage")]
  node_storagebase["Storage behavior"]
  node_localization[("Localization tables<br/>[Localization.cs]")]
  node_lineprovider["Localized line providers"]
end

subgraph group_presentation["Presentation"]
  node_presenterbase["Presenter interface"]
  node_lineview["Line presentation<br/>[LinePresenter.cs]"]
  node_options["Option presentation"]
  node_typewriter["Typewriter effects"]
end

subgraph group_addons["Presentation add-ons"]
  node_rpgaddon["Classic RPG presenter"]
  node_headaddon["Talking-head presenter"]
  node_animatoraddon["Text Animator integration"]
end

node_developer(("Unity developer"))

node_developer -->|"imports assets"| node_importer
node_importer -->|"creates project"| node_project
node_importer -->|"updates tables"| node_localization
node_importer -->|"configures storage"| node_storage
node_editor -->|"reports findings"| node_diagnostics
node_runner -->|"runs program"| node_project
node_runner -->|"uses variables"| node_storage
node_runner -->|"uses localization"| node_localization
node_runner -->|"requests lines"| node_lineprovider
node_runner -->|"dispatches dialogue"| node_presenterbase
node_runner -->|"dispatches commands"| node_commands
node_commands -->|"registers actions"| node_runner
node_storage -->|"implements storage"| node_storagebase
node_presenterbase -.->|"specialized by"| node_lineview
node_presenterbase -.->|"specialized by"| node_options
node_lineview -.->|"uses typewriter"| node_typewriter
node_presenterbase -.->|"extended by"| node_rpgaddon
node_presenterbase -.->|"extended by"| node_headaddon
node_typewriter -.->|"augmented by"| node_animatoraddon

click node_editor "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Editor/Analysis/Analyser.cs"
click node_diagnostics "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Editor/Analysis/Diagnostics.cs"
click node_importer "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Editor/Importers/YarnProjectImporter.cs"
click node_project "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/YarnProject/YarnProject.cs"
click node_runner "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/DialogueRunner/DialogueRunner.cs"
click node_commands "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Commands/Actions.cs"
click node_storage "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Storage/InMemoryVariableStorage.cs"
click node_storagebase "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Storage/VariableStorageBehaviour.cs"
click node_localization "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Localisation/Localization.cs"
click node_lineprovider "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/LineProviders/UnityLocalisedLineProvider.cs"
click node_presenterbase "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Views/DialoguePresenterBase.cs"
click node_lineview "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Views/LinePresenter.cs"
click node_options "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Views/OptionsPresenter.cs"
click node_typewriter "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Views/Typewriter/LetterTypewriter.cs"
click node_rpgaddon "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity.addons.classicrpg/Runtime/Scripts/RPGDialoguePresenter.cs"
click node_headaddon "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity.addons.snaaake/Runtime/Scripts/TalkingHeadDialoguePresenter.cs"
click node_animatoraddon "https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/TextAnimatorYarnTypewriter.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_editor,node_diagnostics,node_importer toneBlue
class node_runner,node_commands toneAmber
class node_project,node_storage,node_storagebase,node_localization,node_lineprovider toneMint
class node_presenterbase,node_lineview,node_options,node_typewriter toneRose
class node_rpgaddon,node_headaddon,node_animatoraddon,node_developer toneIndigo
```

## Components

### Editor authoring

- [Editor analysis](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Editor/Analysis/Analyser.cs): `Packages/dev.yarnspinner.unity/Editor/Analysis/Analyser.cs`
- [Action diagnostics](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Editor/Analysis/Diagnostics.cs): `Packages/dev.yarnspinner.unity/Editor/Analysis/Diagnostics.cs`
- [Project importer](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Editor/Importers/YarnProjectImporter.cs): `Packages/dev.yarnspinner.unity/Editor/Importers/YarnProjectImporter.cs`

### Dialogue runtime

- [Dialogue runner](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/DialogueRunner/DialogueRunner.cs): `Packages/dev.yarnspinner.unity/Runtime/DialogueRunner/DialogueRunner.cs`
- [Command dispatch](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Commands/Actions.cs): `Packages/dev.yarnspinner.unity/Runtime/Commands/Actions.cs`

### Content and state

- [Yarn project](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/YarnProject/YarnProject.cs): `Packages/dev.yarnspinner.unity/Runtime/YarnProject/YarnProject.cs`
- [Variable storage](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Storage/InMemoryVariableStorage.cs): `Packages/dev.yarnspinner.unity/Runtime/Storage/InMemoryVariableStorage.cs`
- [Storage behavior](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Storage/VariableStorageBehaviour.cs): `Packages/dev.yarnspinner.unity/Runtime/Storage/VariableStorageBehaviour.cs`
- [Localization tables](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Localisation/Localization.cs): `Packages/dev.yarnspinner.unity/Runtime/Localisation/Localization.cs`
- [Localized line providers](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/LineProviders/UnityLocalisedLineProvider.cs): `Packages/dev.yarnspinner.unity/Runtime/LineProviders/UnityLocalisedLineProvider.cs`

### Presentation

- [Presenter interface](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Views/DialoguePresenterBase.cs): `Packages/dev.yarnspinner.unity/Runtime/Views/DialoguePresenterBase.cs`
- [Line presentation](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Views/LinePresenter.cs): `Packages/dev.yarnspinner.unity/Runtime/Views/LinePresenter.cs`
- [Option presentation](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Views/OptionsPresenter.cs): `Packages/dev.yarnspinner.unity/Runtime/Views/OptionsPresenter.cs`
- [Typewriter effects](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity/Runtime/Views/Typewriter/LetterTypewriter.cs): `Packages/dev.yarnspinner.unity/Runtime/Views/Typewriter/LetterTypewriter.cs`

### Presentation add-ons

- [Classic RPG presenter](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity.addons.classicrpg/Runtime/Scripts/RPGDialoguePresenter.cs): `Packages/dev.yarnspinner.unity.addons.classicrpg/Runtime/Scripts/RPGDialoguePresenter.cs`
- [Talking-head presenter](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity.addons.snaaake/Runtime/Scripts/TalkingHeadDialoguePresenter.cs): `Packages/dev.yarnspinner.unity.addons.snaaake/Runtime/Scripts/TalkingHeadDialoguePresenter.cs`
- [Text Animator integration](https://github.com/cooperplease/pai-gow-civilization-official/blob/main/Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/TextAnimatorYarnTypewriter.cs): `Packages/dev.yarnspinner.unity.addons.textanimator/Scripts/TextAnimatorYarnTypewriter.cs`

### Other components

- **Unity developer**

## Connections

- Unity developer → Project importer: imports assets (evidence: `Packages/dev.yarnspinner.unity/Editor/Importers/YarnProjectImporter.cs`)
- Project importer → Yarn project: creates project (evidence: `Packages/dev.yarnspinner.unity/Editor/Importers/YarnProjectImporter.cs`)
- Project importer → Localization tables: updates tables (evidence: `Packages/dev.yarnspinner.unity/Editor/Importers/YarnProjectImporter.cs`)
- Project importer → Variable storage: configures storage (evidence: `Packages/dev.yarnspinner.unity/Editor/Importers/YarnProjectImporter.cs`)
- Editor analysis → Action diagnostics: reports findings (evidence: `Packages/dev.yarnspinner.unity/Editor/Analysis/Analyser.cs`)
- Dialogue runner → Yarn project: runs program (evidence: `Packages/dev.yarnspinner.unity/Runtime/DialogueRunner/DialogueRunner.cs`)
- Dialogue runner → Variable storage: uses variables (evidence: `Packages/dev.yarnspinner.unity/Runtime/DialogueRunner/DialogueRunner.cs`)
- Dialogue runner → Localization tables: uses localization (evidence: `Packages/dev.yarnspinner.unity/Runtime/DialogueRunner/DialogueRunner.cs`)
- Dialogue runner → Localized line providers: requests lines (evidence: `Packages/dev.yarnspinner.unity/Runtime/DialogueRunner/DialogueRunner.cs`)
- Dialogue runner → Presenter interface: dispatches dialogue (evidence: `Packages/dev.yarnspinner.unity/Runtime/DialogueRunner/DialogueRunner.cs`)
- Dialogue runner → Command dispatch: dispatches commands (evidence: `Packages/dev.yarnspinner.unity/Runtime/DialogueRunner/DialogueRunner.cs`)
- Command dispatch → Dialogue runner: registers actions (evidence: `Packages/dev.yarnspinner.unity/Runtime/Commands/Actions.cs`)
- Variable storage → Storage behavior: implements storage (evidence: `Packages/dev.yarnspinner.unity/Runtime/Storage/InMemoryVariableStorage.cs`)
- Presenter interface → Line presentation: specialized by
- Presenter interface → Option presentation: specialized by
- Line presentation → Typewriter effects: uses typewriter
- Presenter interface → Classic RPG presenter: extended by (evidence: `Packages/dev.yarnspinner.unity.addons.classicrpg/Runtime/Scripts/RPGDialoguePresenter.cs`)
- Presenter interface → Talking-head presenter: extended by (evidence: `Packages/dev.yarnspinner.unity.addons.snaaake/Runtime/Scripts/TalkingHeadDialoguePresenter.cs`)
- Typewriter effects → Text Animator integration: augmented by
