using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Rewired;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SoDControllerFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("SoDControllerFix")]
[assembly: AssemblyTitle("SoDControllerFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace SoDControllerFix
{
[BepInPlugin("sm3gm.sod.controllerfix", "Controller Fix", "1.3.6")]
public sealed class Plugin : BasePlugin
{
public const string VER = "1.3.6";
internal static ManualLogSource L;
internal static ConfigEntry<bool> OnePressPerClick;
internal static ConfigEntry<bool> LogBlocked;
internal static ConfigEntry<float> ClickWindow;
internal static ConfigEntry<bool> SelectUnderCursor;
internal static ConfigEntry<float> DragThreshold;
internal static ConfigEntry<bool> PhoneLook;
internal static ConfigEntry<bool> YClosesCard;
internal static ConfigEntry<bool> YClosesMapNotes;
internal static ConfigEntry<bool> PhotoFirst;
internal static ConfigEntry<bool> TapOpens;
internal static ConfigEntry<bool> OnScreen;
public override void Load()
{
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Expected O, but got Unknown
L = ((BasePlugin)this).Log;
OnePressPerClick = ((BasePlugin)this).Config.Bind<bool>("Buttons", "OnePressPerClick", true, "Keypads, phone keys and elevator buttons take one press per click. Stops one click typing a digit several times.");
ClickWindow = ((BasePlugin)this).Config.Bind<float>("Buttons", "ClickWindowSeconds", 0.6f, "How long after a click the game may still press the key (the hand moves to it first).");
SelectUnderCursor = ((BasePlugin)this).Config.Bind<bool>("Buttons", "SelectUnderCursor", true, "When the cursor moves onto a button, that button becomes the selected one, so a controller click presses what you point at and not a tab elsewhere.");
DragThreshold = ((BasePlugin)this).Config.Bind<float>("CaseBoard", "DragThreshold", 24f, "How far (in pixels at 1080p) the cursor must move with the button held before a click becomes a drag. A shaky controller or trackpad click then opens the item instead of moving it. The game uses 10. 0 = leave the game's value.");
PhoneLook = ((BasePlugin)this).Config.Bind<bool>("Phone", "KeepViewOnPhone", true, "On a phone call the view stays put when you switch between controller and keyboard (the game let it go).");
YClosesCard = ((BasePlugin)this).Config.Bind<bool>("CaseBoard", "YClosesTopCard", true, "On the case board with a controller, Y (Triangle on PlayStation) closes the card you opened last, one per press (B, Circle on PlayStation, closes the whole board). Over a pin, Y opens its menu as usual.");
YClosesMapNotes = ((BasePlugin)this).Config.Bind<bool>("Buttons", "YClosesMapAndNotes", false, "With a controller, Y (Triangle on PlayStation) also closes the map and the notebook, like B does. Off by default.");
PhotoFirst = ((BasePlugin)this).Config.Bind<bool>("CaseBoard", "PhotoOpensCard", true, "On the case board the photo always opens the card and the rest of the card moves it. The game sometimes let the card take over the photo, so the cursor and the click switched between opening and moving.");
TapOpens = ((BasePlugin)this).Config.Bind<bool>("CaseBoard", "TapOpensCard", true, "With a controller, a tap anywhere on a case board card opens it, and holding and moving anywhere on it moves it, whatever the cursor shows. The game decided by which part of the card got the press, so a tap sometimes moved the card or did nothing. With a mouse or trackpad, a click on the frame still starts a string as in the game.");
OnScreen = ((BasePlugin)this).Config.Bind<bool>("CaseBoard", "OpenCardsOnScreen", true, "Open cards are kept fully on the screen, below the top bar, instead of opening (or coming back) partly under the bar or past the edge. While you drag a card it goes where you take it.");
LogBlocked = ((BasePlugin)this).Config.Bind<bool>("Debug", "LogBlocked", false, "Write a line to the log for every repeated press that was stopped.");
((BasePlugin)this).AddComponent<InputWatch>();
Harmony val = new Harmony("sm3gm.sod.controllerfix");
val.PatchAll(typeof(Presses));
val.PatchAll(typeof(CardTap));
ManualLogSource l = L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Controller Fix ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.3.6");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" loaded");
}
l.LogInfo(val2);
}
}
public class InputWatch : MonoBehaviour
{
internal static int LastDownFrame = -10;
internal static float LastDownTime = -10f;
internal static bool Used = true;
internal static float AutoUntil = -10f;
private static string lastKey = "";
private static float lastKeyTime = -10f;
private static int lastKeyFrame = -1;
internal static float CursorUntil = -10f;
internal static float PadCursorUntil = -10f;
private static int photoErr;
private static int photoLogs;
private static readonly Dictionary<IntPtr, int> seenWindows = new Dictionary<IntPtr, int>();
private static int screenLogs;
private static float lastHeld = -1f;
private static bool wasOnBoard;
private static int yButton = -2;
private static int secondary = -2;
private static int lastCardFrame = -1;
private static int cardErr;
private static int cardLogs;
private static int mapNotesFrame = -1;
private static float nextDrag;
private static int lastMode = -1;
private static int relock;
private static bool lockedThisCall;
private static int logged;
private static Vector3 lastMouse;
private static float lastMove = -10f;
public InputWatch(IntPtr ptr)
: base(ptr)
{
}
private void Update()
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Expected O, but got Unknown
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Expected O, but got Unknown
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Expected O, but got Unknown
Seen();
try
{
Drag();
}
catch
{
}
try
{
Phone();
}
catch
{
}
try
{
KeepCursor();
}
catch
{
}
bool flag = default(bool);
try
{
PhotoOnTop();
}
catch (Exception ex)
{
if (photoErr++ < 3)
{
ManualLogSource l = Plugin.L;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(8, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PHOTO] ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
l.LogWarning(val);
}
}
try
{
KeepOnScreen();
}
catch (Exception ex2)
{
if (photoErr++ < 3)
{
ManualLogSource l2 = Plugin.L;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(9, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SCREEN] ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message);
}
l2.LogWarning(val);
}
}
try
{
CardTap.MenuPending();
}
catch (Exception ex3)
{
if (photoErr++ < 3)
{
ManualLogSource l3 = Plugin.L;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(7, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MENU] ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex3.Message);
}
l3.LogWarning(val);
}
}
try
{
CardTap.Resolve();
}
catch (Exception ex4)
{
if (photoErr++ < 3)
{
ManualLogSource l4 = Plugin.L;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(6, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[TAP] ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex4.Message);
}
l4.LogWarning(val);
}
}
try
{
CloseCard();
}
catch (Exception ex5)
{
if (cardErr++ < 3)
{
ManualLogSource l5 = Plugin.L;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(7, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[CARD] ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex5.Message);
}
l5.LogWarning(val);
}
}
if (Plugin.SelectUnderCursor.Value)
{
FollowCursor(OnBoard());
}
}
private static void KeepCursor()
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
if (Time.unscaledTime <= PadCursorUntil && OnBoard())
{
VirtualCursorController instance = VirtualCursorController.Instance;
if ((Object)(object)instance != (Object)null && !instance.isActive)
{
instance.TryActivateVirtualCursor((StartingMousePosition)0, (RectTransform)null);
}
}
else if (!(Time.unscaledTime > CursorUntil) && OnBoard())
{
InputController instance2 = InputController.Instance;
if ((Object)(object)instance2 != (Object)null && !instance2.cursorVisible)
{
instance2.SetCursorVisible(true);
}
if (!Cursor.visible)
{
Cursor.visible = true;
}
if ((int)Cursor.lockState != 0)
{
Cursor.lockState = (CursorLockMode)0;
}
try
{
InterfaceController.Instance.UpdateCursorSprite();
}
catch
{
}
}
}
internal static PinnedItemController? PhotoCard(List<MonoBehaviour>? over)
{
if (over == null || over.Count == 0)
{
return null;
}
MonoBehaviour val = over[over.Count - 1];
if ((Object)(object)val == (Object)null || (Object)(object)((Il2CppObjectBase)val).TryCast<EvidenceButtonController>() == (Object)null || (Object)(object)((Component)val).GetComponentInParent<InfoWindow>() != (Object)null)
{
return null;
}
return ((Component)val).GetComponentInParent<PinnedItemController>();
}
private static void PhotoOnTop()
{
if (!Plugin.PhotoFirst.Value || !OnBoard())
{
return;
}
InterfaceController instance = InterfaceController.Instance;
List<MonoBehaviour> val = (((Object)(object)instance != (Object)null) ? instance.currentMouseOverElement : null);
if (val == null || val.Count < 2)
{
return;
}
int num = -1;
for (int i = 0; i < val.Count; i++)
{
MonoBehaviour val2 = val[i];
if ((Object)(object)val2 != (Object)null && (Object)(object)((Il2CppObjectBase)val2).TryCast<EvidenceButtonController>() != (Object)null && (Object)(object)((Component)val2).GetComponentInParent<PinnedItemController>() != (Object)null)
{
num = i;
}
}
if (num >= 0 && num != val.Count - 1)
{
MonoBehaviour val3 = val[num];
val.RemoveAt(num);
val.Add(val3);
instance.UpdateCursorSprite();
if (Plugin.LogBlocked.Value && photoLogs++ < 200)
{
Plugin.L.LogInfo((object)"[PHOTO] photo put on top of its card");
}
}
}
private static void KeepOnScreen()
{
if (!Plugin.OnScreen.Value)
{
return;
}
InterfaceController instance = InterfaceController.Instance;
List<InfoWindow> val = (((Object)(object)instance != (Object)null) ? instance.activeWindows : null);
if (val == null)
{
return;
}
bool flag = Input.GetMouseButton(0);
try
{
if (Input.GetKey((KeyCode)330))
{
flag = true;
}
}
catch
{
}
if (flag)
{
lastHeld = Time.unscaledTime;
}
bool desktopMode = instance.desktopMode;
if (desktopMode && !wasOnBoard)
{
seenWindows.Clear();
}
wasOnBoard = desktopMode;
HashSet<IntPtr> hashSet = new HashSet<IntPtr>();
for (int i = 0; i < val.Count; i++)
{
InfoWindow val2 = val[i];
if ((Object)(object)val2 == (Object)null || (Object)(object)val2.rect == (Object)null)
{
continue;
}
IntPtr pointer = ((Il2CppObjectBase)val2).Pointer;
hashSet.Add(pointer);
if (!((Component)val2).gameObject.activeInHierarchy)
{
seenWindows.Remove(pointer);
continue;
}
if (!seenWindows.TryGetValue(pointer, out var value))
{
value = Time.frameCount;
seenWindows[pointer] = value;
}
if (!flag && !(Time.unscaledTime - lastHeld < 0.25f))
{
Fit(val2.rect);
}
}
if (seenWindows.Count <= hashSet.Count)
{
return;
}
foreach (IntPtr item in new List<IntPtr>(seenWindows.Keys))
{
if (!hashSet.Contains(item))
{
seenWindows.Remove(item);
}
}
}
private static void Fit(RectTransform r)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Expected O, but got Unknown
Canvas componentInParent = ((Component)r).GetComponentInParent<Canvas>();
if ((Object)(object)componentInParent == (Object)null)
{
return;
}
componentInParent = componentInParent.rootCanvas;
Camera val = (((int)componentInParent.renderMode == 0) ? null : componentInParent.worldCamera);
Il2CppStructArray<Vector3> val2 = new Il2CppStructArray<Vector3>(4L);
r.GetWorldCorners(val2);
float num = float.MaxValue;
float num2 = float.MaxValue;
float num3 = float.MinValue;
float num4 = float.MinValue;
for (int i = 0; i < 4; i++)
{
Vector2 val3 = RectTransformUtility.WorldToScreenPoint(val, ((Il2CppArrayBase<Vector3>)(object)val2)[i]);
num = Mathf.Min(num, val3.x);
num3 = Mathf.Max(num3, val3.x);
num2 = Mathf.Min(num2, val3.y);
num4 = Mathf.Max(num4, val3.y);
}
float num5 = Screen.width;
float num6 = Screen.height;
float num7 = num6 * 0.89f;
float num8 = num6 * 0.07f;
float num9 = num5 * 0.01f;
float num10 = 0f;
float num11 = 0f;
if (num3 > num5 - num9)
{
num10 = num5 - num9 - num3;
}
if (num + num10 < num9)
{
num10 = num9 - num;
}
if (num2 < num8)
{
num11 = num8 - num2;
}
if (num4 + num11 > num7)
{
num11 = num7 - num4;
}
if (Mathf.Abs(num10) < 1f && Mathf.Abs(num11) < 1f)
{
return;
}
RectTransform val4 = (((Object)(object)((Transform)r).parent != (Object)null) ? ((Il2CppObjectBase)((Transform)r).parent).TryCast<RectTransform>() : null);
if ((Object)(object)val4 == (Object)null)
{
if (Plugin.LogBlocked.Value && screenLogs++ < 100)
{
Plugin.L.LogInfo((object)"[SCREEN] card has no rect parent");
}
return;
}
Vector2 val5 = RectTransformUtility.WorldToScreenPoint(val, ((Transform)r).position);
Vector3 position = default(Vector3);
if (!RectTransformUtility.ScreenPointToWorldPointInRectangle(val4, val5 + new Vector2(num10, num11), val, ref position))
{
return;
}
((Transform)r).position = position;
if (Plugin.LogBlocked.Value && screenLogs++ < 100)
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[SCREEN] moved an opened card by (");
((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<float>(num10, "0");
((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(",");
((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<float>(num11, "0");
((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(") px");
}
l.LogInfo(val6);
}
}
private static void CloseCard()
{
if (!OnBoard())
{
if (Plugin.YClosesMapNotes.Value && YDown())
{
CloseMapOrNotes();
}
}
else
{
if (!Plugin.YClosesCard.Value && !Plugin.YClosesMapNotes.Value)
{
return;
}
bool num = YDown();
CardTap.KeepClosed();
if (num && Time.frameCount != lastCardFrame)
{
lastCardFrame = Time.frameCount;
if ((!Plugin.YClosesCard.Value || !CardTap.CloseMenu()) && (!Plugin.YClosesMapNotes.Value || !HideDesktopMap()) && Plugin.YClosesCard.Value)
{
CloseTopCard();
}
}
}
}
private static bool HideDesktopMap()
{
InterfaceController instance = InterfaceController.Instance;
if ((Object)(object)instance == (Object)null || !instance.showDesktopMap)
{
return false;
}
instance.SetShowDesktopMap(false, true);
if (Plugin.LogBlocked.Value)
{
Plugin.L.LogInfo((object)"[CARD] Y closed the map");
}
return true;
}
private static void CloseMapOrNotes()
{
if (Time.frameCount == mapNotesFrame)
{
return;
}
mapNotesFrame = Time.frameCount;
InterfaceController instance = InterfaceController.Instance;
MapController instance2 = MapController.Instance;
bool flag = false;
try
{
flag = (Object)(object)instance2 != (Object)null && (Object)(object)instance2.contentCanvas != (Object)null && ((Component)instance2.contentCanvas).gameObject.activeInHierarchy && ((Behaviour)instance2.contentCanvas).enabled;
}
catch
{
}
if (flag)
{
instance2.CloseMap(true);
if (Plugin.LogBlocked.Value)
{
Plugin.L.LogInfo((object)"[CARD] Y closed the map");
}
return;
}
InfoWindow val = null;
try
{
val = (((Object)(object)instance != (Object)null) ? instance.detectiveNotebook : null);
}
catch
{
}
if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy)
{
instance.ToggleNotebook("", false);
if (Plugin.LogBlocked.Value)
{
Plugin.L.LogInfo((object)"[CARD] Y closed the notebook");
}
}
}
private static bool YDown()
{
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Expected O, but got Unknown
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Expected O, but got Unknown
InputController instance = InputController.Instance;
if ((Object)(object)instance == (Object)null || instance.mouseInputMode)
{
return false;
}
Joystick val = null;
ControllerHelper controllers = ReInput.controllers;
int num = 0;
while (controllers != null && num < 8 && val == null)
{
val = controllers.GetJoystick(num);
num++;
}
if (val == null)
{
return false;
}
bool flag = default(bool);
if (yButton == -2)
{
yButton = -1;
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < ((Controller)val).buttonCount; i++)
{
string text = "";
try
{
text = ((Element)((Controller)val).Buttons[i]).elementIdentifier.name;
}
catch
{
}
stringBuilder.Append(i).Append('=').Append(text)
.Append(' ');
string text2 = text.Replace(" ", "").ToLowerInvariant();
if (yButton < 0)
{
switch (text2)
{
case "y":
case "ybutton":
case "buttony":
case "triangle":
yButton = i;
break;
}
}
}
if (yButton < 0 && ((Controller)val).buttonCount > 3)
{
yButton = 3;
}
if (Plugin.LogBlocked.Value)
{
ManualLogSource l = Plugin.L;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(28, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[CARD] pad buttons: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<StringBuilder>(stringBuilder);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("-> Y is ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(yButton);
}
l.LogInfo(val2);
}
}
bool flag2 = yButton >= 0 && ((Controller)val).GetButtonDown(yButton);
try
{
if (secondary == -2)
{
secondary = ReInput.mapping.GetActionId("Secondary");
if (Plugin.LogBlocked.Value)
{
ManualLogSource l2 = Plugin.L;
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(27, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[CARD] Secondary action is ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(secondary);
}
l2.LogInfo(val2);
}
}
if (!flag2 && secondary >= 0 && ReInput.players.GetPlayer(0).GetButtonDown(secondary))
{
flag2 = true;
}
}
catch
{
}
return flag2;
}
private static void CloseTopCard()
{
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Expected O, but got Unknown
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Expected O, but got Unknown
InterfaceController instance = InterfaceController.Instance;
bool flag = false;
StringBuilder stringBuilder = new StringBuilder();
List<MonoBehaviour> currentMouseOverElement = instance.currentMouseOverElement;
int num = 0;
while (currentMouseOverElement != null && num < currentMouseOverElement.Count)
{
MonoBehaviour val = currentMouseOverElement[num];
if (!((Object)(object)val == (Object)null))
{
stringBuilder.Append(((Object)val).name).Append(' ');
if ((Object)(object)((Component)val).GetComponentInParent<InfoWindow>() == (Object)null && (Object)(object)((Component)val).GetComponentInParent<PinnedItemController>() != (Object)null)
{
flag = true;
}
}
num++;
}
InfoWindow val2 = null;
List<InfoWindow> activeWindows = instance.activeWindows;
int num2 = ((activeWindows != null) ? (activeWindows.Count - 1) : (-1));
while (num2 >= 0 && (Object)(object)val2 == (Object)null)
{
InfoWindow val3 = activeWindows[num2];
if ((Object)(object)val3 != (Object)null && ((Component)val3).gameObject.activeInHierarchy && !val3.forceDisableClose)
{
val2 = val3;
}
num2--;
}
bool flag2 = default(bool);
if (Plugin.LogBlocked.Value && cardLogs++ < 30)
{
StringBuilder stringBuilder2 = new StringBuilder();
try
{
Player player = ReInput.players.GetPlayer(0);
for (int i = 0; i < 300; i++)
{
InputAction action = ReInput.mapping.GetAction(i);
if (action != null && player.GetButtonDown(i))
{
stringBuilder2.Append(action.name).Append(' ');
}
}
}
catch
{
}
ManualLogSource l = Plugin.L;
BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(61, 5, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[CARD] Y on the board: actions [");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<StringBuilder>(stringBuilder2);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] over [");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<StringBuilder>(stringBuilder);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("] open cards ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(activeWindows?.Count ?? 0);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(", top '");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)(object)val2 != (Object)null) ? ((Object)val2).name : "-");
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("'");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(flag ? ", over a pin: left to the game" : "");
}
l.LogInfo(val4);
}
if (flag)
{
CardTap.MenuSoon(PhotoCard(currentMouseOverElement));
}
else
{
if ((Object)(object)val2 == (Object)null)
{
return;
}
val2.CloseWindow(true);
if (Plugin.LogBlocked.Value)
{
ManualLogSource l2 = Plugin.L;
BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(16, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[CARD] closed '");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)val2).name);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("'");
}
l2.LogInfo(val4);
}
}
}
private static bool OnBoard()
{
try
{
InterfaceController instance = InterfaceController.Instance;
return (Object)(object)instance != (Object)null && instance.desktopMode;
}
catch
{
return false;
}
}
private static void Drag()
{
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
if (Time.unscaledTime < nextDrag || Plugin.DragThreshold.Value <= 0f)
{
return;
}
nextDrag = Time.unscaledTime + 1f;
EventSystem current = EventSystem.current;
if ((Object)(object)current == (Object)null)
{
return;
}
int num = Mathf.RoundToInt(Plugin.DragThreshold.Value * (float)Screen.height / 1080f);
if (current.pixelDragThreshold == num)
{
return;
}
if (Plugin.LogBlocked.Value)
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(25, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[FIX] drag threshold ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(current.pixelDragThreshold);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
}
l.LogInfo(val);
}
current.pixelDragThreshold = num;
}
private static void Phone()
{
if (!Plugin.PhoneLook.Value)
{
return;
}
InputController instance = InputController.Instance;
Player instance2 = Player.Instance;
if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null)
{
return;
}
int num = (instance.mouseInputMode ? 1 : 0);
if (lastMode != -1 && num != lastMode && instance2.phoneInteractable != null)
{
relock = 10;
lockedThisCall = true;
}
lastMode = num;
if (lockedThisCall && instance2.phoneInteractable == null)
{
lockedThisCall = false;
relock = 0;
instance2.EnablePlayerMouseLook(true, false);
if (Plugin.LogBlocked.Value)
{
Plugin.L.LogInfo((object)"[FIX] call over, view given back");
}
}
else
{
if (relock <= 0)
{
return;
}
relock--;
if (instance2.phoneInteractable == null)
{
relock = 0;
return;
}
instance2.EnablePlayerMouseLook(false, false);
if (relock == 0 && Plugin.LogBlocked.Value)
{
Plugin.L.LogInfo((object)"[FIX] kept the view still on the phone after an input switch");
}
}
}
private static void FollowCursor(bool board)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Expected O, but got Unknown
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
try
{
Vector3 val = Vector2.op_Implicit(CursorPos());
Vector3 val2 = val - lastMouse;
if (((Vector3)(ref val2)).sqrMagnitude > 1f)
{
lastMouse = val;
lastMove = Time.unscaledTime;
}
EventSystem current = EventSystem.current;
GameObject val3 = (((Object)(object)current != (Object)null) ? current.currentSelectedGameObject : null);
if ((Object)(object)val3 == (Object)null)
{
return;
}
bool flag = InPanel(val3);
bool flag2 = !flag && (Object)(object)val3.GetComponentInParent<InfoWindow>() != (Object)null;
if ((board && !flag && !flag2) || (Time.unscaledTime - lastMove > 2f && !flag && !flag2) || (Object)(object)val3.GetComponent<TMP_InputField>() != (Object)null || (Object)(object)val3.GetComponent<InputField>() != (Object)null || (Object)(object)val3.GetComponentInParent<TMP_Dropdown>() != (Object)null || (Object)(object)val3.GetComponentInParent<Dropdown>() != (Object)null || (Object)(object)val3.GetComponent<Scrollbar>() != (Object)null || ((Object)val3).name.StartsWith("Item "))
{
return;
}
RectTransform component = val3.GetComponent<RectTransform>();
if ((Object)(object)component == (Object)null)
{
return;
}
Canvas componentInParent = val3.GetComponentInParent<Canvas>();
Camera val4 = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null);
if (RectTransformUtility.RectangleContainsScreenPoint(component, CursorPos(), val4))
{
return;
}
current.SetSelectedGameObject((GameObject)null);
if (Plugin.LogBlocked.Value && logged++ < 300)
{
ManualLogSource l = Plugin.L;
bool flag3 = default(bool);
BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(53, 2, ref flag3);
if (flag3)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[FIX] dropped selection '");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)val3).name);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' (not under the cursor at ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<Vector2>(CursorPos());
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(")");
}
l.LogInfo(val5);
}
}
catch
{
}
}
private static bool InPanel(GameObject go)
{
try
{
InfoWindow componentInParent = go.GetComponentInParent<InfoWindow>();
return (Object)(object)componentInParent != (Object)null && (((Object)componentInParent).name.Contains("Keypad") || ((Object)componentInParent).name.Contains("Elevator") || ((Object)componentInParent).name.Contains("Telephone"));
}
catch
{
return false;
}
}
private static Vector2 CursorPos()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
try
{
VirtualCursorController instance = VirtualCursorController.Instance;
if ((Object)(object)instance != (Object)null && instance.isActive && (Object)(object)instance.mouse != (Object)null)
{
return instance.mouse.screenPosition;
}
}
catch
{
}
Vector3 mousePosition = Input.mousePosition;
return new Vector2(mousePosition.x, mousePosition.y);
}
internal static void Seen()
{
if (Input.anyKeyDown && LastDownFrame != Time.frameCount)
{
LastDownFrame = Time.frameCount;
LastDownTime = Time.unscaledTime;
Used = false;
}
}
internal static bool Allow(string what, int n)
{
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Expected O, but got Unknown
if (!Plugin.OnePressPerClick.Value)
{
return true;
}
if (Time.unscaledTime < AutoUntil)
{
return true;
}
Seen();
if (!Used && Time.unscaledTime - LastDownTime <= Plugin.ClickWindow.Value)
{
Used = true;
lastKey = what + n;
lastKeyTime = Time.unscaledTime;
lastKeyFrame = Time.frameCount;
return true;
}
bool flag = Time.frameCount == lastKeyFrame;
if (what + n != lastKey || Time.unscaledTime - lastKeyTime > 1f || (flag && what != "elevator"))
{
lastKey = what + n;
lastKeyTime = Time.unscaledTime;
lastKeyFrame = Time.frameCount;
return true;
}
if (Plugin.LogBlocked.Value)
{
ManualLogSource l = Plugin.L;
bool flag2 = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(60, 3, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[FIX] stopped a repeated ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(what);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" press of ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(n);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (last click ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Time.frameCount - LastDownFrame);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" frames ago)");
}
l.LogInfo(val);
}
return false;
}
}
[HarmonyPatch]
[HarmonyPatch]
internal static class CardTap
{
private static PinnedItemController? card;
private static float downTime;
private static bool moved;
private static bool opened;
private static bool pad;
private static int logs;
private static int releaseFrame = -1;
private static float pinnedAt = -10f;
private static PinnedItemController? menuCard;
private static int menuAsked = -1;
private static int menuOpened = -1;
private static int menuClosedAt = -10;
[HarmonyPostfix]
[HarmonyPatch(typeof(CasePanelController), "PinToCasePanel", new Type[]
{
typeof(Case),
typeof(Evidence),
typeof(List<DataKey>),
typeof(bool),
typeof(Vector2),
typeof(bool)
})]
private static void Pinned()
{
pinnedAt = Time.unscaledTime;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CasePanelController), "PinToCasePanel", new Type[]
{
typeof(Case),
typeof(Evidence),
typeof(DataKey),
typeof(bool),
typeof(Vector2),
typeof(bool)
})]
private static void PinnedOne()
{
pinnedAt = Time.unscaledTime;
}
internal static void MenuSoon(PinnedItemController? c)
{
if ((Object)(object)c != (Object)null)
{
menuCard = c;
menuAsked = Time.frameCount;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ButtonController), "OnRightClick")]
private static bool RightClick(ButtonController __instance)
{
if ((Object)(object)((Il2CppObjectBase)__instance).TryCast<EvidenceButtonController>() == (Object)null)
{
return true;
}
PinnedItemController componentInParent = ((Component)__instance).GetComponentInParent<PinnedItemController>();
if ((Object)(object)componentInParent == (Object)null || (Object)(object)((Component)__instance).GetComponentInParent<InfoWindow>() != (Object)null)
{
return true;
}
OpenMenu(componentInParent, "right-click on photo");
return false;
}
private static void OpenMenu(PinnedItemController c, string why)
{
if (menuOpened != Time.frameCount && !((Object)(object)c.contextMenu == (Object)null))
{
menuOpened = Time.frameCount;
c.contextMenu.OpenMenu();
Log(why + ": menu of '" + Name(c) + "'");
}
}
private static bool MenuOpen()
{
ContextMenuController activeMenu = ContextMenuController.activeMenu;
if ((Object)(object)activeMenu != (Object)null)
{
return (Object)(object)activeMenu.spawnedMenu != (Object)null;
}
return false;
}
internal static bool CloseMenu()
{
if (!MenuOpen())
{
return false;
}
ContextMenuController.activeMenu.ForceClose();
menuClosedAt = Time.frameCount;
menuCard = null;
Log("Y closed the menu");
return true;
}
internal static void KeepClosed()
{
if (Time.frameCount - menuClosedAt <= 2 && Time.frameCount != menuClosedAt && MenuOpen())
{
ContextMenuController.activeMenu.ForceClose();
Log("menu reopened by the same Y, closed again");
}
}
internal static void MenuPending()
{
if (!((Object)(object)menuCard == (Object)null) && Time.frameCount != menuAsked)
{
PinnedItemController c = menuCard;
menuCard = null;
if (menuOpened < menuAsked)
{
OpenMenu(c, "Y on photo");
}
}
}
private static void Log(string s)
{
if (Plugin.LogBlocked.Value && logs++ < 300)
{
Plugin.L.LogInfo((object)("[TAP] " + s));
}
}
private static string Name(PinnedItemController c)
{
try
{
return ((Object)(object)c.titleText != (Object)null) ? ((TMP_Text)c.titleText).text : "?";
}
catch
{
return "?";
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PinnedItemController), "OnPointerDown")]
private static void Down(PinnedItemController __instance, PointerEventData eventData)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.TapOpens.Value)
{
return;
}
if (eventData != null && (int)eventData.button != 0)
{
card = null;
return;
}
bool flag = false;
try
{
flag = __instance.isDragging;
}
catch
{
}
if (flag || Time.unscaledTime - pinnedAt < 1.5f)
{
card = null;
Log("press on '" + Name(__instance) + "' places a new pin, not a tap");
return;
}
card = __instance;
downTime = Time.unscaledTime;
moved = false;
opened = false;
releaseFrame = -1;
pad = !Input.GetMouseButton(0);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PinnedItemController), "ForceDrag")]
private static void Drag(PinnedItemController __instance)
{
if ((Object)(object)__instance == (Object)(object)card)
{
moved = true;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(EvidenceButtonController), "OnLeftClick")]
private static void PhotoClick(EvidenceButtonController __instance)
{
if ((Object)(object)card != (Object)null && (Object)(object)((Component)__instance).GetComponentInParent<PinnedItemController>() == (Object)(object)card)
{
opened = true;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PinnedPinButtonController), "OnLeftClick")]
private static bool PinClick(PinnedPinButtonController __instance)
{
if (!Plugin.TapOpens.Value)
{
return true;
}
PinnedItemController componentInParent = ((Component)__instance).GetComponentInParent<PinnedItemController>();
if ((Object)(object)componentInParent == (Object)null || (Object)(object)componentInParent != (Object)(object)card || moved || opened || componentInParent.isDragging)
{
return true;
}
if (!pad)
{
opened = true;
return true;
}
Open(componentInParent, "frame tap");
return false;
}
private static void Open(PinnedItemController c, string why)
{
opened = true;
EvidenceButtonController evidenceButton = c.evidenceButton;
if (!((Object)(object)evidenceButton == (Object)null))
{
((ButtonController)evidenceButton).OnLeftClick();
Log(why + ": opened '" + Name(c) + "'");
}
}
private static bool Held()
{
if (Input.GetMouseButton(0))
{
return true;
}
try
{
if (Input.GetKey((KeyCode)330))
{
return true;
}
}
catch
{
}
return false;
}
internal static void Resolve()
{
if ((Object)(object)card == (Object)null)
{
return;
}
if (Held())
{
if (Time.unscaledTime - downTime > 5f)
{
card = null;
}
return;
}
if (releaseFrame < 0)
{
releaseFrame = Time.frameCount;
}
if (Time.frameCount - releaseFrame < 2)
{
return;
}
PinnedItemController val = card;
card = null;
if (!moved && !opened && !((Object)(object)val == (Object)null) && !val.isDragging)
{
if (Time.unscaledTime - downTime > 1.5f)
{
Log("long press on '" + Name(val) + "' left alone");
}
else
{
Open(val, "tap that did nothing");
}
}
}
}
internal static class Presses
{
private static float lastFloorTime = -10f;
private static int lastFloorFrameDown = -1;
private static int lastFloor = int.MinValue;
private static float sliderAt = float.NaN;
private static FloorZoomController? zoom;
[HarmonyPatch(typeof(KeypadController), "OnInputCode")]
[HarmonyPrefix]
private static void SavedCode(List<int> code)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
int num = code?.Count ?? 4;
InputWatch.AutoUntil = Time.unscaledTime + 1.5f + (float)num * 0.6f;
if (Plugin.LogBlocked.Value)
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(66, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[FIX] game is entering a saved code (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" digits), presses let through");
}
l.LogInfo(val);
}
}
[HarmonyPatch(typeof(KeypadController), "PressNumberButton")]
[HarmonyPrefix]
private static bool Keypad(KeypadController __instance, int newInt)
{
return InputWatch.Allow(__instance.isTelephone ? "phone" : "keypad", newInt);
}
private static Slider? FloorSlider()
{
try
{
if ((Object)(object)zoom == (Object)null)
{
zoom = Object.FindObjectOfType<FloorZoomController>();
}
FloorZoomController? obj = zoom;
object result;
if (obj == null)
{
result = null;
}
else
{
SliderController floorSlider = obj.floorSlider;
result = ((floorSlider != null) ? floorSlider.slider : null);
}
return (Slider?)result;
}
catch
{
return null;
}
}
[HarmonyPatch(typeof(MapController), "SetFloorLayer")]
[HarmonyPrefix]
private static bool MapFloor(int newFloor, bool forceLoad)
{
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Expected O, but got Unknown
if (!Plugin.OnePressPerClick.Value || forceLoad)
{
return true;
}
InputWatch.Seen();
bool num = InputWatch.LastDownFrame == lastFloorFrameDown;
int num2 = newFloor - lastFloor;
if (num && (num2 == 1 || num2 == -1) && Time.unscaledTime - lastFloorTime < 0.5f)
{
Slider val = FloorSlider();
bool flag = false;
if ((Object)(object)val != (Object)null && !float.IsNaN(sliderAt) && Mathf.Abs(val.value - sliderAt) > 0.01f)
{
val.SetValueWithoutNotify(sliderAt);
flag = true;
try
{
zoom.floorSlider.UpdateDisplayValue();
}
catch
{
}
}
if (Plugin.LogBlocked.Value)
{
ManualLogSource l = Plugin.L;
bool flag2 = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(43, 2, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[FIX] stopped a repeated map floor step to ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(newFloor);
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(flag ? $", slider put back to {sliderAt}" : "");
}
l.LogInfo(val2);
}
return false;
}
lastFloorTime = Time.unscaledTime;
lastFloorFrameDown = InputWatch.LastDownFrame;
lastFloor = newFloor;
return true;
}
[HarmonyPatch(typeof(MapController), "SetFloorLayer")]
[HarmonyPostfix]
private static void MapFloorDone()
{
Slider val = FloorSlider();
if ((Object)(object)val != (Object)null)
{
sliderAt = val.value;
}
}
[HarmonyPatch(typeof(InputController), "SetMouseInputMode")]
[HarmonyPostfix]
private static void InputSwitched(InputController __instance, bool val)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
try
{
InterfaceController instance = InterfaceController.Instance;
if ((Object)(object)instance == (Object)null || !instance.desktopMode)
{
return;
}
if (!val)
{
InputWatch.CursorUntil = -10f;
InputWatch.PadCursorUntil = Time.unscaledTime + 1f;
VirtualCursorController instance2 = VirtualCursorController.Instance;
if ((Object)(object)instance2 != (Object)null && !instance2.isActive)
{
instance2.TryActivateVirtualCursor((StartingMousePosition)0, (RectTransform)null);
}
if (Plugin.LogBlocked.Value)
{
ManualLogSource l = Plugin.L;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(66, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[FIX] controller cursor switched on again on the case board (was ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)(object)instance2 != (Object)null && instance2.isActive) ? "on" : "off");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
}
l.LogInfo(val2);
}
return;
}
InputWatch.PadCursorUntil = -10f;
InputWatch.CursorUntil = Time.unscaledTime + 1f;
if (!__instance.cursorVisible)
{
__instance.SetCursorVisible(true);
__instance.SetCursorLock(false);
if (Plugin.LogBlocked.Value)
{
Plugin.L.LogInfo((object)"[FIX] mouse cursor shown again on the case board after switching to mouse");
}
}
}
catch
{
}
}
[HarmonyPatch(typeof(ElevatorControlsController), "PressNumberButton")]
[HarmonyPrefix]
private static bool Elevator(int newInt)
{
return InputWatch.Allow("elevator", newInt);
}
}
}