using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Notiffy.API; using NukeLib.Game; using NukeLib.UI; using NukeLib.Utils; using TMPro; using ThornClient.Core; using ThornClient.Core.ConfigurableElements; using ThornClient.Core.DataTypes; using ThornClient.HUD; using ThornClient.HUD.HUDComponents; using ThornClient.Managers; using ThornClient.Modules.Utility; using ThornClient.Patches; using ThornClient.System; using ThornClient.System.ClickGUIComponents; using UnityEngine; using UnityEngine.AddressableAssets; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ThornClient")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+db84fde6ff0fea005b6ecad8063809958db7c7f9")] [assembly: AssemblyProduct("ThornClient")] [assembly: AssemblyTitle("ThornClient")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ThornClient { [BepInPlugin("com.github.end-4.thornClient", "Thorn", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; public static string workingPath = Assembly.GetExecutingAssembly().Location; public static string workingDir = Path.GetDirectoryName(workingPath); public const string PluginGUID = "com.github.end-4.thornClient"; public const string PluginName = "Thorn"; public const string PluginVersion = "0.1.0"; public static string PluginIconPath = Path.Combine(workingDir, "icon.png"); public static Plugin Instance { get; private set; } private void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; if (!((Object)(object)Instance != (Object)null)) { Instance = this; AssetManager.Initialize(); HudManager.Initialize(); EffectManager.Initialize(); ModuleManager.Initialize(); RenderManager.Initialize(); ConfigManager.LoadAll(); ConfigManager.SetupFileWatcher(); new Harmony("com.github.end-4.thornClient").PatchAll(typeof(OptionsManagerPatches)); Log.LogInfo((object)"Thorn is loaded"); } } private void Update() { ConfigManager.UpdateMainThreadQueue(); InputManager.Update(); foreach (ThornClient.Core.Module item in ModuleManager.Items) { if (item.IsEnabled) { try { item.OnUpdate(); } catch (Exception ex) { NotificationSystem.NotifySend("Thorn > " + item.Name, "Error in update loop of " + item.Name + ", disabling to prevent further issues. Check the logs for further details.", (Sprite)null, PluginIconPath, (Urgency)1, "Thorn", 0u, (Dictionary)null, -1); Log.LogError((object)("Error in module '" + item.Name + "' during Update! Disabling to prevent log spam/crashes")); Log.LogError((object)ex); item.Toggle(); } } } } private void OnRenderObject() { RenderManager.RenderPipeline(); } } } namespace ThornClient.System { public class ClickGUI : SystemModule { internal static ClickGUI? Instance; private const string PauseGameStateKey = "Thorn_ClickGUI"; private static readonly string BundlePath = Path.Combine(Plugin.workingDir, "assets", "thorn_clickgui.bundle"); public static readonly string BundleKey = "clickGui"; private static GameObject? _layoutedPagePrefab; private bool _isInitialized; private GameObject? _canvas; private GameObject? _tabBar; private GameObject? _modulePage; private GameObject? _hudPage; private GameObject? _settingsPage; private GameObject? _configPopupPage; private readonly Stack _panelStack = new Stack(); private GameObject? _tooltip; private GameObject? _tabBarButtonRow; private ModuleSearchWindowController? _moduleSearchController; private ModuleSearchWindowController? _hudModuleSearchController; private List> _tabPages = new List>(); private const string ModuleTabName = "Modules"; private const string HudTabName = "HUD"; private static readonly Vector2 PageHiddenOffset = Vector2.down * 15f; private static string _lastTabName = ""; private static OptionsManager? opts => MonoSingleton.Instance; public ClickGUI() : base("thorn.clickGui", "ClickGUI", "The main interaction panel") { AssetManager.LoadBundle(BundleKey, BundlePath); SceneUtils.SafeSceneLoaded += delegate { _isInitialized = InitializeIfNeeded(); if (IsEnabled) { Toggle(); } }; } private bool InitializeIfNeeded() { //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Expected O, but got Unknown //IL_0429: Unknown result type (might be due to invalid IL or missing references) if (Instance != null || (_isInitialized && (Object)(object)_canvas != (Object)null)) { return true; } Instance = this; GameObject val = AssetManager.Get(BundleKey, "ThornClickGUICanvas"); GameObject val2 = AssetManager.Get(BundleKey, "TabBar"); _layoutedPagePrefab = AssetManager.Get(BundleKey, "LayoutedPage"); GameObject val3 = AssetManager.Get(BundleKey, "Tooltip"); GameObject val4 = AssetManager.Get(BundleKey, "TabButton"); GameObject val5 = AssetManager.Get(BundleKey, "ModuleCategory"); GameObject val6 = AssetManager.Get(BundleKey, "SearchWindow"); _canvas = Object.Instantiate(val); ((Object)_canvas).hideFlags = (HideFlags)52; Object.DontDestroyOnLoad((Object)(object)_canvas); _canvas.SetActive(true); _tabBar = Object.Instantiate(val2, _canvas.transform); _tabBar.SetActive(true); GameObjectExtensions.GetOrAddComponent(_tabBar); _modulePage = Object.Instantiate(_layoutedPagePrefab, _canvas.transform); _hudPage = Object.Instantiate(_layoutedPagePrefab, _canvas.transform); _settingsPage = Object.Instantiate(_layoutedPagePrefab, _canvas.transform); _tabPages.Add(Tuple.Create("Modules", _modulePage)); _tabPages.Add(Tuple.Create("HUD", _hudPage)); _tabPages.Add(Tuple.Create("Settings", _settingsPage)); _lastTabName = "Modules"; for (int i = 0; i < Enum.GetValues(typeof(ModuleCategory)).Length; i++) { ModuleCategory moduleCategory = (ModuleCategory)i; if (moduleCategory != ModuleCategory.Hud) { GameObject val7 = Object.Instantiate(val5); AddToLayoutedPage(_modulePage, val7); ModuleCategoryController orAddComponent = GameObjectExtensions.GetOrAddComponent(val7); orAddComponent.Category = moduleCategory; orAddComponent.SetupModules(); UIUtils.UnfuckLayoutHack(val7); } } GameObject val8 = Object.Instantiate(val6); AddToLayoutedPage(_modulePage, val8); _moduleSearchController = val8.AddComponent(); _moduleSearchController.ModuleFilter = (ThornClient.Core.Module module) => !(module is SystemModule) && !(module is HudModule); UIUtils.UnfuckLayoutHack(_modulePage); GameObject val9 = Object.Instantiate(val5); AddToLayoutedPage(_hudPage, val9); ModuleCategoryController orAddComponent2 = GameObjectExtensions.GetOrAddComponent(val9); orAddComponent2.Category = ModuleCategory.Hud; orAddComponent2.SetupModules(); UIUtils.UnfuckLayoutHack(val9); RectTransform val10 = (RectTransform)val9.transform; UIUtils.UnfuckLayoutHack(val9); val10.pivot = new Vector2(0.5f, 0.5f); ((Transform)val10).localPosition = new Vector3(0f, 0f, 0f); GameObject val11 = Object.Instantiate(val6); AddToLayoutedPage(_hudPage, val11); _hudModuleSearchController = val11.AddComponent(); _hudModuleSearchController.ModuleFilter = (ThornClient.Core.Module module) => module is HudModule; UIUtils.UnfuckLayoutHack(_hudPage); GameObject val12 = Object.Instantiate(val5); AddToLayoutedPage(_settingsPage, val12); RectTransform val13 = (RectTransform)val12.transform; val13.pivot = new Vector2(0.5f, 0.5f); ((Transform)val13).localPosition = new Vector3(0f, 0f, 0f); GameObjectExtensions.GetOrAddComponent(val12).TargetConfigurable = ThornModule.Instance; UIUtils.UnfuckLayoutHack(_settingsPage); _tabBarButtonRow = UIUtils.FindRecursive(_tabBar, "Tabs"); foreach (Tuple tabPage in _tabPages) { string key = tabPage.Item1; GameObject obj = Object.Instantiate(val4, _tabBarButtonRow.transform); ((TMP_Text)UIUtils.FindRecursive(obj, "Text").GetComponent()).text = key; ((UnityEvent)obj.GetComponent