Game.TaxiData
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: struct
Base: System.ValueType
Summary:
TaxiData is an ECS component (IComponentData) that stores simple configuration for taxi prefabs: passenger capacity and a maintenance range. It also implements ISerializable to allow reading/writing its two fields to the game's custom binary serializers. The struct is used as a lightweight data container in entity queries and serialization/deserialization flows.
Fields
-
public int m_PassengerCapacity
Holds the number of passengers the taxi can carry. Written/read as a 32-bit integer by the Serialize/Deserialize methods. This value is set via the constructor or by deserialization and is typically used by systems that allocate or evaluate taxi capacity. -
public float m_MaintenanceRange
Holds the maintenance/service range for the taxi as a float. Written/read as a 32-bit float by the Serialize/Deserialize methods. Represents the distance (in game units) used by systems that determine when taxis require maintenance or servicing.
Properties
- This type defines no properties. It exposes two public fields directly.
Constructors
public TaxiData(int passengerCapacity, float maintenanceRange)
Creates a new TaxiData instance and initializes m_PassengerCapacity and m_MaintenanceRange. Parameters:- passengerCapacity: initial passenger capacity (int).
- maintenanceRange: initial maintenance range (float).
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component's data to a writer. The method writes m_PassengerCapacity first (int), then m_MaintenanceRange (float). The order and types must match the expected format used by corresponding deserializers. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads the component's data from a reader into the struct's fields. The method reads into m_PassengerCapacity (int) then into m_MaintenanceRange (float). The reading order must match the writing order used in Serialize.
Usage Example
// Constructing a TaxiData instance
var taxi = new TaxiData(4, 50.0f); // 4 passengers, 50 units maintenance range
// Example pseudocode for serialization (actual writer type depends on the environment)
void SaveTaxi<TWriter>(TWriter writer, TaxiData taxi) where TWriter : IWriter
{
taxi.Serialize(writer);
}
// Example pseudocode for deserialization
TaxiData LoadTaxi<TReader>(TReader reader) where TReader : IReader
{
TaxiData taxi = default;
taxi.Deserialize(reader);
return taxi;
}