Table of Contents

Class GridObstacleManager

Namespace
GridForge.Grids
Assembly
GridForge.dll

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

byte

Methods

ClearObstacles(VoxelGrid, Voxel)

Clears all obstacles from the specified voxel.

public static void ClearObstacles(this VoxelGrid grid, Voxel targetVoxel)

Parameters

grid VoxelGrid
targetVoxel Voxel

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

world GridWorld
index WorldVoxelIndex
obstacleToken ObstacleToken

Returns

bool

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

grid VoxelGrid

The grid to mutate.

position Vector2d

The 2D position whose X component maps to world X and Y component maps to world Z.

layerY Fixed64

The world Y layer to resolve.

obstacleToken ObstacleToken

The 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

grid VoxelGrid

The grid to mutate.

position Vector2d

The 2D position whose X component maps to world X and Y component maps to world Z.

obstacleToken ObstacleToken

The 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

grid VoxelGrid
position Vector3d
obstacleToken ObstacleToken

Returns

bool

TryAddObstacle(VoxelGrid, Voxel, ObstacleToken)

Adds an obstacle to this voxel.

public static bool TryAddObstacle(this VoxelGrid grid, Voxel targetVoxel, ObstacleToken obstacleToken)

Parameters

grid VoxelGrid
targetVoxel Voxel
obstacleToken ObstacleToken

The process-unique obstacle registration token.

Returns

bool

Exceptions

Exception

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

world GridWorld
index WorldVoxelIndex
obstacleToken ObstacleToken

Returns

bool

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

grid VoxelGrid

The grid to mutate.

position Vector2d

The 2D position whose X component maps to world X and Y component maps to world Z.

layerY Fixed64

The world Y layer to resolve.

obstacleToken ObstacleToken

The 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

grid VoxelGrid

The grid to mutate.

position Vector2d

The 2D position whose X component maps to world X and Y component maps to world Z.

obstacleToken ObstacleToken

The 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

grid VoxelGrid
position Vector3d
obstacleToken ObstacleToken

Returns

bool

TryRemoveObstacle(VoxelGrid, Voxel, ObstacleToken)

Removes an obstacle from a given voxel.

public static bool TryRemoveObstacle(this VoxelGrid grid, Voxel targetVoxel, ObstacleToken obstacleToken)

Parameters

grid VoxelGrid
targetVoxel Voxel
obstacleToken ObstacleToken

Returns

bool

Events

OnObstacleAdded

public static event Action<ObstacleEventInfo> OnObstacleAdded

Event Type

Action<ObstacleEventInfo>

OnObstacleRemoved

public static event Action<ObstacleEventInfo> OnObstacleRemoved

Event Type

Action<ObstacleEventInfo>

OnObstaclesCleared

public static event Action<ObstacleClearEventInfo> OnObstaclesCleared

Event Type

Action<ObstacleClearEventInfo>