Game.LocalConnectData
Assembly: Game
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
LocalConnectData is a value-type ECS component that holds configuration for "local" connection checks used by prefab placement/connection systems. It stores connection flags, layer mask, a height range (min/max), and a search distance. The struct implements ISerializable to allow writing/reading its fields to/from a binary writer/reader (used for saving, networking or entity serialization). The serialization format is stable and writes enums as uints followed by floats for the height range and search distance.
Fields
-
public LocalConnectFlags m_Flags
Flags that control connection behavior (represented by the LocalConnectFlags enum). Serialized as a uint. -
public Layer m_Layers
Layer mask / layer classification affecting what layers are considered for connections (Layer enum). Serialized as a uint. -
public Bounds1 m_HeightRange
Height range with .min and .max floats specifying acceptable vertical bounds for connections. Serialized as two floats: min then max. -
public float m_SearchDistance
Maximum search distance for connection queries. Serialized as a float.
Properties
- This type defines no properties. It exposes only public fields and uses the implicit default struct constructor.
Constructors
public LocalConnectData()
(implicit default)
No explicit constructors are declared. Use the default struct initialization or object initializer to set fields.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component data to the provided writer in this order:- m_Flags as uint
- m_Layers as uint
- m_HeightRange.min as float
- m_HeightRange.max as float
-
m_SearchDistance as float Notes: The method casts enum values to uint before writing to ensure a compact, version-stable representation.
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the component data from the provided reader in the same order as Serialize: - Read a uint into a temporary and cast to LocalConnectFlags for m_Flags
- Read a uint into a temporary and cast to Layer for m_Layers
- Read floats into m_HeightRange.min and m_HeightRange.max (reads by ref)
- Read a float into m_SearchDistance (reads by ref) Important: The read/write order must match to maintain compatibility. The method reads integer enum values first, then floats.
Usage Example
// Create and initialize
LocalConnectData data = new LocalConnectData {
m_Flags = LocalConnectFlags.Snap | LocalConnectFlags.RequireSurface,
m_Layers = Layer.Road | Layer.Terrain,
m_HeightRange = new Bounds1 { min = -2f, max = 2f },
m_SearchDistance = 10f
};
// Serialize (pseudo-code using an IWriter implementation)
using (var writer = new BinaryWriterAdapter(stream)) {
data.Serialize(writer);
}
// Deserialize (pseudo-code using an IReader implementation)
LocalConnectData readData = new LocalConnectData();
using (var reader = new BinaryReaderAdapter(stream)) {
readData.Deserialize(reader);
}
Additional notes: - As a struct and IComponentData, LocalConnectData is suitable for use as an ECS component (compact, copy-by-value). - Keep serialization order unchanged to preserve compatibility between versions and networked clients.