# david-vanderhaar/rogue_engine architecture

> Architecture diagram of the GitHub repository david-vanderhaar/rogue_engine, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/david-vanderhaar/rogue_engine
- Repository: https://github.com/david-vanderhaar/rogue_engine

## Overview

##### Main System Components

a) Core Engine Layer:
- Game Engine (Central coordinator)
- Entity System
- Action System
- System
- Input/Keymap System

b) Game Content Layer:
- Modes (Different game variations)
- Screens (UI states)
- Characters
- Items
- Status Effects

c) Resource Layer:
- Assets (sounds, fonts)
- Maps
- Constants

##### Component Relationships

a) Core Flow:
**User Input → Keymap → Actions → Engine → Display**

b) Entity Composition:
**Entity Base**
- Behaviors (AI)
- Actions
- Components (Acting, Attacking, etc.)

c) Game State Management:
**Game**
- Engine
- Current Mode
- Active Screen
- Entity Manager

##### Specific Implementation Details

Specialized components:

a) Mode System:
- Hidden Leaf
- Jacinto
- Tall Grass
- Development

b) Screen Flow:
**Title → Character Select → Level → Win/Lose**

##### Key Architectural Patterns to Highlight

a) Component-Based Entity System:
- How entities are composed of multiple behaviors
- Demonstrate inheritance and composition patterns

b) Action System:
- Action hierarchy
- Relationship between KeyActions and base Actions

c) Resource Management:
- Asset loading and management
- Sound system integration

##### Technical Details

- React.js integration points
- Konva.js rendering system
- File structure organization
- State management flow

Top Level:
**[User Interface Layer]**
- ↕
**[Game Logic Layer]**
- ↕
**[Engine Core Layer]**
- ↕
**[Resource Management Layer]**

- The modular nature of the engine
- Clear separation of concerns
- Component-based architecture
- Game state flow
- Resource management

##### Implementation Notes

- Use different line styles for different types of relationships
- Notes for key architectural decisions
- Scaling considerations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        UI["Base UI"]:::ui
        HLU["Hidden Leaf UI"]:::ui
        JU["Jacinto UI"]:::ui
        TGU["Tall Grass UI"]:::ui
        Screen["Screen System"]:::ui
    end

    subgraph "Game Logic Layer"
        GameEngine["Game Engine"]:::core
        Modes["Game Modes"]:::game
        HLM["Hidden Leaf Mode"]:::game
        JM["Jacinto Mode"]:::game
        TGM["Tall Grass Mode"]:::game
        DM["Development Mode"]:::game
    end

    subgraph "Engine Core Layer"
        EntitySystem["Entity System"]:::core
        ActionSystem["Action System"]:::core
        DisplaySystem["Display System"]:::core
        InputSystem["Input/Keymap System"]:::core
        
        subgraph "Entity Components"
            Characters["Characters"]:::entity
            Items["Items"]:::entity
            StatusEffects["Status Effects"]:::entity
            Behaviors["Behaviors/AI"]:::entity
        end
    end

    subgraph "Resource Layer"
        Assets["Assets"]:::resource
        Maps["Maps"]:::resource
        Constants["Constants"]:::resource
        Sounds["Sound Assets"]:::resource
        Fonts["Font Assets"]:::resource
    end

    %% Relationships
    InputSystem --> ActionSystem
    ActionSystem --> GameEngine
    GameEngine --> DisplaySystem
    DisplaySystem --> UI
    
    GameEngine --> Modes
    Modes --> |Contains| HLM
    Modes --> |Contains| JM
    Modes --> |Contains| TGM
    Modes --> |Contains| DM
    
    EntitySystem --> |Manages| Characters
    EntitySystem --> |Manages| Items
    EntitySystem --> |Manages| StatusEffects
    EntitySystem --> |Manages| Behaviors
    
    UI --> |Includes| HLU
    UI --> |Includes| JU
    UI --> |Includes| TGU

    %% Click Events
    click GameEngine "https://github.com/david-vanderhaar/rogue_engine/blob/master/src/nystrum/Engine/engine.js"
    click EntitySystem "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/Entities/"
    click ActionSystem "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/Actions/"
    click DisplaySystem "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/Display/"
    click InputSystem "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/Keymap/"
    click Modes "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/Modes/"
    click Screen "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/Screen/"
    click Characters "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/Characters/"
    click Items "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/Items/"
    click StatusEffects "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/StatusEffects/"
    click Maps "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/Maps/"
    click Constants "https://github.com/david-vanderhaar/rogue_engine/blob/master/src/nystrum/constants.js"
    click HLM "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/Modes/HiddenLeaf/"
    click JM "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/Modes/Jacinto/"
    click TGM "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/Modes/TallGrass/"
    click DM "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/Modes/Development/"
    click UI "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/UI/"
    click HLU "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/UI/HiddenLeaf/"
    click JU "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/UI/Jacinto/"
    click TGU "https://github.com/david-vanderhaar/rogue_engine/tree/master/src/nystrum/UI/TallGrass/"
    click Sounds "https://github.com/david-vanderhaar/rogue_engine/tree/master/public/sounds/"
    click Fonts "https://github.com/david-vanderhaar/rogue_engine/tree/master/public/fonts/"

    %% Styles
    classDef core fill:#2374ab
    classDef game fill:#48a9a6
    classDef ui fill:#9c528b
    classDef entity fill:#1f8ac0
    classDef resource fill:#d4b483
    
    %% Legend
    subgraph Legend
        L1["Core Systems"]:::core
        L2["Game Content"]:::game
        L3["UI Components"]:::ui
        L4["Entity Components"]:::entity
        L5["Resources"]:::resource
    end
```
