Table of Contents

Interface IArchetypeMask<TSelf>

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

Generic interface for archetype bitsets. Enables JIT specialization via constrained generics: where TMask : struct, IArchetypeMask<TMask> compiles to direct calls with zero virtual dispatch. Same pattern as Typhon.Engine.Internals.IPageStore (PersistentStore/TransientStore).

public interface IArchetypeMask<TSelf> where TSelf : struct

Type Parameters

TSelf

The implementing value type itself (curiously-recurring generic pattern), so set operations return the concrete mask type.

Properties

IsEmpty

true when no archetype bits are set.

bool IsEmpty { get; }

Property Value

bool

MaxId

Highest archetype ID this mask can represent.

int MaxId { get; }

Property Value

int

PopCount

Number of archetypes in the set (count of set bits).

int PopCount { get; }

Property Value

int

Methods

And(in TSelf)

Set intersection (bitwise AND) — inclusion filtering.

TSelf And(in TSelf other)

Parameters

other TSelf

Mask to intersect with.

Returns

TSelf

A new mask containing only the archetypes present in both.

AndNot(in TSelf)

Set difference (bitwise AND NOT) — exclusion filtering.

TSelf AndNot(in TSelf other)

Parameters

other TSelf

Mask whose archetypes are removed from this one.

Returns

TSelf

A new mask containing the archetypes present in this mask but not in other.

Clear(ushort)

Removes archetype archetypeId from the set (clears its bit).

void Clear(ushort archetypeId)

Parameters

archetypeId ushort

Archetype ID to exclude.

Or(in TSelf)

Set union (bitwise OR).

TSelf Or(in TSelf other)

Parameters

other TSelf

Mask to union with.

Returns

TSelf

A new mask containing every archetype present in either mask.

Set(ushort)

Adds archetype archetypeId to the set (sets its bit).

void Set(ushort archetypeId)

Parameters

archetypeId ushort

Archetype ID to include; must be in the range 0..MaxId.

Test(ushort)

Tests whether archetype archetypeId is present in the set.

bool Test(ushort archetypeId)

Parameters

archetypeId ushort

Archetype ID to test.

Returns

bool

true if the bit is set; otherwise false.