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

79 lines
2.8 KiB
C#
Raw Normal View History

2021-08-09 10:49:58 +00:00
using QSB.ClientServerStateSync;
using QSB.Player;
2021-06-19 10:24:23 +00:00
using QSB.ProbeSync.TransformSync;
2021-08-14 14:00:46 +00:00
using QSB.Syncs;
2021-06-19 10:24:23 +00:00
using QSB.TimeSync;
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
{
2021-07-19 13:57:40 +00:00
private const float _debugLineSpacing = 8f;
private GUIStyle guiStyle = new GUIStyle()
{
fontSize = 9
};
2021-06-19 10:24:23 +00:00
public void OnGUI()
{
if (!QSBCore.DebugMode)
{
return;
}
2021-07-19 13:57:40 +00:00
guiStyle.normal.textColor = Color.white;
GUI.contentColor = Color.white;
2021-06-19 10:24:23 +00:00
var offset = 10f;
2021-07-19 13:57:40 +00:00
GUI.Label(new Rect(220, 10, 200f, 20f), $"FPS : {Mathf.Round(1f / Time.smoothDeltaTime)}", guiStyle);
2021-06-19 10:24:23 +00:00
offset += _debugLineSpacing;
2021-07-19 13:57:40 +00:00
GUI.Label(new Rect(220, offset, 200f, 20f), $"HasWokenUp : {QSBCore.WorldObjectsReady}", guiStyle);
2021-06-19 10:24:23 +00:00
offset += _debugLineSpacing;
if (WakeUpSync.LocalInstance != null)
{
2021-08-08 19:04:27 +00:00
GUI.Label(new Rect(220, offset, 200f, 20f), $"Server State : {ServerStateManager.Instance.GetServerState()}", guiStyle);
offset += _debugLineSpacing;
GUI.Label(new Rect(220, offset, 200f, 20f), $"WakeUpSync State : {WakeUpSync.LocalInstance.CurrentState}", guiStyle);
offset += _debugLineSpacing;
2021-07-19 13:57:40 +00:00
GUI.Label(new Rect(220, offset, 200f, 20f), $"Time Difference : {WakeUpSync.LocalInstance.GetTimeDifference()}", guiStyle);
2021-06-19 10:24:23 +00:00
offset += _debugLineSpacing;
2021-07-19 13:57:40 +00:00
GUI.Label(new Rect(220, offset, 200f, 20f), $"Timescale : {OWTime.GetTimeScale()}", guiStyle);
2021-06-19 10:24:23 +00:00
offset += _debugLineSpacing;
}
var offset2 = 10f;
2021-08-08 19:04:27 +00:00
GUI.Label(new Rect(420, offset2, 200f, 20f), $"Player data :", guiStyle);
2021-06-19 10:24:23 +00:00
offset2 += _debugLineSpacing;
2021-08-08 19:04:27 +00:00
foreach (var player in QSBPlayerManager.PlayerList)
2021-06-19 10:24:23 +00:00
{
2021-08-08 19:04:27 +00:00
GUI.Label(new Rect(420, offset2, 400f, 20f), $"{player.PlayerId}.{player.Name}", guiStyle);
2021-07-05 18:56:55 +00:00
offset2 += _debugLineSpacing;
2021-08-08 19:04:27 +00:00
GUI.Label(new Rect(420, offset2, 400f, 20f), $"State : {player.State}", guiStyle);
2021-07-05 18:56:55 +00:00
offset2 += _debugLineSpacing;
2021-08-08 19:04:27 +00:00
GUI.Label(new Rect(420, offset2, 400f, 20f), $"Dead : {player.IsDead}", guiStyle);
2021-07-05 18:56:55 +00:00
offset2 += _debugLineSpacing;
2021-08-08 19:04:27 +00:00
if (player.PlayerStates.IsReady && QSBCore.WorldObjectsReady)
2021-07-06 15:28:12 +00:00
{
2021-08-08 19:04:27 +00:00
var networkTransform = player.TransformSync;
var sector = networkTransform.ReferenceSector;
2021-08-22 15:54:48 +00:00
2021-08-08 19:04:27 +00:00
GUI.Label(new Rect(420, offset2, 400f, 20f), $" - L.Pos : {networkTransform.transform.localPosition}", guiStyle);
offset2 += _debugLineSpacing;
GUI.Label(new Rect(420, offset2, 400f, 20f), $" - Sector : {(sector == null ? "NULL" : sector.Name)}", guiStyle);
2021-07-19 13:57:40 +00:00
offset2 += _debugLineSpacing;
2021-08-14 14:00:46 +00:00
var probeSync = SyncBase.GetPlayers<PlayerProbeSync>(player);
2021-08-08 19:04:27 +00:00
if (probeSync != default)
{
var probeSector = probeSync.ReferenceSector;
GUI.Label(new Rect(420, offset2, 400f, 20f), $" - Probe Sector : {(probeSector == null ? "NULL" : probeSector.Name)}", guiStyle);
offset2 += _debugLineSpacing;
}
2021-07-06 15:28:12 +00:00
}
2021-06-19 10:24:23 +00:00
}
}
}
}