# kawaiimt/hoilai-galgame-framework architecture

> Architecture diagram of the GitHub repository kawaiimt/hoilai-galgame-framework, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kawaiimt/hoilai-galgame-framework
- Repository: https://github.com/kawaiimt/hoilai-galgame-framework

## Overview

##### Project Type and Purpose
- It is a game framework specifically for Galgames (visual novels) built on top of Unity.
- The framework supports narrative scripting via plain text/XML, offers full runtime (hot update) support, and includes animation support for characters and scenes.
- It is open source (Apache licensed) and extensible for customization.

##### File Structure
- The Assets folder is the primary container where most project components reside. Under Assets, you have subdirectories such as:
- HGF: Contains the main Unity scene(s), scripts, and framework logic.
- Scripts: Divided into submodules like Galgame (which hosts various galgame manager components like text, choices, character animations, etc.) and utility scripts (such as BGScaler, GameAPI, GameConfig, StringInList, ZoomImage).
- Tetra Attributes: An independent module providing a suite of custom Unity editor attributes, property drawers, and GUI customization tools. This is a key component for easing scene/editor development and boosting editor functionality.
- Plugins: Integrates external libraries. In this case, the DOTween and DOTweenPro libraries are included, which are used to drive in-game animations, tweens, and potentially other dynamic effects.
- StreamingAssets: Holds external text/XML scripts, audio files, INI configuration files, and textures. This indicates that game narrative and media resources are loaded at runtime from disk, supporting the theme of “pure text” and hot update capability.
- ProjectSettings, Packages, and other configuration files indicate standard Unity project configurations.

##### Major Components
a. Core Unity Engine Environment:
- Unity engine as the foundational runtime environment where your assets, scenes, and game objects are managed.
b. HGF Framework Core Modules:
- Galgame Module: Include the GalManager components (for managing text display, choices, background images, character images, etc.).
- Game API & Configuration: Represent GameAPI, GameConfig, and StringInList that serve as interfaces for game control and configuration.
- Scene & Asset Management: Show the linkage between Scenes (Assets/HGF/Scenes), StreamingAssets for dynamic content (XML, audio, textures), and runtime assets.
c. Tetra Attributes Module:
d. External Libraries:
- DOTween and DOTweenPro (and accompanying Demigiant libraries) should be shown as independent external animation modules that the core game scripts interact with.
e. Data & Asset Layers:
- Resources from the Resources folder and Settings folder which contain prefabs, audio, and graphics assets essential to the project.

##### Relationships and Interactions
- Dependency: The Galgame module leverages external libraries (DOTween) for tweening/animation effects.
- Plugin Integration: Tetra Attributes enhances editor behaviors which indirectly influence the editing and runtime behavior of the application.
- Configuration: The project settings interact with game configuration systems (GameConfig.cs and INI/XML files in StreamingAssets) enabling hot updates and dynamic storytelling changes.

##### Architectural Patterns and Design Principles
- Component-Based Design: Each game feature (text display, choice management, background handling, character animations) is implemented as separate manager classes that loosely couple through a central game API.
- Modular Separation: The clear separation of core game logic (in HGF/Scripts) from editor and visual attributes (in Tetra Attributes) and external animations (in Plugins/Demigiant) shows a modular architecture.
- Data-Driven Design: The reliance on external assets (XML, INI, plain-text scripts) emphasizes a data-driven approach for the narrative content.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Unity Engine / Game Runtime"]:::runtime

    subgraph "HGF Core Modules"
        B["Galgame Module"]:::core
        C["GameAPI"]:::core
        D["GameConfig"]:::core
        E["StringInList"]:::core
    end

    subgraph "Asset & Scene Management"
        F["Scenes"]:::assets
        G["StreamingAssets"]:::assets
    end

    subgraph "External Animation Libraries"
        H["DOTween"]:::external
        I["DOTweenPro"]:::external
    end

    subgraph "Data & Asset Layers"
        J["Resources"]:::data
        K["Settings"]:::data
    end

    L["Tetra Attributes Module"]:::editor

    %% Connections between core components and runtime
    A -->|"uses"| B
    A -->|"calls"| C
    A -->|"configures"| D
    A -->|"utilizes"| E

    %% Unity Engine manages scenes and assets
    A -->|"manages"| F
    A -->|"loads"| G

    %% GameAPI loads dynamic content from StreamingAssets
    C -->|"loads"| G

    %% Galgame module uses external animation libraries
    B -->|"animates"| H
    B -->|"animates"| I

    %% Data & Asset Layers supply resources and configuration
    J -->|"supplies"| A
    K -->|"supplies"| A

    %% Tetra Attributes enhance Unity Editor environment
    L -->|"enhances"| A

    %% Click Events
    click B "https://github.com/kawaiimt/hoilai-galgame-framework/tree/master/Assets/HGF/Scripts/Galgame"
    click C "https://github.com/kawaiimt/hoilai-galgame-framework/blob/master/Assets/HGF/Scripts/GameAPI.cs"
    click D "https://github.com/kawaiimt/hoilai-galgame-framework/blob/master/Assets/HGF/Scripts/GameConfig.cs"
    click E "https://github.com/kawaiimt/hoilai-galgame-framework/blob/master/Assets/HGF/Scripts/StringInList.cs"
    click F "https://github.com/kawaiimt/hoilai-galgame-framework/tree/master/Assets/HGF/Scenes"
    click G "https://github.com/kawaiimt/hoilai-galgame-framework/tree/master/Assets/StreamingAssets/HGF"
    click L "https://github.com/kawaiimt/hoilai-galgame-framework/tree/master/Assets/HGF/Tetra Attributes"
    click H "https://github.com/kawaiimt/hoilai-galgame-framework/tree/master/Assets/Plugins/Demigiant/DOTween"
    click I "https://github.com/kawaiimt/hoilai-galgame-framework/tree/master/Assets/Plugins/Demigiant/DOTweenPro"
    click J "https://github.com/kawaiimt/hoilai-galgame-framework/tree/master/Assets/Resources/HGF"
    click K "https://github.com/kawaiimt/hoilai-galgame-framework/tree/master/Assets/Settings"

    %% Styles
    classDef runtime fill:#f9c,stroke:#333,stroke-width:2px;
    classDef core fill:#bbf,stroke:#333,stroke-width:2px;
    classDef assets fill:#afa,stroke:#333,stroke-width:2px;
    classDef external fill:#fb8,stroke:#333,stroke-width:2px;
    classDef data fill:#ddd,stroke:#333,stroke-width:2px;
    classDef editor fill:#fdd,stroke:#333,stroke-width:2px;
```
