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
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
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
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
sourceIInputSourceThe input source to register.
SetActiveInputSource(IInputSource?)
Sets the active input source.
public bool SetActiveInputSource(IInputSource? source)
Parameters
sourceIInputSource
Returns
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
sourceTypeInputSourceTypeThe type of input source to activate.
Returns
- bool
trueif the source was found and activated; otherwisefalse.
SetReady(bool)
Sets the ready state.
public void SetReady(bool isReady)
Parameters
isReadybool
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
TrySetTargetPosition(CoreVector2I)
Attempts to set the current target position.
public bool TrySetTargetPosition(CoreVector2I newPosition)
Parameters
newPositionCoreVector2IThe new target position.
Returns
- bool
trueif the position changed; otherwisefalse.
UnregisterInputSource(IInputSource)
Unregisters an input source from the targeting service.
public void UnregisterInputSource(IInputSource source)
Parameters
sourceIInputSourceThe input source to unregister.
Events
ActiveSourceChanged
Raised when the active input source changes.
public event Action<IInputSource?>? ActiveSourceChanged
Event Type
TargetPositionChanged
Raised when the target position changes.
public event Action<CoreVector2I>? TargetPositionChanged
Event Type
- Action<CoreVector2I>