Skip to content

Game.Areas.ServiceDistrict

Assembly:
Assembly-CSharp

Namespace:
Game.Areas

Type:
struct ServiceDistrict

Base:
IBufferElementData, IEquatable, ISerializable

Summary:
Represents a single entry in a dynamic ECS buffer that references a service district entity. This struct is intended to be used as a buffer element (DynamicBuffer) on an entity to keep track of related district Entities. It is serializable using Colossal.Serialization.Entities and implements equality based on the contained Entity reference. The buffer has an explicit attribute [InternalBufferCapacity(0)] so no elements are stored inline on the entity — all elements are stored externally.


Fields

  • public Unity.Entities.Entity m_District
    Holds the Unity.Entities.Entity reference for the service district. This is the value used for equality and hashing and is written/read during serialization.

Properties

  • (none)
    This type exposes no properties; it exposes a single public field m_District.

Constructors

  • public ServiceDistrict(Unity.Entities.Entity district)
    Creates a new ServiceDistrict wrapping the provided Entity reference.

Methods

  • public bool Equals(ServiceDistrict other)
    Compares this instance to another ServiceDistrict by comparing their m_District fields (Entity equality).

  • public override int GetHashCode()
    Returns the hash code of the contained m_District Entity. Useful when using this struct in hashed collections.

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Serializes the contained Entity by calling writer.Write(m_District). This allows the buffer entries to be saved with the game's serialization pipeline.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Deserializes the contained Entity by calling reader.Read(out m_District). Restores the Entity reference when loading.

Usage Example

// Add a ServiceDistrict entry to a DynamicBuffer<ServiceDistrict> on an entity
using Unity.Entities;
using Game.Areas;

// assume world/em/ents are available and entityWithBuffer has a DynamicBuffer<ServiceDistrict> component
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity districtEntity = /* obtain or create the district entity */;
Entity entityWithBuffer = /* entity that holds the buffer */;

// Get or add the buffer and add a new entry
var buffer = em.GetBuffer<ServiceDistrict>(entityWithBuffer);
buffer.Add(new ServiceDistrict(districtEntity));

Additional notes: - The [InternalBufferCapacity(0)] attribute indicates the buffer stores no inline elements on the entity; expect elements to be stored out-of-line. - Equality and hashing are solely based on the Entity reference; two ServiceDistrict instances wrapping the same Entity are considered equal.