Skip to content

Game.Routes.Connected

Assembly:
Assembly-CSharp (game assembly)

Namespace:
Game.Routes

Type:
struct

Base:
IComponentData, IQueryTypeParameter, ISerializable

Summary:
Component used by the game's ECS to represent a connection to another entity (for example a linked route segment/node). It stores a Unity.Entities.Entity reference and implements Colossal's ISerializable contract so the connection is written to and restored from save/state data. As an IComponentData it can be used in EntityManager/Systems and in jobs; IQueryTypeParameter marks it for use in the game's query APIs.


Fields

  • public Unity.Entities.Entity m_Connected
    Holds the entity reference that this component points to. Can be Entity.Null when there is no connection. This value is what gets serialized/deserialized by the ISerializable implementation.

Properties

  • None

Constructors

  • public Connected(Unity.Entities.Entity connected)
    Initializes the component with the provided entity reference and assigns it to m_Connected.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : Colossal.Serialization.Entities.IWriter
    Writes the m_Connected Entity to the writer so the connection is persisted in saves/state transfers.

  • public void Deserialize<TReader>(TReader reader) where TReader : Colossal.Serialization.Entities.IReader
    Reads an Entity value from the reader and stores it into m_Connected during load/restore.

Usage Example

// Create or obtain Entity references
Entity otherEntity = /* some existing entity */;
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;

// Create an entity and attach a Connected component pointing to otherEntity
Entity e = em.CreateEntity();
em.AddComponentData(e, new Game.Routes.Connected(otherEntity));

// Read the connection later
var conn = em.GetComponentData<Game.Routes.Connected>(e);
Entity linked = conn.m_Connected;

// During save/load the Serialize/Deserialize methods are used by the game's serialization system