mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:50:43 -05:00
Revert Loadofflineraidscreenpatch back to its original state. Add patch to allow loading in as a scav.
This commit is contained in:
parent
bfff4108f4
commit
00a2a3a984
@ -0,0 +1,54 @@
|
|||||||
|
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)
|
||||||
|
{
|
||||||
|
if (!___raidSettings_0.IsScav)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
if (!___raidSettings_0.IsScav)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
___raidSettings_0.RaidMode = storedRaidMode;
|
||||||
|
___raidSettings_0.Side = storedSide;
|
||||||
|
___raidSettings_0.SelectedLocation.ForceOnlineRaidInPVE = storedOnlineRaidInPVE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -117,7 +117,6 @@ namespace SPT.SinglePlayer.Patches.ScavMode
|
|||||||
|
|
||||||
// Get fields from MainMenuController.cs
|
// Get fields from MainMenuController.cs
|
||||||
var raidSettings = Traverse.Create(menuController).Field("raidSettings_0").GetValue<RaidSettings>();
|
var raidSettings = Traverse.Create(menuController).Field("raidSettings_0").GetValue<RaidSettings>();
|
||||||
raidSettings.RaidMode = ERaidMode.Local;
|
|
||||||
|
|
||||||
// Find the private field of type `MatchmakerPlayerControllerClass`
|
// Find the private field of type `MatchmakerPlayerControllerClass`
|
||||||
var matchmakerPlayersController = menuController.GetType()
|
var matchmakerPlayersController = menuController.GetType()
|
||||||
@ -144,8 +143,6 @@ namespace SPT.SinglePlayer.Patches.ScavMode
|
|||||||
raidSettings.WavesSettings.IsBosses = true;
|
raidSettings.WavesSettings.IsBosses = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
raidSettings.RaidMode = ERaidMode.Local;
|
|
||||||
|
|
||||||
// Set offline raid values
|
// Set offline raid values
|
||||||
_isLocalField.SetValue(menuController, raidSettings.Local);
|
_isLocalField.SetValue(menuController, raidSettings.Local);
|
||||||
|
|
||||||
|
@ -76,6 +76,7 @@ namespace SPT.SinglePlayer
|
|||||||
new DisableMatchmakerPlayerPreviewButtonsPatch().Enable();
|
new DisableMatchmakerPlayerPreviewButtonsPatch().Enable();
|
||||||
new EnableRefForPVEPatch().Enable();
|
new EnableRefForPVEPatch().Enable();
|
||||||
new EnableRefIntermScreenPatch().Enable();
|
new EnableRefIntermScreenPatch().Enable();
|
||||||
|
new EnablePlayerScavPatch().Enable();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user