Skip to content

Game.Simulation.GarbageTransferRequest

Assembly:
Likely the game's main managed assembly (e.g. Assembly-CSharp). This type is defined in the game's "Game" codebase under the Simulation subsystem.

Namespace:
Game.Simulation

Type:
struct

Base:
System.ValueType, IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents a garbage transfer request in the ECS simulation. This value-type component holds the destination facility Entity, request flags, priority and amount. It implements ISerializable so it can be written to and read from the game's save/serialization streams. Typical use is as an ECS component/query parameter for scheduling or routing garbage transfers between facilities.


Fields

  • public Entity m_Facility
    Entity representing the target facility (destination or source depending on context). Uses Unity.Entities.Entity to reference another ECS entity.

  • public GarbageTransferRequestFlags m_Flags
    Flags describing request options/behavior. Serialized as a 16-bit unsigned integer (ushort) when written.

  • public float m_Priority
    Floating-point priority value for the transfer request. Higher values typically indicate higher urgency.

  • public int m_Amount
    Integer amount of garbage to transfer (units defined by the simulation logic).

Properties

  • This type does not declare any C# properties. It exposes public fields.

Constructors

  • public GarbageTransferRequest(Entity facility, GarbageTransferRequestFlags flags, float priority, int amount)
    Creates a new GarbageTransferRequest with the supplied facility Entity, flags, priority and amount.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Serializes the struct fields to the provided writer. Order and encoding used:
  • Writes m_Facility as an Entity.
  • Writes m_Flags cast to ushort.
  • Writes m_Priority as a float.
  • Writes m_Amount as an int. Note: flags are narrowed to 16 bits for persistence; ensure any custom flags fit in ushort.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Deserializes fields from the provided reader in the same order as Serialize:

  • Reads an Entity into m_Facility.
  • Reads a ushort and assigns it to m_Flags (cast).
  • Reads a float into m_Priority.
  • Reads an int into m_Amount. The method reads directly into field storage (uses ref locals) and reconstructs the flags from the ushort value.

Usage Example

// Create a request
var req = new GarbageTransferRequest(facilityEntity, GarbageTransferRequestFlags.None, 1.0f, 100);

// Serialize (pseudo-code; writer must implement IWriter)
req.Serialize(writer);

// Deserialize (pseudo-code; reader must implement IReader)
var req2 = new GarbageTransferRequest();
req2.Deserialize(reader);

Notes and tips: - As an IComponentData, this struct is intended to be used with Unity's ECS (entities, systems, and queries) within the game's simulation. - Because serialization stores flags as a ushort, avoid adding flag values that exceed 16 bits or adjust serialization accordingly for backward compatibility. - The type also implements IQueryTypeParameter — it may be used to parameterize ECS queries or entity chunk operations in the game's systems.