2021-07-04 21:34:38 +00:00
|
|
|
|
using QSB.Utility;
|
2021-11-14 11:51:22 +00:00
|
|
|
|
using QSB.WorldSync;
|
2021-07-04 15:46:51 +00:00
|
|
|
|
using System.Linq;
|
2021-07-04 21:34:38 +00:00
|
|
|
|
using UnityEngine;
|
2021-07-04 15:46:51 +00:00
|
|
|
|
|
2021-11-09 17:46:46 +00:00
|
|
|
|
namespace QSB.Tools.ProbeTool
|
2021-07-04 15:46:51 +00:00
|
|
|
|
{
|
2021-07-12 21:02:50 +00:00
|
|
|
|
internal class QSBProbeEffects : MonoBehaviour
|
2021-07-04 15:46:51 +00:00
|
|
|
|
{
|
|
|
|
|
public OWAudioSource _flightLoopAudio;
|
|
|
|
|
public OWAudioSource _anchorAudio;
|
|
|
|
|
public ParticleSystem _anchorParticles;
|
|
|
|
|
|
|
|
|
|
private QSBProbe _probe;
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
2021-11-14 11:51:22 +00:00
|
|
|
|
_probe = QSBWorldSync.GetUnityObjects<QSBProbe>().First(x => gameObject.transform.IsChildOf(x.transform));
|
2021-07-04 15:46:51 +00:00
|
|
|
|
if (_probe == null)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Error - Couldn't find QSBProbe!", OWML.Common.MessageType.Error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_probe.OnLaunchProbe += OnLaunch;
|
|
|
|
|
_probe.OnAnchorProbe += OnAnchor;
|
|
|
|
|
_probe.OnUnanchorProbe += OnUnanchor;
|
|
|
|
|
_probe.OnStartRetrieveProbe += OnStartRetrieve;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
_probe.OnLaunchProbe -= OnLaunch;
|
|
|
|
|
_probe.OnAnchorProbe -= OnAnchor;
|
|
|
|
|
_probe.OnUnanchorProbe -= OnUnanchor;
|
|
|
|
|
_probe.OnStartRetrieveProbe -= OnStartRetrieve;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-27 05:08:36 +00:00
|
|
|
|
private void OnLaunch() => _flightLoopAudio.FadeIn(0.1f, true, true);
|
2021-07-04 15:46:51 +00:00
|
|
|
|
|
|
|
|
|
private void OnAnchor()
|
|
|
|
|
{
|
|
|
|
|
// TODO : Come up with some other way of doing this
|
|
|
|
|
|
|
|
|
|
//if (this._fluidDetector.InFluidType(FluidVolume.Type.WATER))
|
|
|
|
|
//{
|
|
|
|
|
// this._underwaterAnchorParticles.Play();
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
2021-07-04 21:34:38 +00:00
|
|
|
|
_anchorParticles.Play();
|
2021-07-04 15:46:51 +00:00
|
|
|
|
//}
|
2021-12-27 05:08:36 +00:00
|
|
|
|
_flightLoopAudio.FadeOut(0.5f);
|
|
|
|
|
_anchorAudio.PlayOneShot(AudioType.ToolProbeAttach);
|
2021-07-04 15:46:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-04 21:34:38 +00:00
|
|
|
|
private void OnUnanchor()
|
2021-12-27 05:08:36 +00:00
|
|
|
|
=> _flightLoopAudio.FadeIn(0.5f);
|
2021-07-04 15:46:51 +00:00
|
|
|
|
|
2021-07-04 21:34:38 +00:00
|
|
|
|
private void OnStartRetrieve(float retrieveLength)
|
2021-12-27 05:08:36 +00:00
|
|
|
|
=> _flightLoopAudio.FadeOut(retrieveLength);
|
2021-07-04 15:46:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|