# jkim-hack/cse3902 architecture

> Architecture diagram of the GitHub repository jkim-hack/cse3902, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jkim-hack/cse3902
- Repository: https://github.com/jkim-hack/cse3902

## Overview

##### Main Components
- Game Core & Engine: At the center, include the primary game loop (Game1.cs) along with the GameStateManager and GameConditionManager that control overall game flow.
- Input & Command Processing: Show the Controllers (KeyboardController, MouseController) sending input to the Command system. Include the command classes (in the Commands directory) that encapsulate various user actions (e.g., LinkMovementCommand, PauseCommand).
- Collision System: Create a separate block for collision detection. This should include the CollisionManager, the assortment of ICollidable implementations (BlockCollidable, EnemyCollidable, etc.) and the QuadTree for spatial partitioning.
- Room & Level Management: Reflect the Rooms system that includes Room, RoomHandler, RoomTransitionManager and the XMLParsing subsystem used for level descriptions (files like Level1.xml, etc.). Don’t forget to include aspects related to door handling (in the Doors directory) and conditions applied in Rooms/Conditions.
- Graphics & Sprite Management: Include the SpriteFactory modules (BlockSpriteFactory, DoorSpriteFactory, EnemySpriteFactory, etc.) and the Sprites directory with specialized sprites for Link, enemies and HUD components. Also show the separation of interior/exterior assets.
- HUD & UI: Illustrate the HUD components under the HUD directory – including the HUDManager, InventoryHUDItem, HealthHUDItem, etc. This is important as it reflects the interaction with game settings and real-time player feedback.
- Audio & Content Management: Include a Content block for audio files (the many LOZ_*.wav files and other sound assets) and font assets. This may be shown in parallel with the content pipeline (Content.mgcb).
- Particle & Effects System: Represent the ParticleSystem component along with its emitters (e.g., ArrowEmitter, BombEmitter) and particles for effects.
- Settings & Utilities: Finally, add components that manage game settings (SettingsManager, SettingsValues) and various utilities (HUDUtilities, InventoryUtilities, etc.) that are used across multiple systems.

##### Relationships and Interactions
- Directional links from the Input/Controllers to the Commands component, and from Commands to the Entities (for instance, moving Link and triggering attacks).
- The GameCore interacts with the Room/Level Management module to drive transitions between rooms. The Room system in turn works closely with the Collision system to ensure proper physics and interactions.
- The Entities module should have a two-way connection with both the SpriteFactory and Collision system, indicating that each game entity is represented visually and is involved in collision handling.
- The HUD interacts with the GameCore to provide game state feedback, and the Settings component interacts both with the HUD and the GameCore.
- Finally, the XMLParsing module feeds data into Room/Level Management, establishing how game levels are constructed at runtime.

