Configuration vs. Settings

Understanding the distinction between Core Configurations and Godot Settings in GridPlacement 6.0

sort Weight: 30

Overview

To achieve strict separation between the Pure Logic Core (6.0) and Engine Adapters (Godot/Unity), distinguishes between Settings and Configuration.

LayerTypeSuffixDescription
Core (Logic)C# POCOConfigurationPure data POCOs. Structural, immutable snapshots valid for a logic frame.
Engine (Adapter)Godot ResourceSettingsInspector-friendly assets (.tres). Used for configuration persistence.

1. Core Layer: *Configuration

Located in GridPlacement.Core.Configuration, these are pure C# classes. They implement the IConfiguration marker interface and have zero dependencies on engine APIs.

1
2
3
4
5
public class TargetingConfiguration : IConfiguration 
{
    public int MaxTargetingRange { get; set; } = 50;
    public bool SnapToGrid { get; set; } = true;
}

Benefits

  • Deterministic Testing: Test logic in XUnit without loading Godot or Unity.
  • Immutability: Components receive a snapshot, preventing accidental global state mutation during calculations.
  • Portability: The same configuration schema works in any engine.

2. Engine Layer: *Settings

In Godot, settings are implemented as Resource objects. These provide the bridge between the Inspector and the Core logic.

The IConfigurationProvider Bridge

Engine-side objects implement the IConfigurationProvider<T> interface. This acts as a factory that converts mutable engine data into a pure logic snapshot.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// Godot Adapter Layer
public partial class GridTargetingSettings : Resource, IConfigurationProvider<TargetingConfiguration> 
{
    [Export] public int MaxRange = 50;

    public TargetingConfiguration GetConfiguration() => new TargetingConfiguration 
    { 
        MaxTargetingRange = this.MaxRange 
    };
}

3. Dependency Injection Pattern

Core Services must never depend on Godot Resources. Instead, they inject the provider interface to maintain the engine boundary.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
public class TargetingService 
{
    private readonly IConfigurationProvider<TargetingConfiguration> _config;

    public TargetingService(IConfigurationProvider<TargetingConfiguration> config) 
    {
        _config = config;
    }

    public void Update() 
    {
        // Resolve the pure POCO for logic processing
        var current = _config.GetConfiguration();
        if (current.SnapToGrid) { ... }
    }
}

4. Standard Logical Actions

Input mapping is handled by the InputConfiguration, which maps engine actions to system intents.

Logical ActionDefault Godot Mapping
Build Modebuild_mode
Confirm Buildbuild_confirm
Cancel / Offbuild_cancel
Rotate Leftbuild_rotate_left
Flip Horizontalbuild_flip_h

Last updated: 2025-12-22