Development ⚠️ GridPlacement 6.0 documentation is in active development. APIs and content may change, and the site may be temporarily unstable.

GridBuilding Godot Architecture

Overview

GridBuilding uses a dual-layer architecture: Godot presentation layer + C# Core business logic.

Architecture Principles

1. Core/Godot Separation

  • Core: Pure C# business logic, no Godot dependencies
  • Godot: Engine integration, UI, and scene management

2. Service-Based Pattern

  • Services contain business logic and events
  • State classes contain pure data only
  • Clear data flow: Godot ↔ Services ↔ State

3. Enhanced Service Registry

  • ServiceCompositionRoot with automatic discovery
  • ServiceHelper utilities for clean resolution
  • Multiplayer-ready service scoping

Key Components

ServiceCompositionRoot

Location: /Godot/Bootstrap/ServiceCompositionRoot.cs

  • Scope-aware registration (Global, Session, Player, Scene)
  • Automatic service discovery via attributes
  • Health monitoring and dependency injection

ServiceHelper Utilities

Location: /Core/Services/DI/ServiceHelper.cs

  • GetRequiredService()
  • GetOptionalService()
  • TryGetService() with error handling

System Nodes

  • ManipulationSystemNode: Object manipulation (10/10 score)
  • GridTargetingSystem: Grid navigation (10/10 score, pure service via TargetingShapeCast2D adapter)
  • PlacementSystem: Building placement (10/10 score, stateless & multi-user ready)
  • IndicatorManager: Visual feedback (10/10 score, surface adapter over IndicatorServiceIntegrated)

Data Flow

User Input (Godot)
    ↓
Service Layer (Business Logic)
    ↓
State Layer (Pure Data)
    ↓
Events Dispatched
    ↓
Godot Updates Visuals

Service Interface Pattern

1
2
3
4
5
6
public interface IBuildingService
{
    event EventHandler<BuildingPlacedEvent> BuildingPlaced;
    void PlaceBuilding(Vector2I position, string buildingType);
    bool CanPlaceBuilding(Vector2I position, string buildingType);
}

Benefits

  • Clean separation of concerns
  • Excellent testability
  • Multiplayer support
  • Cross-engine compatibility
  • Performance optimization

Current Status

Enhanced Service Registry Architecture achieved 9.5/10 score with:

  • Simplified service resolution
  • Better error handling
  • Automatic registration
  • Comprehensive testing

References

  • Enhanced Service Architecture: /docs/ENHANCED_SERVICE_ARCHITECTURE.md
  • Godot Frontend Architecture: /docs/GODOT_FRONTEND_ARCHITECTURE.md
  • Service-Based Architecture: /content/gridbuilding/SERVICE_BASED_ARCHITECTURE.md