Table of Contents

Class GridOccupantManager

Namespace
GridForge.Grids
Assembly
GridForge.dll

Provides utility methods for managing voxel occupants within a grid. Supports adding, removing, and retrieving occupants with thread-safe operations.

public static class GridOccupantManager
Inheritance
GridOccupantManager
Inherited Members

Fields

MaxOccupantCount

Maximum number of occupants allowed per voxel.

public const byte MaxOccupantCount = 255

Field Value

byte

Methods

GetOccupiedIndices(GridWorld, IVoxelOccupant)

Returns a snapshot of the voxel indices currently tracked for the occupant in the supplied world.

public static IEnumerable<WorldVoxelIndex> GetOccupiedIndices(GridWorld world, IVoxelOccupant occupant)

Parameters

world GridWorld

The world whose occupancy registry should be queried.

occupant IVoxelOccupant

The occupant whose tracked voxel indices should be returned.

Returns

IEnumerable<WorldVoxelIndex>

A deterministic snapshot of the occupant's currently tracked voxel indices.

TryAddVoxelOccupant(GridWorld, WorldVoxelIndex, IVoxelOccupant)

Attempts to add an occupant from the given world-scoped voxel identity in the supplied world.

public static bool TryAddVoxelOccupant(GridWorld world, WorldVoxelIndex index, IVoxelOccupant occupant)

Parameters

world GridWorld
index WorldVoxelIndex
occupant IVoxelOccupant

Returns

bool

TryAddVoxelOccupant(VoxelGrid, Voxel, IVoxelOccupant)

Adds an occupant to the grid.

public static bool TryAddVoxelOccupant(this VoxelGrid grid, Voxel targetVoxel, IVoxelOccupant occupant)

Parameters

grid VoxelGrid
targetVoxel Voxel
occupant IVoxelOccupant

Returns

bool

TryAddVoxelOccupant(VoxelGrid, IVoxelOccupant)

Attempts to add an occupant at the given world position.

public static bool TryAddVoxelOccupant(this VoxelGrid grid, IVoxelOccupant occupant)

Parameters

grid VoxelGrid
occupant IVoxelOccupant

Returns

bool

TryAddVoxelOccupant(VoxelGrid, VoxelIndex, IVoxelOccupant)

Attempts to add an occupant at the specified voxel index.

public static bool TryAddVoxelOccupant(this VoxelGrid grid, VoxelIndex voxelIndex, IVoxelOccupant occupant)

Parameters

grid VoxelGrid
voxelIndex VoxelIndex
occupant IVoxelOccupant

Returns

bool

TryDeregister(GridWorld, IVoxelOccupant)

Attempts to de-register the occupant from every voxel currently tracked in the supplied world.

public static bool TryDeregister(GridWorld world, IVoxelOccupant occupant)

Parameters

world GridWorld
occupant IVoxelOccupant

Returns

bool

TryGetOccupancyTicket(GridWorld, IVoxelOccupant, WorldVoxelIndex, out OccupantTicket)

Attempts to retrieve the scan-cell ticket for the occupant at a specific voxel in the supplied world.

public static bool TryGetOccupancyTicket(GridWorld world, IVoxelOccupant occupant, WorldVoxelIndex index, out OccupantTicket ticket)

Parameters

world GridWorld

The world whose occupancy registry should be queried.

occupant IVoxelOccupant

The occupant whose registration should be queried.

index WorldVoxelIndex

The tracked voxel index to look up.

ticket OccupantTicket

The tracked scan-cell ticket for the occupant at that voxel.

Returns

bool

True if the occupant is registered to the voxel, otherwise false.

TryRegister(GridWorld, IVoxelOccupant)

Attempts to register the occupant with the current voxel it is on in the supplied world.

public static bool TryRegister(GridWorld world, IVoxelOccupant occupant)

Parameters

world GridWorld
occupant IVoxelOccupant

Returns

bool

TryRemoveVoxelOccupant(GridWorld, WorldVoxelIndex, IVoxelOccupant)

Attempts to remove an occupant from the given world-scoped voxel identity in the supplied world.

public static bool TryRemoveVoxelOccupant(GridWorld world, WorldVoxelIndex index, IVoxelOccupant occupant)

Parameters

world GridWorld
index WorldVoxelIndex
occupant IVoxelOccupant

Returns

bool

TryRemoveVoxelOccupant(VoxelGrid, Voxel, IVoxelOccupant)

Removes an occupant from this grid.

public static bool TryRemoveVoxelOccupant(this VoxelGrid grid, Voxel targetVoxel, IVoxelOccupant occupant)

Parameters

grid VoxelGrid
targetVoxel Voxel
occupant IVoxelOccupant

Returns

bool

TryRemoveVoxelOccupant(VoxelGrid, IVoxelOccupant)

Attempts to remove an occupant from the given world position.

public static bool TryRemoveVoxelOccupant(this VoxelGrid grid, IVoxelOccupant occupant)

Parameters

grid VoxelGrid
occupant IVoxelOccupant

Returns

bool

TryRemoveVoxelOccupant(VoxelGrid, VoxelIndex, IVoxelOccupant)

Attempts to remove an occupant at the specified voxel coordinates.

public static bool TryRemoveVoxelOccupant(this VoxelGrid grid, VoxelIndex voxelIndex, IVoxelOccupant occupant)

Parameters

grid VoxelGrid
voxelIndex VoxelIndex
occupant IVoxelOccupant

Returns

bool

Events

OnOccupantAdded

public static event Action<OccupantEventInfo> OnOccupantAdded

Event Type

Action<OccupantEventInfo>

OnOccupantRemoved

public static event Action<OccupantEventInfo> OnOccupantRemoved

Event Type

Action<OccupantEventInfo>