# terminalcrazy1/planet-null architecture

> Architecture diagram of the GitHub repository terminalcrazy1/planet-null, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/terminalcrazy1/planet-null
- Repository: https://github.com/terminalcrazy1/planet-null

## Overview

##### Main Components

A. Client-Side Components:
- Player System
- Movement Controller
- Combat System
- Inventory Management
- Skills System
- Terrain System
- Height Generation
- Water Generation
- Resource Generation
- Building System
- Rendering Pipeline (URP)
- UI Layer
- Main Menu
- Server Browser
- Build Menu

B. Server-Side Components:
- Networking Layer
- Game State Manager
- World State Persistence
- Anti-Cheat System (Packet Spoofing Protection)

**┌─ Client Layer ─────────────────────┐**
- UI → Player Controller → Rendering │
- ↑          ↕           ↑       │
- Input    Game Systems   Assets    │
- ┬───────────────────┘
- ↕
**┌─ Network Layer ──────────────────┐**
- Client-Server Communication      │
- Anti-Cheat / Security           │
- ┬────────────────────┘
- ↕
**┌─ Server Layer ─────────────────┐**
- World State → Persistence     │
- Game Logic → Player Data      │
- ┘

##### Important Relationships to Highlight

- Player Controller's interaction with the terrain system
- Building system's dependency on terrain
- Combat system's integration with networking
- Resource generation's connection to world persistence
- UI system's connection to game state

##### Specific Implementation Details

- Universal Render Pipeline (URP)
- Physics2D system
- Scene management
- Prefab system (Player, Weapon, TerrainManager)

##### Data Flow Indicators

- Real-time player updates
- World state synchronization
- Resource gathering and modification
- Combat interactions
- Building placement validation

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef server fill:#2ecc71,stroke:#27ae60,color:white
    classDef network fill:#f1c40f,stroke:#f39c12,color:white
    classDef storage fill:#9b59b6,stroke:#8e44ad,color:white
    classDef ui fill:#e67e22,stroke:#d35400,color:white

    %% Client Layer
    subgraph ClientLayer
        UI["UI System"]:::ui
        PlayerSystem["Player System"]:::client
        RenderingSystem["Rendering Pipeline (URP)"]:::client
        GameSystems["Game Systems"]:::client

        %% UI Components
        UI --> |Input| MainMenu["Main Menu"]:::ui
        UI --> |Input| ServerBrowser["Server Browser"]:::ui
        UI --> |Input| BuildMenu["Build Menu"]:::ui

        %% Player Components
        PlayerSystem --> MovementController["Movement Controller"]:::client
        PlayerSystem --> CombatSystem["Combat System"]:::client
        PlayerSystem --> Inventory["Inventory Management"]:::client
        PlayerSystem --> Skills["Skills System"]:::client

        %% Game Systems
        GameSystems --> TerrainSystem["Terrain System"]:::client
        GameSystems --> BuildingSystem["Building System"]:::client
        TerrainSystem --> HeightGen["Height Generation"]:::client
        TerrainSystem --> WaterGen["Water Generation"]:::client
        TerrainSystem --> ResourceGen["Resource Generation"]:::client
    end

    %% Network Layer
    subgraph NetworkLayer
        NetworkManager["Networking Layer"]:::network
        AntiCheat["Anti-Cheat System"]:::network
    end

    %% Server Layer
    subgraph ServerLayer
        GameStateManager["Game State Manager"]:::server
        WorldState["World State"]:::server
        Persistence["World State Persistence"]:::storage
        PlayerData["Player Data"]:::storage
    end

    %% Relationships
    UI --> PlayerSystem
    PlayerSystem --> RenderingSystem
    GameSystems --> RenderingSystem
    ClientLayer --> NetworkLayer
    NetworkLayer --> ServerLayer
    GameStateManager --> WorldState
    WorldState --> Persistence
    GameStateManager --> PlayerData

    %% Click Events
    click PlayerSystem "https://github.com/terminalcrazy1/Planet-Null/tree/master/Assets/scripts/player/"
    click CombatSystem "https://github.com/terminalcrazy1/Planet-Null/blob/master/Assets/scripts/Generic/damage_handler.cs"
    click TerrainSystem "https://github.com/terminalcrazy1/Planet-Null/blob/master/Assets/scripts/terrain/terrainManager.cs"
    click RenderingSystem "https://github.com/terminalcrazy1/Planet-Null/blob/master/Assets/Settings/UniversalRP.asset"
    click NetworkManager "https://github.com/terminalcrazy1/Planet-Null/blob/master/ProjectSettings/NetworkManager.asset"
    click PlayerSystem "https://github.com/terminalcrazy1/Planet-Null/blob/master/Assets/prefabs/Player.prefab"
    click CombatSystem "https://github.com/terminalcrazy1/Planet-Null/blob/master/Assets/prefabs/Weapon.prefab"
    click TerrainSystem "https://github.com/terminalcrazy1/Planet-Null/blob/master/Assets/prefabs/terrainManager.prefab"

    %% Legend
    subgraph Legend
        Client["Client Component"]:::client
        Server["Server Component"]:::server
        Net["Network Component"]:::network
        Store["Storage Component"]:::storage
        UIComp["UI Component"]:::ui
    end
```
