From 6034c42dd56d514803ab5a9b42bd6966f9c26c4b Mon Sep 17 00:00:00 2001 From: SamSWAT Date: Wed, 8 Feb 2023 15:50:01 +0300 Subject: [PATCH] SamSWAT.WatchAnims fix for aki 3.4.x --- .../GameWorldDisposePatch.cs | 20 +++++++++++++++++++ .../SamSWAT.WatchAnims/Plugin.cs | 3 ++- .../SamSWAT.WatchAnims.csproj | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 Projects/SamSWAT.WatchAnims/SamSWAT.WatchAnims/GameWorldDisposePatch.cs diff --git a/Projects/SamSWAT.WatchAnims/SamSWAT.WatchAnims/GameWorldDisposePatch.cs b/Projects/SamSWAT.WatchAnims/SamSWAT.WatchAnims/GameWorldDisposePatch.cs new file mode 100644 index 0000000..25ea0f6 --- /dev/null +++ b/Projects/SamSWAT.WatchAnims/SamSWAT.WatchAnims/GameWorldDisposePatch.cs @@ -0,0 +1,20 @@ +using System.Reflection; +using Aki.Reflection.Patching; +using EFT; + +namespace SamSWAT.WatchAnims +{ + public class GameWorldDisposePatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return typeof(GameWorld).GetMethod(nameof(GameWorld.Dispose)); + } + + [PatchPrefix] + private static void PatchPrefix() + { + Plugin.Controllers.Clear(); + } + } +} \ No newline at end of file diff --git a/Projects/SamSWAT.WatchAnims/SamSWAT.WatchAnims/Plugin.cs b/Projects/SamSWAT.WatchAnims/SamSWAT.WatchAnims/Plugin.cs index 10106d6..5675c84 100644 --- a/Projects/SamSWAT.WatchAnims/SamSWAT.WatchAnims/Plugin.cs +++ b/Projects/SamSWAT.WatchAnims/SamSWAT.WatchAnims/Plugin.cs @@ -17,6 +17,7 @@ namespace SamSWAT.WatchAnims private void Awake() { new GamePlayerOwnerPatch().Enable(); + new GameWorldDisposePatch().Enable(); Controllers = new Dictionary(); SuitsLookup = new Dictionary { @@ -62,7 +63,7 @@ namespace SamSWAT.WatchAnims }; var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); AnimationClips = AssetBundle.LoadFromFile($"{directory}/bundles/watch animations.bundle").LoadAllAssets(); - GameWorld.OnDispose += () => Controllers.Clear(); + //GameWorld.OnDispose += () => Controllers.Clear(); doesn't exist yet in eft 3.4.x } } } \ No newline at end of file diff --git a/Projects/SamSWAT.WatchAnims/SamSWAT.WatchAnims/SamSWAT.WatchAnims.csproj b/Projects/SamSWAT.WatchAnims/SamSWAT.WatchAnims/SamSWAT.WatchAnims.csproj index cf30cbb..df06b6d 100644 --- a/Projects/SamSWAT.WatchAnims/SamSWAT.WatchAnims/SamSWAT.WatchAnims.csproj +++ b/Projects/SamSWAT.WatchAnims/SamSWAT.WatchAnims/SamSWAT.WatchAnims.csproj @@ -66,6 +66,7 @@ +