Game.Routes.BoardingVehicle
Assembly: Assembly-CSharp.dll
Namespace: Game.Routes
Type: struct
Base: System.ValueType, implements IComponentData, IQueryTypeParameter, ISerializable
Summary:
Represents a small ECS component used to track a vehicle Entity and an optional "testing" Entity related to boarding/route testing logic. This struct is a plain value-type component that integrates with Colossal's binary serialization system (IWriter/IReader) and is safe to use in queries (IQueryTypeParameter). It serializes both Entity fields, but the second field is conditionally deserialized depending on the saved data version.
Fields
-
public Entity m_Vehicle
Holds the primary vehicle Entity reference associated with this boarding record (e.g., the vehicle that is boarding or being tracked). -
public Entity m_Testing
Holds an optional/testing Entity reference used by boarding tests or diagnostics. This field is only read from serialized data when the saved-game/stream version is >= Version.boardingTest; otherwise it remains at its default (Entity.Null).
Properties
- This type defines no properties.
Constructors
public BoardingVehicle()
No explicit constructor is declared in source; the default parameterless struct constructor is used. Both Entity fields default to Entity.Null when a new instance is created with the default constructor or default(BoardingVehicle).
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component's Entity fields into the provided writer in a fixed order: first m_Vehicle, then m_Testing. This method is used by the Colossal.Serialization.Entities pipeline when saving component data. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads component data from the provided reader. The method always reads m_Vehicle. It reads m_Testing only if reader.context.version >= Version.boardingTest. This ensures backward compatibility with older save formats that did not include the m_Testing field.
Notes: - The generic writer/reader types are constrained to IWriter/IReader from Colossal.Serialization.Entities. - The version check uses reader.context.version, so the presence of the second field depends on the serialized stream's version constant (Version.boardingTest).
Usage Example
// Example: creating and adding the component to an entity
BoardingVehicle bv = default;
bv.m_Vehicle = vehicleEntity; // an Entity representing the vehicle
bv.m_Testing = testingEntity; // optional test entity, or Entity.Null
entityManager.AddComponentData(targetEntity, bv);
// Serialization is handled by Colossal's pipeline; methods above are called by that system.
// During deserialization, m_Testing will only be populated if the saved data's version >= Version.boardingTest.