Class DBComponentDefinition.Field
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
fieldIdintUnique field identifier within the component.
namestringField name (a single word, at most 63 UTF-8 bytes).
typeFieldTypeField type as stored on the component.
underlyingTypeFieldTypeElement type when
typeis a collection; otherwise None.offsetInComponentStorageintByte offset of this field within the component's storage.
dotNetTypeTypeThe 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
DotNetType
The backing CLR type of the field.
public Type DotNetType { get; }
Property Value
DotNetUnderlyingType
The CLR element type when the field is a collection; otherwise null.
public Type DotNetUnderlyingType { get; }
Property Value
FieldId
Unique field identifier within the component. Stable across schema revisions so persisted data can be re-mapped.
public int FieldId { get; }
Property Value
FieldSize
Byte width of one element of this field (from Type); see SizeInComponentStorage for the total including arrays.
public int FieldSize { get; }
Property Value
ForeignKeyTargetType
The target component type the foreign key points at, from TargetComponentType. Null when IsForeignKey is false.
public Type ForeignKeyTargetType { get; set; }
Property Value
HasIndex
True when the field carries a scalar index ([Index]).
public bool HasIndex { get; set; }
Property Value
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
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
IsArray
True when this field is a fixed-length array, i.e. ArrayLength is greater than 0.
public bool IsArray { get; }
Property Value
IsForeignKey
True when the field is a foreign key ([ForeignKey]) referencing another component's entities.
public bool IsForeignKey { get; set; }
Property Value
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
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
Name
Field name.
public string Name { get; }
Property Value
OffsetInComponentStorage
Byte offset of this field within the component's storage.
public int OffsetInComponentStorage { get; }
Property Value
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
SpatialCategory
Archetype-level category bitmask for spatial broadphase filtering, from Category. Defaults to MaxValue.
public uint SpatialCategory { get; set; }
Property Value
SpatialCellSize
Broadphase cell size for the spatial index, from CellSize. 0 selects the engine default.
public float SpatialCellSize { get; set; }
Property Value
SpatialFieldType
Kind of spatial bounds indexed (AABB / bounding sphere, 2D/3D, single/double precision). Meaningful when HasSpatialIndex.
public SpatialFieldType SpatialFieldType { get; set; }
Property Value
SpatialMargin
Fat-AABB margin used for movement hysteresis in the dynamic R-Tree, from Margin.
public float SpatialMargin { get; set; }
Property Value
SpatialMode
Whether the spatial index is static or dynamic, from Mode.
public SpatialMode SpatialMode { get; set; }
Property Value
Type
The field's type as stored on the component.
public FieldType Type { get; }
Property Value
UnderlyingType
public FieldType UnderlyingType { get; }
Property Value
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
fieldNamestringThe 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
fieldTypeFieldTypeThe 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()