2022-01-13 16:38:34 +00:00

47 lines
1.2 KiB
C#

using QSB.EyeOfTheUniverse.EyeStateSync.Messages;
using QSB.Messaging;
using QSB.Player;
using QSB.Utility;
using QSB.WorldSync;
using System.Linq;
using UnityEngine;
namespace QSB.EyeOfTheUniverse.MaskSync
{
internal class MaskManager : MonoBehaviour
{
private static bool _flickering;
private static float _flickerOutTime;
public void Awake() => QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
private static void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool inUniverse)
{
_flickering = false;
_flickerOutTime = 0f;
}
public static void FlickerOutShuttle()
{
FlickerMessage.IgnoreNextMessage = true;
GlobalMessenger<float, float>.FireEvent(OWEvents.FlickerOffAndOn, 0.5f, 0.5f);
_flickerOutTime = Time.time + 0.5f;
_flickering = true;
// hide all players in shuttle
QSBPlayerManager.PlayerList.Where(x => x.IsInEyeShuttle).ForEach(x => x.DitheringAnimator.SetVisibleImmediate(false));
}
private void Update()
{
if (_flickering && Time.time > _flickerOutTime)
{
var controller = QSBWorldSync.GetUnityObjects<EyeShuttleController>().First();
controller._shuttleObject.SetActive(false);
_flickering = false;
_flickerOutTime = 0f;
}
}
}
}