Table of Contents

Class TargetingService

Namespace
MoonBark.GridPlacement.Core.Services.Targeting
Assembly
MoonBark.GridPlacement.Core.dll

Pure domain targeting service - single source of truth for grid targeting. All state is stored in plain C# structs, not ECS components.

DESIGN DECISIONS:

  • Pure domain: All state in plain structs
  • No Godot dependencies: Core layer is engine-agnostic
  • Direct event invocation: No wrapper methods
public sealed class TargetingService : ITargetingService, IGridTargetingSystem, IDisposable
Inheritance
TargetingService
Implements
Inherited Members

Constructors

TargetingService()

Initializes a new instance of the TargetingService class.

public TargetingService()

Properties

ActiveInputSource

Gets the currently active input source, if any.

public IInputSource? ActiveInputSource { get; }

Property Value

IInputSource

CurrentTargetPosition

Gets the current target position on the grid.

public CoreVector2I CurrentTargetPosition { get; }

Property Value

CoreVector2I

Revision

Gets a monotonically increasing revision number that changes whenever the target state changes.

public long Revision { get; }

Property Value

long

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetDebugSnapshot()

Gets a snapshot of current targeting state for debugging.

public TargetingSnapshot GetDebugSnapshot()

Returns

TargetingSnapshot

GetSnapshot()

Gets the current targeting state.

public TargetingSnapshot2D GetSnapshot()

Returns

TargetingSnapshot2D

A snapshot of the current targeting state.

RegisterInputSource(IInputSource)

Registers an input source with the targeting service.

public void RegisterInputSource(IInputSource source)

Parameters

source IInputSource

The input source to register.

SetActiveInputSource(IInputSource?)

Sets the active input source.

public bool SetActiveInputSource(IInputSource? source)

Parameters

source IInputSource

Returns

bool

SetActiveInputSource(InputSourceType)

Sets the active input source by type. If multiple sources of the same type exist, the first registered one is used.

public bool SetActiveInputSource(InputSourceType sourceType)

Parameters

sourceType InputSourceType

The type of input source to activate.

Returns

bool

true if the source was found and activated; otherwise false.

SetReady(bool)

Sets the ready state.

public void SetReady(bool isReady)

Parameters

isReady bool

SetTargetReferences(string?, string?, string?)

Sets target references (Godot layer calls this to register node IDs).

public void SetTargetReferences(string? targetId, string? positionerId, string? targetMapId)

Parameters

targetId string
positionerId string
targetMapId string

TrySetTargetPosition(CoreVector2I)

Attempts to set the current target position.

public bool TrySetTargetPosition(CoreVector2I newPosition)

Parameters

newPosition CoreVector2I

The new target position.

Returns

bool

true if the position changed; otherwise false.

UnregisterInputSource(IInputSource)

Unregisters an input source from the targeting service.

public void UnregisterInputSource(IInputSource source)

Parameters

source IInputSource

The input source to unregister.

Events

ActiveSourceChanged

Raised when the active input source changes.

public event Action<IInputSource?>? ActiveSourceChanged

Event Type

Action<IInputSource>

TargetPositionChanged

Raised when the target position changes.

public event Action<CoreVector2I>? TargetPositionChanged

Event Type

Action<CoreVector2I>