Smooth 3C & simplify hallucination trigger

This commit is contained in:
Ferlat Thibaud
2026-03-22 18:03:21 +01:00
parent 0d968f75ab
commit 1589a7a543
24 changed files with 1318 additions and 621 deletions
@@ -1,19 +1,16 @@
using UnityEngine;
using Unheimlich.Core.Events;
namespace Unheimlich.Features.Hallucination
{
/// <summary>
/// Drives the HallucinationManager when its GameEventTrigger fires.
/// Can increase sanity, fire a discrete HallucinationEvent, or both.
/// Compose a GameEventTrigger on the same GameObject to control the firing condition
/// (OnStart, OnEnable, delay, once-flag, external call via UnityEvent, etc.).
/// Standalone hallucination payload component.
/// Call Trigger() from any external script, UnityEvent, interaction, dialogue callback, etc.
/// No other component required alongside it — compose freely.
/// </summary>
[RequireComponent(typeof(GameEventTrigger))]
public class HallucinationTrigger : MonoBehaviour
{
[Header("Sanity")]
[Tooltip("Amount of sanity to add when this trigger fires (0 = no change)")]
[Tooltip("Amount of insanity to add when this trigger fires (0 = no change)")]
[SerializeField, Range(0f, 1f)] private float _insanityAmount = 0f;
[Header("Hallucination Event")]
@@ -23,22 +20,9 @@ namespace Unheimlich.Features.Hallucination
[Header("Debug")]
[SerializeField] private bool _debugMode;
private GameEventTrigger _eventTrigger;
private void Awake()
{
_eventTrigger = GetComponent<GameEventTrigger>();
_eventTrigger.OnTriggered += Trigger;
}
private void OnDestroy()
{
if (_eventTrigger != null)
_eventTrigger.OnTriggered -= Trigger;
}
/// <summary>
/// Fires the hallucination effect. Can be called directly from external scripts or UnityEvents.
/// Fires the hallucination effect.
/// Wire this to any UnityEvent, interaction callback, dialogue node event, audio trigger, etc.
/// </summary>
public void Trigger()
{
@@ -53,7 +37,7 @@ namespace Unheimlich.Features.Hallucination
HallucinationManager.Instance.AddInsanity(_insanityAmount);
if (_debugMode)
Debug.Log($"[HallucinationTrigger] Added {_insanityAmount:F2} insanity. New sanity: {HallucinationManager.Instance.SanityLevel:F2}", this);
Debug.Log($"[HallucinationTrigger] Added {_insanityAmount:F2} insanity. Sanity now: {HallucinationManager.Instance.SanityLevel:F2}", this);
}
if (_hallucinationEvent != null)