Table of Contents

Struct SpatialTriggerVolumes

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

Trigger volumes for one spatial component type: define regions, then ask each which entities entered, left, or stayed since the last evaluation.

public readonly struct SpatialTriggerVolumes
Inherited Members

Remarks

Obtained from SpatialTriggers<T>(DatabaseEngine). See SpatialObserverSet for why both surfaces became public in #872 step 13.

Evaluation is a set diff, not a bitmap XOR. Occupancy is tracked by entity id against the per-cell cluster index; the component-chunk-id bitmap the old entity-level path used could not represent cluster storage, whose chunk ids live in a different namespace.

Properties

ActiveRegionCount

How many regions are currently defined.

public int ActiveRegionCount { get; }

Property Value

int

IsValid

false for a default-constructed value, which every other member rejects.

public bool IsValid { get; }

Property Value

bool

Remarks

A public struct can always be default-constructed, and this one is a façade over engine state it cannot invent. Without the check every member would throw NullReferenceException — the one exception that tells a caller nothing about what they did wrong.

Methods

CreateRegion(ReadOnlySpan<double>, uint, byte)

Define a trigger region over bounds.

public SpatialRegionHandle CreateRegion(ReadOnlySpan<double> bounds, uint categoryMask = 0, byte evaluationFrequency = 1)

Parameters

bounds ReadOnlySpan<double>

[minX, minY, maxX, maxY] for a 2D component, [minX, minY, minZ, maxX, maxY, maxZ] for a 3D one.

categoryMask uint

Category bits the region reacts to; 0 means "no filter".

evaluationFrequency byte

Minimum ticks between real evaluations; calls in between return Typhon.Engine.SpatialTriggerResult.Skipped.

Returns

SpatialRegionHandle

DestroyRegion(SpatialRegionHandle)

Remove a region. The handle is invalid afterwards.

public void DestroyRegion(SpatialRegionHandle handle)

Parameters

handle SpatialRegionHandle

EvaluateRegion(SpatialRegionHandle, int)

Which entities entered, left, or stayed in the region since its previous evaluation.

public SpatialTriggerResult EvaluateRegion(SpatialRegionHandle handle, int currentTick)

Parameters

handle SpatialRegionHandle
currentTick int

Returns

SpatialTriggerResult

Remarks

The returned spans are valid only until the next EvaluateRegion(SpatialRegionHandle, int) call on this system — they are shared result buffers, not per-region.

UpdateRegionBounds(SpatialRegionHandle, ReadOnlySpan<double>)

Move or resize a region. Its occupant set is kept, so the next evaluation reports the difference as enters and leaves.

public void UpdateRegionBounds(SpatialRegionHandle handle, ReadOnlySpan<double> newBounds)

Parameters

handle SpatialRegionHandle
newBounds ReadOnlySpan<double>

UpdateRegionCategoryMask(SpatialRegionHandle, uint)

Change which categories a region reacts to.

public void UpdateRegionCategoryMask(SpatialRegionHandle handle, uint newMask)

Parameters

handle SpatialRegionHandle
newMask uint