Skip to content

Game.Simulation.GoodsDeliveryRequest

Assembly: Game (inferred)
Namespace: Game.Simulation

Type: struct (value type)
Base: System.ValueType
Implements: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents a request for delivering goods to a target entity in the game's economy. This value-type component carries the destination entity, delivery flags, the resource type being requested, and the requested amount. It provides custom binary serialization/deserialization so it can be written to/read from the game's save/stream format using the Colossal.Serialization writers/readers. The serialization order must be preserved (target, flags, resource index, amount).


Fields

  • public Unity.Entities.Entity m_Target
    Entity that is the target (destination) of the goods delivery request.

  • public GoodsDeliveryFlags m_Flags
    Flags that modify the behavior of the delivery request (enum defined in the game's economy types). Note: serialized as a ushort.

  • public Resource m_Resource
    Resource identifier describing which good/resource is requested. The struct uses EconomyUtils.GetResourceIndex / GetResource to map between the Resource instance and an integer index for serialization.

  • public int m_Amount
    Requested amount (integer) of the specified resource.

Properties

  • (none)
    This struct does not declare any C# properties; it exposes plain public fields.

Constructors

  • (implicit) public GoodsDeliveryRequest()
    Default parameterless constructor (struct default). No explicit constructors are defined in source.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component to a writer in this exact sequence:
  • m_Target (Entity) via writer.Write(Entity)
  • m_Flags cast to ushort via writer.Write((ushort)m_Flags)
  • resource index via EconomyUtils.GetResourceIndex(m_Resource) and writer.Write(int)
  • m_Amount via writer.Write(int)

Important: callers must preserve the sequence and types to remain compatible with the corresponding Deserialize implementation.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the component from a reader in the same sequence used by Serialize:
  • reader.Read(out Entity m_Target)
  • reader.Read(out ushort value) -> cast to GoodsDeliveryFlags
  • reader.Read(out int resourceIndex) -> m_Resource = EconomyUtils.GetResource(resourceIndex)
  • reader.Read(out int m_Amount)

Note: resource mapping is performed using EconomyUtils.GetResource(index).

Usage Example

// Creating and attaching a GoodsDeliveryRequest as a component to an entity
var request = new GoodsDeliveryRequest {
    m_Target = destinationEntity,
    m_Flags  = GoodsDeliveryFlags.None,
    m_Resource = EconomyUtils.GetResource(someResourceIndex),
    m_Amount = 250
};

entityManager.AddComponentData(requestEntity, request);

// Example of how the struct is serialized (conceptual; actual writer implementation provided by game)
writer.Write(request.m_Target);
writer.Write((ushort)request.m_Flags);
writer.Write(EconomyUtils.GetResourceIndex(request.m_Resource));
writer.Write(request.m_Amount);

// Corresponding deserialization will read the fields back in the same order.

Additional notes for modders: - Because this is an IComponentData, you can add, remove, and query this component using standard DOTS APIs (EntityManager, SystemBase Entities.ForEach, EntityQuery, etc.). - Keep the serialization order and types identical if you interoperate with existing save/stream readers or other mods. - EconomyUtils.GetResourceIndex/GetResource are used to convert between the Resource representation and an integer index for compact serialization; avoid storing raw indices in place of Resource without using these helpers.