Game.Events.AddHealthProblem
Assembly: Assembly-CSharp (inferred)
Namespace: Game.Events
Type: struct
Base: System.ValueType
Implements: IComponentData, IQueryTypeParameter
Summary: Represents an ECS "event" component used to signal that a health problem should be added to a target entity (for example a citizen). This is a plain data container intended to be attached to a transient event entity that systems will read and handle. The component carries a reference to the originating event entity, the target entity that should receive the health problem, and flags describing the problem.
Fields
-
public Entity m_Event
Holds the Entity that represents the source event. When creating a one-shot event entity, this is typically the entity itself (or another event-tracking entity) so processors can identify or remove the event after processing. -
public Entity m_Target
The Entity which is the intended recipient of the health problem (for example a citizen or person entity). Systems responding to this event will use this Entity to apply health state changes. -
public HealthProblemFlags m_Flags
A flags enum describing the specifics of the health problem (type, severity, modifiers, etc.). The definition for HealthProblemFlags is located in Game.Citizens; consult that enum for available flag values and their semantics.
Properties
- None. This struct exposes only public fields and implements ECS marker interfaces.
Constructors
public AddHealthProblem()
(implicit default)
No explicit constructors are defined in the source file; the default parameterless constructor is provided by the runtime. Create instances by assigning fields directly or by using object initialization.
Methods
- None. The struct contains no methods; behaviour is implemented by systems which read/writes this component.
Usage Example
Typical pattern: create a short-lived event entity, attach AddHealthProblem, then let a system handle it and destroy the event entity after processing.
using Unity.Entities;
using Game.Events;
using Game.Citizens;
public static class HealthEventSender
{
public static void SendAddHealthProblem(EntityManager em, Entity target, HealthProblemFlags flags)
{
// Create a transient event entity with no archetype other than the component.
Entity eventEntity = em.CreateEntity(typeof(AddHealthProblem));
em.SetComponentData(eventEntity, new AddHealthProblem
{
m_Event = eventEntity,
m_Target = target,
m_Flags = flags
});
// A system should pick this up, apply effects to 'target', then destroy 'eventEntity'.
}
}
Notes and recommendations: - This component is intended for event-style usage: create an entity with the component, process it in a system (usually in a reactive or event-processing system), then remove/destroy the event entity to avoid repeated processing. - Prefer using EntityCommandBuffer for creating/destroying event entities from Jobs or multi-threaded systems. - Check the definition and semantics of HealthProblemFlags in Game.Citizens to ensure correct flag combinations.