using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Il2CppPhoton.Pun;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppTMPro;
using MelonLoader;
using PingDisplay;
using RumbleModUI;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(PingDisplayClass), "PingDisplay", "2.1.1", "Baumritter", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: VerifyLoaderVersion(0, 6, 4, true)]
[assembly: MelonColor(200, 0, 200, 0)]
[assembly: MelonAuthorColor(200, 0, 200, 0)]
[assembly: AssemblyTitle("PingDisplay")]
[assembly: AssemblyDescription("Gets the Ping of Players")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PingDisplay")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3a4c6714-8ec3-4ac3-b179-1f3f81f6fd55")]
[assembly: AssemblyFileVersion("2.1.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("2.1.1.0")]
namespace PingDisplay;
public static class BuildInfo
{
public const string ModName = "PingDisplay";
public const string ModVersion = "2.1.1";
public const string Description = "Gets the Ping of Players";
public const string Author = "Baumritter";
public const string Company = "";
}
public class PlayerPing
{
public string userID = "";
public string name = "";
public int ping = 0;
}
public class PingContainer
{
private PlayerManager pmref = null;
private PlayerPing hostping = new PlayerPing();
private List<PlayerPing> playerpings = new List<PlayerPing>();
public void GetPlayerPings(bool InitList)
{
GetHostPing();
if (InitList)
{
ClearPlayerList();
}
if (hostping.ping == -1)
{
return;
}
try
{
Enumerator<Player> enumerator = pmref.AllPlayers.GetEnumerator();
while (enumerator.MoveNext())
{
Player current = enumerator.Current;
PlayerPing playerPing = new PlayerPing();
if (current.Data.GeneralData.ActorNo != 1)
{
playerPing.userID = current.Data.GeneralData.InternalUsername;
playerPing.name = StringExtension.SanitizeName(current.Data.GeneralData.PublicUsername);
playerPing.ping = GetPingFromString(((Object)((Component)current.Controller).gameObject.GetComponent<PhotonView>().Controller.CustomProperties).ToString());
if (playerPing.ping != -1)
{
playerPing.ping += hostping.ping;
}
playerpings.Add(playerPing);
}
}
}
catch
{
playerpings.Clear();
}
}
public string ReturnAllPings()
{
string text = "Host" + Environment.NewLine + "Ping: " + hostping.ping.ToString().PadRight(4) + " Name: " + hostping.name + Environment.NewLine + "Client" + Environment.NewLine;
foreach (PlayerPing playerping in playerpings)
{
text = text + "Ping: " + playerping.ping.ToString().PadRight(4) + " Name: " + playerping.name + Environment.NewLine;
}
return text;
}
public PlayerPing ReturnPing(int PlayerNumber)
{
if (PlayerNumber == 0)
{
return hostping;
}
if (playerpings.Count == 0)
{
return new PlayerPing
{
name = "None",
userID = "None",
ping = 0
};
}
return playerpings[PlayerNumber - 1];
}
public void DebugLog()
{
MelonLogger.Msg("Host - Name: " + hostping.name + " ID: " + hostping.userID + " Ping: " + hostping.ping);
foreach (PlayerPing playerping in playerpings)
{
MelonLogger.Msg("Client - Name: " + playerping.name + " ID: " + playerping.userID + " Ping: " + playerping.ping);
}
}
private void GetHostPing()
{
InitPM();
PlayerPing playerPing = new PlayerPing();
Enumerator<Player> enumerator = pmref.AllPlayers.GetEnumerator();
while (enumerator.MoveNext())
{
Player current = enumerator.Current;
if (current.Data.GeneralData.ActorNo == 1 || current.Data.GeneralData.ActorNo == -1)
{
playerPing.userID = current.Data.GeneralData.InternalUsername;
playerPing.name = StringExtension.SanitizeName(current.Data.GeneralData.PublicUsername);
try
{
playerPing.ping = GetPingFromString(((Object)((Component)current.Controller).gameObject.GetComponent<PhotonView>().Controller.CustomProperties).ToString());
}
catch
{
playerPing.ping = -1;
}
break;
}
}
hostping = playerPing;
}
private void ClearPlayerList()
{
playerpings.Clear();
}
private int GetPingFromString(string str)
{
int result = -1;
string[] array = str.Split(new char[1] { ',' });
string[] array2 = array;
foreach (string text in array2)
{
if (text.Contains("ping"))
{
string text2 = text.Split(new char[1] { ')' })[^1];
text2.Replace(" ", string.Empty);
int.TryParse(text2, out result);
if (!int.TryParse(text2, out var _))
{
result = -1;
}
}
}
return result;
}
private void InitPM()
{
if ((Object)(object)pmref == (Object)null)
{
pmref = GameObject.Find("Game Instance/Initializable/PlayerManager").GetComponent<PlayerManager>();
}
}
}
public class PingDisplayClass : MelonMod
{
private UI UI = UI.instance;
private Mod Mod = new Mod();
private Delay Delay = new Delay();
private Delay MatchInfoDelay = new Delay();
public static PingContainer Pings = new PingContainer();
private GameObject MatchInfoRef = null;
private GameObject RemotePlayerText = null;
private GameObject LocalPlayerText = null;
private PlayerManager PlayerManager = null;
private string currentscene;
private bool MatchInfoRefDone = false;
private bool MatchInfoRefInvalid = false;
public override void OnLateInitializeMelon()
{
((MelonBase)this).OnLateInitializeMelon();
UI.UI_Initialized += OnUIInit;
}
public override void OnFixedUpdate()
{
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
((MelonBase)this).OnFixedUpdate();
if (currentscene == "Gym" && (Object)(object)PlayerManager == (Object)null)
{
PlayerManager = GameObject.Find("Game Instance/Initializable/PlayerManager").GetComponent<PlayerManager>();
}
if (Delay.Done && UI.IsUIVisible() && UI.IsModSelected("PingDisplay") && UI.IsOptionSelected("Pings"))
{
Pings.GetPlayerPings(InitList: true);
Mod.Settings[1].Description = Pings.ReturnAllPings();
UI.ForceRefresh();
Delay.Delay_Start(1.0, false);
}
if (MatchInfoDelay.Done && !MatchInfoRefInvalid)
{
if ((Object)(object)MatchInfoRef != (Object)null)
{
MelonLogger.Msg("Children clone start");
RemotePlayerText = Object.Instantiate<GameObject>(((Component)MatchInfoRef.transform.GetChild(5)).gameObject);
LocalPlayerText = Object.Instantiate<GameObject>(((Component)MatchInfoRef.transform.GetChild(6)).gameObject);
((Object)RemotePlayerText).name = "Remote Ping";
((Object)LocalPlayerText).name = "Local Ping";
RemotePlayerText.transform.SetParent(MatchInfoRef.transform, false);
LocalPlayerText.transform.SetParent(MatchInfoRef.transform, false);
RemotePlayerText.transform.localPosition = new Vector3(-1.25f, 1.5f, 0f);
LocalPlayerText.transform.localPosition = new Vector3(1.25f, 1.5f, 0f);
((TMP_Text)RemotePlayerText.GetComponent<TextMeshPro>()).text = "999ms";
((TMP_Text)LocalPlayerText.GetComponent<TextMeshPro>()).text = "999ms";
MatchInfoDelay.Done = false;
MatchInfoRefDone = true;
MelonLogger.Msg("Children cloned");
}
else
{
MatchInfoRef = GameObject.Find("MatchInfoMod");
if ((Object)(object)MatchInfoRef == (Object)null)
{
MatchInfoRefInvalid = true;
MelonLogger.Msg("MatchInfoRef doesn't exist");
}
else
{
MelonLogger.Msg("MatchInfoRef get");
}
}
}
if (Delay.Done && (currentscene == "Map0" || currentscene == "Map1") && MatchInfoRefDone && !MatchInfoRefInvalid)
{
Pings.GetPlayerPings(InitList: true);
if (PhotonNetwork.IsMasterClient)
{
((TMP_Text)RemotePlayerText.GetComponent<TextMeshPro>()).text = Pings.ReturnPing(1).ping + "ms";
((TMP_Text)LocalPlayerText.GetComponent<TextMeshPro>()).text = Pings.ReturnPing(0).ping + "ms";
}
else
{
((TMP_Text)RemotePlayerText.GetComponent<TextMeshPro>()).text = Pings.ReturnPing(0).ping + "ms";
((TMP_Text)LocalPlayerText.GetComponent<TextMeshPro>()).text = Pings.ReturnPing(1).ping + "ms";
}
Delay.Delay_Start(1.0, false);
}
}
private void OnUIInit()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
Mod.ModName = "PingDisplay";
Mod.ModVersion = "2.1.1";
Mod.SetFolder("PingDisplay");
Mod.AddDescription("Description", "", "Gets the Ping of Players", new Tags());
Mod.AddDescription("Pings", "", "None.", new Tags
{
IsEmpty = true
});
Mod.GetFromFile();
UI.AddMod(Mod);
MelonLoggerExtension.Log("Added Mod.");
Delay.Delay_Start(1.0, false);
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
((MelonMod)this).OnSceneWasLoaded(buildIndex, sceneName);
currentscene = sceneName;
if ((currentscene == "Map0" || currentscene == "Map1") && (Object)(object)MatchInfoRef == (Object)null)
{
MatchInfoDelay.Delay_Start(0.5, true);
}
}
}