Skip to content

Game.Triggers.RadioEvent

Assembly: Game
Namespace: Game.Triggers

Type: struct

Base: IComponentData, IQueryTypeParameter, ISerializable

Summary:
A small ECS component used to represent a "radio" event tied to an Entity. It stores a single Entity reference and supports serialization for save/load. The struct implements IQueryTypeParameter so it can be used as a parameter in queries and systems, and ISerializable to persist the entity reference through the game's serialization system.


Fields

  • public Unity.Entities.Entity m_Entity
    Holds the Entity associated with the radio event (for example, the source or target Entity the event relates to). This is a plain ECS Entity value and will be the default (Entity.Null) if not initialized.

Properties

  • This type declares no properties.

Constructors

  • public RadioEvent(Unity.Entities.Entity entity)
    Initializes a new RadioEvent with the supplied Entity. Sets m_Entity = entity.

Methods

  • public void Serialize<TWriter>(TWriter writer) where TWriter : IWriter
    Writes the contained Entity to the provided writer. Uses writer.Write(m_Entity) to persist the entity reference.

  • public void Deserialize<TReader>(TReader reader) where TReader : IReader
    Reads an Entity value from the provided reader into m_Entity. Uses reader.Read(out m_Entity) to restore the reference during loading.

Usage Example

// Add a RadioEvent component to an entity, referencing another entity (e.g., a sound emitter)
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Entity triggerEntity = em.CreateEntity(); // entity that will hold the event
Entity sourceEntity = /* existing entity that represents the radio/source */;

em.AddComponentData(triggerEntity, new Game.Triggers.RadioEvent(sourceEntity));

// In a system you might query for RadioEvent to process events:
Entities.ForEach((ref Game.Triggers.RadioEvent radio) =>
{
    // handle radio event using radio.m_Entity
});