Decompiled source of SymbiotePanelExpanderPlugin v1.2.0

SymbiotePanelExpanderPlugin.dll

Decompiled 3 weeks ago
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.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Bounce.Singletons;
using HarmonyLib;
using Newtonsoft.Json;
using Symbiotes;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SymbiotePanelExpanderPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SymbiotePanelExpanderPlugin")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("SymbiotePanelExpanderPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.2.0.0")]
namespace LordAshes;

[BepInPlugin("org.lordashes.plugins.symbiotepanelexpander", "Symbiote Panel Expander Plug-In", "1.2.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class SymbiotePanelExpanderPlugin : BaseUnityPlugin
{
	public class Manifest
	{
		public string manifestVersion { get; set; }

		public string name { get; set; }

		public string version { get; set; }

		public string summary { get; set; }

		public string entryPoint { get; set; }

		public Dictionary<string, object> environment { get; set; }
	}

	[HarmonyPatch(typeof(SymbiotesManager), "OnLoadingStateChanged")]
	public static class PatchAddDiceResultMessage
	{
		public static bool Prefix(SymbioteItem symbioteItem)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Expected O, but got Unknown
			Debug.Log((object)("Symbiote Panel Expander Plugin: Processing Symbiote " + ((Object)symbioteItem).name + " (" + symbioteItem.Symbiote.RootPath + ")"));
			string text = File.ReadAllText(symbioteItem.Symbiote.RootPath + "/manifest.json");
			Manifest manifest = JsonConvert.DeserializeObject<Manifest>(text);
			if (!manifest.environment.ContainsKey("symbiote_width"))
			{
				manifest.environment.Add("symbiote_width", 600);
			}
			if (manifest.environment["symbiote_width"].ToString().Trim().EndsWith("%"))
			{
				Debug.Log((object)("Symbiote Panel Expander Plugin: Symbiote Panel Width Requested " + Screen.width + "x" + manifest.environment["symbiote_width"].ToString().Replace("%", "") + "/100"));
				manifest.environment["symbiote_width"] = (Screen.width * int.Parse(manifest.environment["symbiote_width"].ToString().Replace("%", "")) / 100).ToString();
			}
			UI_SymbiotesPanel obj = Object.FindObjectOfType<UI_SymbiotesPanel>();
			foreach (FieldInfo runtimeField in typeof(UI_SymbiotesPanel).GetRuntimeFields())
			{
				if (runtimeField.Name == "_rectTransform")
				{
					RectTransform val = (RectTransform)runtimeField.GetValue(obj);
					RectTransformExtensions.Left(val, (float)(-1 * int.Parse(manifest.environment["symbiote_width"].ToString())));
					runtimeField.SetValue(obj, val);
					Debug.Log((object)("Symbiote Panel Expander Plugin: Symbiote Panel Width Set To " + manifest.environment["symbiote_width"]));
				}
			}
			return true;
		}
	}

	public static class Utility
	{
		public static void PostOnMainPage(MemberInfo plugin)
		{
			SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode)
			{
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Expected O, but got Unknown
				try
				{
					if (((Scene)(ref scene)).name == "UI")
					{
						TextMeshProUGUI uITextByName = GetUITextByName("BETA");
						if (Object.op_Implicit((Object)(object)uITextByName))
						{
							((TMP_Text)uITextByName).text = "INJECTED BUILD - unstable mods";
						}
					}
					else
					{
						TextMeshProUGUI uITextByName2 = GetUITextByName("TextMeshPro Text");
						if (Object.op_Implicit((Object)(object)uITextByName2))
						{
							BepInPlugin val = (BepInPlugin)Attribute.GetCustomAttribute(plugin, typeof(BepInPlugin));
							if (((TMP_Text)uITextByName2).text.EndsWith("</size>"))
							{
								((TMP_Text)uITextByName2).text = ((TMP_Text)uITextByName2).text + "\n\nMods Currently Installed:\n";
							}
							TextMeshProUGUI val2 = uITextByName2;
							((TMP_Text)val2).text = ((TMP_Text)val2).text + "\nLord Ashes' " + val.Name + " - " + val.Version;
						}
					}
				}
				catch (Exception ex)
				{
					Debug.Log((object)ex);
				}
			};
		}

		public static bool isBoardLoaded()
		{
			return SimpleSingletonBehaviour<CameraController>.HasInstance && SingletonStateMBehaviour<BoardSessionManager, State<BoardSessionManager>>.HasInstance && !BoardSessionManager.IsLoading;
		}

		private static TextMeshProUGUI GetUITextByName(string name)
		{
			TextMeshProUGUI[] array = Object.FindObjectsOfType<TextMeshProUGUI>();
			for (int i = 0; i < array.Length; i++)
			{
				if (((Object)array[i]).name == name)
				{
					return array[i];
				}
			}
			return null;
		}
	}

	private enum SymbiotePanelState
	{
		closed,
		transition,
		open
	}

	public const string Name = "Symbiote Panel Expander Plug-In";

	public const string Guid = "org.lordashes.plugins.symbiotepanelexpander";

	public const string Version = "1.2.0.0";

	private SymbiotePanelState symbiotePanelOpen = SymbiotePanelState.closed;

	private KeyboardShortcut triggerOpen;

	private KeyboardShortcut triggerClose;

	private void Awake()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: 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_00c1: Expected O, but got Unknown
		LoggingPlugin.SetLogLevel(((BaseUnityPlugin)this).Config.Bind<DiagnosticLevel>("Settings", "Diagnostic Level", (DiagnosticLevel)3, (ConfigDescription)null).Value);
		string? assemblyQualifiedName = ((object)this).GetType().AssemblyQualifiedName;
		DiagnosticLevel logLevel = LoggingPlugin.GetLogLevel();
		LoggingPlugin.LogInfo(assemblyQualifiedName + ": Active. (Diagnostic Mode = " + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + ")");
		triggerOpen = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Settings", "Trigger To Open Symbiote Panel", new KeyboardShortcut((KeyCode)280, Array.Empty<KeyCode>()), (ConfigDescription)null).Value;
		triggerClose = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Settings", "Trigger To Close Symbiote Panel", new KeyboardShortcut((KeyCode)281, Array.Empty<KeyCode>()), (ConfigDescription)null).Value;
		Harmony val = new Harmony("org.lordashes.plugins.symbiotepanelexpander");
		val.PatchAll();
		Utility.PostOnMainPage(((object)this).GetType());
	}

	private void Update()
	{
		if (symbiotePanelOpen == SymbiotePanelState.closed && ((KeyboardShortcut)(ref triggerOpen)).IsPressed())
		{
			LoggingPlugin.LogDebug("Opening Symbiote Panel");
			((MonoBehaviour)this).StartCoroutine(SetSymbiotePanelState(SymbiotePanelState.open));
			SingletonBehaviour<GUIManager>.Instance.OpenSymbiotePanel();
		}
		else if (symbiotePanelOpen == SymbiotePanelState.open && ((KeyboardShortcut)(ref triggerClose)).IsPressed())
		{
			LoggingPlugin.LogDebug("Closing Symbiote Panel");
			((MonoBehaviour)this).StartCoroutine(SetSymbiotePanelState(SymbiotePanelState.closed));
			SingletonBehaviour<GUIManager>.Instance.CloseSymbiotePanel();
		}
	}

	private IEnumerator SetSymbiotePanelState(SymbiotePanelState state)
	{
		symbiotePanelOpen = SymbiotePanelState.transition;
		yield return (object)new WaitForSeconds(1f);
		symbiotePanelOpen = state;
	}
}