# wwr-12/terraria-source-code architecture

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

- Interactive diagram: https://gitdiagram.com/wwr-12/terraria-source-code
- Repository: https://github.com/wwr-12/terraria-source-code

## Overview

This repository is a collection of decompiled Terraria source snapshots (1.2.4.1, 1.3.5.3, and a partial 1.4.5.6 tree), presented for study and reuse. The principal product workflow is gameplay: the game loop advances players, NPCs, projectiles, and world simulation, while networking synchronizes multiplayer state and rendering presents the result. The tree also shows world generation and persistence, chat, achievements, and social integrations. Most implementation files were not sampled, so uncertain links are dashed and uncited; the supplied excerpts for several 1.4.5.6 files are not present in the tree.

Main entry points: [`1.3.5.3/Terraria/Main.cs`](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/Main.cs) (Game loop), [`1.3.5.3/Terraria/Netplay.cs`](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/Netplay.cs) (Network runtime), [`1.3.5.3/Terraria/WorldGen.cs`](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/WorldGen.cs) (World generation), [`1.3.5.3/Terraria/MessageBuffer.cs`](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/MessageBuffer.cs) (Message handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game runtime"]
  node_player_actor["Player state<br/>[Player.cs]"]
  node_npc["NPC simulation<br/>[NPC.cs]"]
  node_projectile["Projectile simulation<br/>[Projectile.cs]"]
  node_main["Game loop<br/>[Main.cs]"]
end

subgraph group_world["World systems"]
  node_worldgen["World generation<br/>[WorldGen.cs]"]
  node_generation["Generation framework<br/>[WorldGenerator.cs]"]
  node_worldfile["World persistence<br/>[WorldFile.cs]"]
  node_map["World map<br/>[Map.cs]"]
  node_tile["Tile state<br/>[Tile.cs]"]
end

subgraph group_network["Multiplayer"]
  node_netplay["Network runtime<br/>[Netplay.cs]"]
  node_messages["Message handling<br/>[MessageBuffer.cs]"]
  node_netmessage["Network messages<br/>[NetMessage.cs]"]
end

subgraph group_player["Player features"]
  node_chat["Chat rendering<br/>[ChatManager.cs]"]
  node_achievements["Achievements"]
  node_social["Social services<br/>[SocialAPI.cs]"]
end

subgraph group_presentation["Presentation"]
  node_language["Localization<br/>[LanguageManager.cs]"]
  node_effects["Screen effects<br/>[FilterManager.cs]"]
  node_waterfall["Waterfall rendering"]
end

node_user(("Player"))
node_remote(("Remote players"))

node_user -.->|"plays"| node_main
node_main -.->|"advances"| node_player_actor
node_main -.->|"advances"| node_npc
node_main -.->|"advances"| node_projectile
node_worldgen -.->|"uses"| node_generation
node_main -.->|"starts"| node_worldgen
node_main -.->|"loads world"| node_worldfile
node_main -.->|"updates"| node_map
node_main -.->|"simulates"| node_tile
node_main -.->|"starts networking"| node_netplay
node_netplay -.->|"dispatches"| node_messages
node_messages -.->|"uses"| node_netmessage
node_remote -.->|"connects"| node_netplay
node_main -.->|"presents chat"| node_chat
node_main -.->|"updates progress"| node_achievements
node_main -.->|"uses services"| node_social
node_main -.->|"uses text"| node_language
node_main -.->|"renders effects"| node_effects
node_main -.->|"renders water"| node_waterfall

click node_player_actor "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/Player.cs"
click node_npc "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/NPC.cs"
click node_projectile "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/Projectile.cs"
click node_main "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/Main.cs"
click node_worldgen "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/WorldGen.cs"
click node_generation "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria.World.Generation/WorldGenerator.cs"
click node_worldfile "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria.IO/WorldFile.cs"
click node_map "https://github.com/wwr-12/terraria-source-code/blob/main/1.2.4.1/Terraria/Map.cs"
click node_tile "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/Tile.cs"
click node_netplay "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/Netplay.cs"
click node_messages "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/MessageBuffer.cs"
click node_netmessage "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/NetMessage.cs"
click node_chat "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria.UI.Chat/ChatManager.cs"
click node_achievements "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria.Achievements/AchievementManager.cs"
click node_social "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria.Social/SocialAPI.cs"
click node_language "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria.Localization/LanguageManager.cs"
click node_effects "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria.Graphics.Effects/FilterManager.cs"
click node_waterfall "https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/WaterfallManager.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_player_actor,node_npc,node_projectile,node_main toneBlue
class node_worldgen,node_generation,node_worldfile,node_map,node_tile toneAmber
class node_netplay,node_messages,node_netmessage toneMint
class node_chat,node_achievements,node_social toneRose
class node_language,node_effects,node_waterfall,node_user,node_remote toneIndigo
```

## Components

### Game runtime

- [Player state](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/Player.cs): `1.3.5.3/Terraria/Player.cs`
- [NPC simulation](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/NPC.cs): `1.3.5.3/Terraria/NPC.cs`
- [Projectile simulation](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/Projectile.cs): `1.3.5.3/Terraria/Projectile.cs`
- [Game loop](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/Main.cs): `1.3.5.3/Terraria/Main.cs`

### World systems

- [World generation](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/WorldGen.cs): `1.3.5.3/Terraria/WorldGen.cs`
- [Generation framework](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria.World.Generation/WorldGenerator.cs): `1.3.5.3/Terraria.World.Generation/WorldGenerator.cs`
- [World persistence](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria.IO/WorldFile.cs): `1.3.5.3/Terraria.IO/WorldFile.cs`
- [World map](https://github.com/wwr-12/terraria-source-code/blob/main/1.2.4.1/Terraria/Map.cs): `1.2.4.1/Terraria/Map.cs`
- [Tile state](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/Tile.cs): `1.3.5.3/Terraria/Tile.cs`

### Multiplayer

- [Network runtime](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/Netplay.cs): `1.3.5.3/Terraria/Netplay.cs`
- [Message handling](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/MessageBuffer.cs): `1.3.5.3/Terraria/MessageBuffer.cs`
- [Network messages](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/NetMessage.cs): `1.3.5.3/Terraria/NetMessage.cs`

### Player features

- [Chat rendering](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria.UI.Chat/ChatManager.cs): `1.3.5.3/Terraria.UI.Chat/ChatManager.cs`
- [Achievements](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria.Achievements/AchievementManager.cs): `1.3.5.3/Terraria.Achievements/AchievementManager.cs`
- [Social services](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria.Social/SocialAPI.cs): `1.3.5.3/Terraria.Social/SocialAPI.cs`

### Presentation

- [Localization](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria.Localization/LanguageManager.cs): `1.3.5.3/Terraria.Localization/LanguageManager.cs`
- [Screen effects](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria.Graphics.Effects/FilterManager.cs): `1.3.5.3/Terraria.Graphics.Effects/FilterManager.cs`
- [Waterfall rendering](https://github.com/wwr-12/terraria-source-code/blob/main/1.3.5.3/Terraria/WaterfallManager.cs): `1.3.5.3/Terraria/WaterfallManager.cs`

### Other components

- **Player**
- **Remote players**

## Connections

- Player → Game loop: plays
- Game loop → Player state: advances
- Game loop → NPC simulation: advances
- Game loop → Projectile simulation: advances
- World generation → Generation framework: uses
- Game loop → World generation: starts
- Game loop → World persistence: loads world
- Game loop → World map: updates
- Game loop → Tile state: simulates
- Game loop → Network runtime: starts networking
- Network runtime → Message handling: dispatches
- Message handling → Network messages: uses
- Remote players → Network runtime: connects
- Game loop → Chat rendering: presents chat
- Game loop → Achievements: updates progress
- Game loop → Social services: uses services
- Game loop → Localization: uses text
- Game loop → Screen effects: renders effects
- Game loop → Waterfall rendering: renders water
