Table of Contents

Struct RealmId

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

Identifies a realm: one of the strictly isolated worlds a DatabaseEngine hosts (a planet, a space sector, a building interior, a dungeon instance). An entity is in exactly one realm at a time; every spatial structure, query and replication view is scoped to one realm.

public readonly struct RealmId : IEquatable<RealmId>
Implements
Inherited Members

Remarks

A dense index, not a handle: realms are addressed by array index everywhere on the hot path, so the value is bounded by the engine's configured realm count and None (0xFFFF) is reserved — at most 65 535 realms.

Default (0) is the realm a single-world application lives in without ever naming one: ConfigureSpatialGrid configures it, and a spatial archetype with no realm key lives in it.

Constructors

RealmId(ushort)

Creates a realm id from its index.

public RealmId(ushort value)

Parameters

value ushort

Fields

Default

Realm 0 — the single world of an application that never names a realm.

public static readonly RealmId Default

Field Value

RealmId

MaxCount

The largest realm count an engine can be configured with (every index but None).

public const int MaxCount = 65535

Field Value

int

None

No realm (for example a session outside every realm). Never a valid index.

public static readonly RealmId None

Field Value

RealmId

NoneValue

The raw value of None.

public const ushort NoneValue = 65535

Field Value

ushort

Value

The realm index.

public readonly ushort Value

Field Value

ushort

Properties

IsNone

True for None.

public bool IsNone { get; }

Property Value

bool

Methods

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

Equals(RealmId)

public bool Equals(RealmId other)

Parameters

other RealmId

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

public override string ToString()

Returns

string

Operators

operator ==(RealmId, RealmId)

Equality.

public static bool operator ==(RealmId left, RealmId right)

Parameters

left RealmId
right RealmId

Returns

bool

explicit operator RealmId(ushort)

A realm id from its index.

public static explicit operator RealmId(ushort value)

Parameters

value ushort

Returns

RealmId

explicit operator ushort(RealmId)

The index. Explicit: None converts to 65 535, which indexes nothing, so a conversion is a decision, never an accident.

public static explicit operator ushort(RealmId realm)

Parameters

realm RealmId

Returns

ushort

operator !=(RealmId, RealmId)

Inequality.

public static bool operator !=(RealmId left, RealmId right)

Parameters

left RealmId
right RealmId

Returns

bool