2019-05-26 00:08:55 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using UnityEngine;
|
|
|
|
using Mirror;
|
2021-02-06 19:07:53 +00:00
|
|
|
using SanAndreasUnity.Behaviours.Peds;
|
2019-05-26 00:08:55 +00:00
|
|
|
using SanAndreasUnity.Net;
|
|
|
|
|
|
|
|
namespace SanAndreasUnity.Stats
|
|
|
|
{
|
|
|
|
public class NetStats : MonoBehaviour
|
|
|
|
{
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
Utilities.Stats.RegisterStat(new Utilities.Stats.Entry(){category = "NET", onGUI = OnStatGUI});
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnStatGUI()
|
|
|
|
{
|
|
|
|
|
|
|
|
GUILayout.Label("Time: " + NetworkTime.time);
|
|
|
|
|
|
|
|
if (NetStatus.IsServer)
|
|
|
|
{
|
|
|
|
Utilities.GUIUtils.DrawHorizontalLine(1, 1, Color.black);
|
|
|
|
GUILayout.Label("Num connections: " + NetworkServer.connections.Count);
|
2019-06-25 20:43:00 +00:00
|
|
|
GUILayout.Label("Max num players: " + NetManager.maxNumPlayers);
|
2021-02-06 19:07:53 +00:00
|
|
|
GUILayout.Label($"Dead body traffic per player: {DeadBody.DeadBodies.Sum(db => db.TrafficKbps)} Kb/s");
|
2019-05-26 00:08:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NetStatus.IsClientActive())
|
|
|
|
{
|
|
|
|
Utilities.GUIUtils.DrawHorizontalLine(1, 1, Color.black);
|
|
|
|
GUILayout.Label("Ping: " + NetworkTime.rtt);
|
|
|
|
GUILayout.Label("Ping send frequency: " + NetworkTime.PingFrequency);
|
|
|
|
GUILayout.Label("Rtt sd: " + NetworkTime.rttSd);
|
|
|
|
GUILayout.Label("Rtt var: " + NetworkTime.rttVar);
|
|
|
|
GUILayout.Label("Server ip: " + NetworkClient.serverIp);
|
|
|
|
GUILayout.Label("Time since last message: " + (Time.unscaledTime - NetworkClient.connection.lastMessageTime));
|
|
|
|
}
|
|
|
|
|
2020-07-05 11:50:22 +00:00
|
|
|
GUILayout.Label($"Num spawned network objects: {NetManager.NumSpawnedNetworkObjects}");
|
|
|
|
|
2019-05-26 00:08:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|