Class OwnerContext
- Namespace
- MoonBark.GridPlacement.Core.Domain.State
- Assembly
- MoonBark.GridPlacement.Core.dll
Default implementation of IOwnerContext that manages the active owner for a grid building session.
ARCHITECTURAL RATIONALE: This class replaces the legacy GBOwner Godot node with a pure domain-layer implementation.
WHY THIS ARCHITECTURE:
- Separation of Concerns: Ownership is a domain concept, not a presentation concern
- Testability: Core domain logic can be tested without Godot dependencies
- Multiplayer Ready: Supports multiple owners without coupling to cursor nodes
- Single Responsibility: OwnerContext manages ownership state, Cursor2D manages cursor positioning
WHAT THIS REPLACES:
- GBOwner Godot node (presentation layer wrapper)
- GbOwnerContext resource (Godot-specific implementation)
DESIGN DECISIONS:
- Owner is stored as IOwner interface, not concrete Godot Node type
- Supports owner change notification via events
- Allows owner override control for testing scenarios
- Provides validation for editor and runtime scenarios
public class OwnerContext : IOwnerContext
- Inheritance
-
OwnerContext
- Implements
- Inherited Members
Properties
AllowOverridingOwner
Whether to allow overriding an existing owner. Useful in testing scenarios where multiple owners need to be set.
public bool AllowOverridingOwner { get; set; }
Property Value
OutputChangeFail
Whether to output a warning when owner change fails. Helps with debugging in development and editor scenarios.
public bool OutputChangeFail { get; set; }
Property Value
Methods
GetEditorIssues()
Gets issues found during editor validation. Called when the scene is validated in the Godot editor.
public List<string> GetEditorIssues()
Returns
GetOrigin()
Returns the origin node associated with the active owner. Currently returns the same as owner root, but could be extended to support different origin points (e.g., camera, spawn point, etc.).
public object? GetOrigin()
Returns
- object
Origin node or null
GetOwner()
Returns the current owner of this context.
public IOwner? GetOwner()
Returns
- IOwner
Current owner or null if not set
GetOwnerRoot()
Returns the owner root or null if not set. The owner root is typically the player character node, AI agent, or NPC.
public object? GetOwnerRoot()
Returns
- object
Owner root node or null
GetRuntimeIssues()
Gets issues found during runtime validation. Called when the game is running to ensure the context is properly configured.
public List<string> GetRuntimeIssues()
Returns
SetOwner(IOwner?)
Sets the owner for this context.
ARCHITECTURAL DECISION: Owner changes are controlled to prevent accidental ownership loss. In production, AllowOverridingOwner should be false to prevent bugs. In tests, AllowOverridingOwner can be true to test multiple scenarios.
public void SetOwner(IOwner? value)
Parameters
valueIOwnerThe new owner to set for this context
Events
OwnerChanged
Event raised when the owner changes. Subscribers can react to owner changes (e.g., update UI, change active player).
public event Action<IOwner?>? OwnerChanged