Decompiled source of EasyKey v1.2.0
EasyKey.dll
Decompiled 21 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.Json; using System.Text.RegularExpressions; using AskaShared.Game; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP.Utils; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using Microsoft.CodeAnalysis; using SSSGame; using SSSGame.Controllers; using SSSGame.Network; using SSSGame.UI; using SandSailorStudio; using SandSailorStudio.Attributes; using SandSailorStudio.Inventory; using SandSailorStudio.Localization; using SandSailorStudio.Storage; using SandSailorStudio.UI; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("EasyKey")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.0")] [assembly: AssemblyInformationalVersion("1.2.0+4c7a691b8d7d12b16689677ac9684b6aeb7d9e4a")] [assembly: AssemblyProduct("EasyKey")] [assembly: AssemblyTitle("EasyKey")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AskaEasyKey { [HarmonyPatch] public static class AutoMove { private const float PressThreshold = 0.5f; private const float InputPresentThreshold = 0.2f; private const float DominanceRatio = 1.2f; private const float NearMissWindows = 3f; private static int _driveId; private static bool _haveDrive; private static bool _failed; private static bool _sawPostfix; private static bool _sawRealInput; private static bool _tapping; private static Vector2 _tapPeak; private static float _tapPressTime; private static Vector2 _pendingTap; private static float _pendingPressTime; private static bool _engaged; private static bool _engagedSwimming; private static Vector2 _forced; private static int _frames; static AutoMove() { EasyKeyConfig.SwitchChanged += OnSwitchChanged; } private static void OnSwitchChanged(EasyKeySwitch which, bool on) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!on && which == EasyKeySwitch.AutoMoveOn) { Disengage(); _tapping = false; _pendingTap = Vector2.zero; } } internal static void OnLocalPlayerSpawned() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Disengage(); _tapping = false; _pendingTap = Vector2.zero; _haveDrive = false; Character localCharacter = LocalPlayerTool.LocalCharacter; PlayerDrive val = (((Object)(object)localCharacter == (Object)null) ? null : ((Component)localCharacter).GetComponentInChildren<PlayerDrive>()); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"AutoMove: the local character has no PlayerDrive, so double-tap to auto-move is off for this session."); return; } _driveId = ((Object)val).GetInstanceID(); _haveDrive = true; _failed = false; _sawPostfix = false; _sawRealInput = false; } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerDrive), "ReadInput")] public static void AfterReadInput(PlayerDrive __instance) { //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) if (!EasyKeyConfig.AutoMoveOn || _failed || !_haveDrive || (Object)(object)__instance == (Object)null || ((Object)__instance).GetInstanceID() != _driveId) { return; } bool flag = default(bool); if (!_sawPostfix) { _sawPostfix = true; ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(89, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AutoMove: the ReadInput postfix is running on the local drive, instance "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_driveId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Tap window "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(EasyKeyConfig.AutoMoveTapWindowMs.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ms."); } log.LogInfo(val); } try { Vector2 direction = __instance._direction; float magnitude = ((Vector2)(ref direction)).magnitude; if (_engaged && magnitude >= 0.2f) { ManualLogSource log2 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(89, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AutoMove off: movement input "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Format(direction)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" magnitude "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(magnitude, "F2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" after "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_frames); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" frames of "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name(_forced)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". That press is passed through."); } log2.LogInfo(val); Disengage(); } if (_engaged) { string text = CancelReason(__instance); if (text != null) { ManualLogSource log3 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AutoMove off: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" after "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_frames); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" frames of "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name(_forced)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log3.LogInfo(val); Disengage(); } } TrackTap(__instance, direction, magnitude); if (_engaged) { __instance._direction = _forced; _frames++; } } catch (Exception ex) { _failed = true; Disengage(); ManualLogSource log4 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(76, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("AutoMove: the ReadInput postfix threw "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(". Auto-move is off for this session."); } log4.LogError(val2); } } private static string CancelReason(PlayerDrive drive) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (Cursor.visible || (int)Cursor.lockState != 1) { return "a UI has focus, so the cursor is free"; } PlayerInteractionAgent playerInteractionAgent = drive._playerInteractionAgent; if ((Object)(object)playerInteractionAgent != (Object)null && (int)playerInteractionAgent.State != 0) { return $"an interaction is {playerInteractionAgent.State}"; } CharacterMovement characterMovement = drive._characterMovement; if (!((Object)(object)characterMovement != (Object)null) || !characterMovement.IsSwimming) { _engagedSwimming = false; } else if (!_engagedSwimming) { return "swimming started after the walk did"; } return null; } private static void TrackTap(PlayerDrive drive, Vector2 input, float magnitude) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_002d: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (!_tapping) { if (magnitude < 0.5f) { return; } if (!_sawRealInput) { _sawRealInput = true; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(99, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AutoMove: real movement input reaches the ReadInput postfix, first reading "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Format(input)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Tap detection is live."); } log.LogInfo(val); } _tapping = true; _tapPeak = input; _tapPressTime = Time.realtimeSinceStartup; } else if (magnitude >= 0.2f) { if (magnitude > ((Vector2)(ref _tapPeak)).magnitude) { _tapPeak = input; } } else { _tapping = false; CompleteTap(drive, Cardinal(_tapPeak), _tapPressTime); } } private static void CompleteTap(PlayerDrive drive, Vector2 cardinal, float pressTime) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) int value = EasyKeyConfig.AutoMoveTapWindowMs.Value; float num = (pressTime - _pendingPressTime) * 1000f; bool flag = _pendingTap != Vector2.zero; bool flag2 = flag && num <= (float)value * 3f; bool flag3 = default(bool); if (Plugin.DebugLogging) { ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(55, 3, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AutoMove: tap peak "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Format(_tapPeak)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" reads "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name(cardinal)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num, "F0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ms after the previous tap."); } log.LogInfo(val); } if (cardinal == Vector2.zero) { if (flag2) { ManualLogSource log2 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(102, 3, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AutoMove: tap peak "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Format(_tapPeak)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is diagonal and names no single direction, so the "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name(_pendingTap)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" tap "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num, "F0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ms before it is discarded."); } log2.LogInfo(val); } _pendingTap = Vector2.zero; return; } if (flag && _pendingTap == cardinal) { if (num <= (float)value) { Engage(drive, cardinal, num, value); return; } if (flag2) { ManualLogSource log3 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(86, 3, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AutoMove: second "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name(cardinal)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" tap arrived "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num, "F0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ms after the first and the window is "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ms. No auto-move."); } log3.LogInfo(val); } } _pendingTap = cardinal; _pendingPressTime = pressTime; } private static void Engage(PlayerDrive drive, Vector2 cardinal, float gapMs, int window) { //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_0010: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) _pendingTap = Vector2.zero; _engaged = true; _forced = cardinal; _frames = 0; CharacterMovement characterMovement = drive._characterMovement; _engagedSwimming = (Object)(object)characterMovement != (Object)null && characterMovement.IsSwimming; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(77, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AutoMove on: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name(cardinal)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Format(cardinal)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", two taps "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(gapMs, "F0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ms apart inside a "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(window); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ms window. Swimming at engage: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(_engagedSwimming); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); } private static void Disengage() { //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) _engaged = false; _engagedSwimming = false; _forced = Vector2.zero; _frames = 0; } private static Vector2 Cardinal(Vector2 v) { //IL_0000: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Abs(v.x); float num2 = Mathf.Abs(v.y); if (num > num2 * 1.2f) { return new Vector2(Mathf.Sign(v.x), 0f); } if (num2 > num * 1.2f) { return new Vector2(0f, Mathf.Sign(v.y)); } return Vector2.zero; } private static string Name(Vector2 cardinal) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0039: Unknown result type (might be due to invalid IL or missing references) if (cardinal == Vector2.zero) { return "no direction"; } if (cardinal.y > 0f) { return "forward"; } if (cardinal.y < 0f) { return "back"; } if (!(cardinal.x > 0f)) { return "left"; } return "right"; } private static string Format(Vector2 v) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) return $"({v.x:F2}, {v.y:F2})"; } } [HarmonyPatch] public static class DropAllStacks { private static bool _dropping; internal static void DropAll(ItemThumbnailPanel slot) { SameTypeStacks sameTypeStacks = SameTypeStacks.Of(slot); if (sameTypeStacks != null) { DropOne(slot); DropRemainingStacks(sameTypeStacks); } } internal static void DropOne(ItemThumbnailPanel slot) { _dropping = true; try { slot.CommandDropItem(); } finally { _dropping = false; } } [HarmonyPrefix] [HarmonyPatch(typeof(ItemThumbnailPanel), "CommandDropItem")] public static void BeforeCommandDropItem(ItemThumbnailPanel __instance, out SameTypeStacks __state) { __state = null; if (EasyKeyConfig.DropAllModifierOn && !_dropping && MeansAllStacks()) { __state = SameTypeStacks.Of(__instance); } } [HarmonyPostfix] [HarmonyPatch(typeof(ItemThumbnailPanel), "CommandDropItem")] public static void AfterCommandDropItem(SameTypeStacks __state) { if (__state != null) { DropRemainingStacks(__state); } } private static bool MeansAllStacks() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return Input.GetKey(EasyKeyConfig.DropAllModifier.Value); } private static void DropRemainingStacks(SameTypeStacks stacks) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown List<ItemThumbnailPanel> list = stacks.OtherPanels(); int num = 1; int num2 = 0; _dropping = true; try { foreach (ItemThumbnailPanel item2 in list) { if (!stacks.StillHolds(item2, out var _)) { num2++; continue; } item2.CommandDropItem(); num++; } } finally { _dropping = false; } ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(50, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DropAll: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" stacks of "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(stacks.ItemName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" dropped. candidates="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(list.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" skipped="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num2); } log.LogInfo(val); } } internal static class DropSomeItems { internal static void DropSome(SameTypeStacks stacks, int count) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown Character localCharacter = LocalPlayerTool.LocalCharacter; CharacterInventory val = (((Object)(object)localCharacter == (Object)null) ? null : ((Component)localCharacter).GetComponent<CharacterInventory>()); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"DropSome: the local character has no CharacterInventory, so nothing was dropped."); return; } bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2; if (!val.IsReady()) { ManualLogSource log = Plugin.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(71, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("DropSome: 0 of "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(stacks.ItemName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" dropped. The inventory is busy with another operation."); } log.LogInfo(val2); return; } List<ItemThumbnailPanel> list = stacks.ClickedFirst(); int num = 0; int num2 = 0; int num3 = 0; for (int i = 0; i < list.Count; i++) { if (num >= count) { break; } ItemThumbnailPanel panel = list[i]; if (!stacks.StillHolds(panel, out var item)) { num3++; continue; } int num4 = Math.Min(count - num, item.count); val.SelectItem(item, num4); num += num4; if (i == 0) { num2 = num4; } } string text = $"candidates={list.Count} skipped={num3}"; if (!Drop(val)) { val.DeselectAll(); ManualLogSource log2 = Plugin.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(88, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("DropSome: 0 of "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(stacks.ItemName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" dropped. The game refused the drop of "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", and the selection was cleared. "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text); } log2.LogInfo(val2); return; } ManualLogSource log3 = Plugin.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(50, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("DropSome: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" of "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(stacks.ItemName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" dropped, "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" from the clicked stack. "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text); } log3.LogInfo(val2); } private static bool Drop(CharacterInventory inventory) { return inventory.DropSelectedItems(false); } } internal static class EasyKeyConfig { private const string Section = "Easy Key"; private static readonly EasyKeySwitch[] AllSwitches = (EasyKeySwitch[])Enum.GetValues(typeof(EasyKeySwitch)); private static readonly bool[] State = new bool[AllSwitches.Length]; private static bool _snapshotBuilt; internal static ConfigEntry<bool> Enabled { get; private set; } internal static ConfigEntry<bool> DropAllModifierEnabled { get; private set; } internal static ConfigEntry<bool> InstantMultiPickupEnabled { get; private set; } internal static ConfigEntry<bool> TapGatherEnabled { get; private set; } internal static ConfigEntry<bool> TapHarvestEnabled { get; private set; } internal static ConfigEntry<bool> TapBuildEnabled { get; private set; } internal static ConfigEntry<bool> TapRepairEnabled { get; private set; } internal static ConfigEntry<bool> TapDrinkEnabled { get; private set; } internal static ConfigEntry<bool> TapFireEnabled { get; private set; } internal static ConfigEntry<bool> AutoWorkshopsEnabled { get; private set; } internal static ConfigEntry<bool> AutoRotateEnabled { get; private set; } internal static ConfigEntry<bool> AutoQuenchEnabled { get; private set; } internal static ConfigEntry<bool> TapToolSwapEnabled { get; private set; } internal static ConfigEntry<bool> AutoMoveEnabled { get; private set; } internal static ConfigEntry<bool> HoldPromptStripEnabled { get; private set; } internal static ConfigEntry<bool> ItemMenuEnabled { get; private set; } internal static ConfigEntry<bool> EnhancedDialogEnabled { get; private set; } internal static ConfigEntry<bool> LoadScreenEnabled { get; private set; } internal static ConfigEntry<KeyCode> MenuTriggerKey { get; private set; } internal static ConfigEntry<KeyCode> MenuTriggerModifier { get; private set; } internal static ConfigEntry<KeyCode> DropAllModifier { get; private set; } internal static ConfigEntry<int> AutoMoveTapWindowMs { get; private set; } internal static ConfigEntry<float> MultiPickupRadius { get; private set; } internal static bool MasterEnabled => State[0]; internal static bool DropAllModifierOn => State[1]; internal static bool InstantMultiPickupOn => State[2]; internal static bool TapGatherOn => State[3]; internal static bool TapHarvestOn => State[4]; internal static bool TapBuildOn => State[5]; internal static bool TapRepairOn => State[6]; internal static bool TapDrinkOn => State[7]; internal static bool TapFireOn => State[8]; internal static bool AutoWorkshopsOn => State[9]; internal static bool AutoRotateOn => State[10]; internal static bool AutoQuenchOn => State[11]; internal static bool TapToolSwapOn => State[12]; internal static bool AutoMoveOn => State[13]; internal static bool HoldPromptStripOn => State[14]; internal static bool ItemMenuOn => State[15]; internal static bool EnhancedDialogOn => State[16]; internal static bool LoadScreenOn => State[17]; internal static event Action<EasyKeySwitch, bool> SwitchChanged; internal static bool IsOn(EasyKeySwitch which) { return State[(int)which]; } internal static void Init(ConfigFile file) { Enabled = file.Bind<bool>("Easy Key", "Enabled", true, "Master on/off switch for this mod."); DropAllModifierEnabled = file.Bind<bool>("Easy Key", "DropAllModifierEnabled", true, "Let DropAllModifier plus the game's drop key on an item drop every stack of that item's type at once."); InstantMultiPickupEnabled = file.Bind<bool>("Easy Key", "InstantMultiPickupEnabled", true, "Put pick-up-everything-nearby on E as a single press, and retire the single-item pickup."); TapGatherEnabled = file.Bind<bool>("Easy Key", "TapGatherEnabled", true, "Gather on one press: the first press starts gathering and it continues with the key released, the second press stops it."); TapHarvestEnabled = file.Bind<bool>("Easy Key", "TapHarvestEnabled", true, "Chop and mine on one press: the first press starts the action and it continues with the key released, the second press stops it."); TapBuildEnabled = file.Bind<bool>("Easy Key", "TapBuildEnabled", true, "Build on one press: the first press starts hammering and it continues with the key released, the second press stops it."); TapRepairEnabled = file.Bind<bool>("Easy Key", "TapRepairEnabled", true, "Repair a damaged structure or boat on one press: the first press starts repairing and it continues with the key released, the second press stops it. Rebuild and salvage are unchanged."); TapDrinkEnabled = file.Bind<bool>("Easy Key", "TapDrinkEnabled", true, "Drink from a well or water source on one press: the first press starts drinking and it continues with the key released, the second press stops it, and it stops by itself when thirst is quenched."); TapFireEnabled = file.Bind<bool>("Easy Key", "TapFireEnabled", true, "Light or put out a fire on one press: the first press starts it and it continues with the key released, the second press stops it, and it ends by itself when the fire catches or goes out."); AutoWorkshopsEnabled = file.Bind<bool>("Easy Key", "AutoWorkshopsEnabled", true, "Automate the hold work at workshops. At the anvil and the woodworking bench, one press starts the work and it continues with the key released, and a second press stops it."); AutoRotateEnabled = file.Bind<bool>("Easy Key", "AutoRotateEnabled", true, "Wherever a worked piece must be turned to reach every side, such as the anvil and the woodworking bench, turn it to the next side by itself as each side is finished, using the game's own turn rule, so you never press the rotate key."); AutoQuenchEnabled = file.Bind<bool>("Easy Key", "AutoQuenchEnabled", true, "At the anvil and woodworking bench, quench the piece by itself once every side is finished, so you never press the quench key."); TapToolSwapEnabled = file.Bind<bool>("Easy Key", "TapToolSwapEnabled", true, "When a tap needs a different tool, keep the action alive until the tool is in hand so one tap still starts it."); AutoMoveEnabled = file.Bind<bool>("Easy Key", "AutoMoveEnabled", true, "Double-tap a movement key to walk in that direction until any movement key is pressed or the context changes."); HoldPromptStripEnabled = file.Bind<bool>("Easy Key", "HoldPromptStripEnabled", true, "Remove the stray 'Hold' word from the prompt of interactions this mod turns into one tap (harvest, gather, build, repair, fire, anvil). The key and label stay; real holds keep their word."); ItemMenuEnabled = file.Bind<bool>("Easy Key", "ItemMenuEnabled", true, "Open a menu of move and drop actions on an item slot with MenuTriggerKey."); EnhancedDialogEnabled = file.Bind<bool>("Easy Key", "EnhancedDialogEnabled", true, "In dialogs where you type a name, password or count, start with the field ready to type and its text selected, and confirm with Enter."); LoadScreenEnabled = file.Bind<bool>("Easy Key", "LoadScreenEnabled", true, "On the load screen, a click, Space or controller confirm on the selected save keeps it selected, so the Load button stays, and a double-click on a save starts it."); DropAllModifier = file.Bind<KeyCode>("Easy Key", "DropAllModifier", (KeyCode)306, "The modifier held while pressing the game's drop key to drop every stack of a type. Held drops all; the plain drop key still drops one. LeftControl also crouches and is a menu click modifier in the game; both firing is harmless."); AutoMoveTapWindowMs = file.Bind<int>("Easy Key", "AutoMoveTapWindowMs", 300, "How long, in milliseconds, the second tap of a movement key has to arrive to count as a double-tap."); MenuTriggerKey = file.Bind<KeyCode>("Easy Key", "MenuTriggerKey", (KeyCode)325, "The key or mouse button that opens the item menu on the item slot under the cursor. Mouse2 is the middle button. Mouse1, the right button, opens the menu on a quick click in place of the game's stack move, and a held right-click still adds the item to the quickbar. Any other key the game already uses in the inventory, such as the drop key, runs both actions."); MenuTriggerModifier = file.Bind<KeyCode>("Easy Key", "MenuTriggerModifier", (KeyCode)0, "A key that must be held with MenuTriggerKey to open the item menu, such as LeftControl. None needs no modifier."); MultiPickupRadius = file.Bind<float>("Easy Key", "MultiPickupRadius", 25f, "How far, in meters, pick-up-everything-nearby reaches from the item you aim at, measured along the ground. 0 keeps the game's own reach."); Rebuild(); _snapshotBuilt = true; file.SettingChanged += OnSettingChanged; file.ConfigReloaded += OnConfigReloaded; } internal static string DescribeSwitches() { string[] array = new string[AllSwitches.Length]; for (int i = 0; i < AllSwitches.Length; i++) { array[i] = $"{AllSwitches[i]}={State[i]}"; } return string.Join(", ", array); } private static void OnSettingChanged(object sender, SettingChangedEventArgs args) { Rebuild(); } private static void OnConfigReloaded(object sender, EventArgs args) { Rebuild(); } private static void Rebuild() { //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Expected O, but got Unknown bool value = Enabled.Value; bool[] array = new bool[AllSwitches.Length]; array[0] = value; array[1] = value && DropAllModifierEnabled.Value; array[2] = value && InstantMultiPickupEnabled.Value; array[3] = value && TapGatherEnabled.Value; array[4] = value && TapHarvestEnabled.Value; array[5] = value && TapBuildEnabled.Value; array[6] = value && TapRepairEnabled.Value; array[7] = value && TapDrinkEnabled.Value; array[8] = value && TapFireEnabled.Value; array[9] = value && AutoWorkshopsEnabled.Value; array[10] = value && AutoRotateEnabled.Value; array[11] = value && AutoQuenchEnabled.Value; array[12] = value && TapToolSwapEnabled.Value; array[13] = value && AutoMoveEnabled.Value; array[14] = value && HoldPromptStripEnabled.Value; array[15] = value && ItemMenuEnabled.Value; array[16] = value && EnhancedDialogEnabled.Value; array[17] = value && LoadScreenEnabled.Value; List<EasyKeySwitch> list = null; for (int i = 0; i < array.Length; i++) { if (State[i] != array[i]) { State[i] = array[i]; if (_snapshotBuilt) { (list ?? (list = new List<EasyKeySwitch>())).Add(AllSwitches[i]); } } } if (list == null) { return; } bool flag2 = default(bool); foreach (EasyKeySwitch item in list) { bool flag = State[(int)item]; ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(11, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Easy Key"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<EasyKeySwitch>(item); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is now "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(flag ? "on" : "off"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); EasyKeyConfig.SwitchChanged?.Invoke(item, flag); } } } internal enum EasyKeySwitch { MasterEnabled, DropAllModifierOn, InstantMultiPickupOn, TapGatherOn, TapHarvestOn, TapBuildOn, TapRepairOn, TapDrinkOn, TapFireOn, AutoWorkshopsOn, AutoRotateOn, AutoQuenchOn, TapToolSwapOn, AutoMoveOn, HoldPromptStripOn, ItemMenuOn, EnhancedDialogOn, LoadScreenOn } public class EasyKeyTool : MonoBehaviour { private void Start() { AutoMove.OnLocalPlayerSpawned(); PickupSlots.OnLocalPlayerSpawned(); } private void Update() { PickupSlots.Tick(); if (EasyKeyConfig.MasterEnabled) { TapToWork.Tick(); ItemMenu.Tick(); } } } internal static class EntryDialog { private const string Prefix = "[EntryDialog]"; private const float ReEditDelaySeconds = 0.3f; private const int FocusWaitFrames = 10; private static readonly Action<string> SubmitListener = OnSubmit; private static readonly Action<string> EndEditListener = OnEndEdit; private static readonly HashSet<IntPtr> Wired = new HashSet<IntPtr>(); private static readonly HashSet<string> Reported = new HashSet<string>(); private static ConfirmActionMenu _menu; private static TMP_InputField _field; private static Action _beginEdit; private static int _cancelledFrame = -1000; internal static void Attach(ConfirmActionMenu menu, TMP_InputField field, Action beginEdit) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)MenuManager.CurrentInputMode == 2) { return; } if ((Object)(object)field == (Object)null) { ReportOnce(menu, "has no input field"); return; } if ((Object)(object)ConfirmButton(menu) == (Object)null) { ReportOnce(menu, "has no Confirm button"); return; } _menu = menu; _field = field; _beginEdit = beginEdit; if (Wired.Add(((Il2CppObjectBase)field).Pointer)) { ((UnityEvent<string>)(object)field.onSubmit).AddListener(DelegateSupport.ConvertDelegate<UnityAction<string>>((Delegate)SubmitListener)); ((UnityEvent<string>)(object)field.onEndEdit).AddListener(DelegateSupport.ConvertDelegate<UnityAction<string>>((Delegate)EndEditListener)); } MonoBehaviourExtensions.StartCoroutine((MonoBehaviour)(object)menu, BeginEditWhenSelected(menu)); } private static IEnumerator BeginEditWhenSelected(ConfirmActionMenu menu) { for (int waited = 0; waited < 10; waited++) { if (!Holds("Open", () => IsTracked(menu) && !SelectionInside(menu))) { break; } yield return null; } Guard("Open", delegate { if (IsTracked(menu)) { _beginEdit(); } }); } private static bool IsTracked(ConfirmActionMenu menu) { if ((Object)(object)menu != (Object)null && (Object)(object)_menu != (Object)null && ((Il2CppObjectBase)menu).Pointer == ((Il2CppObjectBase)_menu).Pointer) { return (Object)(object)_field != (Object)null; } return false; } private static bool SelectionInside(ConfirmActionMenu menu) { EventSystem current = EventSystem.current; GameObject val = (((Object)(object)current == (Object)null) ? null : current.currentSelectedGameObject); if ((Object)(object)val != (Object)null) { return val.transform.IsChildOf(((Component)menu).transform); } return false; } internal static bool EscapeUsed() { return Time.frameCount - _cancelledFrame <= 1; } internal static void Guard(string where, Action action) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown try { action(); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(48, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[EntryDialog]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(where); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" threw; the dialog keeps the game's behaviour: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } log.LogError(val); } } private static bool Holds(string where, Func<bool> test) { bool result = false; Guard(where, delegate { result = test(); }); return result; } private static void OnSubmit(string text) { if (!EasyKeyConfig.EnhancedDialogOn) { return; } Guard("Enter", delegate { ConfirmActionMenu menu = _menu; if (IsOpen(menu)) { MonoBehaviourExtensions.StartCoroutine((MonoBehaviour)(object)menu, ConfirmAfterEdit(menu, _field.caretPosition)); } }); } private static IEnumerator ConfirmAfterEdit(ConfirmActionMenu menu, int caret) { yield return null; bool refused = false; Guard("Enter", delegate { if (IsOpen(menu)) { Button val = ConfirmButton(menu); if ((Object)(object)val != (Object)null && ((Selectable)val).IsInteractable()) { ((UnityEvent)val.onClick).Invoke(); } else { refused = true; } } }); if (!refused) { yield break; } float until = Time.unscaledTime + 0.3f; while (Time.unscaledTime < until) { yield return null; } if (!Holds("Re-edit", () => IsOpen(menu))) { yield break; } Guard("Re-edit", delegate { _beginEdit(); }); for (int i = 0; i < 10; i++) { if (!Holds("Re-edit", () => IsOpen(menu) && !_field.isFocused)) { break; } yield return null; } Guard("Re-edit", delegate { if (IsOpen(menu) && _field.isFocused) { _field.caretPosition = caret; } }); } private static void OnEndEdit(string text) { if (!EasyKeyConfig.EnhancedDialogOn) { return; } Guard("Escape", delegate { ConfirmActionMenu menu = _menu; if (IsOpen(menu) && _field.wasCanceled) { _cancelledFrame = Time.frameCount; ((Menu)menu).OnBackPressed(); } }); } private static bool IsOpen(ConfirmActionMenu menu) { if (IsTracked(menu)) { return ((Menu)menu).IsActive; } return false; } private static Button ConfirmButton(ConfirmActionMenu menu) { if (!((Object)(object)menu.ConfirmButton == (Object)null)) { return ((Component)menu.ConfirmButton).GetComponent<Button>(); } return null; } private static void ReportOnce(ConfirmActionMenu menu, string problem) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown string name = ((MemberInfo)((Object)menu).GetIl2CppType()).Name; if (Reported.Add(name + problem)) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[EntryDialog]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(problem); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", so it keeps the game's behaviour."); } log.LogError(val); } } } [HarmonyPatch] public static class EntryDialogPatches { [HarmonyPostfix] [HarmonyPatch(typeof(InputFieldConfirmActionMenu), "OnActivate")] public static void AfterTextDialogActivate(InputFieldConfirmActionMenu __instance) { if (!EasyKeyConfig.EnhancedDialogOn) { return; } EntryDialog.Guard("Open", delegate { InputFieldHelper helper = __instance.InputFieldHelper; EntryDialog.Attach((ConfirmActionMenu)(object)__instance, ((Object)(object)helper == (Object)null) ? null : helper.inputField, delegate { BeginTextEdit(helper); }); }); } [HarmonyPostfix] [HarmonyPatch(typeof(ConfirmActionMenu), "OnActivate")] public static void AfterConfirmDialogActivate(ConfirmActionMenu __instance) { if (!EasyKeyConfig.EnhancedDialogOn) { return; } EntryDialog.Guard("Open", delegate { ItemSplitMenu val = ((Il2CppObjectBase)__instance).TryCast<ItemSplitMenu>(); if (!((Object)(object)val == (Object)null)) { TMP_InputField field = (((Object)(object)val.increaseDecreasePanel == (Object)null) ? null : val.increaseDecreasePanel.InputField); EntryDialog.Attach((ConfirmActionMenu)(object)val, field, delegate { BeginSplitEdit(field); }); } }); } [HarmonyPrefix] [HarmonyPatch(typeof(MenuManager), "BackPressTopMenu")] public static bool BeforeBackPressTopMenu() { if (EasyKeyConfig.EnhancedDialogOn) { return !EntryDialog.EscapeUsed(); } return true; } private static void BeginTextEdit(InputFieldHelper helper) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown helper.OnPointerClick(new PointerEventData(EventSystem.current)); } private static void BeginSplitEdit(TMP_InputField field) { EventSystem.current.SetSelectedGameObject(((Component)field).gameObject); field.ActivateInputField(); } } [HarmonyPatch] public static class HoldPromptStrip { private static string _word; private static bool _wordResolved; [HarmonyPostfix] [HarmonyPatch(typeof(PlayerHarvestInteractionSession), "RefreshWidgetData")] public static void HarvestRefresh(PlayerHarvestInteractionSession __instance, IInteractionWidgetProvider interactWidget) { Strip(TapToWork.KindOn("harvest"), (Il2CppObjectBase)(object)__instance, interactWidget); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerHarvestInteractionSession), "SetupWidget")] public static void HarvestSetup(PlayerHarvestInteractionSession __instance, IInteractionWidgetProvider interactWidget) { Strip(TapToWork.KindOn("harvest"), (Il2CppObjectBase)(object)__instance, interactWidget); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerGatherInteractionSession), "RefreshWidgetData")] public static void GatherRefresh(PlayerGatherInteractionSession __instance, IInteractionWidgetProvider interactWidget) { Strip(GatherPromptsTap(__instance), (Il2CppObjectBase)(object)__instance, interactWidget); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerGatherInteractionSession), "SetupWidget")] public static void GatherSetup(PlayerGatherInteractionSession __instance, IInteractionWidgetProvider interactWidget) { Strip(GatherPromptsTap(__instance), (Il2CppObjectBase)(object)__instance, interactWidget); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerBuildInteractionSession), "RefreshWidgetData")] public static void BuildRefresh(PlayerBuildInteractionSession __instance, IInteractionWidgetProvider interactWidget) { Strip(TapToWork.KindOn("build"), (Il2CppObjectBase)(object)__instance, interactWidget); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerBuildInteractionSession), "SetupWidget")] public static void BuildSetup(PlayerBuildInteractionSession __instance, IInteractionWidgetProvider interactWidget) { Strip(TapToWork.KindOn("build"), (Il2CppObjectBase)(object)__instance, interactWidget); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerRepairInteractionSession), "RefreshWidgetData")] public static void RepairRefresh(PlayerRepairInteractionSession __instance, IInteractionWidgetProvider interactWidget) { Strip(TapToWork.KindOn("repair"), (Il2CppObjectBase)(object)__instance, interactWidget); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerRepairInteractionSession), "SetupWidget")] public static void RepairSetup(PlayerRepairInteractionSession __instance, IInteractionWidgetProvider interactWidget) { Strip(TapToWork.KindOn("repair"), (Il2CppObjectBase)(object)__instance, interactWidget); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerFireInteractionSession), "RefreshWidgetData")] public static void FireRefresh(PlayerFireInteractionSession __instance, IInteractionWidgetProvider interactWidget) { Strip(TapToWork.KindOn("fire"), (Il2CppObjectBase)(object)__instance, interactWidget); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerFireInteractionSession), "SetupWidget")] public static void FireSetup(PlayerFireInteractionSession __instance, IInteractionWidgetProvider interactWidget) { Strip(TapToWork.KindOn("fire"), (Il2CppObjectBase)(object)__instance, interactWidget); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerAnvilInteractionSession), "RefreshWidgetData")] public static void AnvilRefresh(PlayerAnvilInteractionSession __instance, IInteractionWidgetProvider interactWidget) { Strip(TapToWork.KindOn("anvil"), (Il2CppObjectBase)(object)__instance, interactWidget); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerAnvilInteractionSession), "SetupWidget")] public static void AnvilSetup(PlayerAnvilInteractionSession __instance, IInteractionWidgetProvider interactWidget) { Strip(TapToWork.KindOn("anvil"), (Il2CppObjectBase)(object)__instance, interactWidget); } private static bool GatherPromptsTap(PlayerGatherInteractionSession session) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown if (session == null || !TapToWork.KindOn("gather")) { return false; } try { GatherInteraction gatherInteraction = session.GatherInteraction; return (Object)(object)gatherInteraction == (Object)null || !gatherInteraction.AllowsUseMode || TapToWork.KindOn("drink"); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(89, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("HoldPromptStrip: reading the gather interaction threw "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". The prompt keeps its Hold word."); } log.LogWarning(val); return false; } } private static void Strip(bool tapOn, Il2CppObjectBase session, IInteractionWidgetProvider provider) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown if (!tapOn || !EasyKeyConfig.HoldPromptStripOn) { return; } try { IInteractionWidgetUser val = ((session == null) ? null : session.TryCast<IInteractionWidgetUser>()); InteractWidget val2 = ((provider == null) ? null : ((Il2CppObjectBase)provider).TryCast<InteractWidget>()); if (val == null || (Object)(object)val2 == (Object)null) { return; } Dictionary<IInteractionWidgetUser, Dictionary<int, ValueTuple<InteractSlot, InteractSlot>>> interactions = val2._interactions; if (interactions == null || !interactions.ContainsKey(val)) { return; } Dictionary<int, ValueTuple<InteractSlot, InteractSlot>> val3 = interactions[val]; if (val3 != null) { Enumerator<int, ValueTuple<InteractSlot, InteractSlot>> enumerator = val3.GetEnumerator(); while (enumerator.MoveNext()) { ValueTuple<InteractSlot, InteractSlot> value = enumerator.Current.Value; StripSlot(value.Item1); StripSlot(value.Item2); } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(19, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("HoldPromptStrip: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message); } log.LogWarning(val4); } } private static void StripSlot(InteractSlot slot) { if ((Object)(object)slot == (Object)null || !slot._requiresHold) { return; } TMP_Text keyText = slot.keyText; if ((Object)(object)keyText == (Object)null) { return; } string text = keyText.text; if (string.IsNullOrEmpty(text)) { return; } string text2 = HoldWord(); if (!string.IsNullOrEmpty(text2) && text.IndexOf(text2, StringComparison.Ordinal) >= 0) { string text3 = Regex.Replace(text.Replace(text2, ""), "\\s+", " ").Trim(); if (text3 != text) { keyText.text = text3; } } } private static string HoldWord() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown if (_wordResolved) { return _word; } _wordResolved = true; try { LocalizationManager instance = LocalizationManager.Instance; if ((Object)(object)instance != (Object)null) { string text = instance.Loc("misc.ui_hold_format", false); if (!string.IsNullOrEmpty(text)) { _word = text.Replace("{0}", "").Trim(); } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(43, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("HoldPromptStrip: hold word lookup threw: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); } if (string.IsNullOrEmpty(_word)) { _word = "Hold"; } return _word; } } internal static class ItemMenu { private const string Prefix = "[ItemMenu]"; private static GameObject _root; private static RectTransform _panel; private static Camera _camera; private static ItemThumbnailPanel _slot; private static IntPtr _item; private static Menu _host; private static bool _hadHost; internal static void Tick() { if (!EasyKeyConfig.ItemMenuOn) { return; } if ((Object)(object)_root != (Object)null && !StillValid()) { Close(); } if (TriggerPressed()) { ItemThumbnailPanel val = SlotUnderCursor(); if ((Object)(object)val != (Object)null && val.Item != null) { Open(val); return; } } if ((Object)(object)_root != (Object)null && (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) && !OverPanel()) { Close(); } } private static bool TriggerPressed() { //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_0011: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) KeyCode value = EasyKeyConfig.MenuTriggerKey.Value; if ((int)value == 324 || !Input.GetKeyDown(value)) { return false; } return ModifierHeld(); } internal static bool ModifierHeld() { //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_000e: Unknown result type (might be due to invalid IL or missing references) KeyCode value = EasyKeyConfig.MenuTriggerModifier.Value; if ((int)value != 0) { return Input.GetKey(value); } return true; } internal static void OpenOn(ItemThumbnailPanel slot) { if ((Object)(object)slot != (Object)null && slot.Item != null) { Open(slot); } } private static bool StillValid() { if ((Object)(object)_slot == (Object)null || SameTypeStacks.PointerOf((Il2CppObjectBase)(object)_slot.Item) != _item) { return false; } if (!_hadHost) { return true; } if ((Object)(object)_host != (Object)null) { return ((Component)_host).gameObject.activeInHierarchy; } return false; } private static ItemThumbnailPanel SlotUnderCursor() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown EventSystem current = EventSystem.current; if ((Object)(object)current == (Object)null) { return null; } PointerEventData val = new PointerEventData(current) { position = Vector2.op_Implicit(Input.mousePosition) }; List<RaycastResult> val2 = new List<RaycastResult>(); current.RaycastAll(val, val2); Enumerator<RaycastResult> enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { GameObject gameObject = enumerator.Current.gameObject; if (!((Object)(object)gameObject == (Object)null)) { if ((Object)(object)_panel != (Object)null && gameObject.transform.IsChildOf((Transform)(object)_panel)) { return null; } ItemThumbnailPanel componentInParent = gameObject.GetComponentInParent<ItemThumbnailPanel>(); if ((Object)(object)componentInParent != (Object)null) { return componentInParent; } } } return null; } private static void Open(ItemThumbnailPanel slot) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Expected O, but got Unknown Close(); Canvas componentInParent = ((Component)slot).GetComponentInParent<Canvas>(); if ((Object)(object)componentInParent == (Object)null) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(55, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("[ItemMenu]"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" the slot has no Canvas above it; the menu cannot open."); } log.LogWarning(val); return; } GameObject val2 = ButtonTemplate(); if ((Object)(object)val2 == (Object)null) { return; } componentInParent = componentInParent.rootCanvas; _camera = (((int)componentInParent.renderMode == 0) ? null : componentInParent.worldCamera); _slot = slot; _item = SameTypeStacks.PointerOf((Il2CppObjectBase)(object)slot.Item); _host = ((Component)slot).GetComponentInParent<Menu>(); _hadHost = (Object)(object)_host != (Object)null; _root = new GameObject("EasyKeyItemMenu"); RectTransform val3 = _root.AddComponent<RectTransform>(); ((Transform)val3).SetParent(((Component)componentInParent).transform, false); val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; val3.offsetMin = Vector2.zero; val3.offsetMax = Vector2.zero; ((Transform)val3).SetAsLastSibling(); ((Graphic)_root.AddComponent<Image>()).color = Color.clear; GameObject val4 = new GameObject("Panel"); _panel = val4.AddComponent<RectTransform>(); ((Transform)_panel).SetParent((Transform)(object)val3, false); _panel.anchorMin = new Vector2(0.5f, 0.5f); _panel.anchorMax = new Vector2(0.5f, 0.5f); _panel.pivot = new Vector2(0f, 1f); Vector2 anchoredPosition = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(val3, Vector2.op_Implicit(Input.mousePosition), _camera, ref anchoredPosition); _panel.anchoredPosition = anchoredPosition; ((Graphic)val4.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.85f); VerticalLayoutGroup obj = val4.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)obj).spacing = 4f; ((LayoutGroup)obj).padding = new RectOffset(6, 6, 6, 6); ContentSizeFitter obj2 = val4.AddComponent<ContentSizeFitter>(); obj2.horizontalFit = (FitMode)2; obj2.verticalFit = (FitMode)2; Action<ItemThumbnailPanel> move; bool num = MoveHost(slot, out move); int num2 = SameTypeStacks.Of(slot)?.Total() ?? 0; if (num) { AddEntry(val2, ModStrings.Get("menu.move"), Move); AddEntry(val2, ModStrings.Get("menu.moveAll"), MoveAll); if (num2 > 1) { AddEntry(val2, ModStrings.Get("menu.moveSome"), MoveSome); } } AddEntry(val2, ModStrings.Get("menu.drop"), Drop); AddEntry(val2, ModStrings.Get("menu.dropAll"), DropAll); if (num2 > 1) { AddEntry(val2, ModStrings.Get("menu.dropSome"), DropSome); } FitEntries(); } private static void AddEntry(GameObject template, string label, Action action) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(template, (Transform)(object)_panel, false); val.SetActive(true); TMP_Text componentInChildren = val.GetComponentInChildren<TMP_Text>(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.text = label; } Button component = val.GetComponent<Button>(); if ((Object)(object)component == (Object)null) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(61, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("[ItemMenu]"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" the cloned button has no UnityEngine.UI.Button; components: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Describe(val)); } log.LogError(val2); } else { component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)action)); } } private static void FitEntries() { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) List<RectTransform> list = new List<RectTransform>(); List<TMP_Text> list2 = new List<TMP_Text>(); float num = 0f; for (int i = 0; i < ((Transform)_panel).childCount; i++) { RectTransform val = ((Il2CppObjectBase)((Transform)_panel).GetChild(i)).TryCast<RectTransform>(); TMP_Text val2 = (((Object)(object)val == (Object)null) ? null : ((Component)val).GetComponentInChildren<TMP_Text>(true)); if (!((Object)(object)val2 == (Object)null)) { val2.ForceMeshUpdate(false, false); num = Mathf.Max(num, val2.fontSize); list.Add(val); list2.Add(val2); } } float num2 = 0f; for (int j = 0; j < list.Count; j++) { TMP_Text val3 = list2[j]; val3.enableAutoSizing = false; val3.fontSize = num; Rect rect = list[j].rect; float width = ((Rect)(ref rect)).width; rect = val3.rectTransform.rect; float num3 = width - ((Rect)(ref rect)).width + EndCaps(list[j]); float[] obj = new float[3] { num2, 0f, 0f }; rect = list[j].rect; obj[1] = ((Rect)(ref rect)).width; obj[2] = val3.preferredWidth + num3; num2 = Mathf.Max(obj); } foreach (RectTransform item in list) { item.SetSizeWithCurrentAnchors((Axis)0, num2); } } private static float EndCaps(RectTransform entry) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0043: Unknown result type (might be due to invalid IL or missing references) Image component = ((Component)entry).GetComponent<Image>(); if ((Object)(object)component == (Object)null || (Object)(object)component.sprite == (Object)null || component.multipliedPixelsPerUnit <= 0f) { return 0f; } Vector4 border = component.sprite.border; return (border.x + border.z) / component.multipliedPixelsPerUnit; } private static GameObject ButtonTemplate() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown MenuManager instance = MenuManager.Instance; ItemSplitMenu val = (((Object)(object)instance == (Object)null) ? null : instance.GetPrefab<ItemSplitMenu>()); RectTransform val2 = (((Object)(object)val == (Object)null) ? null : ((ConfirmActionMenu)val).ConfirmButton); if ((Object)(object)val2 == (Object)null) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(73, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>("[ItemMenu]"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" the ItemSplitMenu confirm button is not available; the menu cannot open."); } log.LogError(val3); return null; } return ((Component)val2).gameObject; } private static bool MoveHost(ItemThumbnailPanel slot, out Action<ItemThumbnailPanel> move) { move = null; StorageMenu componentInParent = ((Component)slot).GetComponentInParent<StorageMenu>(); if ((Object)(object)componentInParent != (Object)null) { if ((Object)(object)componentInParent.GetDestinationContainer(slot.parent, slot, true) == (Object)null) { return false; } move = componentInParent.SwitchContainer; return true; } TradeTabPage componentInParent2 = ((Component)slot).GetComponentInParent<TradeTabPage>(); if ((Object)(object)componentInParent2 != (Object)null) { if ((Object)(object)componentInParent2.GetDestinationContainer(slot.parent, slot, true) == (Object)null) { return false; } move = componentInParent2.SwitchContainer; return true; } return false; } private static ItemContainer MoveTarget(ItemThumbnailPanel slot) { StorageMenu componentInParent = ((Component)slot).GetComponentInParent<StorageMenu>(); if ((Object)(object)componentInParent != (Object)null) { ItemContainer val = ContainerOf(componentInParent.GetDestinationContainer(slot.parent, slot, true)); if (val == null || !val.canAddItems) { return null; } return val; } TradeTabPage componentInParent2 = ((Component)slot).GetComponentInParent<TradeTabPage>(); if (!((Object)(object)componentInParent2 == (Object)null)) { return ContainerOf(componentInParent2.GetDestinationContainer(slot.parent, slot, true)); } return null; } private static ItemContainer ContainerOf(BaseContainerPanel panel) { if (!((Object)(object)panel == (Object)null)) { return panel.Container; } return null; } private static void Move() { ItemThumbnailPanel slot = _slot; Close(); if ((Object)(object)slot != (Object)null && MoveHost(slot, out var move)) { move(slot); } } private static void MoveAll() { ItemThumbnailPanel slot = _slot; Close(); if ((Object)(object)slot != (Object)null && MoveHost(slot, out var move)) { MoveAllStacks.MoveAll(slot, move); } } private static void MoveSome() { ItemThumbnailPanel slot = _slot; Close(); if ((Object)(object)slot != (Object)null) { AskCount(slot, delegate(SameTypeStacks stacks, int count) { MoveSomeItems.MoveSome(stacks, count, MoveTarget); }); } } private static void Drop() { ItemThumbnailPanel slot = _slot; Close(); if ((Object)(object)slot != (Object)null) { DropAllStacks.DropOne(slot); } } private static void DropAll() { ItemThumbnailPanel slot = _slot; Close(); if ((Object)(object)slot != (Object)null) { DropAllStacks.DropAll(slot); } } private static void DropSome() { ItemThumbnailPanel slot = _slot; Close(); if ((Object)(object)slot != (Object)null) { AskCount(slot, DropSomeItems.DropSome); } } private static void AskCount(ItemThumbnailPanel slot, Action<SameTypeStacks, int> act) { SameTypeStacks stacks = SameTypeStacks.Of(slot); int num = ((stacks != null) ? stacks.Total() : 0); if (num >= 1) { SplitDialog.Open(slot.Item, num, delegate(int count) { act(stacks, count); }); } } private static bool OverPanel() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_panel != (Object)null) { return RectTransformUtility.RectangleContainsScreenPoint(_panel, Vector2.op_Implicit(Input.mousePosition), _camera); } return false; } internal static void Close() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _root = null; _panel = null; _slot = null; _item = IntPtr.Zero; _host = null; _hadHost = false; } private static string Describe(GameObject target) { List<string> list = new List<string>(); foreach (Component componentsInChild in target.GetComponentsInChildren<Component>(true)) { if ((Object)(object)componentsInChild != (Object)null) { list.Add(((Object)componentsInChild.gameObject).name + ":" + ((MemberInfo)((Object)componentsInChild).GetIl2CppType()).Name); } } return string.Join(", ", list); } } [HarmonyPatch] public static class ItemMenuRightClick { private static bool _modifierAtPress; [HarmonyPrefix] [HarmonyPatch(typeof(ItemThumbnailPanel), "OnCustomAction1")] public static bool BeforeCustomAction1(ItemThumbnailPanel __instance, CustomActionEventData eventData) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 if (!EasyKeyConfig.ItemMenuOn || (int)EasyKeyConfig.MenuTriggerKey.Value != 324 || eventData == null) { return true; } if (!eventData.IsTap) { _modifierAtPress = ItemMenu.ModifierHeld(); return true; } if (!Input.GetMouseButtonUp(1) || (!_modifierAtPress && !ItemMenu.ModifierHeld())) { return true; } _modifierAtPress = false; try { ItemMenu.OpenOn(__instance); } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(66, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ItemMenu] opening on right-click threw; the stack was not moved: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } log.LogError(val); } return false; } } [HarmonyPatch] public static class LoadScreen { private const float DoubleClickWindow = 0.5f; private const float LaunchDeadline = 5f; private static IntPtr _savesGroup; private static HostTabPage _page; private static Button _playButton; private static GameObject _playButtonObject; private static string _lastClickSession; private static float _lastClickAt; private static string _pendingSession; private static float _pendingAt; private static bool _launched; [HarmonyPostfix] [HarmonyPatch(typeof(HostTabPage), "Show")] public static void AfterShow(HostTabPage __instance, bool value) { ToggleGroup savesToggleGroup = __instance.savesToggleGroup; IntPtr intPtr = (((Object)(object)savesToggleGroup == (Object)null) ? IntPtr.Zero : ((Il2CppObjectBase)savesToggleGroup).Pointer); if (!value) { if (intPtr == _savesGroup) { _savesGroup = IntPtr.Zero; } return; } _savesGroup = intPtr; _page = __instance; _playButton = __instance.playButton; _playButtonObject = ((Component)_playButton).gameObject; _lastClickSession = null; _launched = false; if (_pendingSession != null) { DropPending("the load screen was shown again"); } if ((Object)(object)((Component)__instance).gameObject.GetComponent<LoadScreenTicker>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<LoadScreenTicker>(); } } [HarmonyPrefix] [HarmonyPatch(typeof(Toggle), "OnPointerClick")] public static bool BeforePointerClick(Toggle __instance, PointerEventData eventData) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!EasyKeyConfig.LoadScreenOn || !IsSaveRow(__instance)) { return true; } if (eventData != null && (int)eventData.button == 0) { NoteLeftClick(__instance); } if (!__instance.isOn) { return true; } return false; } [HarmonyPrefix] [HarmonyPatch(typeof(Toggle), "OnSubmit")] public static bool BeforeSubmit(Toggle __instance) { if (!EasyKeyConfig.LoadScreenOn || !IsSaveRow(__instance) || !__instance.isOn) { return true; } return false; } internal static void Tick() { if (EasyKeyConfig.LoadScreenOn && _pendingSession != null) { if (Time.realtimeSinceStartup - _pendingAt > 5f) { DropPending("5 s passed without that save selected and the Load button showing"); } else if (_playButtonObject.activeSelf && !(SelectedSession() != _pendingSession)) { _pendingSession = null; _launched = true; ((UnityEvent)_playButton.onClick).Invoke(); } } } internal static void ClearPending() { _lastClickSession = null; _pendingSession = null; } private static bool IsSaveRow(Toggle toggle) { if (_savesGroup == IntPtr.Zero) { return false; } ToggleGroup val = toggle.group; if ((Object)(object)val != (Object)null) { return ((Il2CppObjectBase)val).Pointer == _savesGroup; } return false; } private static void NoteLeftClick(Toggle toggle) { SaveSlotPanel componentInParent = ((Component)toggle).GetComponentInParent<SaveSlotPanel>(); string text = (((Object)(object)componentInParent == (Object)null) ? null : componentInParent.sessionID); if (string.IsNullOrEmpty(text)) { return; } float realtimeSinceStartup = Time.realtimeSinceStartup; if (text != _lastClickSession || realtimeSinceStartup - _lastClickAt > 0.5f) { _lastClickSession = text; _lastClickAt = realtimeSinceStartup; return; } _lastClickSession = null; if (!_launched) { _pendingSession = text; _pendingAt = realtimeSinceStartup; } } private static void DropPending(string reason) { _pendingSession = null; } private static string SelectedSession() { SessionData selectedSessionData = _page.SelectedSessionData; if (selectedSessionData != null) { return selectedSessionData.metadata.sessionId; } return null; } } public class LoadScreenTicker : MonoBehaviour { private void Update() { LoadScreen.Tick(); } } internal static class MoveAllStacks { internal static void MoveAll(ItemThumbnailPanel slot, Action<ItemThumbnailPanel> move) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown SameTypeStacks sameTypeStacks = SameTypeStacks.Of(slot); if (sameTypeStacks == null) { return; } Item item = slot.Item; IntPtr beforeContainer = SameTypeStacks.PointerOf((Il2CppObjectBase)(object)item.Container); int count = item.count; move(slot); bool flag = default(bool); if (!Moved(item, beforeContainer, count)) { ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(64, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("MoveAll: 0 stacks of "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(sameTypeStacks.ItemName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" moved. The game refused the clicked stack."); } log.LogInfo(val); return; } List<ItemThumbnailPanel> list = sameTypeStacks.OtherPanels(); int num = 1; int num2 = 0; bool flag2 = false; foreach (ItemThumbnailPanel item3 in list) { if (!sameTypeStacks.StillHolds(item3, out var item2)) { num2++; continue; } IntPtr beforeContainer2 = SameTypeStacks.PointerOf((Il2CppObjectBase)(object)item2.Container); int count2 = item2.count; move(item3); if (!Moved(item2, beforeContainer2, count2)) { flag2 = true; break; } num++; } string text = $" candidates={list.Count} skipped={num2}"; if (flag2) { ManualLogSource log2 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(80, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("MoveAll: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" stacks of "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(sameTypeStacks.ItemName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" moved. The game refused the next one, so the rest stay put."); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); } log2.LogInfo(val); } else { ManualLogSource log3 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("MoveAll: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" stacks of "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(sameTypeStacks.ItemName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" moved."); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); } log3.LogInfo(val); } } private static bool Moved(Item item, IntPtr beforeContainer, int beforeCount) { if (item == null) { return true; } if (SameTypeStacks.PointerOf((Il2CppObjectBase)(object)item.Container) != beforeContainer) { return true; } return item.count < beforeCount; } } internal static class MoveSomeItems { internal static void MoveSome(SameTypeStacks stacks, int count, Func<ItemThumbnailPanel, ItemContainer> destinationOf) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown List<ItemThumbnailPanel> list = stacks.ClickedFirst(); int num = 0; int num2 = 0; int num3 = 0; bool flag = false; for (int i = 0; i < list.Count; i++) { if (num >= count) { break; } ItemThumbnailPanel val = list[i]; if (!stacks.StillHolds(val, out var item)) { num3++; continue; } int num4 = Math.Min(count - num, item.count); ItemContainer val2 = destinationOf(val); int num5 = ((val2 != null) ? val2.Inventory.AddItems(item, num4, val2, (List<Item>)null) : 0); num += num5; if (i == 0) { num2 = num5; } if (num5 < num4) { flag = true; break; } } string text = (flag ? " The destination took less than asked, so the rest stay put." : string.Empty); ManualLogSource log = Plugin.Log; bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(68, 7, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("MoveSome: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" of "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(stacks.ItemName); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" moved, "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num2); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" from the clicked stack."); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" candidates="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(list.Count); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" skipped="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num3); } log.LogInfo(val3); } } [HarmonyPatch] public static class PickupRadius { private const int LoggedInstances = 3; private static int _queriesWidened; [HarmonyPrefix] [HarmonyPatch(typeof(MultiInteractionProxy), "FindAllInteractionsAround")] public static void BeforeFind(MultiInteractionProxy __instance, out float __state) { __state = float.NaN; float value = EasyKeyConfig.MultiPickupRadius.Value; if (EasyKeyConfig.MasterEnabled && !(value <= 0f) && !((Object)(object)__instance == (Object)null)) { NetworkInteractionTable interactionTable = __instance._interactionTable; if (!((Object)(object)interactionTable == (Object)null)) { __state = interactionTable.multiInteractionRange; interactionTable.multiInteractionRange = value * 2f; } } } [HarmonyPostfix] [HarmonyPatch(typeof(MultiInteractionProxy), "FindAllInteractionsAround")] public static void AfterFind(MultiInteractionProxy __instance, float __state) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if (float.IsNaN(__state) || (Object)(object)__instance == (Object)null) { return; } NetworkInteractionTable interactionTable = __instance._interactionTable; if ((Object)(object)interactionTable == (Object)null) { return; } interactionTable.multiInteractionRange = __state; _queriesWidened++; if (_queriesWidened <= 3) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(95, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("PickupRadius: found "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(interactionTable.multiInteractionItems?.Count ?? (-1)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" items within "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(EasyKeyConfig.MultiPickupRadius.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" m (game diameter "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(__state); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" m). "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("The game takes at most "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(interactionTable.maxInteractablesCountPerMultiInteraction); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" per press (#"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_queriesWidened); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log.LogInfo(val); } } } [HarmonyPatch] public static class PickupSlots { private const int LoggedInstances = 3; private const int ItemsPerFrame = 20; private static int _proxiesPromoted; private static int _pickupsRetired; private static PlayerMultiInteractionConfig _holdConfig; private static bool _holdInputOriginal; private static bool _holdInputCleared; private static readonly List<(MultiInteractionProxy Proxy, PickupInteraction Pickup)> Proxies; private static readonly List<Interaction> Touched; private static PlayerInteractionAgent _agent; private static IInteractionAgent _agentKey; private static IntPtr _agentPointer; private static bool _rewriting; private static bool _target; private static int _cursor; private static int _pruneCursor; private static bool _resyncHold; private static int _items; private static int _pickupsMoved; private static int _released; private static int _sessions; private static int _frames; private static double _holdMs; private static double _itemsMs; private static double _touchMs; private static double _slowestMs; private static bool On => EasyKeyConfig.InstantMultiPickupOn; private static bool SessionHold { get { if (!_holdInputCleared) { return _holdInputOriginal; } return false; } } static PickupSlots() { Proxies = new List<(MultiInteractionProxy, PickupInteraction)>(); Touched = new List<Interaction>(); EasyKeyConfig.SwitchChanged += OnSwitchChanged; } private static void OnSwitchChanged(EasyKeySwitch changed, bool on) { if (changed == EasyKeySwitch.InstantMultiPickupOn) { BeginRewrite(on); } } internal static void OnLocalPlayerSpawned() { Touched.Clear(); _agent = LocalAgent(); _agentKey = (((Object)(object)_agent == (Object)null) ? null : ((Il2CppObjectBase)_agent).TryCast<IInteractionAgent>()); _agentPointer = ((_agentKey == null) ? IntPtr.Zero : ((Il2CppObjectBase)_agentKey).Pointer); if (_agentKey == null) { Plugin.Log.LogWarning((object)"PickupSlots: no PlayerInteractionAgent on the local player at spawn, so a pickup switch change cannot release the focused item."); } } private static void BeginRewrite(bool on) { long timestamp = Stopwatch.GetTimestamp(); _target = on; _cursor = 0; _rewriting = true; _items = 0; _pickupsMoved = 0; _released = 0; _frames = 0; _itemsMs = 0.0; _touchMs = 0.0; _slowestMs = 0.0; bool holdInputCleared = _holdInputCleared; if (on) { ClearHoldInputOnce(); } else { RestoreHoldInput(); } _sessions = 0; if (_holdInputCleared != holdInputCleared) { _resyncHold = true; if ((Object)(object)_agent != (Object)null) { _sessions = SetSessionHold(_agent, SessionHold); } } _holdMs = Ms(timestamp); } internal static void Tick() { if (!_rewriting) { return; } long timestamp = Stopwatch.GetTimestamp(); for (int i = 0; i < 20; i++) { if (_cursor >= Proxies.Count) { break; } (MultiInteractionProxy, PickupInteraction) tuple = Proxies[_cursor]; if ((Object)(object)tuple.Item1 == (Object)null) { int index = Proxies.Count - 1; Proxies[_cursor] = Proxies[index]; Proxies.RemoveAt(index); } else { Rewrite(tuple.Item1, tuple.Item2); _cursor++; } } _frames++; _itemsMs += Ms(timestamp); if (_cursor >= Proxies.Count) { FinishRewrite(); } _slowestMs = Math.Max(_slowestMs, Ms(timestamp)); if (!_rewriting) { LogRewrite(); } } private static void PruneSome() { if (_rewriting) { return; } for (int i = 0; i < 2; i++) { if (Proxies.Count <= 0) { break; } if (_pruneCursor >= Proxies.Count) { _pruneCursor = 0; } if ((Object)(object)Proxies[_pruneCursor].Proxy != (Object)null) { _pruneCursor++; continue; } int index = Proxies.Count - 1; Proxies[_pruneCursor] = Proxies[index]; Proxies.RemoveAt(index); } } private static void Rewrite(MultiInteractionProxy proxy, PickupInteraction pickup) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) bool flag = IsTouched((Interaction)(object)proxy); bool flag2 = pickup != null && IsTouched((Interaction)(object)pickup); long since = ((flag || flag2) ? Stopwatch.GetTimestamp() : 0); if (flag) { ((Interaction)proxy)._OnPickableTouch(_agentKey, false); } if (flag2) { ((Interaction)pickup)._OnPickableTouch(_agentKey, false); } ((Interaction)proxy).order = ProxySlot(_target); if (pickup != null && MovePickup((Interaction)(object)pickup, _target)) { _pickupsMoved++; } if (flag || flag2) { if (_resyncHold && (Object)(object)_agent != (Object)null) { SetSessionHold(_agent, SessionHold); } if (flag) { ((Interaction)proxy)._OnPickableTouch(_agentKey, true); } if (flag2) { ((Interaction)pickup)._OnPickableTouch(_agentKey, true); } _released += (flag ? 1 : 0) + (flag2 ? 1 : 0); _touchMs += Ms(since); } _items++; } private static void FinishRewrite() { long timestamp = Stopwatch.GetTimestamp(); if (_resyncHold && (Object)(object)_agent != (Object)null) { SetSessionHold(_agent, SessionHold); } _resyncHold = false; _rewriting = false; _holdMs += Ms(timestamp); } private static void LogRewrite() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(233, 11, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("PickupSlots: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_target ? "multi-pickup on E" : "single pickup on E"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_items); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" items in "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_frames); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" frames of up to "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(20); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("moved "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_pickupsMoved); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" pickups, released and reattached "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_released); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" touched interactions, set usesHoldInput on "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_sessions); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" sessions. "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Hold flag and sessions "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(_holdMs, "F1"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ms, items "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(_itemsMs, "F1"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ms of which release and reattach "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(_touchMs, "F1"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ms, slowest frame "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(_slowestMs, "F1"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ms."); } log.LogInfo(val); } private static double Ms(long since) { return (double)(Stopwatch.GetTimestamp() - since) * 1000.0 / (double)Stopwatch.Frequency; } private static bool IsTouched(Interaction interaction) { IntPtr pointer = ((Il2CppObjectBase)interaction).Pointer; for (int i = 0; i < Touched.Count; i++) { if (((Il2CppObjectBase)Touched[i]).Pointer == pointer) { return interaction.IsTouchedByAgent(_agentKey); } } return false; } private static InteractionOrder ProxySlot(bool on) { if (on) { return (InteractionOrder)0; } return (InteractionOrder)2; } private static bool MovePickup(Interaction pickup, bool on) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 if ((int)pickup.order != ((!on) ? 8 : 0)) { return false; } pickup.order = (InteractionOrder)(on ? 8 : 0); return true; } [HarmonyPostfix] [HarmonyPatch(typeof(Interaction), "_OnPickableTouch")] public static void AfterPickableTouch(Interaction __instance, IInteractionAgent agent, bool touch) { if (agent == null || ((Il2CppObjectBase)agent).Pointer != _agentPointer || _agentPointer == IntPtr.Zero) { return; } IntPtr pointer = ((Il2CppObjectBase)__instance).Pointer; for (int num = Touched.Count - 1; num >= 0; num--) { Interaction val = Touched[num]; if (((Il2CppObjectBase)val).Pointer == pointer || (Object)(object)val == (Object)null || !val.IsTouchedByAgent(_agentKey)) { Touched.RemoveAt(num); } } if (touch) { Touched.Add(__instance); } } private static int SetSessionHold(PlayerInteractionAgent agent, bool hold) { int num = 0; Dictionary<InteractionConfiguration, List<InteractionSession>> sessionsPools = agent._sessionsPools; if (sessionsPools != null) { Enumerator<InteractionConfiguration, List<InteractionSession>> enumerator = sessionsPools.GetEnumerator(); while (enumerator.MoveNext()) { List<InteractionSession> value = enumerator.Current.Value; if (value != null) { for (int i = 0; i < value.Count; i++) { num += SetHold(value[i], hold); } } } } List<InteractionSession> sessionsClearPendingList = agent._sessionsClearPendingList; if (sessionsClearPendingList != null) { for (int j = 0; j < sessionsClearPendingList.Count; j++) { num += SetHold(sessionsClearPendingList[j], hold); } } return num; } private static int SetHold(InteractionSession session, bool hold) { PlayerMultiInteractionSession val = ((session == null) ? null : ((Il2CppObjectBase)session).TryCast<PlayerMultiInteractionSession>()); if (val == null) { return 0; } val.usesHoldInput = hol