Skip to content

Game.MaintenanceDepot

Assembly: Game (Game.dll) Namespace: Game.Buildings

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents component data for a maintenance depot building. Holds a reference to a "target request" entity (used to track a service/repair request or similar request-entity) and a set of flags describing depot state. Implements custom binary serialization/deserialization with a version check to maintain backward compatibility with older save formats.


Fields

  • public Unity.Entities.Entity m_TargetRequest
    This Entity stores a reference to a service/request entity associated with the depot (for example, a request for maintenance or service). Note: when deserializing, this field is only read if the save/version is at least Version.reverseServiceRequests2.

  • public MaintenanceDepotFlags m_Flags
    Byte-packed flags describing the depot state. Serialized as a single byte. MaintenanceDepotFlags is an enum (not defined in this file) representing the various boolean/state flags for the depot.

Properties

  • None.
    This struct exposes only public fields and does not define C# properties.

Constructors

  • public MaintenanceDepot() (default struct constructor)
    No explicit constructors are defined in the source; the C# default struct constructor applies.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component's data to the provided writer. Serialization order:
  • Writes m_TargetRequest (Entity).
  • Writes m_Flags cast to byte. This produces a compact representation (flags stored as one byte).

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the component's data from the provided reader. Deserialization is version-aware:

  • If reader.context.version >= Version.reverseServiceRequests2, the reader will read an Entity into m_TargetRequest. Otherwise m_TargetRequest is left as whatever default value the struct has (older saves didn't include this field).
  • Always reads a byte and casts it to MaintenanceDepotFlags to populate m_Flags. This preserves backwards compatibility with older saved data formats.

Usage Example

using Unity.Entities;
using Colossal.Serialization.Entities;

// Example: constructing and serializing a MaintenanceDepot instance
var depot = new Game.Buildings.MaintenanceDepot
{
    m_TargetRequest = new Entity { Index = 0, Version = 1 }, // example Entity
    m_Flags = MaintenanceDepotFlags.Active | MaintenanceDepotFlags.SomeOtherFlag
};

// Pseudo-code: using a writer to serialize
IWriter writer = /* obtain writer from serialization system */;
depot.Serialize(writer);

// Pseudo-code: using a reader to deserialize
IReader reader = /* obtain reader from serialization system */;
var readDepot = new Game.Buildings.MaintenanceDepot();
readDepot.Deserialize(reader);

// When used as an ECS component, this struct would be attached to an entity
// and systems would read/modify m_TargetRequest and m_Flags as needed.

Additional notes: - The Version.reverseServiceRequests2 constant controls whether the target request Entity is present in the serialized data. This is important for modders interacting with saved game compatibility. - MaintenanceDepotFlags is stored as a single byte in the stream — ensure any changes to that enum preserve the byte layout or provide migration logic.