Game.Prefabs.NetLaneData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
NetLaneData is a lightweight ECS component used to describe a single lane prefab's runtime data for the road/traffic systems. It stores a reference to a pathfinding/visual prefab (Entity), lane-specific flags, and the lane width. The struct implements ISerializable so it can be written/read to the game's custom serialization streams and IComponentData so it can be attached to Entities in Unity.Entities-based systems.
Fields
-
public Entity m_PathfindPrefab
Holds an Entity reference to the lane's pathfinding or visual prefab. This Entity is written/read first in serialization and typically points to the prefab used for lane/pathfinding behavior or visuals. -
public LaneFlags m_Flags
An enum (LaneFlags) storing per-lane flags (e.g., direction, type, special attributes). When serialized it is written as a uint. -
public float m_Width
Width of the lane in game units (float). Serialized as a float and read back into the field during deserialization.
Properties
- None. (The struct exposes only public fields; there are no C# properties defined.)
Constructors
public NetLaneData()
No explicit constructors are defined in the source. As a value type it has the default parameterless constructor which zero-initializes fields. Create and populate fields manually when instantiating.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component data to the provided writer in this order: m_PathfindPrefab (Entity), m_Flags (cast to uint), m_Width (float). This ordering must be preserved by any reader to ensure correct deserialization. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads component data from the provided reader in the same order used for serialization: first the Entity for m_PathfindPrefab, then a uint which is converted to LaneFlags and stored into m_Flags, then the float for m_Width.
Notes for modders: - The Serialize/Deserialize methods are generic over IWriter/IReader and are intended to integrate with Colossal's custom serialization. Ensure matching writer/reader sequences when extending or copying this data. - m_PathfindPrefab is an Entity reference; when creating or patching saved data, be careful to resolve prefab Entities correctly in the target world/context.
Usage Example
// Create and populate a NetLaneData instance
var laneData = new NetLaneData
{
m_PathfindPrefab = somePrefabEntity, // Entity obtained from EntityManager or prefab registry
m_Flags = LaneFlags.Forward | LaneFlags.HasShoulder, // example flags
m_Width = 3.25f
};
// Attach to an entity (example)
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity laneEntity = entityManager.CreateEntity();
entityManager.AddComponentData(laneEntity, laneData);
// Custom serialization (pseudo-code using game's writer)
writer.Write(laneData.m_PathfindPrefab);
writer.Write((uint)laneData.m_Flags);
writer.Write(laneData.m_Width);