Game.Triggers.TriggerAction
Assembly: Assembly-CSharp
Namespace: Game.Triggers
Type: struct
Base: System.ValueType
Summary:
Represents a trigger action used by the game's trigger system. Encapsulates the kind of action to perform (TriggerType), the prefab entity used to spawn or reference the trigger, up to two target entities that the action affects, and an optional numeric value (for e.g. amount, duration, priority). This is a plain data container (mutable public fields) intended to be created and passed around by trigger code and systems.
Fields
-
public TriggerType m_TriggerType
The type of trigger action to perform. This is an enum (not included here) that the trigger system interprets to decide behavior (for example: spawn, enable, disable, modify, etc.). -
public Entity m_TriggerPrefab
An Entity reference to a prefab or template used by the action (for example, an entity to spawn). Uses Unity.Entities.Entity; can be Entity.Null when not applicable. -
public Entity m_PrimaryTarget
Primary target entity that the action operates on. May be Entity.Null if there is no primary target. -
public Entity m_SecondaryTarget
Secondary target entity for multi-target actions. May be Entity.Null when unused. -
public float m_Value
Numeric parameter for the action. Meaning depends on TriggerType (could be amount, intensity, duration, etc.). Defaults to 0f when not specified.
Properties
- This struct exposes no properties — it uses public fields.
Constructors
-
public TriggerAction(TriggerType triggerType, Entity triggerPrefab, Entity primaryTarget, Entity secondaryTarget, float value = 0f)
Creates a TriggerAction specifying the trigger type, prefab entity, both primary and secondary targets, and an optional float value. All fields are set from the provided arguments. -
public TriggerAction(TriggerType triggerType, Entity triggerPrefab, float value)
Convenience constructor that sets the trigger type, prefab, and value while leaving primary and secondary targets as Entity.Null.
Methods
- This struct defines no methods beyond the constructors.
Usage Example
// Example usage showing creation of TriggerAction instances.
// Assume TriggerType is an enum available in your mod, and 'somePrefabEntity' is a valid Entity.
using Unity.Entities;
using Game.Triggers;
// Create an action with explicit targets and a value
var actionWithTargets = new TriggerAction(
TriggerType.Spawn,
somePrefabEntity,
primaryTargetEntity,
secondaryTargetEntity,
value: 1.0f);
// Create a simple action with no targets (targets default to Entity.Null)
var simpleAction = new TriggerAction(
TriggerType.Toggle,
somePrefabEntity,
value: 0f);
Notes: - Fields are public and mutable; the struct is a plain data holder intended for lightweight passing between systems. - Entity.Null is used to indicate "no entity" for target fields when appropriate. - Interpret the m_Value field according to the TriggerType semantics used by your trigger system.