2021-07-04 22:34:38 +01:00
|
|
|
|
using QSB.Utility;
|
2021-11-14 03:51:22 -08:00
|
|
|
|
using QSB.WorldSync;
|
2021-07-04 16:46:51 +01:00
|
|
|
|
using System.Linq;
|
2021-07-04 22:34:38 +01:00
|
|
|
|
using UnityEngine;
|
2021-07-04 16:46:51 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
namespace QSB.Tools.ProbeTool;
|
|
|
|
|
|
2022-08-27 11:44:52 -07:00
|
|
|
|
[UsedInUnityProject]
|
2022-03-02 19:46:33 -08:00
|
|
|
|
internal class QSBProbeEffects : MonoBehaviour
|
2021-07-04 16:46:51 +01:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public OWAudioSource _flightLoopAudio;
|
|
|
|
|
public OWAudioSource _anchorAudio;
|
|
|
|
|
public ParticleSystem _anchorParticles;
|
2021-07-04 16:46:51 +01:00
|
|
|
|
|
2022-08-27 11:30:15 -07:00
|
|
|
|
private QSBSurveyorProbe _probe;
|
2021-07-04 16:46:51 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
2022-08-27 11:30:15 -07:00
|
|
|
|
_probe = QSBWorldSync.GetUnityObjects<QSBSurveyorProbe>().First(x => gameObject.transform.IsChildOf(x.transform));
|
2022-03-02 19:46:33 -08:00
|
|
|
|
if (_probe == null)
|
2022-02-27 04:40:44 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
DebugLog.ToConsole($"Error - Couldn't find QSBProbe!", OWML.Common.MessageType.Error);
|
2022-02-27 04:40:44 -08:00
|
|
|
|
}
|
2021-07-04 16:46:51 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
_probe.OnLaunchProbe += OnLaunch;
|
|
|
|
|
_probe.OnAnchorProbe += OnAnchor;
|
|
|
|
|
_probe.OnUnanchorProbe += OnUnanchor;
|
|
|
|
|
_probe.OnStartRetrieveProbe += OnStartRetrieve;
|
2022-08-27 14:06:28 -04:00
|
|
|
|
_probe.OnTakeSnapshot += OnTakeSnapshot;
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2021-07-04 16:46:51 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
_probe.OnLaunchProbe -= OnLaunch;
|
|
|
|
|
_probe.OnAnchorProbe -= OnAnchor;
|
|
|
|
|
_probe.OnUnanchorProbe -= OnUnanchor;
|
|
|
|
|
_probe.OnStartRetrieveProbe -= OnStartRetrieve;
|
2022-08-27 14:06:28 -04:00
|
|
|
|
_probe.OnTakeSnapshot -= OnTakeSnapshot;
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2022-02-24 22:04:54 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private void OnLaunch() => _flightLoopAudio.FadeIn(0.1f, true, true);
|
2022-02-24 22:04:54 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08: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
|
|
|
|
|
//{
|
|
|
|
|
_anchorParticles.Play();
|
|
|
|
|
//}
|
|
|
|
|
_flightLoopAudio.FadeOut(0.5f);
|
|
|
|
|
_anchorAudio.PlayOneShot(AudioType.ToolProbeAttach);
|
2022-02-27 04:40:44 -08:00
|
|
|
|
}
|
2022-03-02 19:46:33 -08:00
|
|
|
|
|
|
|
|
|
private void OnUnanchor()
|
|
|
|
|
=> _flightLoopAudio.FadeIn(0.5f);
|
|
|
|
|
|
|
|
|
|
private void OnStartRetrieve(float retrieveLength)
|
2022-08-27 14:41:44 -04:00
|
|
|
|
{
|
|
|
|
|
_flightLoopAudio.FadeOut(retrieveLength);
|
|
|
|
|
_anchorAudio.PlayOneShot(AudioType.ToolProbeRetrieve);
|
|
|
|
|
}
|
2022-08-27 14:06:28 -04:00
|
|
|
|
|
|
|
|
|
private void OnTakeSnapshot()
|
|
|
|
|
=> _anchorAudio.PlayOneShot(AudioType.ToolProbeTakePhoto);
|
2022-02-24 22:04:54 -08:00
|
|
|
|
}
|