Skip to content

Game.Prefabs.PersonalCarData

Assembly: Assembly-CSharp (likely)
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents configuration data for a personal car prefab used by the game's entity/component system. Contains capacity and cost values and implements custom serialization via ISerializable. Note: although there is a m_Probability field present, it is not written/read by the Serialize/Deserialize implementations in the provided code (likely used at runtime but not persisted by this serializer).


Fields

  • public int m_PassengerCapacity
    Number of passengers the car can carry. This value is written during Serialize and read during Deserialize.

  • public int m_BaggageCapacity
    Amount of baggage capacity for the car. This value is written during Serialize and read during Deserialize.

  • public int m_CostToDrive
    Cost metric associated with driving the car (game-specific). This value is written during Serialize and read during Deserialize.

  • public int m_Probability
    Probability value (likely for random selection or spawning). NOTE: This field is present on the struct but is not serialized/deserialized by the current Serialize/Deserialize methods.

Properties

  • None — this type exposes public fields and does not declare any C# properties.

Constructors

  • public PersonalCarData()
    Implicit default constructor (compiler-provided). Fields are plain ints and default to 0 if not initialized.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the values of m_PassengerCapacity, m_BaggageCapacity, and m_CostToDrive to the provided writer, in that order. m_Probability is not written.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads values (in the same order) into m_PassengerCapacity, m_BaggageCapacity, and m_CostToDrive from the provided reader. m_Probability is not read.

Usage Example

// Example: creating a PersonalCarData instance and serializing it via a custom IWriter.
// (Assumes you have an implementation of IWriter/IReader available in your modding environment.)

var carData = new PersonalCarData
{
    m_PassengerCapacity = 4,
    m_BaggageCapacity  = 2,
    m_CostToDrive      = 10,
    m_Probability      = 75 // Note: this field will not be serialized by the current implementation
};

// Serialize
carData.Serialize(myWriter);

// Later, deserialize
var loaded = new PersonalCarData();
loaded.Deserialize(myReader);
// loaded.m_PassengerCapacity, loaded.m_BaggageCapacity, loaded.m_CostToDrive are restored.

{{ Additional notes: - This struct implements IComponentData, so it can be used as a component in Unity's ECS (Entities) world. - It also implements IQueryTypeParameter which may be used for specific query APIs in the game's modding framework. - If you need m_Probability persisted, update Serialize/Deserialize to include that field (and maintain consistent ordering). }}