Economic simulation game built with Godot 4 and C#
Build and manage a small economy: place production buildings (farms, power plants, water pumps), connect them with roads, and fulfill dynamic city orders through a logistics system.
Core Gameplay:
- ๐๏ธ Build - Place farms, power plants, and infrastructure
- โก Manage Resources - Balance power, water, and production
- ๐ Logistics - Road-based transport system with pathfinding
- ๐ฐ Trade - Fulfill dynamic market orders from cities
- ๐ Upgrade - Improve building capacity and truck logistics
For Developers: This project showcases modern C# architecture patterns in a game development context. See Technical Highlights below for implementation details.
- Engine: Godot 4.x (C# / .NET 8)
- Architecture: Clean DI, Event-Driven, Manager Pattern
- Key Patterns: Dependency Injection Container, CQRS, Deterministic Simulation (20Hz)
- Data-Driven: Buildings, Resources, and Recipes via
.tresdefinitions - Testing: Unit tests (.NET), Integration tests (Godot Headless), CI/CD (GitHub Actions)
โ Dependency Injection - DIContainer as Composition Root, no Service Locator โ Event-Driven Architecture - EventHub decouples UI from game logic โ Deterministic Simulation - Fixed 20Hz timestep for reproducible state (save/load, future multiplayer) โ Result Pattern - Structured error handling with typed results โ Data-Driven Design - Game content via Godot Resources (.tres files)
โ Production Chains - Resource flow from producers to consumers โ Road Network - A* pathfinding with dynamic rerouting โ Market Simulation - Cities generate orders with dynamic pricing โ Building Upgrades - Logistics capacity and speed improvements โ Save/Load System - Versioned saves with automatic migration
Hexagonal/Ports & Adapters Architecture
- Core business logic decoupled from Godot engine via port interfaces
PlacementServiceusesILandReadModel,IEconomy,IRoadReadModelports- Adapter pattern bridges Godot managers to port interfaces (
EconomyPort,RoadReadModelPort) - Enables unit testing without Godot runtime dependencies
Explicit Dependency Injection
- Custom
DIContainerwith constructor-based injection (~500 LOC composition root) - 20+ services wired explicitly at startup
ServiceContainerserves as named registry for Godot/GDScript bridge only- CI enforcement: No runtime
ServiceContainerlookups in managers
Event-Driven Design
EventHubprovides pub/sub messaging between systems- Loose coupling: UI, simulation, and managers communicate via events
- Type-safe event definitions with structured payloads
Result Pattern
- Structured error handling without exception-driven control flow
- Type-safe error codes (
ErrorIds) with localized messages - Success/failure state with optional error details
BuildingManager โ Service Extraction (code/buildings/services)
- Refactored 689-line "God Object" into focused services:
PlacementService- Placement validation (bounds, ownership, costs, collisions)BuildingFactory- Building instantiation from definitionsBuildingIndex- GUID and cell-based indexingBuildingQueries- Stateless query helpersBuildingRegistry- Spatial indexing for fast lookups
- Port-based architecture enables unit testing with mocks
- Clear single responsibilities per service
Production System
- Recipe-based production with input/output buffers
- Tick-based simulation (20Hz deterministic)
- Resource constraints and capacity management
Transport System
- Autonomous truck agents with A* pathfinding
- Order management with priority queuing
- Economic calculations (fuel costs, delivery pricing)
Automated CI/CD Pipeline
- โ .NET build with Release configuration
- โ Unit & integration tests with coverage reports
- โ
Code formatting verification (
dotnet format) - โ DI pattern enforcement (custom analyzers)
- โ
Nullability checks (
<Nullable>enable</Nullable>) - โ Warnings as errors
- โ Roslyn static analysis
Development Standards
- Conventional commit messages
- XML documentation for public APIs
- Centralized constants (no magic strings via
ResourceIds,ErrorIds) - Structured logging with categories (
DebugLogger)
- Clone the repository
- Open
project.godotin Godot 4 - Press F5 to run
dotnet testThis project demonstrates Clean Architecture principles in a game context:
- DIContainer - Explicit dependency injection, all manager dependencies wired at startup
- ServiceContainer - Named service registry for GDScript โ C# bridge (no typed Service Locator)
- EventHub - Pub/sub pattern for loose coupling between systems
- Deterministic Simulation - All state changes via fixed-timestep
ITickable.Tick(), guarded by validation - Manager Pattern - Clear separation: BuildingManager, EconomyManager, TransportManager, etc.
See ARCHITECTURE.md for:
- System overview with Mermaid diagrams
- ADR-style architecture decisions
- Known trade-offs & technical debt
- Test strategy
- English identifiers (classes, methods, properties)
- German comments/logs (bilingual codebase)
- Centralized constants (no magic strings)
- XML documentation for public APIs
# Format check
dotnet format --verify-no-changes
# Build
dotnet build
# Run tests
dotnet testCI enforces:
- โ
Code formatting (via
dotnet format) - โ
Nullability checks (
<Nullable>enable</Nullable>) - โ
Warnings as errors (
-warnaserror) - โ Roslyn analyzers
See docs/DEVELOPMENT.md for detailed development docs:
- DI guidelines & migration
- GameClock design & phases
- UI architecture & signals
- Build commands & clean scripts
.
โโโ .github/ # GitHub workflows & templates
โโโ assets/ # Game assets (buildings, tiles, resources, etc.)
โโโ code/ # C# source
โ โโโ buildings/ # Building logic & services
โ โโโ common/ # Shared utilities & constants
โ โโโ data/ # Data models
โ โโโ input/ # Input handling
โ โโโ managers/ # Core managers (Building, Economy, Transport, etc.)
โ โโโ roads/ # Road system
โ โโโ runtime/ # Runtime services (GameManager, UIService, Database)
โ โโโ sim/ # Simulation (ProductionSystem, ITickable)
โ โโโ transport/ # Transport subsystem
โโโ data/ # Game data (.tres definitions)
โโโ dev-scripts/ # Development scripts (PowerShell)
โโโ docs/ # Documentation
โโโ export/ # Export presets
โโโ scenes/ # Godot scenes
โโโ tests/ # Unit & integration tests
โโโ tools/ # CI tools & scripts
โโโ ui/ # GDScript UI
MIT License - Copyright (c) 2025 Jonathan Gehrke
See LICENSE file for full license text.
This game is built with Godot Engine (MIT License). For third-party licenses and attributions, see THIRD_PARTY_LICENSES.md.
All game assets under assets/ were created in-house using an AI tool and are released under
CC0 1.0 (Public Domain). See ASSETS_LICENSE.md for details.