Class GridOccupantManager
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
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
worldGridWorldThe world whose occupancy registry should be queried.
occupantIVoxelOccupantThe 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
worldGridWorldindexWorldVoxelIndexoccupantIVoxelOccupant
Returns
TryAddVoxelOccupant(VoxelGrid, Voxel, IVoxelOccupant)
Adds an occupant to the grid.
public static bool TryAddVoxelOccupant(this VoxelGrid grid, Voxel targetVoxel, IVoxelOccupant occupant)
Parameters
gridVoxelGridtargetVoxelVoxeloccupantIVoxelOccupant
Returns
TryAddVoxelOccupant(VoxelGrid, IVoxelOccupant)
Attempts to add an occupant at the given world position.
public static bool TryAddVoxelOccupant(this VoxelGrid grid, IVoxelOccupant occupant)
Parameters
gridVoxelGridoccupantIVoxelOccupant
Returns
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
gridVoxelGridvoxelIndexVoxelIndexoccupantIVoxelOccupant
Returns
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
worldGridWorldoccupantIVoxelOccupant
Returns
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
worldGridWorldThe world whose occupancy registry should be queried.
occupantIVoxelOccupantThe occupant whose registration should be queried.
indexWorldVoxelIndexThe tracked voxel index to look up.
ticketOccupantTicketThe 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
worldGridWorldoccupantIVoxelOccupant
Returns
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
worldGridWorldindexWorldVoxelIndexoccupantIVoxelOccupant
Returns
TryRemoveVoxelOccupant(VoxelGrid, Voxel, IVoxelOccupant)
Removes an occupant from this grid.
public static bool TryRemoveVoxelOccupant(this VoxelGrid grid, Voxel targetVoxel, IVoxelOccupant occupant)
Parameters
gridVoxelGridtargetVoxelVoxeloccupantIVoxelOccupant
Returns
TryRemoveVoxelOccupant(VoxelGrid, IVoxelOccupant)
Attempts to remove an occupant from the given world position.
public static bool TryRemoveVoxelOccupant(this VoxelGrid grid, IVoxelOccupant occupant)
Parameters
gridVoxelGridoccupantIVoxelOccupant
Returns
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
gridVoxelGridvoxelIndexVoxelIndexoccupantIVoxelOccupant
Returns
Events
OnOccupantAdded
public static event Action<OccupantEventInfo> OnOccupantAdded
Event Type
OnOccupantRemoved
public static event Action<OccupantEventInfo> OnOccupantRemoved