0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/Aki.Custom/Patches/ExitWhileLootingPatch.cs

41 lines
1.3 KiB
C#
Raw Normal View History

2023-03-03 18:52:31 +00:00
using Aki.Reflection.Patching;
using Comfort.Common;
using EFT;
using System.Reflection;
using HarmonyLib;
2023-03-03 18:52:31 +00:00
namespace Aki.Custom.Patches
{
/// <summary>
/// Fix a bsg bug that causes the game to soft-lock when you have a container opened when extracting
/// </summary>
public class ExitWhileLootingPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(BaseLocalGame<GamePlayerOwner>), nameof(BaseLocalGame<GamePlayerOwner>.Stop));
2023-03-03 18:52:31 +00:00
}
// Look at BaseLocalGame<TPlayerOwner> and find a method named "Stop"
// once you find it, there should be a StartBlackScreenShow method with
// a callback method (on dnspy will be called @class.method_0)
// Go into that method. This will be part of the code:
// if (GClass2505.CheckCurrentScreen(EScreenType.Reconnect))
// {
// GClass2505.CloseAllScreensForced();
// }
// The code INSIDE the if needs to run
[PatchPrefix]
private static bool PatchPrefix(string profileId)
{
var player = Singleton<GameWorld>.Instance.MainPlayer;
if (profileId == player?.Profile.Id)
{
2024-03-14 11:23:51 +00:00
GClass3107.Instance.CloseAllScreensForced();
2023-03-03 18:52:31 +00:00
}
return true;
}
}
}