Skip to content

Game.FireEngine

Assembly: Assembly-CSharp
Namespace: Game.Vehicles

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents the runtime component data for a fire engine vehicle. This struct stores the current target request, operational state flags, bookkeeping counters and timing for path traversal, and parameters used for extinguishing fires and efficiency. It implements ISerializable so instances are persisted by the game's serialization system, and implements IComponentData so it can be attached to ECS entities.


Fields

  • public Entity m_TargetRequest
    Holds the Entity reference to the current service/target request for the fire engine (or Entity.Null when none). During deserialization this field is conditionally read only for saves with version >= Version.reverseServiceRequests2.

  • public FireEngineFlags m_State
    Flags enum representing the current state of the fire engine (idle, responding, extinguishing, returning, etc.). In serialization the enum is written as a uint and during deserialization the stored uint is cast back to FireEngineFlags.

  • public int m_RequestCount
    Counter for the number of outstanding or processed requests associated with this vehicle. Written and read as an int in serialization.

  • public float m_PathElementTime
    Timing/bookkeeping float used to track progress along a path element (time spent on current path segment). Serialized as a float.

  • public float m_ExtinguishingAmount
    Amount parameter used by the extinguishing logic. This value is only deserialized when the save version is >= Version.aircraftNavigation (older saves will not have this field).

  • public float m_Efficiency
    Efficiency multiplier used by extinguishing or other logic. This value is deserialized only for save versions >= Version.disasterResponse. For older saves the code sets m_Efficiency = 1f as a compatibility default.

Properties

  • This type defines no managed C# properties; only public fields (component-style data).

Constructors

  • public FireEngine(FireEngineFlags state, int requestCount, float extinguishingAmount, float efficiency)
    Initializes a new FireEngine instance:
  • m_TargetRequest is set to Entity.Null.
  • m_State is set to the provided state.
  • m_RequestCount is set to requestCount.
  • m_PathElementTime is initialized to 0f.
  • m_ExtinguishingAmount is set to extinguishingAmount.
  • m_Efficiency is set to efficiency.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Serializes the component fields in this order:
  • m_TargetRequest (Entity)
  • m_State (written as a uint)
  • m_RequestCount (int)
  • m_PathElementTime (float)
  • m_ExtinguishingAmount (float)
  • m_Efficiency (float)

Note: Serialize unconditionally writes all fields in the listed order. The corresponding Deserialize method performs version-gated reads to maintain compatibility with older save versions.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads fields back from a saved stream with version checks for backward compatibility:
  • If reader.context.version >= Version.reverseServiceRequests2, reads m_TargetRequest.
  • Always reads a uint for the state (stored into a local uint then cast to FireEngineFlags and stored into m_State at the end).
  • Reads m_RequestCount and m_PathElementTime.
  • If reader.context.version >= Version.aircraftNavigation, reads m_ExtinguishingAmount.
  • If reader.context.version >= Version.disasterResponse, reads m_Efficiency; otherwise sets m_Efficiency = 1f (compatibility default).
  • Finally assigns m_State = (FireEngineFlags)value.

Compatibility notes: - Because Serialize writes all fields but Deserialize conditionally reads some fields based on save version, ensure any manual serialization or custom writers/readers you implement respect the same ordering and versioning scheme to avoid data corruption. - The state is stored as a raw uint in the save; custom FireEngineFlags values should remain compatible with saved numeric values.

Usage Example

// Create a new FireEngine component for an ECS entity
var fireEngine = new FireEngine(FireEngineFlags.Idle, requestCount: 0, extinguishingAmount: 0f, efficiency: 1f);
fireEngine.m_TargetRequest = Entity.Null;
fireEngine.m_PathElementTime = 0f;

// When the game serializes ECS components, the Serialize<TWriter> method will be called.
// When loading, Deserialize<TReader> will be called and will handle older save versions
// by conditionally reading fields and applying defaults (e.g. m_Efficiency = 1f for very old saves).

Additional notes for modders: - FireEngine is an ECS component; to modify behavior you typically write systems that query entities with this component (IQueryTypeParameter) and update fields directly. - If adding new fields to this struct in a modded environment, take care to maintain backward-compatible serialization: add version checks in Deserialize and write new fields at the end in Serialize, and use a new version constant so older saves won't attempt to read non-existent data.