Skip to content

Commit b12b64c

Browse files
authored
Disable PDA pause option (#2286)
1 parent a935aec commit b12b64c

File tree

5 files changed

+39
-6
lines changed

5 files changed

+39
-6
lines changed

Nitrox.Test/Patcher/Patches/PatchesTranspilerTest.cs

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class PatchesTranspilerTest
6868
[typeof(SpawnOnKill_OnKill_Patch), 3],
6969
[typeof(SubConsoleCommand_OnConsoleCommand_sub_Patch), 0],
7070
[typeof(SubRoot_OnPlayerEntered_Patch), 5],
71+
[typeof(uGUI_OptionsPanel_AddAccessibilityTab_Patch), -10],
7172
[typeof(uGUI_PDA_Initialize_Patch), 2],
7273
[typeof(uGUI_PDA_SetTabs_Patch), 3],
7374
[typeof(uGUI_Pings_IsVisibleNow_Patch), 0],

NitroxClient/MonoBehaviours/Gui/Modals/Modal.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void Hide()
9292
CurrentModal = null;
9393
if (FreezeGame)
9494
{
95-
FreezeTime.End(FreezeTime.Id.IngameMenu);
95+
FreezeTime.End(FreezeTime.Id.Quit);
9696
}
9797
if (IsAvoidable)
9898
{

NitroxClient/MonoBehaviours/NitroxBootstrapper.cs

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ private void Awake()
2525
// This is very important, see Application_runInBackground_Patch.cs
2626
Application.runInBackground = true;
2727
Log.Info($"Unity run in background set to \"{Application.runInBackground}\"");
28+
// Also very important for similar reasons
29+
MiscSettings.pdaPause = false;
2830
}
2931

3032
#if DEBUG

NitroxPatcher/Patches/Dynamic/FreezeTime_Begin_Patch.cs NitroxPatcher/Patches/Dynamic/FreezeTime_Set_Patch.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
namespace NitroxPatcher.Patches.Dynamic;
77

88
/// <summary>
9-
/// Because we're in multiplayer mode, we generally don't want the game to freeze
9+
/// Because we're in multiplayer mode, we generally don't want the game to freeze.
10+
/// Thus we prevent any FreezeTime that is not for quit screen or (initial sync) wait screen.
1011
/// </summary>
11-
public sealed partial class FreezeTime_Begin_Patch : NitroxPatch, IDynamicPatch
12+
public sealed partial class FreezeTime_Set_Patch : NitroxPatch, IDynamicPatch
1213
{
13-
private static readonly MethodInfo TARGET_METHOD = Reflect.Method(() => FreezeTime.Begin(default(FreezeTime.Id)));
14+
private static readonly MethodInfo TARGET_METHOD = Reflect.Method(() => FreezeTime.Set(default, default));
1415

15-
private static readonly HashSet<FreezeTime.Id> allowedFreezeIds = new() { FreezeTime.Id.Quit, FreezeTime.Id.WaitScreen };
16+
private static readonly HashSet<FreezeTime.Id> allowedFreezeIds = [FreezeTime.Id.Quit, FreezeTime.Id.WaitScreen];
1617

17-
// We don't want to prevent from freezing the game if the opened modal wants to freeze the game
1818
public static bool Prefix(FreezeTime.Id id)
1919
{
2020
return allowedFreezeIds.Contains(id);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Collections.Generic;
2+
using System.Reflection;
3+
using System.Reflection.Emit;
4+
using HarmonyLib;
5+
using NitroxModel.Helper;
6+
7+
namespace NitroxPatcher.Patches.Persistent;
8+
9+
/// <summary>
10+
/// Remove the option for PDA pause
11+
/// </summary>
12+
public sealed partial class uGUI_OptionsPanel_AddAccessibilityTab_Patch : NitroxPatch, IPersistentPatch
13+
{
14+
private static readonly MethodInfo TARGET_METHOD = Reflect.Method((uGUI_OptionsPanel t) => t.AddAccessibilityTab());
15+
16+
/// <summary>
17+
/// Simply removes following line
18+
/// AddToggleOption(num, "PDAPause" ...
19+
/// </summary>
20+
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
21+
{
22+
return new CodeMatcher(instructions).MatchStartForward([
23+
new(OpCodes.Ldarg_0),
24+
new(OpCodes.Ldloc_0),
25+
new(OpCodes.Ldstr, "PDAPause")
26+
])
27+
.RemoveInstructions(10)
28+
.InstructionEnumeration();
29+
}
30+
}

0 commit comments

Comments
 (0)