TheStable/Assets/Scripts/TimerSounds.cs
Jamie Greunbaum 43fdd17b46 - Switched to standard VRC Object Sync for chickens for reliability.
- Added light probes for the future game room.
- Added tooltips to TimerSounds variables.
2026-02-04 17:33:02 -05:00

54 lines
1.5 KiB
C#

using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
[UdonBehaviourSyncMode(BehaviourSyncMode.None)]
public class TimerSounds : TimerBase
{
[SerializeField] private AudioSource _AudioSource;
[SerializeField] private AudioClip[] _AudioClips;
[Space]
[Tooltip("If checked, will loop multiple times. If not checked, will play once after starting the timer and then stop until the timer is restarted.")]
[SerializeField] private bool _Loop = true;
[Space]
[Tooltip("Minimum time in seconds to randomly wait before starting the playback loop")]
[SerializeField] private float _MinimumStart = 0.0f;
[Tooltip("Maximum time in seconds to randomly wait before starting the playback loop")]
[SerializeField] private float _MaximumStart = 1.0f;
[Space]
[Tooltip("Minimum time in seconds to randomly wait before continuing the playback loop")]
[SerializeField] private float _MinimumDelay = 0.0f;
[Tooltip("Maximum time in seconds to randomly wait before continuing the playback loop")]
[SerializeField] private float _MaximumDelay = 1.0f;
private void Start()
{
TimerLength = Random.Range(_MinimumStart, _MaximumStart);
}
public override void StopTimer()
{
base.StopTimer();
TimerLength = 0.0f;
}
public override void TimerEvent()
{
_AudioSource.Stop();
AudioClip NextAudioClip = _AudioClips[Random.Range(0, _AudioClips.Length)];
_AudioSource.clip = NextAudioClip;
_AudioSource.Play();
if (_Loop)
{
TimerLength = NextAudioClip.length + Random.Range(_MinimumDelay, _MaximumDelay);
StartTimer();
}
}
}