Skip to content

Game.Buildings.CargoTransportStation

Assembly: Assembly-CSharp
Namespace: Game.Buildings

Type: struct

Base: System.ValueType, IComponentData, IQueryTypeParameter, ISerializable

Summary:
CargoTransportStation is an ECS component that stores a single floating value representing the "work amount" for a cargo transport station building. It implements ISerializable so the value is read/written during the game's save/load or network serialization processes, and it implements IComponentData so it can be attached to Entities and used in Jobs/Systems.


Fields

  • public System.Single m_WorkAmount
    Holds the current work amount for the cargo transport station. Default value is 0.0f for the default struct instance. This field is serialized/deserialized by the component's ISerializable implementation.

Properties

  • This type has no properties.

Constructors

  • public CargoTransportStation()
    Implicit parameterless/default constructor for the struct. Initializes m_WorkAmount to 0. Use object initializer syntax to set a non-zero value when creating an instance.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the m_WorkAmount value to the provided writer. The writer is expected to implement the game's IWriter interface.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the m_WorkAmount value from the provided reader into the field. The reader is expected to implement the game's IReader interface.

Usage Example

// Create and add the component to an entity (EntityManager usage example)
var station = new CargoTransportStation { m_WorkAmount = 125.0f };
entityManager.AddComponentData(entity, station);

// Reading/writing during custom serialization code (pseudo-usage; actual IWriter/IReader comes from game APIs)
void SaveComponent<TWriter>(TWriter writer, CargoTransportStation comp) where TWriter : IWriter
{
    comp.Serialize(writer); // writer.Write(comp.m_WorkAmount) is called internally
}

void LoadComponent<TReader>(TReader reader, out CargoTransportStation comp) where TReader : IReader
{
    comp = new CargoTransportStation();
    comp.Deserialize(reader); // reader.Read(out comp.m_WorkAmount) is called internally
}

{{ This struct is lightweight and intended to be used as a plain data container in ECS systems. When modding, modify m_WorkAmount via EntityManager or in systems rather than storing state in MonoBehaviours. Because it implements ISerializable, any changes to the serialization format (e.g., adding new fields) require careful versioning to maintain save compatibility. }}