mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-11 09:38:48 +00:00
57 lines
2.1 KiB
C#
57 lines
2.1 KiB
C#
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<SocketedQuantumObject> _socketedQuantumObjects;
|
|
private List<MultiStateQuantumObject> _multiStateQuantumObjects;
|
|
private List<QuantumSocket> _quantumSockets;
|
|
private List<QuantumShuffleObject> _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<QSBSocketedQuantumObject, SocketedQuantumObject>();
|
|
_multiStateQuantumObjects = QSBWorldSync.Init<QSBMultiStateQuantumObject, MultiStateQuantumObject>();
|
|
_quantumSockets = QSBWorldSync.Init<QSBQuantumSocket, QuantumSocket>();
|
|
_quantumShuffleObjects = QSBWorldSync.Init<QSBQuantumShuffleObject, QuantumShuffleObject>();
|
|
}
|
|
|
|
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<ShapeVisibilityTracker>("_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);
|
|
}
|
|
} |