Table of Contents

Class Trigger

Namespace
FishMMO.Shared.Core
Assembly
FishMMO.Shared.dll

A trigger executes a list of actions against a set of targets selected by TargetSelector, branching on whether Conditions are satisfied for each selected target.

Lifecycle (per fire):

  1. Caller builds an EventData and invokes Execute(EventData).
  2. TargetSelector yields N targets (using Initiator / Target as context).
  3. For each target, the trigger forks eventData with the new target, evaluates conditions, and runs the matching action branch.

The Initiator never changes during the trigger's lifecycle.

[CreateAssetMenu(fileName = "New Trigger", menuName = "FishMMO/ECA/Trigger", order = 0)]
public class Trigger : CachedScriptableObject<Trigger>, ICachedObject
Inheritance
Object
ScriptableObject
Trigger
Implements
Derived
Inherited Members
ScriptableObject.SetDirty()
ScriptableObject.CreateInstance<T>()
Object.GetEntityId()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Fields

Conditions

[Header("Conditions")]
[Tooltip("Conditions that must be met for actions to execute. Evaluated top-to-bottom; the first failure short-circuits the rest. Wrap children in a CompositeCondition for OR / NOT semantics.")]
[SerializeReference]
public List<BaseCondition> Conditions

Field Value

List<BaseCondition>

OnConditionsMetActions

[Header("On Conditions Met")]
[Tooltip("Actions to execute when all conditions pass. Executed top-to-bottom. Order matters: an IAbortableAction with StopChainOnFailure set will abort every action below it in this list (and the rest of its fan-out targets) when its TryExecute returns false. Put resource-cost / can-afford gates first.")]
[FormerlySerializedAs("Actions")]
[SerializeReference]
public List<BaseAction> OnConditionsMetActions

Field Value

List<BaseAction>

OnConditionsNotMetActions

[Header("On Conditions Not Met")]
[Tooltip("Actions to execute when any condition fails. Executed top-to-bottom with the same StopChainOnFailure semantics as the met branch.")]
[SerializeReference]
public List<BaseAction> OnConditionsNotMetActions

Field Value

List<BaseAction>

TargetSelector

[Header("Targeting")]
[Tooltip("Selector that produces the targets this trigger fires for. Leave null to act on the event's existing Target. Use InitiatorTargetSelector for self-only, EventTargetSelector for explicit hit-target semantics.")]
[SerializeReference]
public TargetSelector TargetSelector

Field Value

TargetSelector

Verbose

[Header("Debug")]
[Tooltip("When checked, this trigger's own lifecycle logs (conditions met / not met / no targets) are promoted from Debug to Info so they show up without enabling global Debug logging. Diagnostic use only.")]
public bool Verbose

Field Value

bool

Methods

Execute(EventData)

Fires this trigger. The trigger fans out across TargetSelector and runs the condition/action branches once per selected target. The initiator on eventData is never reassigned.

public virtual void Execute(EventData eventData)

Parameters

eventData EventData

The event data driving execution.

OnValidate()

Editor-only sanity checks for designer authoring. Surfaces common misconfigurations as console warnings without blocking play (Unity's OnValidate contract). Strips null entries from action/condition lists that Unity occasionally leaves behind after class renames so designers don't accidentally hit logged "null action" warnings at runtime.

protected virtual void OnValidate()

ShouldEvaluateCondition(BaseCondition)

Determines whether a condition should participate in this trigger execution. Subclasses may override to skip categories of conditions (e.g. resource cost conditions already paid at activation time).

protected virtual bool ShouldEvaluateCondition(BaseCondition condition)

Parameters

condition BaseCondition

The condition being considered.

Returns

bool

True when the condition should be evaluated; otherwise, false.

Events

OnExecuted

Raised after Execute(EventData) finishes processing its targets, regardless of which action branch ran (or whether any targets were produced). Subscribers receive the firing Trigger and the top-level EventData passed in by the caller (post-fan-out, but the caller's data is not the per-target forked copy).

Intended for instrumentation, replay/recording tools, editor breakpoints, and server-side audit. Subscribers should be cheap and non-throwing — exceptions are caught and logged so a bad subscriber cannot poison gameplay. Handlers are invoked on the calling thread immediately after execution completes.

public static event Action<Trigger, EventData> OnExecuted

Event Type

Action<Trigger, EventData>