Due to update 2.4.3, some mods may no longer function. FixedConfig may be necessary.
Decompiled source of RandomButton v1.0.0
RandomButton.dll
Decompiled 9 months agousing System; 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 BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.SceneManagement; 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: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")] [assembly: AssemblyCompany("RandomButton")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RandomButton")] [assembly: AssemblyTitle("RandomButton")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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; } } } public class RandomButtonObject : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler { private Vector2 originalSize; public int index; private void Start() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) originalSize = ((Component)this).GetComponent<RectTransform>().sizeDelta; } public void OnPointerClick(PointerEventData eventData) { Press(); } public void OnPointerEnter(PointerEventData eventData) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_001c: Unknown result type (might be due to invalid IL or missing references) ((Component)this).GetComponent<RectTransform>().sizeDelta = originalSize + Vector2.one * 10f; } public void OnPointerExit(PointerEventData eventData) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) ((Component)this).GetComponent<RectTransform>().sizeDelta = originalSize; } public void Press() { Transform child = GameObject.Find("Rectangle" + index).transform.GetChild(2); for (int i = 1; i <= 3; i++) { ((SelectableMonoBehaviour)((Component)child.GetChild(i)).GetComponent<SelectAbility>()).Select(1); } } } namespace RandomButton { [BepInPlugin("com.thepro.RandomButton", "Random Button", "1.0.0")] [BepInProcess("BoplBattle.exe")] internal class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(CharacterSelectBox), "Update")] private class AdjustVisibility { private static void Postfix(CharacterSelectBox __instance) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 ((Component)((Component)__instance).transform.GetChild(((Component)__instance).transform.childCount - 1)).gameObject.SetActive((int)__instance.menuState == 1); } } [HarmonyPatch(typeof(CharacterSelectBox), "Update")] public class GamepadIntegration { private static void Prefix(CharacterSelectBox __instance) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 if (__instance.currentGamePad != null && __instance.currentGamePad.yButton.wasPressedThisFrame && (int)__instance.menuState == 1) { ((Component)((Component)__instance).transform.GetChild(((Component)__instance).transform.childCount - 1)).GetComponent<RandomButtonObject>().Press(); } } } private static RandomButtonObject randomButton; internal static Harmony harmony; internal static ManualLogSource logger; internal static Sprite randomSprite; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); logger = ((BaseUnityPlugin)this).Logger; harmony.PatchAll(); SceneManager.sceneLoaded += SceneManager_sceneLoaded; randomSprite = LoadSprite("RandomButton.random.png"); } private Sprite LoadSprite(string path) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) Texture2D val2; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path)) { byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(256, 256); ImageConversion.LoadImage(val, array); val2 = val; } return Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 45f); } private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1) { //IL_004e: 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) if (((Scene)(ref arg0)).name == "CharacterSelect" || ((Scene)(ref arg0)).name == "ChSelect_online") { for (int i = 1; i <= 4; i++) { Transform transform = GameObject.Find("Rectangle" + i).transform; randomButton = SpawnRandomButton(Vector2.up * -480f, transform, i); } } } public static RandomButtonObject SpawnRandomButton(Vector2 offset, Transform parent, int index) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0086: Unknown result type (might be due to invalid IL or missing references) RandomButtonObject component = new GameObject("Random Button", new Type[4] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image), typeof(RandomButtonObject) }).GetComponent<RandomButtonObject>(); component.index = index; ((Component)component).transform.parent = parent; ((Component)component).transform.localPosition = Vector2.op_Implicit(offset); ((Component)component).transform.localScale = Vector2.op_Implicit(Vector2.one * 0.8f); ((Component)component).GetComponent<Image>().sprite = randomSprite; return component; } } public static class PluginInfo { public const string PLUGIN_GUID = "RandomButton"; public const string PLUGIN_NAME = "RandomButton"; public const string PLUGIN_VERSION = "1.0.0"; } }