using OWML.Utils; using QSB.Player; using QSB.QuantumSync.WorldObjects; using QSB.WorldSync; using System.Collections.Generic; using System.Reflection; using UnityEngine; namespace QSB.QuantumSync { internal class QuantumManager : MonoBehaviour { public static QuantumManager Instance { get; private set; } private List _socketedQuantumObjects; private List _multiStateQuantumObjects; private List _quantumSockets; private List _quantumShuffleObjects; public void Awake() { Instance = this; QSBSceneManager.OnSceneLoaded += OnSceneLoaded; } public void OnDestroy() => QSBSceneManager.OnSceneLoaded -= OnSceneLoaded; private void OnSceneLoaded(OWScene scene, bool isInUniverse) { _socketedQuantumObjects = QSBWorldSync.Init(); _multiStateQuantumObjects = QSBWorldSync.Init(); _quantumSockets = QSBWorldSync.Init(); _quantumShuffleObjects = QSBWorldSync.Init(); } private void OnGUI() { if (!QSBCore.HasWokenUp || !QSBCore.DebugMode) { return; } GUI.Label(new Rect(220, 10, 200f, 20f), $"QM Visible:{Locator.GetQuantumMoon().IsVisible()}"); var offset = 40f; var tracker = Locator.GetQuantumMoon().GetValue("_visibilityTracker"); foreach (var camera in QSBPlayerManager.GetPlayerCameras()) { GUI.Label(new Rect(220, offset, 200f, 20f), $"{camera.name} : {tracker.GetType().GetMethod("IsInFrustum", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(tracker, new object[] { camera.GetFrustumPlanes() })}"); offset += 30f; } } public int GetId(SocketedQuantumObject obj) => _socketedQuantumObjects.IndexOf(obj); public int GetId(MultiStateQuantumObject obj) => _multiStateQuantumObjects.IndexOf(obj); public int GetId(QuantumSocket obj) => _quantumSockets.IndexOf(obj); public int GetId(QuantumShuffleObject obj) => _quantumShuffleObjects.IndexOf(obj); } }