quantum-space-buddies/QSB/Utility/DebugGUI.cs

65 lines
2.0 KiB
C#
Raw Normal View History

2021-06-19 10:26:05 +00:00
using QSB.Player;
2021-06-19 10:24:23 +00:00
using QSB.ProbeSync.TransformSync;
2021-07-05 18:56:55 +00:00
using QSB.Syncs.TransformSync;
2021-06-19 10:24:23 +00:00
using QSB.TimeSync;
using System.Linq;
using UnityEngine;
namespace QSB.Utility
{
2021-07-12 21:02:50 +00:00
internal class DebugGUI : MonoBehaviour
2021-06-19 10:24:23 +00:00
{
private const float _debugLineSpacing = 11f;
public void OnGUI()
{
if (!QSBCore.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 : {QSBCore.WorldObjectsReady}");
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 (!QSBCore.WorldObjectsReady)
{
return;
}
var offset2 = 10f;
2021-07-05 18:56:55 +00:00
GUI.Label(new Rect(320, offset2, 200f, 20f), $"Player data :");
2021-06-19 10:24:23 +00:00
offset2 += _debugLineSpacing;
foreach (var player in QSBPlayerManager.PlayerList.Where(x => x.PlayerStates.IsReady))
{
var networkTransform = player.TransformSync;
var sector = networkTransform.ReferenceSector;
2021-07-05 18:56:55 +00:00
GUI.Label(new Rect(320, offset2, 400f, 20f), $"{player.PlayerId}.{player.Name}");
offset2 += _debugLineSpacing;
GUI.Label(new Rect(320, offset2, 400f, 20f), $" - L.Pos : {networkTransform.transform.localPosition}");
offset2 += _debugLineSpacing;
GUI.Label(new Rect(320, offset2, 400f, 20f), $" - Sector : {(sector == null ? "NULL" : sector.Name)}");
offset2 += _debugLineSpacing;
var probeSync = BaseTransformSync.GetPlayers<PlayerProbeSync>(player);
2021-07-06 15:28:12 +00:00
if (probeSync == default)
{
return;
}
2021-07-05 18:56:55 +00:00
var probeSector = probeSync.ReferenceSector;
GUI.Label(new Rect(320, offset2, 400f, 20f), $" - Probe Sector : {(probeSector == null ? "NULL" : probeSector.Name)}");
offset2 += _debugLineSpacing;
2021-06-19 10:24:23 +00:00
}
}
}
}