Interface ITriggerableEvent
Defines a contract for objects that have events which can be invoked by a trigger.
public interface ITriggerableEvent
Examples
Wire an ITriggerableEvent implementation to an EventTrigger's
_onEnterTriggered UnityEvent in the Inspector so that StartEvent is called when the
trigger fires. The example below shows a concrete implementation that enables an AI agent when the player
enters its zone, mirroring the pattern used by AIActivationEvent.
using UnityEngine;
using mobisim.Event;
// Attach to the same GameObject as the AI brain.
// In the Inspector, add this component to an EventTrigger's _onEnterTriggered listener
// and target the StartEvent() method so the AI activates on contact.
public class AIActivationEvent : MonoBehaviour, ITriggerableEvent
{
private System.Action subscribableAction;
// Register the AI-enable callback from the brain component.
public void SetActivationCallback(System.Action callback)
=> subscribableAction = callback;
// Called by EventTrigger's UnityEvent when the collider enters the zone.
public void StartEvent() => subscribableAction?.Invoke();
}