Game.Simulation.PostVanRequest
Assembly: Assembly-CSharp (likely)
Namespace: Game.Simulation
Type: struct
Base: System.ValueType, IComponentData, IQueryTypeParameter, ISerializable
Summary:
A lightweight ECS component representing a request to "post" or dispatch a van/vehicle to a target entity. Carries the target entity, request flags, a priority value, and a dispatch index used for tracking/ordering. Implements ISerializable to support network/save serialization with version-aware deserialization.
Fields
-
public Entity m_Target
Holds the ECS Entity that is the target of the post-van request (destination or related object). -
public PostVanRequestFlags m_Flags
Enum (likely a bitmask) describing options for the request (e.g., behavior modifiers, dispatch modes). Stored in serialized form as a ushort. -
public byte m_DispatchIndex
A small index used to disambiguate or order dispatches. Read/written conditionally during deserialization depending on the serialized data version (backwards-compatible). -
public ushort m_Priority
Priority of the request; higher values indicate higher priority when dispatching.
Properties
- None (all data are stored in public fields; no managed properties are defined by this struct).
Constructors
public PostVanRequest(Entity target, PostVanRequestFlags flags, ushort priority)
Initializes a new request with the given target, flags and priority. The constructor sets m_DispatchIndex to 0 by default.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component fields to the provided writer in the following order:- m_Target (Entity)
- m_Flags (written as ushort)
- m_Priority (ushort)
-
m_DispatchIndex (byte)
This method is used for saving or sending the request over the network. -
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads fields from the provided reader. The method is version-aware: - Reads m_Target (Entity)
- Reads a ushort value (temporarily holds the flags value)
- Reads m_Priority (ushort)
- Converts the earlier ushort to PostVanRequestFlags and stores in m_Flags
- If reader.context.version >= Version.requestDispatchIndex then reads m_DispatchIndex (byte)
This ordering and the version check ensure backward compatibility with serialized data that predates the dispatch index field.
Usage Example
// Create a request and add it as component data to an entity using the EntityManager
Entity targetEntity = /* obtain or create target entity */;
PostVanRequest request = new PostVanRequest(targetEntity, PostVanRequestFlags.None, 100);
request.m_DispatchIndex = 0; // optional explicit index
entityManager.AddComponentData(someRequesterEntity, request);
// Example of serializing manually (when implementing custom save/network logic)
writer.Write(request.m_Target);
writer.Write((ushort)request.m_Flags);
writer.Write(request.m_Priority);
writer.Write(request.m_DispatchIndex);
Notes and tips: - PostVanRequest is an IComponentData type — intended to be attached to ECS entities and processed by systems. - The dispatch index field is guarded by a version check in Deserialize: it was introduced later and older serialized streams may not include it. - PostVanRequestFlags is an enum type (likely a bitmask). Inspect its definition for available flags and semantics before setting flags in requests.