Decompiled source of EquipmentAnyways v1.1.0

EquipmentAnyways.dll

Decompiled 2 weeks ago
using System.Collections;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("EquipmentAnyways")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EquipmentAnyways")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8f19f41a-fbd9-4cca-abeb-bdb89afd3193")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace EquipmentAnywaysMod;

[BepInPlugin("com.morsecodeguy.equipmentanyways", "Equipment Anyways", "1.1.0")]
public class EquipmentAnyways : BaseUnityPlugin
{
	private const string targetButtonName = "EquipmentButton";

	private readonly string[] allowedEquipmentSlotChildren = new string[6] { "HandLeftButton", "HandRightButton", "EquipmentPointTotalText", "HandHoldSettingsRight", "HandHoldSettingsLeft", "ClearButton" };

	private readonly string[] allowedMoveSetButtons = new string[5] { "Shield", "Bardiche", "ShortSword", "Longsword", "BeardedAxe" };

	private void Start()
	{
		((MonoBehaviour)this).StartCoroutine(FindAndActivateAllButtons());
	}

	private IEnumerator FindAndActivateAllButtons()
	{
		while (true)
		{
			GameObject[] allObjects = Object.FindObjectsOfType<GameObject>();
			bool equipmentButtonExists = false;
			GameObject[] array = allObjects;
			foreach (GameObject obj in array)
			{
				if (!(((Object)obj).name == "EquipmentButton"))
				{
					continue;
				}
				equipmentButtonExists = true;
				Button buttonComponent = obj.GetComponent<Button>();
				if ((Object)(object)buttonComponent != (Object)null && !((Selectable)buttonComponent).interactable)
				{
					((Selectable)buttonComponent).interactable = true;
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Found and enabled button: " + ((Object)obj).name + "."));
				}
				Transform textChild = obj.transform.Find("Text");
				if ((Object)(object)textChild != (Object)null)
				{
					Text textComponent = ((Component)textChild).GetComponent<Text>();
					if ((Object)(object)textComponent != (Object)null)
					{
						((Graphic)textComponent).color = new Color(0.5804f, 0.9529f, 0.8941f, 1f);
					}
				}
				Component disableForDemo = obj.GetComponent("DisableForDemo");
				if ((Object)(object)disableForDemo != (Object)null)
				{
					Object.Destroy((Object)(object)disableForDemo);
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Removed DisableForDemo component from " + ((Object)obj).name + "."));
				}
			}
			if (equipmentButtonExists)
			{
				GameObject equipmentEditorPanel = GameObject.Find("EquipmentEditorPanel(Clone)");
				if ((Object)(object)equipmentEditorPanel != (Object)null)
				{
					Transform equipmentSlotPanel = equipmentEditorPanel.transform.Find("EquipmentSlotPanel");
					if ((Object)(object)equipmentSlotPanel != (Object)null)
					{
						foreach (Transform item in equipmentSlotPanel)
						{
							Transform child2 = item;
							if (!allowedEquipmentSlotChildren.Contains(((Object)child2).name))
							{
								((Component)child2).gameObject.SetActive(false);
							}
						}
						Transform clearButton = equipmentSlotPanel.Find("ClearButton");
						if ((Object)(object)clearButton != (Object)null)
						{
							clearButton.localPosition = new Vector3(195f, 100f, 0f);
							clearButton.position = new Vector3(195f, 640f, 0f);
						}
						Transform equipmentPointTotalText = equipmentSlotPanel.Find("EquipmentPointTotalText");
						if ((Object)(object)equipmentPointTotalText != (Object)null)
						{
							equipmentPointTotalText.localPosition = new Vector3(195f, 55f, 0f);
							equipmentPointTotalText.position = new Vector3(195f, 595f, 0f);
						}
						Transform handLeftButton = equipmentSlotPanel.Find("HandLeftButton");
						if ((Object)(object)handLeftButton != (Object)null)
						{
							handLeftButton.localPosition = new Vector3(310f, 100f, 0f);
							handLeftButton.position = new Vector3(310f, 640f, 0f);
						}
						Transform handRightButton = equipmentSlotPanel.Find("HandRightButton");
						if ((Object)(object)handRightButton != (Object)null)
						{
							handRightButton.localPosition = new Vector3(80f, 100f, 0f);
							handRightButton.position = new Vector3(80f, 640f, 0f);
						}
					}
					Transform equipmentSelectContent = equipmentEditorPanel.transform.Find("EquipmentSelectPanel/EquipmentSelectScrollView/Viewport/Content");
					if ((Object)(object)equipmentSelectContent != (Object)null)
					{
						foreach (Transform item2 in equipmentSelectContent)
						{
							Transform child = item2;
							if (!(((Object)child).name == "MoveSetButton(Clone)"))
							{
								continue;
							}
							Transform textChild2 = child.Find("Text");
							if ((Object)(object)textChild2 != (Object)null)
							{
								Text textComponent2 = ((Component)textChild2).GetComponent<Text>();
								if ((Object)(object)textComponent2 != (Object)null && !allowedMoveSetButtons.Contains(textComponent2.text))
								{
									((Component)child).gameObject.SetActive(false);
								}
								else
								{
									((Component)textChild2).gameObject.SetActive(true);
								}
							}
						}
					}
				}
			}
			yield return (object)new WaitForSeconds(0.1f);
		}
	}
}