From d1cfb57baa45fedf22f08347180d3efa027f360d Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Fri, 29 Nov 2024 16:41:58 +0100 Subject: [PATCH] FikaNotificationManager changes - Turn into singleton --- .../Networking/Websocket/FikaNotificationManager.cs | 9 +++++++++ .../UI/Patches/TarkovApplication_method_18_Patch.cs | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Fika.Core/Networking/Websocket/FikaNotificationManager.cs b/Fika.Core/Networking/Websocket/FikaNotificationManager.cs index a6112e66..3fc421cf 100644 --- a/Fika.Core/Networking/Websocket/FikaNotificationManager.cs +++ b/Fika.Core/Networking/Websocket/FikaNotificationManager.cs @@ -17,6 +17,14 @@ namespace Fika.Core.Networking.Websocket public class FikaNotificationManager : MonoBehaviour { private static readonly ManualLogSource logger = BepInEx.Logging.Logger.CreateLogSource("FikaNotificationManager"); + public static FikaNotificationManager Instance; + public static bool Exists + { + get + { + return Instance != null; + } + } public string Host { get; set; } public string Url { get; set; } @@ -36,6 +44,7 @@ public bool Connected public void Awake() { + Instance = this; Host = RequestHandler.Host.Replace("http", "ws"); SessionId = RequestHandler.SessionId; Url = $"{Host}/fika/notification/"; diff --git a/Fika.Core/UI/Patches/TarkovApplication_method_18_Patch.cs b/Fika.Core/UI/Patches/TarkovApplication_method_18_Patch.cs index f1b9f249..352f4a72 100644 --- a/Fika.Core/UI/Patches/TarkovApplication_method_18_Patch.cs +++ b/Fika.Core/UI/Patches/TarkovApplication_method_18_Patch.cs @@ -20,7 +20,10 @@ protected override MethodBase GetTargetMethod() [PatchPostfix] internal static void Postfix() { - Singleton.Instance.gameObject.AddComponent(); + if (!FikaNotificationManager.Exists) + { + Singleton.Instance.gameObject.AddComponent(); + } } } }