Class GameEventTrigger<TContext>
- Namespace
- ElectricDrill.AstraRpgFramework.Triggers
- Assembly
- com.electricdrill.astra-rpg-framework.Runtime.dll
Abstract base for IReactiveTrigger implementations that wrap a typed GameEventGeneric1<T> SO.
Concrete subclasses must be non-generic and carry a [SerializeField] reference to
the specific event SO, exposed via Event. This separation is required because
Unity cannot serialize open-generic types with [SerializeReference].
When the event fires each registered Action<object> callback is invoked with
the TContext payload boxed as object. Filtering on
payload content (e.g. "only if the dying entity is my holder") is the responsibility of
the callback or an associated Condition.
public abstract class GameEventTrigger<TContext> : IReactiveTrigger
Type Parameters
TContextThe payload type carried by the wrapped event.
- Inheritance
-
objectGameEventTrigger<TContext>
- Implements
- Derived
Properties
Event
The typed event SO that this trigger listens to. Provided by the concrete subclass.
protected abstract GameEventGeneric1<TContext> Event { get; }
Property Value
- GameEventGeneric1<TContext>
EventSource
Returns the underlying shared event object this trigger wraps, or null.
Triggers returning the same non-null reference are coalesced into a single
subscription per modifier instance so that effects always process before
duration bookkeeping within the same event raise.
public object EventSource { get; }
Property Value
- object
PayloadType
The System.Type of the payload delivered by this trigger when it fires.
typeof(void) for parameterless triggers (no payload); a concrete or interface
type for triggers that carry typed event data. Used by
ConditionCompatibility to
verify that a paired
Condition can consume the
payload at design time.
public Type PayloadType { get; }
Property Value
- Type
Methods
Subscribe(EntityCore, Action<object>)
Registers callback to be invoked when the trigger fires.
Multiple distinct callbacks may be registered for the same holder.
Registering the exact same callback reference for the same
holder a second time is a no-op (idempotent).
public void Subscribe(EntityCore holder, Action<object> callback)
Parameters
holderEntityCoreThe entity on whose behalf the subscription is registered. Used as a key to allow grouped removal, but does not filter which events are delivered.
callbackAction<object>Invoked with the event payload boxed as
object(may benullfor parameterless triggers). The caller is responsible for casting to the expected type.
Unsubscribe(EntityCore, Action<object>)
Removes the subscription for the specific holder/callback
pair. Safe to call even if the pair was never registered or has already been removed.
public void Unsubscribe(EntityCore holder, Action<object> callback)
Parameters
holderEntityCorecallbackAction<object>