Engine Integration Guide
Deep dive into integrating GridPlacement Core with Godot and other game engines.
GridPlacement 6.0 is built on a Dual-Layer Architecture that separates pure simulation logic from engine-specific presentation. This guide explains how to bridge these layers effectively.
1. The Integration Boundary
The boundary between the Core and the Engine is managed through Bridges and Adapters.
sequenceDiagram
participant UI as Godot UI/Input
participant Bridge as Engine Bridge (Node)
participant Adapter as Logic Adapter (C#)
participant Workflow as Core Workflow (POCO)
participant Service as Domain Service
UI->>Bridge: Input Event
Bridge->>Adapter: Translate to Core Types
Adapter->>Workflow: Execute Request
Workflow->>Service: Algorithmic Task
Service-->>Workflow: Result
Workflow-->>Adapter: Data Snapshot
Adapter-->>Bridge: Domain Event
Bridge-->>UI: Godot Signal / Visual Update
2. Key Integration Components
GPUserScopeRoot (Composition Root)
In Godot, the GPUserScopeRoot node serves as the primary entry point. It:
- Initializes the
ServiceRegistry. - Registers core modules (Targeting, Placement, Manipulation).
- Manages the
IUserScopefor multitenancy (e.g., local split-screen or multiple independent grids).
Engine Bridges
Bridges are engine-specific components (e.g., Godot Nodes) that sit in the scene tree. Their primary job is:
- Conversion: Converting
Vector2toCoreVector2,InputEventtoInputEventData. - Lifecycle: Forwarding
_processor_physics_processticks to the logic layer. - Signals: Translating C# Domain Events into engine-native signals.
3. Communication: C# Events to Godot Signals
The Core layer is reactive. When a building is placed or a target changes, the Core publishes a Domain Event.
| C# Domain Event | Godot Signal (Bridge) | Payload |
|---|---|---|
PlacementExecutedEvent | placement_executed | PlacementReport |
TargetingUpdatedEvent | target_changed | TargetingSnapshot |
ManipulationStartedEvent | manipulation_started | ManipulationData |
Example Integration (GDScript)
| |
4. First-Class Identity & Sessions
6.0 treats identity as a core concern.
GPUserId: A unique identifier for a controller or player.IUserScope: An isolated container for state belonging to that ID.IGridBuildingSession: Manages the lifetime of a specific placement/manipulation session.
This allows the same Core DLL to handle multiple players or complex UI-preview scenarios without state leakage.
5. Implementation Checklist
- Scene Setup: Ensure
GPUserScopeRootis at the top of your gameplay subtree. - Configuration: Assign your
GridTargetingSettingsresource to the appropriate bridge. - Input Mapping: Define your logical actions in an
InputConfiguration. - Event Wiring: Connect your UI and VFX systems to the
GPEventBusor specific Bridge signals.
Last updated: 2025-12-22