GridPlacement Migration Guide: 5.1 GDScript → 6.0 C#
Purpose: Help GDScript users understand how 5.1 flows map to 6.0 C# services. Audience: Developers migrating from GDScript 5.1 to C# 6.0. Status: Living document; updated as 6.0 APIs stabilize.
Canonical mapping source
- The canonical 5.x ↔ 6.0 type/class mapping table is maintained in:
docs/6.0/Core/GRIDBUILDING_CLASS_MAPPING.md
- This document focuses on workflow-level guidance (how to translate common behaviours and usage patterns), not on being the authoritative mapping list.
Canonical parity contract (6.0 ↔ 5.1): docs/Parity/PARITY_CONTRACT_6_0_TO_5_1.md
1. Overview
GridPlacement 6.0 represents a significant architectural shift:
- 5.1: GDScript-based with node-centric design and injector pattern
- 6.0: C#-based with service-oriented architecture and dependency injection
This guide maps common 5.1 workflows to their 6.0 equivalents.
2. Core Architectural Changes
2.1 From Nodes to Services
5.1 Pattern: Everything is a Node with signals
| |
6.0 Pattern: Services with interfaces
| |
2.2 From Global Singletons to Service Registry
5.1 Pattern: Autoload singletons
| |
6.0 Pattern: Service Registry
| |
2.3 From Dictionaries to Typed Classes
5.1 Pattern: Dictionary-based data
| |
6.0 Pattern: Strongly-typed classes
| |
3. Common Workflow Mappings
3.1 Building Placement
5.1 Workflow
| |
6.0 Workflow
| |
3.2 Building Manipulation (Move)
5.1 Workflow
| |
6.0 Workflow
| |
3.3 Grid Targeting
5.1 Workflow
| |
6.0 Workflow
| |
3.4 Configuration Access
5.1 Workflow
| |
6.0 Workflow
| |
3.5 Grid Positioner / Targeting Controller
5.1 Workflow (Refactored)
| |
Naming parity note (5.1 ↔ 6.0):
- The pure, engine-agnostic logic behind the positioner should be treated as a service.
- Canonical name:
PositionerService(matches C# 6.0 naming). - Godot Nodes remain adapters/controllers (e.g.
GridPositioner2D,TargetingController2D).
6.0 Workflow
| |
6.0 → 5.1 Mapping (Reverse Lookup)
If you are reading 6.0 C# Godot integration code and want the closest 5.1 GDScript equivalent for behaviour comparison:
- 6.0
GridBuilding.Godot.Targeting.TargetingController2Dmaps to 5.1GridPositioner2D(GDScript, Node2D).
Rules:
- This mapping is for human understanding and migration guidance.
- Parity is NOT required for Nodes and Resources:
- Node/Resource names can drift without blocking parity.
- Parity tooling should focus on Core/service/domain behaviour and typed APIs.
Key Architectural Mapping:
- 5.1
GridPositioner2D≈ 6.0TargetingController2D(Controller Node) - 5.1
GridTargetingControllerEvaluator≈ 6.0 Controller Logic (Pure Decision Logic) - 5.1
TargetingService≈ 6.0GridTargetingService+TargetSensor2D(State + Sensing)
For 6.0 implementations that need a dedicated positioner logic layer, prefer:
PositionerService(pure logic/state; service pattern)- A thin Node/controller that delegates to it
4. Signal to Event Mapping
| 5.1 Signal | 6.0 Event |
|---|---|
target_changed(cell) | TargetChanged(Vector2I cell) |
placement_requested(data) | PlacementRequested(PlacementRequest) |
placement_completed(result) | PlacementCompleted(PlacementResult) |
manipulation_started(data) | ManipulationStarted(ManipulationData) |
manipulation_completed(result) | ManipulationCompleted(ManipulationResult) |
cursor_moved(tile_pos) | CursorMoved(CoreVector2I tilePos) |
cursor_visibility_changed(visible) | CursorVisibilityChanged(bool visible) |
5. API Type Mapping
| 5.1 Type | 6.0 Type |
|---|---|
Dictionary (placement request) | PlacementRequest |
Dictionary (placement result) | PlacementResult |
Dictionary (manipulation data) | ManipulationData |
Vector2i | Vector2I |
Node (systems) | IService interface |
| Autoload singleton | Service in ServiceRegistry |
6. Service Interface Reference
6.1 IPlacementService
Purpose: Handle building placement operations
Methods:
ValidatePlacementAsync(string buildingId, Vector2I cell)→ValidationResultTryPlaceAsync(PlacementRequest request)→PlacementResultRemoveBuildingAsync(Vector2I cell)→bool
Events:
PlacementRequestedPlacementCompletedPlacementFailed
6.2 IGridTargetingService
Purpose: Handle grid cell targeting and cursor
Methods:
GetTargetCell()→Vector2I?SetTargetCell(Vector2I cell)→voidClearTarget()→voidEnable()/Disable()→void
Events:
TargetChanged(Vector2I cell)TargetCleared()
6.3 IManipulationService
Purpose: Handle building manipulation operations
Methods:
BeginMoveAsync(Vector2I sourceCell)→IManipulationHandleBeginRotateAsync(Vector2I cell)→IManipulationHandleCancelManipulation()→void
Events:
ManipulationStartedManipulationCompletedManipulationCancelled
6.4 IGridSystem
Purpose: Core grid management and queries
Methods:
GetBuildingAt(Vector2I cell)→IBuilding?GetOccupiedCells()→IEnumerable<Vector2I>IsValidCell(Vector2I cell)→boolWorldToGrid(Vector2 worldPos)→Vector2IGridToWorld(Vector2I cell)→Vector2
7. Adapter Pattern (Bridging GDScript to C#)
For gradual migration, you can use adapters:
| |
This allows GDScript code to continue working while gradually transitioning to C#.
8. Migration Strategy
Recommended Approach
Understand the Service Model
- Read 6.0 architecture documentation
- Review service interfaces and responsibilities
Identify Touch Points
- List all places your code interacts with 5.1 systems
- Map each interaction to corresponding 6.0 service
Use Adapters Initially
- Create adapter nodes that bridge GDScript to C# services
- Keep existing GDScript UI/gameplay code working
Gradually Migrate
- Convert one system at a time (e.g., placement, then targeting)
- Test thoroughly after each conversion
- Remove adapters once fully migrated to C#
Leverage Type Safety
- Replace Dictionary-based data with typed classes
- Use compile-time checking to catch errors early
9. Common Pitfalls
9.1 Async/Await
Problem: 6.0 uses async methods; GDScript has no async/await
Solution: Use adapters that handle awaiting for you, or use .Result carefully
| |
9.2 Null Handling
Problem: C# nullable reference types vs GDScript null
Solution: Check nullability explicitly
| |
9.3 Signal vs Event Lifecycle
Problem: GDScript signals auto-disconnect; C# events require manual unsubscription
Solution: Always unsubscribe in _ExitTree or disposal
| |
10. Testing Strategy
Unit Tests
5.1 GdUnit tests can be replaced with C# xUnit tests:
| |
| |
Integration Tests
Use the new IntegrationHarness pattern with C# services.
11. Resources
- GDSCRIPT_5_1_PUBLIC_API.md - 5.1 API reference
- Core/GRIDBUILDING_CLASS_MAPPING.md - Detailed class mappings
- ROADMAP.md - 5.1 support timeline
- GDSCRIPT_6_0_PLAN.md - Future GDScript in 6.0
12. Support Timeline
- 5.1: Maintenance mode; critical bugs only
- 6.0: Active development; new features
- Migration support: Available through 2025
Last Updated: 2025-12-11
Version: 5.1 → 6.0
Status: Draft (updates as 6.0 stabilizes)