Skip to content

Game.Simulation.TaxiRequest

Assembly: Game
Namespace: Game.Simulation

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents a taxi request originating from an entity (the seeker). Contains references to up to two district entities, a priority value, and a taxi request type. Implements serialization/deserialization with version checks to maintain backward compatibility with older save formats (some fields are only present when certain game-version flags are available). Useful as a component in ECS-based systems to track taxi service requests.


Fields

  • public Entity m_Seeker
    Holds the Entity ID of the seeker (the entity that requested the taxi). This is always serialized/deserialized.

  • public Entity m_District1
    Holds the primary district Entity associated with the request. Serialized/deserialized only when the reader/writer version supports taxi service districts (checked against Version.taxiServiceDistricts).

  • public Entity m_District2
    Holds the secondary district Entity associated with the request (if any). Also present/serialized only when Version.taxiServiceDistricts is supported.

  • public int m_Priority
    Integer priority for the taxi request. Always serialized/deserialized. Higher/lower values indicate dispatch priority according to game logic.

  • public TaxiRequestType m_Type
    Enum value indicating the type of taxi request. Serialized as a single byte. This field is only read from data when the reader's version is >= Version.taxiDispatchCenter (i.e., added in a later version of the game).

Properties

  • This struct does not expose any C# properties (only public fields).
    You can access and modify the fields directly as it is a plain data component suitable for ECS usage.

Constructors

  • public TaxiRequest(Entity seeker, Entity district1, Entity district2, TaxiRequestType type, int priority)
    Creates a new TaxiRequest with the provided seeker entity, district entities, request type, and priority. Use this to initialize the component before adding it to an entity or queueing it for processing.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component data to the provided writer. The method writes:
  • seeker (Entity)
  • district1 (Entity)
  • district2 (Entity)
  • priority (int)
  • type (written as a single byte) Note: the implementation writes all fields in the current order; compatibility with readers depends on reader-side version handling.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the component data from the provided reader. The method uses version checks:

  • Always reads seeker.
  • Reads district1 and district2 only if reader.context.version >= Version.taxiServiceDistricts.
  • Always reads priority.
  • Reads the type (as a byte and casts to TaxiRequestType) only if reader.context.version >= Version.taxiDispatchCenter. This ensures backward compatibility with older save/game versions that did not include districts or request type.

Usage Example

// Create a new taxi request component for an ECS entity
Entity seeker = mySeekerEntity;
Entity districtA = primaryDistrictEntity;
Entity districtB = secondaryDistrictEntity;
TaxiRequestType requestType = TaxiRequestType.Standard;
int priority = 5;

var request = new TaxiRequest(seeker, districtA, districtB, requestType, priority);

// Add to an entity or a queue depending on your ECS usage:
// entityManager.AddComponentData(targetEntity, request);

// Example (pseudo) serialization usage:
SomeWriter writer = GetWriter();
request.Serialize(writer);

// On load/deserialization:
SomeReader reader = GetReader();
TaxiRequest loadedRequest = default;
loadedRequest.Deserialize(reader);
// now loadedRequest contains fields populated according to reader.version

Notes: - TaxiRequestType is an enum defined elsewhere; treat its values according to game semantics (e.g., Standard, VIP, etc.). - Version constants used in Deserialize (Version.taxiServiceDistricts, Version.taxiDispatchCenter) control conditional reading and reflect when fields were introduced in game save format. Ensure reader/writer context provides these version values for correct behavior.