TargetingService2D

AUTO-GENERATED FILE – DO NOT EDIT MANUALLY

This page documents the supported public API surface only. Private, internal, benchmark, test, and implementation-detail types are intentionally omitted.

Declaration

1
public class TargetingService2D : IService, ITargetingLogic, IDisposable

Summary

Core implementation of grid targeting service providing engine-agnostic business logic for tile validation, pathfinding, and grid navigation.

This service provides the heavy algorithms and business rules that Godot components can delegate to for optimal performance and testability.

OBSOLETE: This service is replaced by modern ECS targeting systems. Use ECSTargetingSystem and related ECS systems for new development.

Metadata

Namespace: GridPlacement.Core.Services.Targeting

Source File: cs/Core/Services/Targeting/TargetingService2D.cs

Assembly: GridPlacement.Core

Type: class

Implements

  • IDisposable
  • IService
  • ITargetingLogic

Constructors

TargetingService2D

1
public TargetingService2D(IConfigurationProvider<TargetingConfiguration> configProvider)

Creates a new GridTargetingService with default configuration


Properties

Configuration

1
public TargetingConfiguration Configuration { get; set; }

CurrentTargetTile

1
public CoreVector2I CurrentTargetTile { get; }

Gets the current target tile


IsTargetingActive

1
public bool IsTargetingActive { get; }

Checks if targeting is currently active


CurrentConfiguration

1
public TargetingConfiguration CurrentConfiguration { get; }

Gets current targeting configuration


Methods

FindPath

1
2
3
4
public List<CoreVector2I> FindPath(
    CoreVector2I startPosition,
    CoreVector2I endPosition
)

Finds a path between two grid positions

Parameters

NameDescription
startPositionStarting grid position
endPositionEnding grid position

Returns

List of grid positions representing the path, empty if no path found


IsPathClear

1
2
3
4
public bool IsPathClear(
    CoreVector2I startPosition,
    CoreVector2I endPosition
)

Checks if a clear path exists between two positions

Parameters

NameDescription
startPositionStarting position
endPositionEnding position

Returns

True if a clear path exists


GetPathDistance

1
2
3
4
public float GetPathDistance(
    CoreVector2I startPosition,
    CoreVector2I endPosition
)

Gets the path distance between two positions

Parameters

NameDescription
startPositionStarting position
endPositionEnding position

Returns

Distance in grid units, or MaxValue if no path


GetClosestValidTile

1
2
3
4
5
public CoreVector2I GetClosestValidTile(
    CoreVector2I targetPosition,
    CoreVector2I sourcePosition,
    int maxDistance
)

Gets the closest valid tile to a target position

Parameters

NameDescription
targetPositionDesired target position
sourcePositionSource position for distance calculations
maxDistanceMaximum distance from source

Returns

Closest valid tile position


IsValidTargetTile

1
public bool IsValidTargetTile(CoreVector2I position)

Validates if a tile position is valid for targeting

Parameters

NameDescription
positionTile position to validate

Returns

True if the tile is valid for targeting


IsWalkableTile

1
public bool IsWalkableTile(CoreVector2I position)

Checks if a tile position is walkable

Parameters

NameDescription
positionTile position to check

Returns

True if the tile is walkable


GetValidTilesInRadius

1
2
3
4
public List<CoreVector2I> GetValidTilesInRadius(
    CoreVector2I centerPosition,
    int radius
)

Gets all valid tiles within a specified radius

Parameters

NameDescription
centerPositionCenter position
radiusSearch radius

Returns

List of valid tile positions


ValidateTilePlacement

1
2
3
4
public List<string> ValidateTilePlacement(
    CoreVector2I position,
    string? buildingType = null
)

Validates tile placement according to targeting rules

Parameters

NameDescription
positionTile position to validate
buildingTypeType of building (optional)

Returns

List of validation errors, empty if valid


UpdateGridNavigation

1
public void UpdateGridNavigation(GridNavigationData gridData)

Updates the grid navigation data

Parameters

NameDescription
gridDataGrid navigation data

SetTileWalkability

1
2
3
4
public void SetTileWalkability(
    CoreVector2I position,
    bool isWalkable
)

Sets walkability for a specific tile

Parameters

NameDescription
positionTile position
isWalkableWhether the tile is walkable

SetTileWeight

1
2
3
4
public void SetTileWeight(
    CoreVector2I position,
    float weight
)

Sets weight for a specific tile

Parameters

NameDescription
positionTile position
weightTile weight (higher = more difficult to traverse)

ClearNavigationData

1
public void ClearNavigationData()

Clears all navigation data


SetTargetTile

1
public void SetTargetTile(CoreVector2I position)

Sets the current target tile

Parameters

NameDescription
positionNew target position

ClearTarget

1
public void ClearTarget()

Clears the current target


SetTargetingEnabled

1
public void SetTargetingEnabled(bool enabled)

Enables or disables targeting mode

Parameters

NameDescription
enabledWhether targeting should be enabled

UpdateConfiguration

1
public void UpdateConfiguration(TargetingConfiguration config)

Updates targeting configuration

Parameters

NameDescription
configNew targeting configuration

ValidateSetup

1
public List<string> ValidateSetup()

Validates the current targeting setup

Returns

List of validation issues, empty if valid


ValidateTargetAtPosition

1
2
3
4
public bool ValidateTargetAtPosition(
    CoreVector2I gridPosition,
    object? targetNode
)

Validates target at specific position for a targeting component

Parameters

NameDescription
gridPositionGrid position to validate
targetNodeTarget node (optional)

Returns

True if target is valid at this position


GetClosestValidTarget

1
2
3
4
public CoreVector2I GetClosestValidTarget(
    CoreVector2I desiredPosition,
    object? sourceNode
)

Gets the closest valid target to a desired position

Parameters

NameDescription
desiredPositionDesired target position
sourceNodeSource node for distance calculations

Returns

Closest valid target position


GetValidTargetsInRange

1
2
3
4
public List<CoreVector2I> GetValidTargetsInRange(
    CoreVector2I centerPosition,
    int range
)

Gets all valid targets within range of a center position

Parameters

NameDescription
centerPositionCenter position for search
rangeSearch range in grid units

Returns

List of valid target positions


UpdateTargetingComponentState

1
2
3
4
public void UpdateTargetingComponentState(
    object component,
    CoreVector2I currentPosition
)

Updates the state of a targeting component

Parameters

NameDescription
componentThe component instance
currentPositionCurrent grid position of the component

IsTargetingValidForComponent

1
2
3
4
public bool IsTargetingValidForComponent(
    object component,
    object target
)

Checks if a target is valid for a specific component

Parameters

NameDescription
componentThe targeting component
targetThe target to validate

Returns

True if target is valid for this component


Dispose

1
public void Dispose()

Disposes of the service resources


Events

PathCalculated

1
public event EventHandler<PathCalculatedEventArgs>? PathCalculated

Event fired when a path is successfully calculated


PathCalculationFailed

1
public event EventHandler<PathCalculationFailedEventArgs>? PathCalculationFailed

Event fired when path calculation fails


TargetingStateChanged

1
public event EventHandler<TargetingStateChangedEventArgs>? TargetingStateChanged

Event fired when the targeting state changes