Class GridObstacleManager
Handles the addition, removal, and tracking of obstacles within a grid. Ensures thread safety and proper event notifications when obstacles change.
public static class GridObstacleManager
- Inheritance
-
GridObstacleManager
- Inherited Members
Fields
MaxObstacleCount
Maximum number of obstacles that can exist on a single voxel.
public const byte MaxObstacleCount = 255
Field Value
Methods
ClearObstacles(VoxelGrid, Voxel)
Clears all obstacles from the specified voxel.
public static void ClearObstacles(this VoxelGrid grid, Voxel targetVoxel)
Parameters
TryAddObstacle(GridWorld, WorldVoxelIndex, ObstacleToken)
Attempts to add an obstacle at the given world-scoped voxel identity in the supplied world.
public static bool TryAddObstacle(GridWorld world, WorldVoxelIndex index, ObstacleToken obstacleToken)
Parameters
worldGridWorldindexWorldVoxelIndexobstacleTokenObstacleToken
Returns
TryAddObstacle(VoxelGrid, Vector2d, Fixed64, ObstacleToken)
Attempts to add an obstacle at the given XZ-plane world position on the supplied world Y layer.
public static bool TryAddObstacle(this VoxelGrid grid, Vector2d position, Fixed64 layerY, ObstacleToken obstacleToken)
Parameters
gridVoxelGridThe grid to mutate.
positionVector2dThe 2D position whose X component maps to world X and Y component maps to world Z.
layerYFixed64The world Y layer to resolve.
obstacleTokenObstacleTokenThe obstacle token to attach to the resolved voxel.
Returns
- bool
True if an obstacle was added to the resolved voxel; otherwise false.
TryAddObstacle(VoxelGrid, Vector2d, ObstacleToken)
Attempts to add an obstacle at the given XZ-plane world position on the default world Y layer.
public static bool TryAddObstacle(this VoxelGrid grid, Vector2d position, ObstacleToken obstacleToken)
Parameters
gridVoxelGridThe grid to mutate.
positionVector2dThe 2D position whose X component maps to world X and Y component maps to world Z.
obstacleTokenObstacleTokenThe obstacle token to attach to the resolved voxel.
Returns
- bool
True if an obstacle was added to the resolved voxel; otherwise false.
TryAddObstacle(VoxelGrid, Vector3d, ObstacleToken)
Attempts to add an obstacle at the given world position.
public static bool TryAddObstacle(this VoxelGrid grid, Vector3d position, ObstacleToken obstacleToken)
Parameters
gridVoxelGridpositionVector3dobstacleTokenObstacleToken
Returns
TryAddObstacle(VoxelGrid, Voxel, ObstacleToken)
Adds an obstacle to this voxel.
public static bool TryAddObstacle(this VoxelGrid grid, Voxel targetVoxel, ObstacleToken obstacleToken)
Parameters
gridVoxelGridtargetVoxelVoxelobstacleTokenObstacleTokenThe process-unique obstacle registration token.
Returns
Exceptions
TryRemoveObstacle(GridWorld, WorldVoxelIndex, ObstacleToken)
Attempts to remove an obstacle at the given world-scoped voxel identity in the supplied world.
public static bool TryRemoveObstacle(GridWorld world, WorldVoxelIndex index, ObstacleToken obstacleToken)
Parameters
worldGridWorldindexWorldVoxelIndexobstacleTokenObstacleToken
Returns
TryRemoveObstacle(VoxelGrid, Vector2d, Fixed64, ObstacleToken)
Attempts to remove an obstacle from the given XZ-plane world position on the supplied world Y layer.
public static bool TryRemoveObstacle(this VoxelGrid grid, Vector2d position, Fixed64 layerY, ObstacleToken obstacleToken)
Parameters
gridVoxelGridThe grid to mutate.
positionVector2dThe 2D position whose X component maps to world X and Y component maps to world Z.
layerYFixed64The world Y layer to resolve.
obstacleTokenObstacleTokenThe obstacle token to remove from the resolved voxel.
Returns
- bool
True if the obstacle was removed from the resolved voxel; otherwise false.
TryRemoveObstacle(VoxelGrid, Vector2d, ObstacleToken)
Attempts to remove an obstacle from the given XZ-plane world position on the default world Y layer.
public static bool TryRemoveObstacle(this VoxelGrid grid, Vector2d position, ObstacleToken obstacleToken)
Parameters
gridVoxelGridThe grid to mutate.
positionVector2dThe 2D position whose X component maps to world X and Y component maps to world Z.
obstacleTokenObstacleTokenThe obstacle token to remove from the resolved voxel.
Returns
- bool
True if the obstacle was removed from the resolved voxel; otherwise false.
TryRemoveObstacle(VoxelGrid, Vector3d, ObstacleToken)
Attempts to remove an obstacle from the specified world position.
public static bool TryRemoveObstacle(this VoxelGrid grid, Vector3d position, ObstacleToken obstacleToken)
Parameters
gridVoxelGridpositionVector3dobstacleTokenObstacleToken
Returns
TryRemoveObstacle(VoxelGrid, Voxel, ObstacleToken)
Removes an obstacle from a given voxel.
public static bool TryRemoveObstacle(this VoxelGrid grid, Voxel targetVoxel, ObstacleToken obstacleToken)
Parameters
gridVoxelGridtargetVoxelVoxelobstacleTokenObstacleToken
Returns
Events
OnObstacleAdded
public static event Action<ObstacleEventInfo> OnObstacleAdded
Event Type
OnObstacleRemoved
public static event Action<ObstacleEventInfo> OnObstacleRemoved
Event Type
OnObstaclesCleared
public static event Action<ObstacleClearEventInfo> OnObstaclesCleared