Table of Contents

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:

  1. Separation of Concerns: Ownership is a domain concept, not a presentation concern
  2. Testability: Core domain logic can be tested without Godot dependencies
  3. Multiplayer Ready: Supports multiple owners without coupling to cursor nodes
  4. 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

bool

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

bool

Methods

GetEditorIssues()

Gets issues found during editor validation. Called when the scene is validated in the Godot editor.

public List<string> GetEditorIssues()

Returns

List<string>

List of validation issues (empty if valid)

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

List<string>

List of validation issues (empty if valid)

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

value IOwner

The 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

Event Type

Action<IOwner>