Skip to content

Game.Prefabs.NetGeometryData

Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
NetGeometryData is a DOTS component-like structure used by the game's prefab/mesh generation for network (road/rail/etc.) geometry. It contains archetypes for node/edge entity composition, references to aggregate/style types, a set of ranges and numeric parameters that control allowed heights, edge lengths, widths and offsets, and layer/flag masks that control merging and intersections. It also implements custom binary serialization (Serialize/Deserialize) used by the engine's data persistence/streaming systems.


Fields

  • public EntityArchetype m_NodeCompositionArchetype
    Archetype used to create node entities for this network geometry.

  • public EntityArchetype m_EdgeCompositionArchetype
    Archetype used to create edge entities for this network geometry.

  • public Entity m_AggregateType
    Entity reference identifying the aggregate (type or category) used by this geometry.

  • public Entity m_StyleType
    Entity reference identifying visual/style type for this geometry.

  • public Bounds1 m_DefaultHeightRange
    Inclusive min/max range for default (ground) height values.

  • public Bounds1 m_ElevatedHeightRange
    Inclusive min/max range for elevated height values (bridges, elevated tracks).

  • public Bounds1 m_DefaultSurfaceHeight
    Range for surface height adjustments (used for aligning surface-level geometry).

  • public Bounds1 m_EdgeLengthRange
    Minimum and maximum allowed edge (segment) lengths for this geometry.

  • public Layer m_MergeLayers
    Layer bitmask indicating which layers this geometry can merge with.

  • public Layer m_IntersectLayers
    Layer bitmask indicating which layers this geometry can intersect.

  • public GeometryFlags m_Flags
    Flags controlling special geometry behaviour (various feature toggles).

  • public float m_DefaultWidth
    Default width of the geometry when not elevated.

  • public float m_ElevatedWidth
    Width to use when geometry is elevated.

  • public float m_ElevatedLength
    Elevated edge length; set on deserialization from m_EdgeLengthRange.max.

  • public float m_MinNodeOffset
    Minimum offset from node allowed by this geometry (used to avoid overlaps).

  • public float m_ElevationLimit
    Maximum permitted elevation for this geometry.

  • public float m_MaxSlopeSteepness
    Maximum allowed slope steepness (used to reject too-steep placements).

  • public float m_Hanging
    A small tolerance/offset used for "hanging" geometry alignment.

Properties

  • (no declared C# properties)
    The type exposes only public fields and implements serialization interfaces; there are no C# auto-properties declared in the source.

Constructors

  • public NetGeometryData()
    The struct has the default parameterless constructor (compiler-provided). Fields are not initialized by an explicit constructor in the source — expected to be set by the code that creates/populates the struct or by deserialization.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the geometry data to the provided writer in a fixed order. The method writes:
  • m_DefaultHeightRange.min, m_DefaultHeightRange.max
  • m_ElevatedHeightRange.min, m_ElevatedHeightRange.max
  • m_DefaultSurfaceHeight.min, m_DefaultSurfaceHeight.max
  • m_EdgeLengthRange.min, m_EdgeLengthRange.max
  • m_MergeLayers (as uint)
  • m_IntersectLayers (as uint)
  • m_Flags (as uint)
  • m_DefaultWidth, m_ElevatedWidth, m_MinNodeOffset, m_ElevationLimit, m_MaxSlopeSteepness, m_Hanging
    Keep the writer order and types in-sync with Deserialize.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads data from the provided reader in the same fixed order used by Serialize and populates fields. After reading ranges and numeric values it:

  • sets m_MergeLayers, m_IntersectLayers and m_Flags from the three read uint values,
  • sets m_ElevatedLength = m_EdgeLengthRange.max (note: elevated length is derived from the edge length range on deserialization).

Notes about serialization: - The read/write order is important — changing it will break compatibility. - Some fields (like archetypes, entities m_AggregateType/m_StyleType, and other complex types) are not serialized here and are expected to be provided/managed elsewhere. - Deserialize writes directly into field storage using ref locals for efficiency.

Usage Example

// Example: create and populate a NetGeometryData instance and serialize it.
// IWriter/IReader are engine-specific; this example assumes a concrete writer exists.

var geom = new NetGeometryData
{
    m_DefaultHeightRange = new Bounds1 { min = 0f, max = 0.5f },
    m_ElevatedHeightRange = new Bounds1 { min = 2f, max = 10f },
    m_DefaultSurfaceHeight = new Bounds1 { min = 0f, max = 0.2f },
    m_EdgeLengthRange = new Bounds1 { min = 5f, max = 50f },
    m_MergeLayers = (Layer)0x1,
    m_IntersectLayers = (Layer)0x2,
    m_Flags = GeometryFlags.None,
    m_DefaultWidth = 6f,
    m_ElevatedWidth = 6f,
    m_MinNodeOffset = 0.5f,
    m_ElevationLimit = 25f,
    m_MaxSlopeSteepness = 0.3f,
    m_Hanging = 0.01f
};

// Serialize to a writer (actual writer implementation depends on engine)
using (var writer = new SomeBinaryWriter(/*stream*/) )
{
    geom.Serialize(writer);
}

// On load, use a reader and Deserialize to reconstruct:
var loaded = new NetGeometryData();
using (var reader = new SomeBinaryReader(/*stream*/) )
{
    loaded.Deserialize(reader);
}
// After Deserialize, loaded.m_ElevatedLength == loaded.m_EdgeLengthRange.max

If you want, I can also generate a short reference table listing the serialization order and types for quick compatibility checks.