Skip to content

Game.Prefabs.NetObjectData

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: System.ValueType

Summary:
NetObjectData is a small ECS component/serializable struct used by net (road/track) prefabs. It stores composition and pass-through/requirement flags that describe how a net object composes with roads and tracks. It implements IComponentData for use with Unity.Entities, IQueryTypeParameter for query-time plumbing, and Colossal.Serialization.Entities.ISerializable to participate in the game's custom serialization pipeline. Note that only m_CompositionFlags is currently serialized by the provided Serialize/Deserialize implementations.


Fields

  • public CompositionFlags m_CompositionFlags
    This bitflag field encodes composition-related options for the net prefab (how it composes with other net pieces). It is the only field read/written by the Serialize/Deserialize methods in this struct.

  • public RoadTypes m_RequireRoad
    Specifies road types that this net object requires (connection or contextual constraint). Not serialized by the struct's Serialize/Deserialize methods.

  • public RoadTypes m_RoadPassThrough
    Specifies which road types this net object allows to pass through it. Not serialized by the struct's Serialize/Deserialize methods.

  • public TrackTypes m_TrackPassThrough
    Specifies which track types this net object allows to pass through it. Not serialized by the struct's Serialize/Deserialize methods.

Properties

  • None. (The type exposes public fields rather than properties.)

Constructors

  • public NetObjectData()
    Default value-type constructor (implicitly provided). All fields are default-initialized (zero/null). Initialize fields manually or with an object initializer when creating a new instance.

Methods

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads component data from the reader. Current implementation only reads m_CompositionFlags:
  • reader.Read(out m_CompositionFlags);

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes component data to the writer. Current implementation only writes m_CompositionFlags:

  • writer.Write(m_CompositionFlags);

Usage Example

// Creating and populating the component for an entity
var netData = new NetObjectData {
    m_CompositionFlags = CompositionFlags.SomeFlagCombination,
    m_RequireRoad = RoadTypes.Motorway,
    m_RoadPassThrough = RoadTypes.Local | RoadTypes.Avenue,
    m_TrackPassThrough = TrackTypes.Tram
};

// Adding to an entity (Unity.Entities API)
entityManager.AddComponentData(entity, netData);

// Serializing (example writer provided by game's serialization system)
netData.Serialize(writer);

// Deserializing into an existing or new instance
var loaded = default(NetObjectData);
loaded.Deserialize(reader);
// Note: loaded will have m_CompositionFlags populated; other fields remain default

{{ This struct is intended to be small and efficient for ECS usage. When extending serialization behavior, remember to keep backwards compatibility with save formats — the current Serialize/Deserialize only handle m_CompositionFlags, so additional fields would require save format updates or versioning. }}