using EFT; using HarmonyLib; using SPT.Reflection.Patching; using System.Reflection; namespace SPT.SinglePlayer.Patches.ScavMode { internal class EnablePlayerScavPatch : ModulePatch { public static ERaidMode storedRaidMode; public static ESideType storedSide; public static bool storedOnlineRaidInPVE; /// /// Temporarily trick client into thinking we are PMC and in offline mode to allow loading of scavs in PVE mode /// protected override MethodBase GetTargetMethod() { return AccessTools.Method(typeof(MainMenuController), nameof(MainMenuController.method_22)); } [PatchPrefix] private static void PatchPrefix(ref MainMenuController __instance, ref RaidSettings ___raidSettings_0, ref ISession ___iSession) { // Store old settings to restore them later in postfix storedRaidMode = ___raidSettings_0.RaidMode; storedSide = ___raidSettings_0.Side; storedOnlineRaidInPVE = ___raidSettings_0.SelectedLocation.ForceOnlineRaidInPVE; ___raidSettings_0.RaidMode = ERaidMode.Online; ___raidSettings_0.Side = ESideType.Pmc; ___raidSettings_0.SelectedLocation.ForceOnlineRaidInPVE = false; } [PatchPostfix] private static void PatchPostfix(ref MainMenuController __instance, ref RaidSettings ___raidSettings_0, ref ISession ___iSession) { ___raidSettings_0.RaidMode = storedRaidMode; ___raidSettings_0.Side = storedSide; ___raidSettings_0.SelectedLocation.ForceOnlineRaidInPVE = storedOnlineRaidInPVE; } } }