Skip to content

Game.Prefabs.ZoneData

Assembly:
Likely the main game assembly (e.g. Assembly-CSharp or Game). Check your project's compiled assemblies if you need the exact assembly name.
{{ ZoneData is a lightweight struct used by the game's ECS (Unity.Entities) to describe zone-related metadata for prefabs. It implements IComponentData so it can be attached to Entities, IQueryTypeParameter for query usage, and a custom ISerializable for binary serialization used by the game. }}

Namespace: Game.Prefabs

Type:
struct

Base:
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter, Colossal.Serialization.Entities.ISerializable
{{ This is a value type (struct) intended to be stored on Entities in the game's DOTS/ECS systems. It carries a few small enum/primitive fields describing the zone. }}


Fields

  • public Game.Zones.ZoneType m_ZoneType
    {{ The primary zone type (e.g., Residential, Commercial, Industrial, etc.). Stored as the ZoneType enum from Game.Zones. }}

  • public Game.Zones.AreaType m_AreaType
    {{ The area subtype as an AreaType enum. Note: serialized as a single byte. }}

  • public Game.Zones.ZoneFlags m_ZoneFlags
    {{ Bitflags describing additional zone properties (e.g., Office). Serialized as a single byte. Use bitwise checks to test flags. }}

  • public ushort m_MinOddHeight
    {{ Minimum allowed height for odd-numbered lots/plots (ushort). Exact semantics depend on game logic that consumes these values. }}

  • public ushort m_MinEvenHeight
    {{ Minimum allowed height for even-numbered lots/plots (ushort). As above, used by zone layout/placement logic. }}

  • public ushort m_MaxHeight
    {{ Maximum allowed height (ushort). Used to clamp building heights or zoning rules. }}

Properties

  • None declared.
    {{ ZoneData exposes its data via public fields rather than properties. The struct does not define any C# properties. }}

Constructors

  • Implicit default constructor (parameterless)
    {{ As a struct, ZoneData has the default value-type constructor provided by C#. No explicit constructors are declared in the source. Initialize fields inline or via object initializer when creating instances. }}

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    {{ Serializes the struct to the provided writer. Implementation details:
  • Writes m_ZoneType (as the ZoneType value).
  • Writes m_AreaType cast to a byte.
  • Writes m_ZoneFlags cast to a byte. The order and types matter for deserialization compatibility. Note that height fields (m_MinOddHeight, m_MinEvenHeight, m_MaxHeight) are not written here; likely handled elsewhere or assumed default/derived. }}

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    {{ Deserializes fields from the provided reader. Implementation details:

  • Reads ZoneType into m_ZoneType.
  • Reads a byte into a temporary and assigns to m_AreaType (casts from byte).
  • Reads a byte into a temporary and assigns to m_ZoneFlags (casts from byte). Again, min/max heights are not read here. Ensure reader's read order matches Serialize's write order. }}

  • public bool IsOffice()
    {{ Returns true if the ZoneFlags has the Office flag set:

  • Implementation uses bitwise AND: (m_ZoneFlags & ZoneFlags.Office) != 0. Useful shorthand when code needs to quickly test whether this zone represents office zoning. }}

Usage Example

// Create and initialize a ZoneData instance
var zone = new Game.Prefabs.ZoneData {
    m_ZoneType = Game.Zones.ZoneType.Commercial,
    m_AreaType = Game.Zones.AreaType.Urban,
    m_ZoneFlags = Game.Zones.ZoneFlags.Office,
    m_MinOddHeight = 1,
    m_MinEvenHeight = 1,
    m_MaxHeight = 50
};

// Attach to an entity (EntityManager usage example)
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity e = entityManager.CreateEntity();
entityManager.AddComponentData(e, zone);

// Check for office flag
if (zone.IsOffice()) {
    // Handle office-specific logic
}

{{ Notes: - The struct is optimized for compact serialization: AreaType and ZoneFlags are written/read as bytes. - Height fields are present in the struct but not serialized in the provided Serialize/Deserialize methods — verify whether height values are stored elsewhere or intentionally omitted. - Because ZoneData implements IComponentData, use it with Unity's ECS APIs (EntityManager, Systems, queries). As it also implements IQueryTypeParameter, it can be used in query type parameter contexts for optimized queries. - When modifying or extending serialization, preserve the write/read order to maintain save/load compatibility with existing game data. }}