New mod: ServerConnectionInfo

JS is weird
This commit is contained in:
SDraw 2022-08-16 13:57:06 +03:00
parent a5a7fef3df
commit 15ba984362
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
13 changed files with 180 additions and 39 deletions

23
ml_sci/Main.cs Normal file
View file

@ -0,0 +1,23 @@
using ABI_RC.Core.UI;
using DarkRift.Client;
namespace ml_sci
{
public class ServerConnectionInfo : MelonLoader.MelonMod
{
public override void OnApplicationStart()
{
HarmonyInstance.Patch(
typeof(ABI_RC.Core.Networking.NetworkManager).GetMethod("OnGameNetworkConnectionClosed", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance),
null,
new HarmonyLib.HarmonyMethod(typeof(ServerConnectionInfo).GetMethod(nameof(OnGameNetworkConnectionClosed), System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static))
);
}
static void OnGameNetworkConnectionClosed(object __0, DisconnectedEventArgs __1)
{
if((CohtmlHud.Instance != null) && (__1 != null) && (!__1.LocalDisconnect))
CohtmlHud.Instance.ViewDropTextImmediate("(Global) Server", "Connection lost", (__1.Error != System.Net.Sockets.SocketError.Success) ? ("Reason: " + __1.Error.ToString()) : "");
}
}
}