Game.Simulation.MaintenanceRequest
Assembly: Game
Namespace: Game.Simulation
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
Represents a maintenance request in the simulation as an ECS component. Holds a target Entity to perform maintenance on, a priority value used by dispatching logic, and a small dispatch index (byte) used for routing/order. Implements serialization so requests can be saved/loaded across game versions; reading of the dispatch index is version-gated.
Fields
-
public Entity m_Target
Holds the target Entity that the maintenance request applies to. -
public int m_Priority
Integer priority used by the dispatching system to order/choose requests. Higher/lower semantics depend on the dispatch code. -
public byte m_DispatchIndex
A small index (byte) used by dispatch/routing logic. Initialized to 0 by the constructor. This value is only read from serialized data when the save version is at or above Version.requestDispatchIndex (see Deserialize).
Properties
- (none)
Constructors
public MaintenanceRequest(Entity target, int priority)
Creates a new MaintenanceRequest with the given target and priority. m_DispatchIndex is initialized to 0.
Methods
-
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component fields to a writer in the following order: m_Target, m_Priority, m_DispatchIndex. This ensures the request is persisted. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads component data from the reader into the fields. Reads m_Target and m_Priority unconditionally. The m_DispatchIndex is read only if the reader.context.version >= Version.requestDispatchIndex; otherwise the field remains at its default value (0). This preserves backward compatibility with older save formats that did not include dispatch index data.
Usage Example
// create a maintenance request for a target entity with priority 5
var request = new MaintenanceRequest(targetEntity, 5);
// Example: add the request component to an ECS entity using EntityManager
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
entityManager.AddComponentData(requestEntity, request);
// The dispatch index starts at 0. Dispatching systems may update it later.