Table of Contents

Class DBComponentDefinition.Field

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

A single field of a component: its identity, type, byte offset within the component storage, and any index / spatial / foreign-key metadata.

public class DBComponentDefinition.Field
Inheritance
DBComponentDefinition.Field
Inherited Members

Constructors

Field(int, string, FieldType, FieldType, int, Type)

Creates a field descriptor. Index, spatial, and foreign-key metadata are set separately after construction.

public Field(int fieldId, string name, FieldType type, FieldType underlyingType, int offsetInComponentStorage, Type dotNetType)

Parameters

fieldId int

Unique field identifier within the component.

name string

Field name (a single word, at most 63 UTF-8 bytes).

type FieldType

Field type as stored on the component.

underlyingType FieldType

Element type when type is a collection; otherwise None.

offsetInComponentStorage int

Byte offset of this field within the component's storage.

dotNetType Type

The backing CLR type of the field.

Properties

ArrayLength

Fixed element count when the field is an array; 0 for a scalar field.

public int ArrayLength { get; set; }

Property Value

int

DotNetType

The backing CLR type of the field.

public Type DotNetType { get; }

Property Value

Type

DotNetUnderlyingType

The CLR element type when the field is a collection; otherwise null.

public Type DotNetUnderlyingType { get; }

Property Value

Type

FieldId

Unique field identifier within the component. Stable across schema revisions so persisted data can be re-mapped.

public int FieldId { get; }

Property Value

int

FieldSize

Byte width of one element of this field (from Type); see SizeInComponentStorage for the total including arrays.

public int FieldSize { get; }

Property Value

int

ForeignKeyTargetType

The target component type the foreign key points at, from TargetComponentType. Null when IsForeignKey is false.

public Type ForeignKeyTargetType { get; set; }

Property Value

Type

HasIndex

True when the field carries a scalar index ([Index]).

public bool HasIndex { get; set; }

Property Value

bool

HasSpatialIndex

True when the field carries a spatial index ([SpatialIndex]). At most one spatial field is allowed per component.

public bool HasSpatialIndex { get; set; }

Property Value

bool

IndexAllowMultiple

True when the index permits multiple entities per key (non-unique). Only meaningful when HasIndex is true.

public bool IndexAllowMultiple { get; set; }

Property Value

bool

IsArray

True when this field is a fixed-length array, i.e. ArrayLength is greater than 0.

public bool IsArray { get; }

Property Value

bool

IsForeignKey

True when the field is a foreign key ([ForeignKey]) referencing another component's entities.

public bool IsForeignKey { get; set; }

Property Value

bool

IsIndexAuto

True when the index was created implicitly by the engine rather than declared with an explicit [Index] attribute.

public bool IsIndexAuto { get; set; }

Property Value

bool

IsStatic

True for a static field — carried on the definition but excluded from per-entity component storage and the FieldId layout.

public bool IsStatic { get; set; }

Property Value

bool

Name

Field name.

public string Name { get; }

Property Value

string

OffsetInComponentStorage

Byte offset of this field within the component's storage.

public int OffsetInComponentStorage { get; }

Property Value

int

SizeInComponentStorage

Total bytes this field occupies in component storage: one element's width times ArrayLength for arrays, otherwise one element.

public int SizeInComponentStorage { get; }

Property Value

int

SpatialCategory

Archetype-level category bitmask for spatial broadphase filtering, from Category. Defaults to MaxValue.

public uint SpatialCategory { get; set; }

Property Value

uint

SpatialCellSize

Broadphase cell size for the spatial index, from CellSize. 0 selects the engine default.

public float SpatialCellSize { get; set; }

Property Value

float

SpatialFieldType

Kind of spatial bounds indexed (AABB / bounding sphere, 2D/3D, single/double precision). Meaningful when HasSpatialIndex.

public SpatialFieldType SpatialFieldType { get; set; }

Property Value

SpatialFieldType

SpatialMargin

Fat-AABB margin used for movement hysteresis in the dynamic R-Tree, from Margin.

public float SpatialMargin { get; set; }

Property Value

float

SpatialMode

Whether the spatial index is static or dynamic, from Mode.

public SpatialMode SpatialMode { get; set; }

Property Value

SpatialMode

Type

The field's type as stored on the component.

public FieldType Type { get; }

Property Value

FieldType

UnderlyingType

Element type when Type is a collection; otherwise None.

public FieldType UnderlyingType { get; }

Property Value

FieldType

Methods

CheckName(string)

Validates a field name: it must be a non-empty run of ASCII letters at most 63 UTF-8 bytes long.

public static void CheckName(string fieldName)

Parameters

fieldName string

The candidate field name.

Exceptions

ArgumentException

The name is empty, contains non-letter characters, or exceeds the byte-length limit.

CheckType(FieldType)

Validates that a field type is a defined value other than None.

public static void CheckType(FieldType fieldType)

Parameters

fieldType FieldType

The candidate field type.

Exceptions

ArgumentException

The type is undefined or None.

DoesFieldTypeSupportIndex()

True when Type can back an index — the scalar and string types in the indexable range (byte through String64).

public bool DoesFieldTypeSupportIndex()

Returns

bool