Skip to content

Game.Areas.BorderDistrict

Assembly: Assembly-CSharp (inferred)
Namespace: Game.Areas

Type: struct

Base: System.ValueType

Summary:
BorderDistrict is a lightweight ECS component that pairs two Entity references representing a border between districts (left and right). It implements IComponentData so it can be used as a component in Unity's ECS, IQueryTypeParameter for query usage, and ISerializable to support custom serialization for save/load through Colossal.Serialization.Entities.


Fields

  • public Entity m_Left
    Represents the left-side entity of the border pair. Public field holding an Entity reference.

  • public Entity m_Right
    Represents the right-side entity of the border pair. Public field holding an Entity reference.

Properties

  • This type defines no properties. It exposes its data via public fields.

Constructors

  • public BorderDistrict(Entity left, Entity right)
    Creates a new BorderDistrict with the provided left and right Entity references. Sets m_Left = left and m_Right = right.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component data to the provided writer (Colossal.Serialization). The implementation writes m_Left first, then m_Right.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads component data from the provided reader. The implementation reads into m_Left then m_Right (reads by reference).

Usage Example

// Create a BorderDistrict instance and add it to an entity via the EntityManager
Entity leftEntity = /* obtain or create entity */;
Entity rightEntity = /* obtain or create entity */;
var border = new BorderDistrict(leftEntity, rightEntity);

// Using Unity.Entities.EntityManager
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity targetEntity = /* some entity to attach this component to */;

// Add as a component
entityManager.AddComponentData(targetEntity, border);

// Later, retrieve and use
BorderDistrict loaded = entityManager.GetComponentData<BorderDistrict>(targetEntity);
Entity left = loaded.m_Left;
Entity right = loaded.m_Right;

{{ Notes: - This struct is blittable and intended for use as an ECS component. - The Serialize/Deserialize methods rely on Colossal.Serialization.Entities writer/reader types; they must be used in the mod's save/load pipeline. - Because fields are public, modify with care when operating across jobs or threads. }}