# bluebilly2/earthgame2 architecture

> Architecture diagram of the GitHub repository bluebilly2/earthgame2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bluebilly2/earthgame2
- Repository: https://github.com/bluebilly2/earthgame2

## Overview

EarthGame2 is an authoritative-server survival simulation: a Unity client presents the world, while an engine-free simulation owns world state and player outcomes. The main loop is player input over the protocol, server-side validation and simulation, then state and terrain updates back to the client. World creation/preparation and persistence are separate server responsibilities. The README documents these product boundaries; source excerpts are limited, so uncertain internal call relationships are omitted.

Main entry points: [`Engine/packages/com.earthgame.server/Runtime/GameServer.cs`](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/GameServer.cs) (Game server), [`Engine/packages/com.earthgame.engine/Runtime/World/WorldState.cs`](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.engine/Runtime/World/WorldState.cs) (World state), [`Engine/packages/com.earthgame.clientcore/Runtime/GameClient.cs`](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.clientcore/Runtime/GameClient.cs) (Client core), [`Engine/packages/com.earthgame.server/Runtime/TileService.cs`](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/TileService.cs) (Tile service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_clientcore["Client core<br/>[GameClient.cs]"]
  node_clientground["Client terrain<br/>[ClientGround.cs]"]
end

subgraph group_server["Server runtime"]
  node_server["Game server<br/>[GameServer.cs]"]
  node_session["Player sessions<br/>[PlayerSession.cs]"]
  node_movement["Movement validation"]
  node_tiles["Tile service<br/>[TileService.cs]"]
  node_creation["World creation<br/>[WorldCreation.cs]"]
  node_preparation["World preparation"]
  node_persistence["World saves<br/>[WorldSave.cs]"]
end

subgraph group_simulation["Simulation engine"]
  node_world["World state<br/>[WorldState.cs]"]
  node_body["Body needs<br/>[Body]"]
  node_locomotion["Locomotion<br/>[Locomotion.cs]"]
  node_fire["Fire making<br/>[Fire]"]
  node_materials["Materials crafting<br/>[Materials]"]
  node_time["World time<br/>[WorldClock.cs]"]
end

subgraph group_wire["Networking"]
  node_protocol["Wire messages<br/>[Messages.cs]"]
  node_transport["Transport interface<br/>[ITransport.cs]"]
  node_udp["UDP transport"]
end

node_player(("Player"))

node_player -->|"plays through"| node_clientcore
node_clientcore -->|"sends and receives"| node_transport
node_clientcore -->|"encodes messages"| node_protocol
node_clientcore -->|"updates terrain"| node_clientground
node_server -->|"manages players"| node_session
node_server -->|"authoritative state"| node_world
node_server -->|"serves tile requests"| node_tiles
node_server -->|"communicates through"| node_transport
node_server -->|"handles messages"| node_protocol
node_tiles -->|"reads terrain layers"| node_world
node_tiles -->|"sends tile chunks"| node_protocol
node_session -->|"validates movement"| node_movement
node_creation -->|"creates world"| node_world
node_preparation -->|"prepares world"| node_world
node_persistence -->|"saves world"| node_world
node_transport -.->|"optional UDP implementation"| node_udp

click node_clientcore "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.clientcore/Runtime/GameClient.cs"
click node_clientground "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.clientcore/Runtime/ClientGround.cs"
click node_server "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/GameServer.cs"
click node_session "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/PlayerSession.cs"
click node_movement "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/MovementValidator.cs"
click node_tiles "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/TileService.cs"
click node_creation "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/WorldCreation.cs"
click node_preparation "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/WorldPreparation.cs"
click node_persistence "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/WorldSave.cs"
click node_world "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.engine/Runtime/World/WorldState.cs"
click node_body "https://github.com/bluebilly2/earthgame2/tree/main/Engine/packages/com.earthgame.engine/Runtime/Body"
click node_locomotion "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.engine/Runtime/Body/Locomotion.cs"
click node_fire "https://github.com/bluebilly2/earthgame2/tree/main/Engine/packages/com.earthgame.engine/Runtime/Fire"
click node_materials "https://github.com/bluebilly2/earthgame2/tree/main/Engine/packages/com.earthgame.engine/Runtime/Materials"
click node_time "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.engine/Runtime/Time/WorldClock.cs"
click node_protocol "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.protocol/Runtime/Messages.cs"
click node_transport "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.transport/Runtime/ITransport.cs"
click node_udp "https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.transport/Runtime/Udp/LiteNetLibTransport.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_clientcore,node_clientground toneBlue
class node_server,node_session,node_movement,node_tiles,node_creation,node_preparation,node_persistence toneAmber
class node_world,node_body,node_locomotion,node_fire,node_materials,node_time toneMint
class node_protocol,node_transport,node_udp toneRose
class node_player toneIndigo
```

## Components

### Client

- [Client core](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.clientcore/Runtime/GameClient.cs): `Engine/packages/com.earthgame.clientcore/Runtime/GameClient.cs`
- [Client terrain](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.clientcore/Runtime/ClientGround.cs): `Engine/packages/com.earthgame.clientcore/Runtime/ClientGround.cs`

### Server runtime

- [Game server](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/GameServer.cs): `Engine/packages/com.earthgame.server/Runtime/GameServer.cs`
- [Player sessions](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/PlayerSession.cs): `Engine/packages/com.earthgame.server/Runtime/PlayerSession.cs`
- [Movement validation](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/MovementValidator.cs): `Engine/packages/com.earthgame.server/Runtime/MovementValidator.cs`
- [Tile service](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/TileService.cs): `Engine/packages/com.earthgame.server/Runtime/TileService.cs`
- [World creation](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/WorldCreation.cs): `Engine/packages/com.earthgame.server/Runtime/WorldCreation.cs`
- [World preparation](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/WorldPreparation.cs): `Engine/packages/com.earthgame.server/Runtime/WorldPreparation.cs`
- [World saves](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.server/Runtime/WorldSave.cs): `Engine/packages/com.earthgame.server/Runtime/WorldSave.cs`

### Simulation engine

- [World state](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.engine/Runtime/World/WorldState.cs): `Engine/packages/com.earthgame.engine/Runtime/World/WorldState.cs`
- [Body needs](https://github.com/bluebilly2/earthgame2/tree/main/Engine/packages/com.earthgame.engine/Runtime/Body): `Engine/packages/com.earthgame.engine/Runtime/Body`
- [Locomotion](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.engine/Runtime/Body/Locomotion.cs): `Engine/packages/com.earthgame.engine/Runtime/Body/Locomotion.cs`
- [Fire making](https://github.com/bluebilly2/earthgame2/tree/main/Engine/packages/com.earthgame.engine/Runtime/Fire): `Engine/packages/com.earthgame.engine/Runtime/Fire`
- [Materials crafting](https://github.com/bluebilly2/earthgame2/tree/main/Engine/packages/com.earthgame.engine/Runtime/Materials): `Engine/packages/com.earthgame.engine/Runtime/Materials`
- [World time](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.engine/Runtime/Time/WorldClock.cs): `Engine/packages/com.earthgame.engine/Runtime/Time/WorldClock.cs`

### Networking

- [Wire messages](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.protocol/Runtime/Messages.cs): `Engine/packages/com.earthgame.protocol/Runtime/Messages.cs`
- [Transport interface](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.transport/Runtime/ITransport.cs): `Engine/packages/com.earthgame.transport/Runtime/ITransport.cs`
- [UDP transport](https://github.com/bluebilly2/earthgame2/blob/main/Engine/packages/com.earthgame.transport/Runtime/Udp/LiteNetLibTransport.cs): `Engine/packages/com.earthgame.transport/Runtime/Udp/LiteNetLibTransport.cs`

### Other components

- **Player**

## Connections

- Player → Client core: plays through
- Client core → Transport interface: sends and receives
- Client core → Wire messages: encodes messages
- Client core → Client terrain: updates terrain
- Game server → Player sessions: manages players
- Game server → World state: authoritative state
- Game server → Tile service: serves tile requests
- Game server → Transport interface: communicates through
- Game server → Wire messages: handles messages
- Tile service → World state: reads terrain layers
- Tile service → Wire messages: sends tile chunks
- Player sessions → Movement validation: validates movement
- World creation → World state: creates world
- World preparation → World state: prepares world
- World saves → World state: saves world
- Transport interface → UDP transport: optional UDP implementation
