2021-11-09 19:39:56 +00:00
|
|
|
|
using System.Linq;
|
2021-11-14 11:51:22 +00:00
|
|
|
|
using QSB.WorldSync;
|
2021-11-03 09:18:52 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace QSB.SatelliteSync
|
|
|
|
|
{
|
2021-11-09 19:39:56 +00:00
|
|
|
|
internal class SatelliteProjectorManager : MonoBehaviour
|
2021-11-03 09:18:52 +00:00
|
|
|
|
{
|
|
|
|
|
public static SatelliteProjectorManager Instance { get; private set; }
|
|
|
|
|
|
|
|
|
|
public SatelliteSnapshotController Projector { get; private set; }
|
|
|
|
|
|
|
|
|
|
public void Start()
|
|
|
|
|
{
|
|
|
|
|
Instance = this;
|
|
|
|
|
QSBSceneManager.OnUniverseSceneLoaded += OnSceneLoaded;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-09 19:39:56 +00:00
|
|
|
|
public void OnDestroy() => QSBSceneManager.OnUniverseSceneLoaded -= OnSceneLoaded;
|
2021-11-03 09:18:52 +00:00
|
|
|
|
|
|
|
|
|
private void OnSceneLoaded(OWScene oldScene, OWScene newScene)
|
|
|
|
|
{
|
|
|
|
|
if (newScene == OWScene.SolarSystem)
|
|
|
|
|
{
|
2021-11-14 11:51:22 +00:00
|
|
|
|
Projector = QSBWorldSync.GetUnityObjects<SatelliteSnapshotController>().First();
|
2021-11-03 09:18:52 +00:00
|
|
|
|
Projector._loopingSource.spatialBlend = 1f;
|
|
|
|
|
Projector._oneShotSource.spatialBlend = 1f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RemoteEnter()
|
|
|
|
|
{
|
|
|
|
|
Projector.enabled = true;
|
|
|
|
|
Projector._interactVolume.DisableInteraction();
|
|
|
|
|
|
|
|
|
|
if (Projector._showSplashTexture)
|
|
|
|
|
{
|
|
|
|
|
Projector._splashObject.SetActive(false);
|
|
|
|
|
Projector._diagramObject.SetActive(true);
|
|
|
|
|
Projector._projectionScreen.gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Projector._fadeLight != null)
|
|
|
|
|
{
|
|
|
|
|
Projector._fadeLight.StartFade(0f, 2f, 0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var audioClip = Projector._oneShotSource.PlayOneShot(AudioType.TH_ProjectorActivate, 1f);
|
|
|
|
|
Projector._loopingSource.FadeIn(audioClip.length, false, false, 1f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RemoteExit()
|
|
|
|
|
{
|
|
|
|
|
Projector.enabled = false;
|
2021-11-03 12:10:26 +00:00
|
|
|
|
Projector._interactVolume.EnableInteraction();
|
2021-11-03 09:18:52 +00:00
|
|
|
|
Projector._interactVolume.ResetInteraction();
|
|
|
|
|
|
|
|
|
|
if (Projector._showSplashTexture)
|
|
|
|
|
{
|
|
|
|
|
Projector._splashObject.SetActive(true);
|
|
|
|
|
Projector._diagramObject.SetActive(false);
|
|
|
|
|
Projector._projectionScreen.gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Projector._fadeLight != null)
|
|
|
|
|
{
|
|
|
|
|
Projector._fadeLight.StartFade(Projector._initLightIntensity, 2f, 0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var audioClip = Projector._oneShotSource.PlayOneShot(AudioType.TH_ProjectorStop, 1f);
|
|
|
|
|
Projector._loopingSource.FadeOut(audioClip.length, OWAudioSource.FadeOutCompleteAction.STOP, 0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RemoteTakeSnapshot(bool forward)
|
|
|
|
|
{
|
|
|
|
|
Projector._satelliteCamera.transform.localEulerAngles = forward
|
|
|
|
|
? Projector._initCamLocalRot
|
|
|
|
|
: Projector._initCamLocalRot + new Vector3(0f, 180f, 0f);
|
|
|
|
|
|
|
|
|
|
Projector.RenderSnapshot();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|