Skip to content

Game.Events.OnFire

Assembly: Assembly-CSharp
Namespace: Game.Events

Type: struct

Base: Implements IComponentData, IQueryTypeParameter, ISerializable

Summary:
Represents a fire event component used with Unity's ECS in Cities: Skylines 2 modding. Contains the event entity, an optional linked rescue-request entity, an intensity value describing the severity of the fire, and a frame index for request timing. Implements ISerializable so instances can be written to/read from Colossal's serializer for persistence or network transfer.


Fields

  • public Entity m_Event
    Holds the Entity that represents the fire event source or identifier.

  • public Entity m_RescueRequest
    Holds a linked rescue-request Entity (can be Entity.Null if none). Used to reference an associated rescue dispatch/request entity.

  • public float m_Intensity
    Float describing the fire's intensity/severity (e.g., used to scale response, effects, or priority).

  • public uint m_RequestFrame
    Frame index (unsigned int) indicating when the request was made or scheduled. Default is 0 when not specified.

Properties

  • This type has no properties.

Constructors

  • public OnFire(Entity _event, float intensity, uint requestFrame = 0u)
    Creates a new OnFire instance.
  • _event: Entity representing the fire event.
  • intensity: Fire intensity value.
  • requestFrame: Optional frame index for timing; defaults to 0.
  • The constructor sets m_RescueRequest to Entity.Null.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the component fields to the given writer in the following order: m_Event, m_RescueRequest, m_Intensity, m_RequestFrame. Used by the game's serialization system to persist or transmit this component.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads the component fields from the given reader into the struct's fields (using refs). The read order matches Serialize: m_Event, m_RescueRequest, m_Intensity, m_RequestFrame. Ensures the component can be reconstructed from serialized data.

Usage Example

// Example: creating and adding an OnFire component to an entity using an EntityManager
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

// Create an entity to represent the fire event (could also be an existing entity)
Entity fireEventEntity = entityManager.CreateEntity();

// Create the OnFire component with intensity and optional request frame
OnFire onFire = new OnFire(fireEventEntity, intensity: 0.8f, requestFrame: (uint)Time.frameCount);

// Optionally set a rescue request entity later (example: after creating a request entity)
onFire.m_RescueRequest = Entity.Null;

// Add the component to a target entity (e.g., an event container or the same entity)
entityManager.AddComponentData(fireEventEntity, onFire);

// Serialization is handled by the game's serializer which will call Serialize/Deserialize

{{ Notes: - Because this struct implements ISerializable, the Serialize/Deserialize methods must keep consistent ordering and types to avoid incompatibilities. - m_RescueRequest is initialized to Entity.Null by the constructor; controllers/systems should set it when a rescue request entity is created. - Typical usage is within ECS systems that detect or manage fire events, dispatch emergency services, and persist game state. }}