mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-04 02:49:23 +00:00
Notification mods into one
This commit is contained in:
parent
9869407802
commit
f6d3d05860
8 changed files with 247 additions and 20 deletions
86
ml_egn/Main.cs
Normal file
86
ml_egn/Main.cs
Normal file
|
@ -0,0 +1,86 @@
|
|||
using ABI_RC.Core.EventSystem;
|
||||
using ABI_RC.Core.InteractionSystem;
|
||||
using ABI_RC.Core.Networking;
|
||||
using ABI_RC.Core.Util;
|
||||
using DarkRift.Client;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ml_egn
|
||||
{
|
||||
public class ExtendedGameNotifications : MelonLoader.MelonMod
|
||||
{
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
HarmonyInstance.Patch(
|
||||
typeof(AssetManagement).GetMethod(nameof(AssetManagement.LoadLocalAvatar)),
|
||||
null,
|
||||
new HarmonyLib.HarmonyMethod(typeof(ExtendedGameNotifications).GetMethod(nameof(OnLocalAvatarLoad), BindingFlags.NonPublic | BindingFlags.Static))
|
||||
);
|
||||
|
||||
HarmonyInstance.Patch(
|
||||
typeof(CVRSyncHelper).GetMethod(nameof(CVRSyncHelper.SpawnProp)),
|
||||
null,
|
||||
new HarmonyLib.HarmonyMethod(typeof(ExtendedGameNotifications).GetMethod(nameof(OnPropSpawned), BindingFlags.NonPublic | BindingFlags.Static))
|
||||
);
|
||||
|
||||
HarmonyInstance.Patch(
|
||||
typeof(NetworkManager).GetMethod("OnGameNetworkConnectionClosed", BindingFlags.NonPublic | BindingFlags.Instance),
|
||||
null,
|
||||
new HarmonyLib.HarmonyMethod(typeof(ExtendedGameNotifications).GetMethod(nameof(OnGameNetworkConnectionClosed), BindingFlags.NonPublic | BindingFlags.Static))
|
||||
);
|
||||
}
|
||||
|
||||
static void OnLocalAvatarLoad()
|
||||
{
|
||||
try
|
||||
{
|
||||
if(Utils.IsMenuOpened())
|
||||
Utils.ShowMenuNotification("Avatar changed", 1f);
|
||||
else
|
||||
Utils.ShowHUDNotification("(Synced) Client", "Avatar changed");
|
||||
}
|
||||
catch(System.Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnPropSpawned()
|
||||
{
|
||||
try
|
||||
{
|
||||
if(Utils.IsConnected())
|
||||
{
|
||||
if(Utils.IsMenuOpened())
|
||||
Utils.ShowMenuNotification("Prop spawned", 1f);
|
||||
else
|
||||
Utils.ShowHUDNotification("(Synced) Client", "Prop spawned");
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Utils.IsMenuOpened())
|
||||
ViewManager.Instance.TriggerAlert("Prop Error", "Not connected to live instance", -1, true);
|
||||
else
|
||||
Utils.ShowHUDNotification("(Local) Client", "Unable to spawn prop", "Not connected to live instance");
|
||||
}
|
||||
}
|
||||
catch(System.Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnGameNetworkConnectionClosed(object __0, DisconnectedEventArgs __1)
|
||||
{
|
||||
try
|
||||
{
|
||||
if((__1 != null) && (!__1.LocalDisconnect))
|
||||
Utils.ShowHUDNotification("(Local) Client", "Connection lost", (__1.Error != System.Net.Sockets.SocketError.Success) ? ("Reason: " + __1.Error.ToString()) : "", true);
|
||||
}
|
||||
catch(System.Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue