Skip to content

Game.Simulation.ServiceDispatch

Assembly:
Assembly-CSharp (likely) — the struct is defined in the game's runtime assemblies used by mods.
Namespace:
Game.Simulation

Type:
struct

Base:
Implements Unity.Entities.IBufferElementData, Colossal.Serialization.Entities.ISerializable

Summary:
A lightweight buffer element that carries an Entity reference representing a service request. Marked with [InternalBufferCapacity(0)] to indicate no statically allocated inline capacity for the DynamicBuffer. Implements ISerializable so the Entity reference can be written/read by the game's custom serialization system (writers/readers). Typical use is to attach a DynamicBuffer to an entity to queue or dispatch service requests between systems in the ECS.


Fields

  • public Unity.Entities.Entity m_Request
    Holds the Entity that represents the service request or target. This is the payload carried by the buffer element.

Properties

  • None. This struct exposes its data via the public field m_Request.

Constructors

  • public ServiceDispatch(Unity.Entities.Entity request)
    Creates a ServiceDispatch with the provided Entity assigned to m_Request.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes m_Request to the provided writer. Used by the game's serialization pipeline to persist the Entity reference.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads an Entity out of the provided reader and stores it in m_Request. Used when loading or deserializing saved state.

Usage Example

// Add or get a DynamicBuffer<ServiceDispatch> on some manager entity and enqueue a request:
Entity requestEntity = /* an Entity that requests a service */;
Entity managerEntity = /* an entity which holds the buffer */;

var buffer = entityManager.GetBuffer<ServiceDispatch>(managerEntity);
buffer.Add(new ServiceDispatch(requestEntity));

// In a system, iterate over buffers to process requests:
Entities.ForEach((ref DynamicBuffer<ServiceDispatch> dispatches) =>
{
    foreach (var d in dispatches)
    {
        Entity req = d.m_Request;
        // handle the request Entity...
    }
});

{{ Notes: - The [InternalBufferCapacity(0)] attribute means the DynamicBuffer will not reserve inline storage on the entity; elements are stored separately (heap) which can be more memory-efficient for variable-length buffers. - Serialization relies on the game-specific IWriter/IReader implementations; the Entity value is written/read through those interfaces so entity remapping handled by the save/load system is respected. - Because the struct uses a public field (m_Request), it is blittable-friendly for ECS use. }}