Struct SpatialTriggerVolumes
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
IsValid
false for a default-constructed value, which every other member rejects.
public bool IsValid { get; }
Property Value
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
boundsReadOnlySpan<double>[minX, minY, maxX, maxY]for a 2D component,[minX, minY, minZ, maxX, maxY, maxZ]for a 3D one.categoryMaskuintCategory bits the region reacts to;
0means "no filter".evaluationFrequencybyteMinimum ticks between real evaluations; calls in between return Typhon.Engine.SpatialTriggerResult.Skipped.
Returns
DestroyRegion(SpatialRegionHandle)
Remove a region. The handle is invalid afterwards.
public void DestroyRegion(SpatialRegionHandle handle)
Parameters
handleSpatialRegionHandle
EvaluateRegion(SpatialRegionHandle, int)
Which entities entered, left, or stayed in the region since its previous evaluation.
public SpatialTriggerResult EvaluateRegion(SpatialRegionHandle handle, int currentTick)
Parameters
handleSpatialRegionHandlecurrentTickint
Returns
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
handleSpatialRegionHandlenewBoundsReadOnlySpan<double>
UpdateRegionCategoryMask(SpatialRegionHandle, uint)
Change which categories a region reacts to.
public void UpdateRegionCategoryMask(SpatialRegionHandle handle, uint newMask)
Parameters
handleSpatialRegionHandlenewMaskuint