SamSWAT.WatchAnims fix for aki 3.4.x

This commit is contained in:
SamSWAT 2023-02-08 15:50:01 +03:00
parent aa5279cdef
commit 6034c42dd5
3 changed files with 23 additions and 1 deletions

View File

@ -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();
}
}
}

View File

@ -17,6 +17,7 @@ namespace SamSWAT.WatchAnims
private void Awake()
{
new GamePlayerOwnerPatch().Enable();
new GameWorldDisposePatch().Enable();
Controllers = new Dictionary<IAnimator, AnimatorOverrideController>();
SuitsLookup = new Dictionary<string, int>
{
@ -62,7 +63,7 @@ namespace SamSWAT.WatchAnims
};
var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
AnimationClips = AssetBundle.LoadFromFile($"{directory}/bundles/watch animations.bundle").LoadAllAssets<AnimationClip>();
GameWorld.OnDispose += () => Controllers.Clear();
//GameWorld.OnDispose += () => Controllers.Clear(); doesn't exist yet in eft 3.4.x
}
}
}

View File

@ -66,6 +66,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="GamePlayerOwnerPatch.cs" />
<Compile Include="GameWorldDisposePatch.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>