Skip to content

Game.Events.Submerge

Assembly: Assembly-CSharp
Namespace: Game.Events

Type: struct (public)

Base: System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter

Summary: A small ECS component struct used to represent a "submerge" event in the game's event system. It carries the event entity, the target entity that should be submerged, and the depth value (float) indicating how deep the target should submerge. This struct is intended to be used as an IComponentData payload on an event entity (or on an entity representing a pending action) and can also be used as a query-type parameter for systems that process submerge events.


Fields

  • public Unity.Entities.Entity m_Event An Entity that represents the event instance itself (commonly the entity that holds this component). Can be used to identify or remove the event entity after processing.

  • public Unity.Entities.Entity m_Target The entity that should be submerged (the target of the event). Systems handling this event will look up components on this entity to apply the submerge behavior.

  • public System.Single m_Depth A floating-point value representing the depth of the submerge. The exact unit depends on the game's coordinate/scale conventions (typically Unity units/meters).

Properties

  • None. This struct exposes only public fields.

Constructors

  • Default (implicit) struct constructor.
    You can initialize via object initializer when adding the component to an entity: new Submerge { m_Event = eventEntity, m_Target = targetEntity, m_Depth = 3.5f }

Methods

  • None. This is a passive data container (IComponentData / IQueryTypeParameter) and contains no behavior.

Usage Example

// Using EntityManager directly
var eventEntity = entityManager.CreateEntity();
entityManager.AddComponentData(eventEntity, new Game.Events.Submerge {
    m_Event = eventEntity,
    m_Target = someTargetEntity,
    m_Depth = 4.0f
});

// Using an EntityCommandBuffer inside a system (recommended for structural changes inside jobified systems)
var newEvent = ecb.CreateEntity();
ecb.SetComponent(newEvent, new Game.Events.Submerge {
    m_Event = newEvent,
    m_Target = someTargetEntity,
    m_Depth = 2.5f
});

// Example system pattern: query and process Submerge events
Entities
    .WithAll<Game.Events.Submerge>()
    .ForEach((Entity evtEntity, ref Game.Events.Submerge submerge) =>
    {
        // Apply submerge logic to submerge.m_Target using submerge.m_Depth
        // ...

        // Destroy or remove the event entity once processed
        // e.g., commandBuffer.DestroyEntity(evtEntity);
    }).Run();