Skip to content

Game.Events.FaceWeather

Assembly: Game
Namespace: Game.Events

Type: struct

Base: IComponentData, IQueryTypeParameter

Summary:
FaceWeather is a lightweight ECS component used to represent a weather-related event affecting a target entity. It stores references to the event entity and the target entity plus a severity value (float). Because it implements IComponentData it is a plain, blittable component suitable for use in DOTS systems and jobs. Implementing IQueryTypeParameter enables the type to be used as a query parameter in certain query APIs.


Fields

  • public Entity m_Event
    Represents the entity that defines the weather event (source). Typically this is an entity that carries additional event data (timing, type, metadata). This field is an Entity handle and is safe to store in component data.

  • public Entity m_Target
    The entity that is affected by the weather event. This is an Entity handle to the target (for example, a district, building, or other in-game object).

  • public float m_Severity
    A floating-point value describing how strong the weather effect is for the target. The range/meaning is determined by the system that produces/consumes this component (commonly normalized 0..1 but not enforced by the type).

Properties

  • This type does not declare any C# properties. It only exposes public fields as shown above.

Constructors

  • This struct does not declare any explicit constructors. It uses the default parameterless value-type constructor provided by C#. {{ The default constructor initializes Entity fields to Entity.Null and the float to 0.0f; populate fields when creating or setting the component. }}

Methods

  • This type does not declare any methods. It is a pure data container (IComponentData).

Usage Example

using Unity.Entities;
using Game.Events;

public class WeatherEventSystem : SystemBase
{
    protected override void OnCreate()
    {
        base.OnCreate();
    }

    protected override void OnUpdate()
    {
        var em = EntityManager;

        // Example: create a FaceWeather component on a new entity
        var weatherEventEntity = em.CreateEntity(); // would normally have more components describing the event
        var targetEntity = /* obtain target entity reference */ Entity.Null;

        var faceWeatherEntity = em.CreateEntity(typeof(FaceWeather));
        em.SetComponentData(faceWeatherEntity, new FaceWeather
        {
            m_Event = weatherEventEntity,
            m_Target = targetEntity,
            m_Severity = 0.75f
        });

        // Example: processing all face-weather components
        Entities
            .ForEach((Entity e, ref FaceWeather fw) =>
            {
                // Process fw.m_Event, fw.m_Target, fw.m_Severity
                // e.g., apply visuals/effects based on severity
            })
            .ScheduleParallel();
    }
}

{{ NOTES: - This component is a simple POD data carrier; systems should be responsible for interpreting m_Severity and resolving the referenced Entity handles. - When storing Entity references, ensure those entities are valid and managed correctly across creation/destruction to avoid dangling references. - Use Entity.Null to represent "no event" or "no target" when appropriate. }}