Skip to content

Game.Endanger

Assembly: Assembly-CSharp
Namespace: Game.Events

Type: struct

Base: System.ValueType

Summary:
Component data used to represent a "danger" event inside the ECS world. This struct is an IComponentData (so it can be attached to entities) and implements IQueryTypeParameter (so it can be used directly in queries). It stores a reference to the event entity, the target entity affected by the event, bitflags describing the nature of the danger, and the frame index when the danger expires. Use this component to mark entities that are currently in a danger state and allow systems to react, update, or remove the event when it ends.


Fields

  • public Entity m_Event
    Reference to the entity that represents the danger event itself (often used as the authoritative event entity).

  • public Entity m_Target
    The entity that is the target of the danger (for example a building, vehicle, or citizen entity affected by the event).

  • public DangerFlags m_Flags
    Bitflags describing the danger type/characteristics (e.g., fire, flood, collapse). DangerFlags is an enum defined elsewhere in the codebase; treat it as a set of flags describing behavior, severity, or subtype of the danger.

  • public uint m_EndFrame
    The simulation frame index when the danger should be considered expired/over. Systems should compare current simulation frame to m_EndFrame to decide when to clear or reactivate/extend the danger.

Properties

  • None (the struct exposes public fields and is intended to be used directly via ECS APIs).

Constructors

  • Implicit default struct constructor (value-initialized).
    You can construct it via an object initializer:

Example: csharp var danger = new Endanger { m_Event = eventEntity, m_Target = targetEntity, m_Flags = DangerFlags.Fire, m_EndFrame = currentFrame + 600u };

Methods

  • None (no instance or static methods are defined on this struct).

Usage Example

// Example: attaching an Endanger component to an event entity in a SystemBase
protected override void OnUpdate()
{
    var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
    Entity eventEntity = entityManager.CreateEntity(); // or obtain existing event entity
    Entity targetEntity = /* some target entity */;
    uint currentFrame = /* retrieve current simulation frame from game state */ 1000u;

    var danger = new Game.Events.Endanger
    {
        m_Event = eventEntity,
        m_Target = targetEntity,
        m_Flags = DangerFlags.Fire | DangerFlags.HighPriority,
        m_EndFrame = currentFrame + 600u // expires after 600 frames
    };

    entityManager.AddComponentData(eventEntity, danger);
}

Additional notes: - Systems that process Endanger components should periodically remove or update the component when m_EndFrame <= currentFrame to avoid stale events. - Because this is a plain data component, prefer using EntityManager/EntityCommandBuffer to add/remove it in multi-threaded job contexts. - DangerFlags is expected to be an enum with the [Flags] attribute; consult its definition for available flag values and semantics.