Skip to content

Game.FireStation

Assembly: Assembly-CSharp
Namespace: Game.Buildings

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary: Represents the component data for a fire station building in the ECS (Unity.Entities) world. Stores a reference to an Entity used for a target request (e.g., a service request entity) and a compact flags field describing the station's state. Implements ISerializable to participate in the game's save/load system and handles version-conditional deserialization for compatibility with save versions before/after Version.reverseServiceRequests2.


Fields

  • public Entity m_TargetRequest Holds an Entity reference that represents a service/target request associated with this fire station. Note: this field is conditionally read during deserialization only when the save version is >= Version.reverseServiceRequests2; older saves may not contain this value.

  • public FireStationFlags m_Flags A byte-backed flags enumeration (FireStationFlags) describing the station's state (stored/read as a byte during serialization). Use this to check or set compact status bits for the fire station.

Properties

  • None. This type exposes public fields and therefore does not provide C# properties.

Constructors

  • public FireStation() Default value-type constructor generated for the struct. Initialize fields explicitly when creating an instance to ensure expected defaults (e.g., Entity.Null for m_TargetRequest).

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter Writes the component data to the provided writer for saving. Implementation details:
  • Writes m_TargetRequest (Entity).
  • Writes m_Flags cast to a single byte. Use when implementing custom save hooks, or when the ECS serialization pipeline invokes ISerializable.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader Reads the component data from the provided reader when loading. Implementation details:

  • If reader.context.version >= Version.reverseServiceRequests2, reads m_TargetRequest from the stream.
  • Always reads a single byte and casts it to FireStationFlags to populate m_Flags.
  • This method preserves compatibility with older save versions that predate the addition of the target-request field.

Usage Example

// Adding a FireStation component to an entity
var station = new FireStation
{
    m_TargetRequest = Entity.Null, // or some request entity
    m_Flags = FireStationFlags.None // example enum value
};
entityManager.AddComponentData(stationEntity, station);

// Example of serializing is handled by the game's serialization pipeline via ISerializable.
// When implementing custom save code that uses the provided writer:
// writer.Write(station.m_TargetRequest);
// writer.Write((byte)station.m_Flags);

// Deserialization is similarly handled; the component's Deserialize<TReader> checks save version
// before reading the target request to maintain backward compatibility.