Struct ComponentFieldSpec
- Namespace
- Typhon.Schema.Definition
- Assembly
- Typhon.Schema.Definition.dll
Pure-data description of a single component field: its identity, CLR type, byte offset, and any array / index / foreign-key / spatial metadata. The engine maps DotNetType to its stored field type and applies field-id resolution (schema migration) when building the definition, so this spec carries the same inputs reflection would read from the struct — never a pre-resolved field id.
public readonly struct ComponentFieldSpec
- Inherited Members
Constructors
ComponentFieldSpec(string, Type, int, string, int?, bool, int, bool, bool, bool, Type, bool, float, SpatialMode, uint, bool, bool)
Creates a component field spec. Only name, dotNetType, and offset are required; the remaining metadata defaults to "absent".
public ComponentFieldSpec(string name, Type dotNetType, int offset, string previousName = null, int? explicitFieldId = null, bool isStatic = false, int arrayLength = 0, bool hasIndex = false, bool indexAllowMultiple = false, bool isForeignKey = false, Type foreignKeyTargetType = null, bool hasSpatialIndex = false, float spatialCellSize = 0, SpatialMode spatialMode = SpatialMode.Dynamic, uint spatialCategory = 4294967295, bool isRealmKey = false, bool indexSparse = false)
Parameters
namestringField name (see Name).
dotNetTypeTypeBacking CLR type (see DotNetType).
offsetintByte offset within component storage (see Offset).
previousNamestringFormer field name (see PreviousName).
explicitFieldIdint?Explicit field id (see ExplicitFieldId).
isStaticboolSchema-static flag (see IsStatic).
arrayLengthintFixed array length (see ArrayLength).
hasIndexboolScalar-index flag (see HasIndex).
indexAllowMultipleboolNon-unique index flag (see IndexAllowMultiple).
isForeignKeyboolForeign-key flag (see IsForeignKey).
foreignKeyTargetTypeTypeForeign-key target type (see ForeignKeyTargetType).
hasSpatialIndexboolSpatial-index flag (see HasSpatialIndex).
spatialCellSizefloatSpatial cell size (see SpatialCellSize).
spatialModeSpatialModeSpatial mode (see SpatialMode).
spatialCategoryuintSpatial category bitmask (see SpatialCategory).
isRealmKeyboolRealm-key flag (see IsRealmKey).
indexSparseboolSparse-index flag (see IndexSparse).
Properties
ArrayLength
Fixed element count when the field is an array; 0 for a scalar field.
public int ArrayLength { get; }
Property Value
DotNetType
The backing CLR type of the field (e.g. typeof(float)). The engine maps this to its stored field type.
public Type DotNetType { get; }
Property Value
ExplicitFieldId
Explicit stable field id (from FieldId), or null to let the engine assign / resolve it.
public int? ExplicitFieldId { get; }
Property Value
- int?
ForeignKeyTargetType
The target component type the foreign key points at (from TargetComponentType); null unless IsForeignKey is true.
public Type ForeignKeyTargetType { get; }
Property Value
HasIndex
True when the field carries a scalar index (IndexAttribute).
public bool HasIndex { get; }
Property Value
HasSpatialIndex
True when the field carries a spatial index (SpatialIndexAttribute). At most one spatial field is allowed per component.
public bool HasSpatialIndex { get; }
Property Value
IndexAllowMultiple
True when the index permits multiple entities per key (non-unique). Only meaningful when HasIndex is true.
public bool IndexAllowMultiple { get; }
Property Value
IndexSparse
public bool IndexSparse { get; }
Property Value
IsForeignKey
True when the field is a foreign key (ForeignKeyAttribute) referencing another component's entities.
public bool IsForeignKey { get; }
Property Value
IsRealmKey
True when the field is the component's realm key (RealmKeyAttribute): a ushort naming the entity's realm.
public bool IsRealmKey { get; }
Property Value
IsStatic
True for a schema-static field — carried on the definition but excluded from per-entity storage and the field-id layout.
public bool IsStatic { get; }
Property Value
Name
Field name — the schema-match key (from Name or the C# field name).
public string Name { get; }
Property Value
Offset
Byte offset of the field within the component's storage, computed once via OffsetOf(Type, string).
public int Offset { get; }
Property Value
PreviousName
Former field name, set when the field was renamed so the persisted field can be carried forward (from PreviousName); null when never renamed.
public string PreviousName { get; }
Property Value
SpatialCategory
Archetype-level category bitmask for spatial broadphase filtering (from Category). Meaningful when HasSpatialIndex.
public uint SpatialCategory { get; }
Property Value
SpatialCellSize
Broadphase cell size (from CellSize); 0 selects the engine default. Meaningful when HasSpatialIndex.
public float SpatialCellSize { get; }
Property Value
SpatialMode
Whether the spatial index is static or dynamic (from Mode). Meaningful when HasSpatialIndex.
public SpatialMode SpatialMode { get; }