Table of Contents

Class Blocker

Namespace
GridForge.Blockers
Assembly
GridForge.dll

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

world GridWorld

The world whose grids this blocker should affect.

active bool

Flag whether or not this blocker will block on update.

cacheCoveredVoxels bool

Flag 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

ObstacleToken

CacheCoveredVoxels

Flags whether or not to hold onto a reference of the voxels this blocker covers.

public bool CacheCoveredVoxels { get; protected set; }

Property Value

bool

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

bool

IsBlocking

Tracks whether the blocker is currently blocking voxels.

public bool IsBlocking { get; protected set; }

Property Value

bool

World

The world this blocker is bound to.

public GridWorld World { get; }

Property Value

GridWorld

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

BlockageEventInfo

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

eventInfo BlockageEventInfo

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

cache bool

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

status bool

Events

OnBlockageApplied

public static event Action<BlockageEventInfo> OnBlockageApplied

Event Type

Action<BlockageEventInfo>

OnBlockageRemoved

public static event Action<BlockageEventInfo> OnBlockageRemoved

Event Type

Action<BlockageEventInfo>