Game.Simulation.MaintenanceConsumer
Assembly:
Assembly-CSharp (game runtime)
Namespace:
Game.Simulation
Type:
struct
Base:
Implements: IComponentData, IQueryTypeParameter, ISerializable
Summary:
Represents a maintenance request consumer component used by the simulation ECS. Stores a reference to the maintenance request Entity and a small dispatch index (byte) that selects/identifies which dispatcher/queue handled (or should handle) the request. The struct supports custom binary serialization and is forward-compatible with versions that add the dispatch index field.
Fields
-
public Entity m_Request
Holds the Entity that represents the maintenance request associated with this consumer. Serialized/written first in the Serialize method. -
public byte m_DispatchIndex
A small index (0..255) used to indicate which dispatch path handled this request. Written/read conditionally depending on serialization version; if not present in serialized data, it remains at the default value (0).
Properties
- This type defines no managed properties; it exposes public fields only.
Constructors
public MaintenanceConsumer()
No explicit constructors are defined in the source; the default parameterless struct constructor is used. Initialize fields manually (e.g., set m_Request and m_DispatchIndex) when creating instances.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes component state to the writer in binary order:- Writes m_Request (Entity).
-
Writes m_DispatchIndex (byte). The writer / serialization context is expected to accept Entity and byte writes.
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads component state from the reader: - Reads m_Request (Entity) unconditionally.
- Reads m_DispatchIndex only if reader.context.version >= Version.requestDispatchIndex. This version check ensures backward compatibility with older save versions that did not include the dispatch index.
Usage Example
// Creating and initializing the component
var consumer = new MaintenanceConsumer
{
m_Request = someRequestEntity,
m_DispatchIndex = 1
};
// Example serialize usage (pseudocode - depends on game's IWriter implementation)
writer.Write(consumer.m_Request);
writer.Write(consumer.m_DispatchIndex);
// Example deserialize usage with version gating awareness
MaintenanceConsumer readConsumer;
reader.Read(out readConsumer.m_Request);
if (reader.context.version >= Version.requestDispatchIndex)
{
reader.Read(out readConsumer.m_DispatchIndex);
}
Additional notes: - As an IComponentData, this struct is intended to be attached to Entities and used in ECS queries. - As an ISerializable implementation, it integrates with the game's custom save/load system; be careful to respect version checks when extending serialized data. - m_DispatchIndex defaults to 0 if not present in serialized data (older versions).