# x2shadow/x2slime3d architecture

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

- Interactive diagram: https://gitdiagram.com/x2shadow/x2slime3d
- Repository: https://github.com/x2shadow/x2slime3d

## Overview

##### Main Components
- Game Engine Context: At the highest level, the Unity engine forms the runtime environment through which all assets, scenes, and scripts are executed.
- Scenes & Levels: Under Assets/_Project/Scenes there are many Unity scene files (e.g., Game Boot Scene, Level1, Level2… Level50), which represent different game states or levels.
- Game Systems & Lifecycles: Inside Assets/_Project/Scripts, you have several subdirectories grouping core game logic:
- GameLifetime: Likely a central game manager controlling overall game state.
- PlayerLifetime: Manages the player-specific logic and state.
- UILifetime: Handles UI-related functionality.
- Input: Contains classes for input handling (e.g., InputReader, PlayerInputActions) which tie into Unity’s Input System.
- Other: Additional supporting behaviors such as camera controls, platform movement, jump configurations, etc.
- Assets & Art: Assets like prefabs, materials, animations, and art assets are organized primarily under Assets/_Project/Art, prefabs under Assets/_Project/Prefabs, and materials under Assets/_Project/Materials.
- External Dependencies & Plugins: The project leverages several packages:
- VContainer for dependency injection, managing object creation and dependency graphs (see GameLifetimeScope, PlayerLifetimeScope, UILifetimeScope).
- UniTask for asynchronous tasks.
- DOTween for tween-based animations.
- NuGetForUnity to manage several NuGet packages (these are managed under Assets/Packages).
- Safe Area Helper and others to enhance UI compatibility across different devices.

##### Architectural Patterns & Relationships
- Separation of Concerns: Each subsystem (Game, Player, UI, Input) is in its own folder/module, indicating a clear breakdown of responsibilities.
- Lifecycle & Event Flow:
- At game startup, a GameLifetimeScope is initialized that might instantiate controllers for the player and UI using the DI container.
- Input is processed via the InputReader and relevant player input actions, distributing data to appropriate components.
- Player and UI systems likely trigger animations via DOTween and coordinate asynchronous tasks via UniTask.

##### Final Recommendations
- Use clear and concise labels for each component.
- Create additional annotations if necessary to explain interactions that may not be obvious at first glance (for example, how asynchronous operations via UniTask are triggered).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Unity Environment
    subgraph "Unity Environment"
        U["Unity Engine (Runtime)"]:::unity
        Scenes["Scenes & Levels"]:::scene
        U --> Scenes
    end

    %% Core Systems
    subgraph "Core Systems"
        GameMgr["Game Manager"]:::core
        PlayerMgr["Player Manager"]:::core
        UI["UI Manager"]:::core
        Input["Input System"]:::input
        Support["Supporting Gameplay Systems"]:::support

        Scenes --> GameMgr
        Scenes --> Input
        GameMgr --> PlayerMgr
        GameMgr --> UI
        Input --> PlayerMgr
        Input --> UI
        GameMgr --> Support
    end

    %% Art & Assets
    subgraph "Art & Assets"
        Art["Art Assets"]:::art
        Materials["Materials"]:::art
        Prefabs["Prefabs"]:::art

        Scenes --> Art
        Scenes --> Materials
        Scenes --> Prefabs
    end

    %% Dependency Injection
    subgraph "Dependency Injection"
        DI["DI Container (VContainer)"]:::di
        GameLifetimeScope["GameLifetimeScope"]:::di
        PlayerLifetimeScope["PlayerLifetimeScope"]:::di
        UILifetimeScope["UILifetimeScope"]:::di

        DI --> GameLifetimeScope
        DI --> PlayerLifetimeScope
        DI --> UILifetimeScope
        DI --- GameMgr
        DI --- PlayerMgr
        DI --- UI
    end

    %% External Libraries & Packages
    subgraph "External Libraries & Packages"
        DOT["DOTween"]:::external
        UniTask["UniTask"]:::external
        NuGet["NuGet Config"]:::external
        Packages["Packages Directory"]:::external

        Support --- DOT
        Support --- UniTask
        NuGet --- Packages
        NuGet --- DI
        Packages --- DI
    end

    %% Click Events
    click Scenes "https://github.com/x2shadow/x2slime3d/tree/main/Assets/_Project/Scenes"
    click GameMgr "https://github.com/x2shadow/x2slime3d/tree/main/Assets/_Project/Scripts/GameLifetime"
    click PlayerMgr "https://github.com/x2shadow/x2slime3d/tree/main/Assets/_Project/Scripts/PlayerLifetime"
    click UI "https://github.com/x2shadow/x2slime3d/tree/main/Assets/_Project/Scripts/UILifetime"
    click Input "https://github.com/x2shadow/x2slime3d/tree/main/Assets/_Project/Scripts/Input"
    click Support "https://github.com/x2shadow/x2slime3d/tree/main/Assets/_Project/Scripts/Other"
    click Art "https://github.com/x2shadow/x2slime3d/tree/main/Assets/_Project/Art"
    click Materials "https://github.com/x2shadow/x2slime3d/tree/main/Assets/_Project/Materials"
    click Prefabs "https://github.com/x2shadow/x2slime3d/tree/main/Assets/_Project/Prefabs"
    click GameLifetimeScope "https://github.com/x2shadow/x2slime3d/blob/main/Assets/_Project/Scripts/GameLifetime/GameLifetimeScope.cs"
    click PlayerLifetimeScope "https://github.com/x2shadow/x2slime3d/blob/main/Assets/_Project/Scripts/PlayerLifetime/PlayerLifetimeScope.cs"
    click UILifetimeScope "https://github.com/x2shadow/x2slime3d/blob/main/Assets/_Project/Scripts/UILifetime/UILifetimeScope.cs"
    click DOT "https://github.com/x2shadow/x2slime3d/blob/main/Assets/Resources/DOTweenSettings.asset"
    click NuGet "https://github.com/x2shadow/x2slime3d/blob/main/Assets/NuGet.config"
    click Packages "https://github.com/x2shadow/x2slime3d/tree/main/Assets/Packages"

    %% Style Definitions
    classDef unity fill:#ccf,stroke:#000,stroke-width:2px;
    classDef scene fill:#cff,stroke:#000,stroke-width:2px;
    classDef core fill:#cfc,stroke:#000,stroke-width:2px;
    classDef input fill:#fcf,stroke:#000,stroke-width:2px;
    classDef support fill:#ffc,stroke:#000,stroke-width:2px;
    classDef art fill:#f9c,stroke:#000,stroke-width:2px;
    classDef di fill:#cf9,stroke:#000,stroke-width:2px;
    classDef external fill:#fcc,stroke:#000,stroke-width:2px;
```
