using UnityEngine; namespace Unheimlich.Features.Hallucination { /// /// Standalone hallucination payload component. /// Call Trigger() from any external script, UnityEvent, interaction, dialogue callback, etc. /// No other component required alongside it — compose freely. /// public class HallucinationTrigger : MonoBehaviour { [Header("Sanity")] [Tooltip("Amount of insanity to add when this trigger fires (0 = no change)")] [SerializeField, Range(0f, 1f)] private float _insanityAmount = 0f; [Header("Hallucination Event")] [Tooltip("Optional discrete hallucination event to fire (ghost word, vision flash, etc.)")] [SerializeField] private HallucinationEvent _hallucinationEvent; [Header("Debug")] [SerializeField] private bool _debugMode; /// /// Fires the hallucination effect. /// Wire this to any UnityEvent, interaction callback, dialogue node event, audio trigger, etc. /// public void Trigger() { if (HallucinationManager.Instance == null) { Debug.LogError("[HallucinationTrigger] HallucinationManager not found in scene!", this); return; } if (_insanityAmount > 0f) { HallucinationManager.Instance.AddInsanity(_insanityAmount); if (_debugMode) Debug.Log($"[HallucinationTrigger] Added {_insanityAmount:F2} insanity. Sanity now: {HallucinationManager.Instance.SanityLevel:F2}", this); } if (_hallucinationEvent != null) { HallucinationManager.Instance.TriggerHallucinationEvent(_hallucinationEvent); if (_debugMode) Debug.Log($"[HallucinationTrigger] Fired event: {_hallucinationEvent.Label}", this); } } } }