##### Architectural Patterns and Design Principles
- Component-Based Design: The project segments functionality into clearly separated components (e.g., Entities, Controllers, Collision, HUD, etc.) which makes the system modular.
- Separation of Concerns: The game logic is segmented into various aspects (e.g., rendering, collision, input) that communicate through well-defined interfaces.
- State Machines: Multiple state machines are evident for entities, particularly for Link and the enemies, and these should be highlighted.
- Command Pattern: The command classes are used to encapsulate actions, allowing flexible input handling.
- Data-Driven Level Loading: Mark the XMLParsing component as the driver for reading level data from XML files, which allows game levels to be data-driven.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Game Core & Engine
    subgraph "Game Core & Engine"
        GC1["Game1.cs"]:::runtime
        GC2["GameStateManager.cs"]:::runtime
        GC3["GameConditionManager.cs"]:::runtime
    end

    %% Input & Command Processing
    subgraph "Input & Command Processing"
        Ctrl1["KeyboardController.cs"]:::input
        Ctrl2["MouseController.cs"]:::input
        CMD["Command Classes"]:::input
    end

    %% Entities & State Machines
    subgraph "Entities & State Machines"
        E1["Link.cs"]:::entities
        E2["LinkStateMachine.cs"]:::entities
        subgraph "Enemies"
            EN["Enemies Directory"]:::entities
        end
    end

    %% Collision System
    subgraph "Collision System"
        COL1["CollisionManager.cs"]:::runtime
        COL2["QuadTree.cs"]:::runtime
        COL3["Collidables"]:::runtime
    end

    %% Room & Level Management
    subgraph "Room & Level Management"
        R1["Room.cs"]:::runtime
        R2["RoomHandler.cs"]:::runtime
        R3["RoomTransitionManager.cs"]:::runtime
        R4["XMLParsing & Level Files"]:::resource
    end

    %% Graphics & Sprite Management
    subgraph "Graphics & Sprite Management"
        SF["SpriteFactory Directory"]:::resource
        SPR["Sprites Directory"]:::resource
    end

    %% HUD & UI
    subgraph "HUD & UI"
        HUDM["HUDManager.cs"]:::ui
        HUDI["HUD Items"]:::ui
        HUDS["HUD Sprites"]:::ui
    end

    %% Audio & Content Management
    subgraph "Audio & Content Management"
        AC1["Content.mgcb & Assets"]:::resource
        AC2["SoundFactory & Sounds"]:::resource
    end

    %% Particle & Effects System
    subgraph "Particle & Effects System"
        PS["ParticleSystem Directory"]:::effects
        PE["Emitters & Particles"]:::effects
    end

    %% Settings & Utilities
    subgraph "Settings & Utilities"
        SET["Settings & Values"]:::settings
        UTIL["Utilities"]:::settings
    end

    %% Connections
    Ctrl1 ---|"input"| CMD
    Ctrl2 ---|"input"| CMD
    CMD ---|"executes"| GC1
    GC1 ---|"controls"| E1
    E1 ---|"stateUpdate"| E2
    E1 ---|"renders"| SF
    E1 ---|"collides"| COL1
    GC1 ---|"triggers"| R2
    R2 ---|"integrates"| COL1
    R4 ---|"parses"| R2
    HUDM ---|"displays"| GC1
    SET ---|"configures"| HUDM
    SET ---|"configures"| GC1
    PS ---|"triggersEffect"| E1
    GC1 ---|"playsAudio"| AC2

    %% Styles
    classDef runtime fill:#ffe6e6,stroke:#cc0000,stroke-width:2px;
    classDef input fill:#e6f7ff,stroke:#005c99,stroke-width:2px;
    classDef entities fill:#fff0cc,stroke:#b38f00,stroke-width:2px;
    classDef resource fill:#e6ffe6,stroke:#009933,stroke-width:2px;
    classDef ui fill:#e6ccff,stroke:#660099,stroke-width:2px;
    classDef effects fill:#d9e6ff,stroke:#003366,stroke-width:2px;
    classDef settings fill:#fff5e6,stroke:#cc7a00,stroke-width:2px;

    %% Click Events
    click GC1 "https://github.com/jkim-hack/cse3902/blob/master/cse3902/Game1.cs"
    click GC2 "https://github.com/jkim-hack/cse3902/blob/master/cse3902/GameStateManager.cs"
    click GC3 "https://github.com/jkim-hack/cse3902/blob/master/cse3902/GameConditionManager.cs"
    click Ctrl1 "https://github.com/jkim-hack/cse3902/blob/master/cse3902/Controllers/KeyboardController.cs"
    click Ctrl2 "https://github.com/jkim-hack/cse3902/blob/master/cse3902/Controllers/MouseController.cs"
    click CMD "https://github.com/jkim-hack/cse3902/tree/master/cse3902/Commands"
    click E1 "https://github.com/jkim-hack/cse3902/blob/master/cse3902/Entities/Link.cs"
    click E2 "https://github.com/jkim-hack/cse3902/blob/master/cse3902/Entities/LinkStateMachine.cs"
    click EN "https://github.com/jkim-hack/cse3902/tree/master/cse3902/Entities/Enemies"
    click COL1 "https://github.com/jkim-hack/cse3902/blob/master/cse3902/Collision/CollisionManager.cs"
    click COL2 "https://github.com/jkim-hack/cse3902/blob/master/cse3902/Collision/QuadTree.cs"
    click COL3 "https://github.com/jkim-hack/cse3902/tree/master/cse3902/Collision/Collidables"
    click R1 "https://github.com/jkim-hack/cse3902/blob/master/cse3902/Rooms/Room.cs"
    click R2 "https://github.com/jkim-hack/cse3902/blob/master/cse3902/Rooms/RoomHandler.cs"
    click R3 "https://github.com/jkim-hack/cse3902/blob/master/cse3902/Rooms/RoomTransitionManager.cs"
    click R4 "https://github.com/jkim-hack/cse3902/tree/master/cse3902/XMLParsing"
    click SF "https://github.com/jkim-hack/cse3902/tree/master/cse3902/SpriteFactory"
    click SPR "https://github.com/jkim-hack/cse3902/tree/master/cse3902/Sprites"
    click HUDM "https://github.com/jkim-hack/cse3902/blob/master/cse3902/HUD/HUDManager.cs"
    click HUDI "https://github.com/jkim-hack/cse3902/tree/master/cse3902/HUD/HUDItems"
    click HUDS "https://github.com/jkim-hack/cse3902/tree/master/cse3902/Sprites/HUD"
    click AC1 "https://github.com/jkim-hack/cse3902/tree/master/cse3902/Content"
    click AC2 "https://github.com/jkim-hack/cse3902/tree/master/cse3902/Sounds"
    click PS "https://github.com/jkim-hack/cse3902/tree/master/cse3902/ParticleSystem"
    click PE "https://github.com/jkim-hack/cse3902/tree/master/cse3902/ParticleSystem/Emitters"
    click SET "https://github.com/jkim-hack/cse3902/tree/master/cse3902/Settings"
    click UTIL "https://github.com/jkim-hack/cse3902/tree/master/cse3902/Utilities"
```
