64 lines
2.2 KiB
C#
64 lines
2.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.Video;
|
|
using OctoCore.Transitions;
|
|
using Unheimlich.Transitions;
|
|
|
|
namespace Unheimlich.Features.Hallucination
|
|
{
|
|
/// <summary>
|
|
/// Scene-local trigger for a double-blink hallucination sequence. Delegates all
|
|
/// visual work to the persistent OctoEyelidBlink singleton.
|
|
/// </summary>
|
|
public class HallucinationFlash : MonoBehaviour
|
|
{
|
|
[SerializeField] private VideoClip _clip;
|
|
[SerializeField] private Material _material;
|
|
|
|
[Header("Timings")]
|
|
[SerializeField, Min(0f)] private float _closeDuration = 0.1f;
|
|
[SerializeField, Min(0f)] private float _holdClosed = 0.05f;
|
|
[SerializeField, Min(0f)] private float _openDuration = 0.15f;
|
|
[SerializeField, Min(0f)] private float _visibleHold = 0.5f;
|
|
[SerializeField, Range(0f, 1f)] private float _showVideoAtCloseProgress = 0.25f;
|
|
|
|
/// <summary>Triggers the hallucination sequence. No-op if the singleton is missing or busy.</summary>
|
|
public void Play()
|
|
{
|
|
OctoEyelidBlink blink = OctoEyelidBlink.Instance;
|
|
|
|
if (blink == null)
|
|
{
|
|
Debug.LogWarning("[HallucinationFlash] OctoEyelidBlink singleton not found in scene.");
|
|
return;
|
|
}
|
|
|
|
if (blink.IsBusy)
|
|
return;
|
|
|
|
blink.SetClip(_clip, _material);
|
|
|
|
blink.CloseEyes(_closeDuration, () =>
|
|
{
|
|
blink.Hold(_holdClosed, () =>
|
|
{
|
|
blink.OpenEyes(_openDuration, () =>
|
|
{
|
|
blink.Hold(_visibleHold, () =>
|
|
{
|
|
blink.CloseEyes(_closeDuration, () =>
|
|
{
|
|
blink.HideVideo();
|
|
blink.Hold(_holdClosed, () =>
|
|
{
|
|
blink.OpenEyes(_openDuration, null);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
blink.ShowVideoAfterDelay(_closeDuration * _showVideoAtCloseProgress);
|
|
}
|
|
}
|
|
} |