mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:50:43 -05:00
45 lines
1.7 KiB
C#
45 lines
1.7 KiB
C#
|
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;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Temporarily trick client into thinking we are PMC and in offline mode to allow loading of scavs in PVE mode
|
|||
|
/// </summary>
|
|||
|
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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|