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
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
IDisposableIServiceITargetingLogic
Constructors
TargetingService2D
Creates a new GridTargetingService with default configuration
Properties
Configuration
CurrentTargetTile
Gets the current target tile
IsTargetingActive
Checks if targeting is currently active
CurrentConfiguration
Gets current targeting configuration
Methods
FindPath
Finds a path between two grid positions
Parameters
| Name | Description |
|---|---|
startPosition | Starting grid position |
endPosition | Ending grid position |
Returns
List of grid positions representing the path, empty if no path found
IsPathClear
Checks if a clear path exists between two positions
Parameters
| Name | Description |
|---|---|
startPosition | Starting position |
endPosition | Ending position |
Returns
True if a clear path exists
GetPathDistance
Gets the path distance between two positions
Parameters
| Name | Description |
|---|---|
startPosition | Starting position |
endPosition | Ending position |
Returns
Distance in grid units, or MaxValue if no path
GetClosestValidTile
Gets the closest valid tile to a target position
Parameters
| Name | Description |
|---|---|
targetPosition | Desired target position |
sourcePosition | Source position for distance calculations |
maxDistance | Maximum distance from source |
Returns
Closest valid tile position
IsValidTargetTile
Validates if a tile position is valid for targeting
Parameters
| Name | Description |
|---|---|
position | Tile position to validate |
Returns
True if the tile is valid for targeting
IsWalkableTile
Checks if a tile position is walkable
Parameters
| Name | Description |
|---|---|
position | Tile position to check |
Returns
True if the tile is walkable
GetValidTilesInRadius
Gets all valid tiles within a specified radius
Parameters
| Name | Description |
|---|---|
centerPosition | Center position |
radius | Search radius |
Returns
List of valid tile positions
ValidateTilePlacement
Validates tile placement according to targeting rules
Parameters
| Name | Description |
|---|---|
position | Tile position to validate |
buildingType | Type of building (optional) |
Returns
List of validation errors, empty if valid
UpdateGridNavigation
Updates the grid navigation data
Parameters
| Name | Description |
|---|---|
gridData | Grid navigation data |
SetTileWalkability
Sets walkability for a specific tile
Parameters
| Name | Description |
|---|---|
position | Tile position |
isWalkable | Whether the tile is walkable |
SetTileWeight
Sets weight for a specific tile
Parameters
| Name | Description |
|---|---|
position | Tile position |
weight | Tile weight (higher = more difficult to traverse) |
ClearNavigationData
Clears all navigation data
SetTargetTile
Sets the current target tile
Parameters
| Name | Description |
|---|---|
position | New target position |
ClearTarget
Clears the current target
SetTargetingEnabled
Enables or disables targeting mode
Parameters
| Name | Description |
|---|---|
enabled | Whether targeting should be enabled |
UpdateConfiguration
Updates targeting configuration
Parameters
| Name | Description |
|---|---|
config | New targeting configuration |
ValidateSetup
Validates the current targeting setup
Returns
List of validation issues, empty if valid
ValidateTargetAtPosition
Validates target at specific position for a targeting component
Parameters
| Name | Description |
|---|---|
gridPosition | Grid position to validate |
targetNode | Target node (optional) |
Returns
True if target is valid at this position
GetClosestValidTarget
Gets the closest valid target to a desired position
Parameters
| Name | Description |
|---|---|
desiredPosition | Desired target position |
sourceNode | Source node for distance calculations |
Returns
Closest valid target position
GetValidTargetsInRange
Gets all valid targets within range of a center position
Parameters
| Name | Description |
|---|---|
centerPosition | Center position for search |
range | Search range in grid units |
Returns
List of valid target positions
UpdateTargetingComponentState
Updates the state of a targeting component
Parameters
| Name | Description |
|---|---|
component | The component instance |
currentPosition | Current grid position of the component |
IsTargetingValidForComponent
Checks if a target is valid for a specific component
Parameters
| Name | Description |
|---|---|
component | The targeting component |
target | The target to validate |
Returns
True if target is valid for this component
Dispose
Disposes of the service resources
Events
PathCalculated
Event fired when a path is successfully calculated
PathCalculationFailed
Event fired when path calculation fails
TargetingStateChanged
Event fired when the targeting state changes