Hallucination system setup & implementation with the infinite staircase + Fake volumetric lights test

This commit is contained in:
Ferlat Thibaud
2026-03-27 20:47:11 +01:00
parent 34d8ffd5b0
commit 395f6266d6
119 changed files with 44996 additions and 816 deletions
@@ -5,24 +5,21 @@ namespace Unheimlich.Features.Hallucination
{
/// <summary>
/// Self-contained zone that triggers a hallucination effect when the player enters.
/// Handles the once-flag, optional delay, insanity increase, and a discrete HallucinationEvent
/// — no GameEventTrigger or HallucinationTrigger required alongside it.
/// Ghost-word spawn removed — words live on FloatingLabel components in the scene.
/// SetEvent() lets InfiniteStaircaseController inject the right event per slot at runtime.
/// </summary>
public class HallucinationTriggerZone : TriggerZoneBase
{
[Header("Zone Behaviour")]
[Tooltip("Allow the zone to fire again after the player exits and re-enters")]
[SerializeField] private bool _retriggerable = false;
[Tooltip("Delay in seconds before the hallucination fires after the player enters")]
[SerializeField] private float _delay = 0f;
[SerializeField] private bool _retriggerable = false;
[SerializeField] private float _delay = 0f;
[Header("Sanity")]
[Tooltip("Amount of insanity added when the zone fires (0 = no change)")]
[Tooltip("Insanity added when the zone fires, on top of any SanityCost on the event.")]
[SerializeField, Range(0f, 1f)] private float _insanityAmount = 0f;
[Header("Hallucination Event")]
[Tooltip("Optional discrete hallucination event (ghost word, vision flash, etc.)")]
[Tooltip("Overridable at runtime via SetEvent().")]
[SerializeField] private HallucinationEvent _hallucinationEvent;
[Header("Debug")]
@@ -32,39 +29,38 @@ namespace Unheimlich.Features.Hallucination
protected override void OnPlayerEntered(Collider playerCollider)
{
if (_delay > 0f)
Invoke(nameof(Fire), _delay);
else
Fire();
if (_delay > 0f) Invoke(nameof(Fire), _delay);
else Fire();
}
/// <summary>
/// Fires the hallucination effect. Can also be called from external scripts or UnityEvents.
/// </summary>
/// <summary>Overrides the event at runtime. Pass null to disable.</summary>
public void SetEvent(HallucinationEvent hallucinationEvent) =>
_hallucinationEvent = hallucinationEvent;
/// <summary>Fires the hallucination. Can be called from external scripts or UnityEvents.</summary>
public void Fire()
{
if (HallucinationManager.Instance == null)
{
Debug.LogError("[HallucinationTriggerZone] HallucinationManager not found in scene!", this);
Debug.LogError("[HallucinationTriggerZone] HallucinationManager not found!", this);
return;
}
if (_insanityAmount > 0f)
{
HallucinationManager.Instance.AddInsanity(_insanityAmount);
if (_debugMode)
Debug.Log($"[HallucinationTriggerZone] Added {_insanityAmount:F2} insanity on '{gameObject.name}'.", this);
if (_debugMode) Debug.Log($"[HallucinationTriggerZone] +{_insanityAmount:F2} insanity.", this);
}
if (_hallucinationEvent != null)
{
HallucinationManager.Instance.TriggerHallucinationEvent(_hallucinationEvent);
if (_debugMode)
Debug.Log($"[HallucinationTriggerZone] Fired event: {_hallucinationEvent.Label}", this);
if (_debugMode) Debug.Log($"[HallucinationTriggerZone] Event: {_hallucinationEvent.Label}", this);
}
else if (_debugMode)
{
Debug.Log($"[HallucinationTriggerZone] No event on '{gameObject.name}'.", this);
}
}
}
}
}