Game.Simulation.FireRescueRequest
Assembly: Assembly-CSharp (game)
Namespace: Game.Simulation
Type: struct
Base: IComponentData, IQueryTypeParameter, ISerializable
Summary:
Represents an ECS component used to request fire/rescue services for a target Entity. Contains the target entity, a priority value (float) used to rank/queue requests, and a request type (FireRescueRequestType). Implements ISerializable to support save/load and includes version-aware deserialization (m_Type is only read when the saved data version is at or after Version.disasterResponse). Also usable as a query parameter type in ECS queries via IQueryTypeParameter.
Fields
-
public Entity m_Target
Entity that is the subject/target of the fire/rescue request (the object that requires attention). -
public float m_Priority
Priority of the request. Higher values typically indicate higher urgency when dispatching units. -
public FireRescueRequestType m_Type
Type of the request. Enum indicating the specific kind of fire/rescue service required (e.g., fire suppression, medical rescue, etc.). Note: this field is conditionally deserialized based on save version (see Deserialize).
Properties
- This struct does not expose any C# properties; it uses public fields.
Constructors
public FireRescueRequest(Entity target, float priority, FireRescueRequestType type)
Creates a new FireRescueRequest with the given target entity, priority, and request type.
Methods
public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
Writes the component data to the supplied writer. Serialization order:- Entity target
- float priority
-
byte-cast of FireRescueRequestType (written as a byte)
-
public void Deserialize<TReader>(TReader reader) where TReader : IReader
Reads component data from the supplied reader. Deserialization order: - Reads Entity into m_Target
- Reads float into m_Priority
- If reader.context.version >= Version.disasterResponse, reads a byte and casts it to FireRescueRequestType into m_Type This conditional read preserves backward compatibility with saves that predate the addition of m_Type.
Usage Example
// Create a request and add it as a component to an entity (typical ECS usage)
Entity targetEntity = /* obtain or create an Entity */;
var request = new FireRescueRequest(targetEntity, 1.0f, FireRescueRequestType.Fire);
// Example using Unity.Entities EntityManager to add the component
var entityManager = Unity.Entities.World.DefaultGameObjectInjectionWorld.EntityManager;
if (!entityManager.HasComponent<FireRescueRequest>(targetEntity))
{
entityManager.AddComponentData(targetEntity, request);
}
else
{
entityManager.SetComponentData(targetEntity, request);
}
Notes: - FireRescueRequestType is an enum defined elsewhere in the game code; check its definition for available values and semantics. - The ISerializable implementation ensures this component can be persisted and restored across game saves; pay attention to Version.disasterResponse when working with save compatibility.