Game.Prefabs.WorkRouteData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
WorkRouteData is a small ECS component used by the game's prefab/vehicle systems to record the size class of a route's required vehicle. It stores a single SizeClass value (from Game.Vehicles) and implements Colossal.Serialization's ISerializable so it can be written to and read from the game's save/stream format. Because it implements IComponentData and IQueryTypeParameter it is intended to be attached to Unity.Entities entities and used in ECS queries.
Fields
public SizeClass m_SizeClass
Stores the size class for the route (an enum defined in Game.Vehicles). This is serialized as a single byte by the ISerializable implementation. Default value is the enum's default (typically 0) when the struct is default-constructed.
Properties
- This type has no properties.
Constructors
public WorkRouteData()
Structs have an implicit parameterless constructor that initializes m_SizeClass to its default enum value. No explicit constructors are defined in the source.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Serializes the component to the provided writer. The implementation writes the SizeClass value as a single byte:-
writer.Write((byte)m_SizeClass);
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Deserializes the component from the provided reader. The implementation reads a byte and casts it back to SizeClass: - reader.Read(out byte value);
- m_SizeClass = (SizeClass)value;
Notes: - The serialization format is compact (single byte). When changing the SizeClass enum or serialization scheme, take care to maintain compatibility with existing saved data. - Generic writer/reader types must implement the IWriter/IReader interfaces from Colossal.Serialization.Entities (these provide the Write/Read methods used here).
Usage Example
// Creating and using the component on an entity (conceptual ECS usage)
var data = new WorkRouteData { m_SizeClass = SizeClass.Medium };
// Serializing
// (TWriter would be provided by the game's serialization system)
writer.Write((byte)data.m_SizeClass);
// Deserializing
// (TReader would be provided by the game's deserialization system)
reader.Read(out byte value);
data.m_SizeClass = (SizeClass)value;
{{ This struct is a small, efficient ECS component intended to be attached to prefabs/entities that need to record the vehicle size class for work routes. Its ISerializable implementation uses a single byte for compact storage, and it fits into Unity's ECS and the game's custom serialization framework. }}