Class Blocker
Base class for all grid blockers that handles applying and removing obstacles.
public abstract class Blocker : IBlocker
- Inheritance
-
Blocker
- Implements
- Derived
- Inherited Members
Constructors
Blocker(GridWorld, bool, bool)
Initializes a new blocker instance bound to the supplied world.
protected Blocker(GridWorld world, bool active = true, bool cacheCoveredVoxels = false)
Parameters
worldGridWorldThe world whose grids this blocker should affect.
activeboolFlag whether or not this blocker will block on update.
cacheCoveredVoxelsboolFlag whether or not to cache covered voxels that are blocked.
Fields
_cachedCoveredVoxels
Stable voxel identifiers cached for safe blocker removal when CacheCoveredVoxels is true.
protected SwiftList<WorldVoxelIndex>? _cachedCoveredVoxels
Field Value
- SwiftList<WorldVoxelIndex>
Properties
BlockageToken
Unique token representing this blockage instance.
public ObstacleToken BlockageToken { get; }
Property Value
CacheCoveredVoxels
Flags whether or not to hold onto a reference of the voxels this blocker covers.
public bool CacheCoveredVoxels { get; protected set; }
Property Value
CacheMax
The cached maximum bounds of the blockage area.
public Vector3d CacheMax { get; }
Property Value
- Vector3d
CacheMin
The cached minimum bounds of the blockage area.
public Vector3d CacheMin { get; protected set; }
Property Value
- Vector3d
IsActive
Indicates whether the blocker is currently active.
public bool IsActive { get; protected set; }
Property Value
IsBlocking
Tracks whether the blocker is currently blocking voxels.
public bool IsBlocking { get; protected set; }
Property Value
World
The world this blocker is bound to.
public GridWorld World { get; }
Property Value
Methods
ApplyBlockage()
Applies the blockage by marking voxels as obstacles.
public virtual void ApplyBlockage()
CreateBlockageEventInfo()
Creates a snapshot describing the current blocker coverage.
protected BlockageEventInfo CreateBlockageEventInfo()
Returns
GetBoundsMax()
Gets the max bounds of the area to block. Must be implemented by subclasses.
protected abstract Vector3d GetBoundsMax()
Returns
- Vector3d
GetBoundsMin()
Gets the min bounds of the area to block. Must be implemented by subclasses.
protected abstract Vector3d GetBoundsMin()
Returns
- Vector3d
NotifyBlockageApplied()
Notifies subscribers that blockage has been applied.
protected virtual void NotifyBlockageApplied()
NotifyBlockageRemoved(BlockageEventInfo)
Notifies subscribers that blockage has been removed.
protected virtual void NotifyBlockageRemoved(BlockageEventInfo eventInfo)
Parameters
eventInfoBlockageEventInfo
RemoveBlockage()
Removes the blockage by clearing obstacle markers from voxels.
public virtual void RemoveBlockage()
Reset()
Resets the blocker to its default state, removing any active blockage and clearing cached data.
public virtual void Reset()
SetCacheCoveredVoxels(bool)
Sets whether or not to cache covered voxels for this blocker. If enabled, the blocker will store references to the voxels it covers when applying blockage, which can improve performance when removing blockage at the cost of increased memory usage.
public virtual void SetCacheCoveredVoxels(bool cache)
Parameters
cachebool
ToggleStatus(bool)
Toggles the blocker from inactive to active or active to inactive state If object is currently blocking, the blocker will be removed. If object is not active and not blocking, the blocker will be applied.
public virtual void ToggleStatus(bool status)
Parameters
statusbool
Events
OnBlockageApplied
public static event Action<BlockageEventInfo> OnBlockageApplied
Event Type
OnBlockageRemoved
public static event Action<BlockageEventInfo> OnBlockageRemoved