Skip to content

Game.Prefabs.PoliceStationData

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter, ICombineData, ISerializable

Summary:
Represents configuration data for a police station prefab. Holds numeric capacities for patrol cars, police helicopters and jail beds along with a purpose mask (PolicePurpose) that flags what roles the station fulfills. This struct is used as an ECS component and supports prefab combination and custom serialization for save/load and prefab merging workflows.


Fields

  • public int m_PatrolCarCapacity
    Holds the number of patrol cars the station can accommodate. Used by AI and game systems to determine available ground patrol resources.

  • public int m_PoliceHelicopterCapacity
    Holds the number of police helicopters the station can accommodate. Used by AI and game systems to determine available aerial patrol resources.

  • public int m_JailCapacity
    Holds the number of jail cells / prisoner capacity the station provides. Used by crime/prison-related systems.

  • public PolicePurpose m_PurposeMask
    Bitmask enum describing the roles/purposes this station covers (e.g., patrol, traffic, special tasks). The value is serialized as a single byte in this implementation.

Properties

  • (none)
    This struct exposes public fields and implements behavior through interfaces; it has no explicit C# properties.

Constructors

  • public PoliceStationData()
    Default value-type constructor. As a struct, fields default to 0 (capacities = 0) and m_PurposeMask defaults to the enum's 0 value unless explicitly initialized.

Methods

  • public void Combine(PoliceStationData otherData)
    Merges another PoliceStationData into this instance. Numeric capacities are summed and the purpose mask is combined with a bitwise OR. This is used when aggregating data from multiple prefabs or overrides (ICombineData pattern).

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the struct fields to a generic writer in a fixed order:

  • m_PatrolCarCapacity (int)
  • m_PoliceHelicopterCapacity (int)
  • m_JailCapacity (int)
  • m_PurposeMask cast to byte This deterministic ordering must match the Deserialize implementation. The purpose mask is explicitly stored as a single byte.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads data back from a generic reader in the same order used by Serialize. The method reads ints into the three capacity fields and reads a byte which is cast back to PolicePurpose for m_PurposeMask. Note that Deserialize uses out/ref reads to assign into the struct fields.

Usage Example

// Create and combine two data instances
var baseData = new PoliceStationData {
    m_PatrolCarCapacity = 2,
    m_PoliceHelicopterCapacity = 1,
    m_JailCapacity = 12,
    m_PurposeMask = PolicePurpose.Patrol | PolicePurpose.Arrest
};

var additionalData = new PoliceStationData {
    m_PatrolCarCapacity = 1,
    m_PoliceHelicopterCapacity = 0,
    m_JailCapacity = 6,
    m_PurposeMask = PolicePurpose.Traffic
};

baseData.Combine(additionalData);
// baseData now has summed capacities and combined purpose mask

// Add to an entity via EntityManager (ECS)
EntityManager em = /* obtain EntityManager */;
Entity policeEntity = /* create or get entity */;
em.AddComponentData(policeEntity, baseData);

// Serialization example (pseudocode — depends on game's IWriter implementation)
using (var writer = new SomeWriter(stream)) {
    baseData.Serialize(writer);
}

// Deserialization example
var loaded = new PoliceStationData();
using (var reader = new SomeReader(stream)) {
    loaded.Deserialize(reader);
}

Additional notes: - The struct is intended for use as a prefab/component data container; modifying fields at runtime should respect game systems that track capacity and service assignment. - The serialized ordering and the single-byte cast for the purpose mask are important compatibility details when creating custom writers/readers or migrating saved data.