-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScoutEquipPatch.cs
104 lines (98 loc) · 4.24 KB
/
ScoutEquipPatch.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using HarmonyLib;
using UnityEngine;
namespace QSBFPS;
[HarmonyPatch]
public class ScoutEquipPatch : MonoBehaviour
{
[HarmonyPrefix]
[HarmonyPatch(typeof(ToolModeSwapper), nameof(ToolModeSwapper.Update))]
public static bool ToolModeSwapper_Update_Prefix(ToolModeSwapper __instance)
{
if (__instance._isSwitchingToolMode && !__instance._equippedTool.IsEquipped())
{
__instance._equippedTool = __instance._nextTool;
__instance._nextTool = null;
if (__instance._equippedTool != null)
{
__instance._equippedTool.EquipTool();
}
__instance._currentToolMode = __instance._nextToolMode;
__instance._nextToolMode = ToolMode.None;
__instance._isSwitchingToolMode = false;
}
InputMode inputMode = InputMode.Character | InputMode.ShipCockpit;
if (!__instance.IsNomaiTextInFocus())
{
__instance._waitForLoseNomaiTextFocus = false;
}
if (__instance._shipDestroyed && __instance._currentToolGroup == ToolGroup.Ship)
{
return false;
}
if (__instance._currentToolMode != ToolMode.None && __instance._currentToolMode != ToolMode.Item &&
(OWInput.IsNewlyPressed(InputLibrary.cancel, inputMode | InputMode.ScopeZoom) || PlayerState.InConversation()))
{
InputLibrary.cancel.ConsumeInput();
if (__instance.GetAutoEquipTranslator() && __instance._currentToolMode == ToolMode.Translator)
{
__instance._waitForLoseNomaiTextFocus = true;
}
__instance.UnequipTool();
}
else if (__instance.IsNomaiTextInFocus() && __instance._currentToolMode != ToolMode.Translator &&
((__instance.GetAutoEquipTranslator() && !__instance._waitForLoseNomaiTextFocus) ||
OWInput.IsNewlyPressed(InputLibrary.interact, inputMode)))
{
__instance.EquipToolMode(ToolMode.Translator);
if (__instance._firstPersonManipulator.GetFocusedNomaiText() != null &&
__instance._firstPersonManipulator.GetFocusedNomaiText().CheckTurnOffFlashlight())
{
Locator.GetFlashlight().TurnOff(false);
}
}
else if (__instance._currentToolMode == ToolMode.Translator && !__instance.IsNomaiTextInFocus() && __instance.GetAutoEquipTranslator())
{
__instance.UnequipTool();
}
else if (OWInput.IsNewlyPressed(InputLibrary.probeLaunch, inputMode) && !qsbFPS.Instance.disableProbeLauncher)
{
if (__instance._currentToolGroup == ToolGroup.Suit && __instance._itemCarryTool.GetHeldItemType() == ItemType.DreamLantern)
{
return false;
}
if (((__instance._currentToolMode == ToolMode.None || __instance._currentToolMode == ToolMode.Item) &&
Locator.GetPlayerSuit().IsWearingSuit(false)) || ((__instance._currentToolMode == ToolMode.None ||
__instance._currentToolMode == ToolMode.SignalScope) && OWInput.IsInputMode(InputMode.ShipCockpit)))
{
__instance.EquipToolMode(ToolMode.Probe);
}
}
else if (OWInput.IsNewlyPressed(InputLibrary.signalscope, inputMode | InputMode.ScopeZoom))
{
if (PlayerState.InDreamWorld())
{
return false;
}
if (__instance._currentToolMode == ToolMode.SignalScope)
{
__instance.UnequipTool();
}
else
{
__instance.EquipToolMode(ToolMode.SignalScope);
}
}
bool flag = __instance._itemCarryTool.UpdateInteract(__instance._firstPersonManipulator, __instance.IsItemToolBlocked());
if (!__instance._itemCarryTool.IsEquipped() && flag)
{
__instance.EquipToolMode(ToolMode.Item);
return false;
}
if (__instance._itemCarryTool.GetHeldItem() != null && __instance._currentToolMode == ToolMode.None &&
OWInput.IsInputMode(InputMode.Character) && !OWInput.IsChangePending())
{
__instance.EquipToolMode(ToolMode.Item);
}
return false;
}
}