示例#1
0
        public void OnGUI()
        {
            if (!DebugMode)
            {
                return;
            }

            var offset = 10f;

            GUI.Label(new Rect(220, 10, 200f, 20f), $"FPS : {Mathf.Round(1f / Time.smoothDeltaTime)}");
            offset += _debugLineSpacing;
            GUI.Label(new Rect(220, offset, 200f, 20f), $"HasWokenUp : {HasWokenUp}");
            offset += _debugLineSpacing;
            if (WakeUpSync.LocalInstance != null)
            {
                GUI.Label(new Rect(220, offset, 200f, 20f), $"Time Difference : {WakeUpSync.LocalInstance.GetTimeDifference()}");
                offset += _debugLineSpacing;
                GUI.Label(new Rect(220, offset, 200f, 20f), $"Timescale : {OWTime.GetTimeScale()}");
                offset += _debugLineSpacing;
            }

            if (!HasWokenUp)
            {
                return;
            }

            var offset3 = 10f;

            GUI.Label(new Rect(420, offset3, 200f, 20f), $"Current synced sector :");
            offset3 += _debugLineSpacing;
            var sector = PlayerTransformSync.LocalInstance.ReferenceSector;
            var text   = sector == null
                                ? "NULL SECTOR"
                                : $"{sector.AttachedObject.name} : {sector.IsFakeSector}";

            GUI.Label(new Rect(420, offset3, 400f, 20f), $"- {text}");
            offset3 += _debugLineSpacing;

            var offset2 = 10f;

            GUI.Label(new Rect(620, offset2, 200f, 20f), $"Owned Objects :");
            offset2 += _debugLineSpacing;
            foreach (var obj in QSBWorldSync.GetWorldObjects <IQSBQuantumObject>().Where(x => x.ControllingPlayer == QSBPlayerManager.LocalPlayerId))
            {
                GUI.Label(new Rect(620, offset2, 200f, 20f), $"- {(obj as IWorldObject).Name}, {obj.ControllingPlayer}, {obj.IsEnabled}");
                offset2 += _debugLineSpacing;
            }

            if (QSBSceneManager.CurrentScene != OWScene.SolarSystem)
            {
                return;
            }

            GUI.Label(new Rect(220, offset, 200f, 20f), $"QM Illuminated : {Locator.GetQuantumMoon().IsIlluminated()}");
            offset += _debugLineSpacing;
            GUI.Label(new Rect(220, offset, 200f, 20f), $"Shrine player in dark? : {QuantumManager.Instance.Shrine.IsPlayerInDarkness()}");
            offset += _debugLineSpacing;
            GUI.Label(new Rect(220, offset, 200f, 20f), $"QM Visible by :");
            offset += _debugLineSpacing;
            var tracker = Locator.GetQuantumMoon().GetValue <ShapeVisibilityTracker>("_visibilityTracker");

            foreach (var player in QSBPlayerManager.GetPlayersWithCameras())
            {
                GUI.Label(new Rect(220, offset, 200f, 20f), $"	- {player.PlayerId} : {tracker.GetType().GetMethod("IsInFrustum", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(tracker, new object[] { player.Camera.GetFrustumPlanes() })}");
                offset += _debugLineSpacing;
            }

            if (SocketedObjToDebug == -1)
            {
                return;
            }

            // Used for diagnosing specific socketed objects.
            // 110 = Cave Twin entanglement shard
            // 342 = Timber Hearth museum shard
            var socketedObject = QSBWorldSync.GetWorldFromId <QSBSocketedQuantumObject>(SocketedObjToDebug);

            GUI.Label(new Rect(220, offset, 200f, 20f), $"{SocketedObjToDebug} Controller : {socketedObject.ControllingPlayer}");
            offset += _debugLineSpacing;
            GUI.Label(new Rect(220, offset, 200f, 20f), $"{SocketedObjToDebug} Illuminated : {socketedObject.AttachedObject.IsIlluminated()}");
            offset += _debugLineSpacing;
            var socketedTrackers = socketedObject.AttachedObject.GetComponentsInChildren <ShapeVisibilityTracker>();

            if (socketedTrackers == null || socketedTrackers.Length == 0)
            {
                GUI.Label(new Rect(220, offset, 200f, 20f), $"- List is null or empty.");
                return;
            }
            if (socketedTrackers.Any(x => x is null))
            {
                GUI.Label(new Rect(220, offset, 200f, 20f), $"- Uses a null.");
                return;
            }
            GUI.Label(new Rect(220, offset, 200f, 20f), $"Visible by :");
            offset += _debugLineSpacing;
            foreach (var player in QSBPlayerManager.GetPlayersWithCameras())
            {
                GUI.Label(new Rect(220, offset, 200f, 20f), $"	- {player.PlayerId} : {socketedTrackers.Any(x => (bool)x.GetType().GetMethod("IsInFrustum", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(x, new object[] { player.Camera.GetFrustumPlanes() }))}");
                offset += _debugLineSpacing;
            }
            GUI.Label(new Rect(220, offset, 200f, 20f), $"Entangled Players :");
            offset += _debugLineSpacing;
            foreach (var player in QuantumManager.GetEntangledPlayers(socketedObject.AttachedObject))
            {
                GUI.Label(new Rect(220, offset, 200f, 20f), $"	- {player.PlayerId}");
                offset += _debugLineSpacing;
            }
            var sockets = socketedObject.AttachedObject.GetValue <List <QuantumSocket> >("_socketList");

            foreach (var socket in sockets)
            {
                GUI.Label(new Rect(220, offset, 200f, 20f), $"- {socket.name} :");
                offset += _debugLineSpacing;
                GUI.Label(new Rect(220, offset, 200f, 20f), $"	- Visible:{socket.GetVisibilityObject().IsVisible()}");
                offset += _debugLineSpacing;
                GUI.Label(new Rect(220, offset, 200f, 20f), $"	- Illuminated:{socket.GetVisibilityObject().IsIlluminated()}");
                offset += _debugLineSpacing;
                GUI.Label(new Rect(220, offset, 200f, 20f), $"	- Occupied?:{socket.IsOccupied()}");
                offset += _debugLineSpacing;
            }
        }