Skip to content

Game.FixedNetElement

Assembly: Assembly-CSharp.dll (game code / modding assembly)
Namespace: Game.Prefabs

Type: struct

Base: Implements Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.ISerializable

Summary:
FixedNetElement is a value-type buffer element used by prefab/network composition. It describes constraints and flags for a "fixed" network element (e.g., a predefined piece of road/vehicle network in a prefab): an allowed length range, a count range, and composition/element flags. The type provides custom serialization logic (ISerializable) that persists the length and count ranges. The composition flags and fixed-net flags are stored in the struct but are not written/read by the current Serialize/Deserialize implementations and must be handled separately when required.


Fields

  • public Bounds1 m_LengthRange
    Range (min/max) for element length. Bounds1 exposes min and max float fields used by the Serialize/Deserialize methods.

  • public int2 m_CountRange
    Integer 2-component range (min/max) for the allowed count of this element, using Unity.Mathematics.int2.

  • public CompositionFlags m_SetState
    Composition flags to set when composing/applying this element. Not serialized by the provided Serialize method.

  • public CompositionFlags m_UnsetState
    Composition flags to unset when composing/applying this element. Not serialized by the provided Serialize method.

  • public FixedNetFlags m_Flags
    Additional flags describing the fixed-net element. Not serialized by the provided Serialize method.

Properties

  • None declared. (All data is stored in public fields; no property accessors are provided.)

Constructors

  • public FixedNetElement()
    Implicit default value-type constructor. Fields will be initialized to their default values (zeros / default enum values). No custom constructors are defined in the source.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the element's serializable data using the provided writer. Current implementation writes:
  • m_LengthRange.min (float)
  • m_LengthRange.max (float)
  • m_CountRange (int2) Note: m_SetState, m_UnsetState and m_Flags are not written by this method.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the element's serializable data from the provided reader in the same order the serializer writes:

  • reads into m_LengthRange.min
  • reads into m_LengthRange.max
  • reads into m_CountRange Note: m_SetState, m_UnsetState and m_Flags are not read by this method and remain at their default values unless set elsewhere.

Usage Example

// Initialize a FixedNetElement and add it to an entity DynamicBuffer<FixedNetElement>
var elem = default(Game.Prefabs.FixedNetElement);

// Set length range
elem.m_LengthRange.min = 10f;
elem.m_LengthRange.max = 50f;

// Set count range (min, max)
elem.m_CountRange = new Unity.Mathematics.int2(1, 3);

// Set composition and element flags (example - use actual enum values from the game)
elem.m_SetState = (CompositionFlags)0;    // replace with real flags as needed
elem.m_UnsetState = (CompositionFlags)0;  // replace with real flags as needed
elem.m_Flags = (FixedNetFlags)0;          // replace with real flags as needed

// Add to an entity buffer (example in an ECS system)
var buffer = entityManager.AddBuffer<Game.Prefabs.FixedNetElement>(entity);
buffer.Add(elem);

// Serialization / deserialization is performed by the game's IWriter/IReader systems.
// The Serialize/Deserialize implementations will only persist the length and count ranges.