Skip to content

Game.Prefabs.MaintenanceVehicleData

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: System.ValueType
Implements: IComponentData, IQueryTypeParameter, ISerializable

Summary:
MaintenanceVehicleData is an ECS component struct that represents configuration data for a maintenance vehicle prefab. It stores the vehicle's maintenance type, how much maintenance it can carry (capacity), and the rate at which it performs maintenance. The struct provides custom binary (de)serialization via the ISerializable pattern used by the game's serialization framework and can be used directly as component data on entities.


Fields

  • public MaintenanceType m_MaintenanceType
    Holds the maintenance category/type for this vehicle (enum MaintenanceType). Serialized as a single byte.

  • public int m_MaintenanceCapacity
    Integer representing how much maintenance the vehicle can hold (capacity). Serialized as an int.

  • public int m_MaintenanceRate
    Integer representing the rate at which the vehicle provides maintenance (per tick/unit). Serialized as an int.

Properties

  • This type does not declare any C# properties. It exposes public fields and implements component/serialization interfaces.

Constructors

  • public MaintenanceVehicleData(MaintenanceType maintenanceType, int maintenanceCapacity, int maintenanceRate)
    Creates a new MaintenanceVehicleData with the specified maintenance type, capacity, and rate. Assigns the provided values directly to the struct fields.

  • Default parameterless constructor (implicit for structs)
    Leaves fields uninitialized (default values).

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component data to a writer in binary order:
  • m_MaintenanceType is written as a byte (cast from enum).
  • m_MaintenanceCapacity is written as an int.
  • m_MaintenanceRate is written as an int. This method is used by the game's serialization system to persist prefab/component data.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the component data from a reader in the same order they were written:

  • Reads a byte and stores it temporarily for m_MaintenanceType (cast to MaintenanceType at the end).
  • Reads an int into m_MaintenanceCapacity.
  • Reads an int into m_MaintenanceRate.
  • Assigns the read byte (cast) to m_MaintenanceType. Ensure reading order matches the writing order — otherwise data will be corrupted.

Usage Example

// Create and attach the component to an entity (EntityManager example)
var em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity entity = em.CreateEntity(typeof(MaintenanceVehicleData));
var maintenanceData = new MaintenanceVehicleData(MaintenanceType.Road, 150, 5);
em.SetComponentData(entity, maintenanceData);

// Example of (pseudo) serialization usage — writer type depends on the game's serialization API
// var writer = new SomeConcreteWriter(...);
// maintenanceData.Serialize(writer);

// And deserialization:
// MaintenanceVehicleData loadedData = default;
// loadedData.Deserialize(someReader);