Skip to content

Game.MailTransferRequest

Assembly: Assembly-CSharp
Namespace: Game.Simulation

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents a mail transfer request used by the game's ECS (Entity Component System). Encapsulates the target facility entity, request flags, priority and amount. This struct is intended to be attached/used as a component in entity queries and supports custom binary serialization via the ISerializable pattern used in the game.


Fields

  • public Entity m_Facility
    Identifies the target facility (entity) associated with this mail transfer request.

  • public MailTransferRequestFlags m_Flags
    Flags describing the request (stored/serialized as a ushort). Use the MailTransferRequestFlags enum to interpret bits/values.

  • public float m_Priority
    Priority value for the request. Higher values typically indicate higher urgency.

  • public int m_Amount
    Amount of mail requested to transfer.

Properties

  • This struct defines no properties.

Constructors

  • public MailTransferRequest(Entity facility, MailTransferRequestFlags flags, float priority, int amount)
    Creates a new MailTransferRequest with the specified target facility, flags, priority and amount.

Parameters: - facility — target Entity for the request. - flags — MailTransferRequestFlags value specifying request options/state. - priority — request priority (float). - amount — requested quantity (int).

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Serializes the struct in the following order:
  • Entity (m_Facility)
  • Flags as ushort (cast from MailTransferRequestFlags)
  • Priority (float)
  • Amount (int)

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Deserializes the struct in the same order as Serialize. The implementation reads the Entity, reads a ushort value (then converts it to MailTransferRequestFlags), and reads the priority and amount into the corresponding fields.

Notes: - Flags are serialized as a ushort; deserialization casts that ushort back to MailTransferRequestFlags. - The struct implements IComponentData and IQueryTypeParameter, so it is intended for use with Unity.Entities queries and EntityManager operations.

Usage Example

// Constructing and adding as a component to an entity
var request = new MailTransferRequest(facilityEntity, MailTransferRequestFlags.None, 1.0f, 100);
entityManager.AddComponentData(targetEntity, request);

// Manual serialization using a writer (pseudo-code for illustrative writer API)
request.Serialize(myWriter);

// Manual deserialization using a reader
MailTransferRequest readRequest = default;
readRequest.Deserialize(myReader);