Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ModelReplacementMenu v1.0.0
MRMenu.dll
Decompiled 2 years agousing System; using System.Collections; 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 GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MRMenuOfficial")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MRMenuOfficial")] [assembly: AssemblyTitle("MRMenuOfficial")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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; } } } public class BundleUtilities { public static byte[] GetResourceBytes(string filename, Assembly assembly) { string[] manifestResourceNames = assembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (!text.Contains(filename)) { continue; } using Stream stream = assembly.GetManifestResourceStream(text); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); return array; } return null; } public static AssetBundle LoadBundleFromInternalAssembly(string filename, Assembly assembly) { return AssetBundle.LoadFromMemory(GetResourceBytes(filename, assembly)); } } public static class AssetBundleExtension { public static T LoadPersistentAsset<T>(this AssetBundle bundle, string name) where T : Object { Object val = bundle.LoadAsset(name); if (val != (Object)null) { val.hideFlags = (HideFlags)32; return (T)(object)val; } return default(T); } } public class InputManager { public static Vector2 mousePosition => new Vector2(((InputControl<float>)(object)((Pointer)InputSystem.GetDevice<Mouse>()).position.x).ReadValue(), ((InputControl<float>)(object)((Pointer)InputSystem.GetDevice<Mouse>()).position.y).ReadValue()); public static bool GetKeyUp(KeyCode key) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return ((ButtonControl)GetKBKeyByKeyCode(key)).wasReleasedThisFrame; } public static bool GetKeyDown(KeyCode key) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return ((ButtonControl)GetKBKeyByKeyCode(key)).wasPressedThisFrame; } public static bool GetKey(KeyCode key) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return ((ButtonControl)GetKBKeyByKeyCode(key)).isPressed; } public static bool GetMouseButtonUp(KeyCode button) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return GetMouseButtonByKeyCode(button).wasReleasedThisFrame; } public static bool GetMouseButtonDown(KeyCode button) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return GetMouseButtonByKeyCode(button).wasPressedThisFrame; } public static bool GetMouseButton(KeyCode button) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return GetMouseButtonByKeyCode(button).isPressed; } public static KeyControl GetKBKeyByKeyCode(KeyCode key) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_07e5: Expected I4, but got Unknown //IL_0e74: Unknown result type (might be due to invalid IL or missing references) return (KeyControl)((key - 8) switch { 0 => InputSystem.GetDevice<Keyboard>().backspaceKey, 119 => InputSystem.GetDevice<Keyboard>().deleteKey, 1 => InputSystem.GetDevice<Keyboard>().tabKey, 5 => InputSystem.GetDevice<Keyboard>().enterKey, 11 => InputSystem.GetDevice<Keyboard>().pauseKey, 19 => InputSystem.GetDevice<Keyboard>().escapeKey, 24 => InputSystem.GetDevice<Keyboard>().spaceKey, 248 => InputSystem.GetDevice<Keyboard>().numpad0Key, 249 => InputSystem.GetDevice<Keyboard>().numpad1Key, 250 => InputSystem.GetDevice<Keyboard>().numpad2Key, 251 => InputSystem.GetDevice<Keyboard>().numpad3Key, 252 => InputSystem.GetDevice<Keyboard>().numpad4Key, 253 => InputSystem.GetDevice<Keyboard>().numpad5Key, 254 => InputSystem.GetDevice<Keyboard>().numpad6Key, 255 => InputSystem.GetDevice<Keyboard>().numpad7Key, 256 => InputSystem.GetDevice<Keyboard>().numpad8Key, 257 => InputSystem.GetDevice<Keyboard>().numpad9Key, 258 => InputSystem.GetDevice<Keyboard>().numpadPeriodKey, 259 => InputSystem.GetDevice<Keyboard>().numpadDivideKey, 260 => InputSystem.GetDevice<Keyboard>().numpadMultiplyKey, 261 => InputSystem.GetDevice<Keyboard>().numpadMinusKey, 262 => InputSystem.GetDevice<Keyboard>().numpadPlusKey, 263 => InputSystem.GetDevice<Keyboard>().numpadEnterKey, 264 => InputSystem.GetDevice<Keyboard>().numpadEqualsKey, 265 => InputSystem.GetDevice<Keyboard>().upArrowKey, 266 => InputSystem.GetDevice<Keyboard>().downArrowKey, 267 => InputSystem.GetDevice<Keyboard>().rightArrowKey, 268 => InputSystem.GetDevice<Keyboard>().leftArrowKey, 269 => InputSystem.GetDevice<Keyboard>().insertKey, 270 => InputSystem.GetDevice<Keyboard>().homeKey, 271 => InputSystem.GetDevice<Keyboard>().endKey, 272 => InputSystem.GetDevice<Keyboard>().pageUpKey, 273 => InputSystem.GetDevice<Keyboard>().pageDownKey, 274 => InputSystem.GetDevice<Keyboard>().f1Key, 275 => InputSystem.GetDevice<Keyboard>().f2Key, 276 => InputSystem.GetDevice<Keyboard>().f3Key, 277 => InputSystem.GetDevice<Keyboard>().f4Key, 278 => InputSystem.GetDevice<Keyboard>().f5Key, 279 => InputSystem.GetDevice<Keyboard>().f6Key, 280 => InputSystem.GetDevice<Keyboard>().f7Key, 281 => InputSystem.GetDevice<Keyboard>().f8Key, 282 => InputSystem.GetDevice<Keyboard>().f9Key, 283 => InputSystem.GetDevice<Keyboard>().f10Key, 284 => InputSystem.GetDevice<Keyboard>().f11Key, 285 => InputSystem.GetDevice<Keyboard>().f12Key, 40 => InputSystem.GetDevice<Keyboard>().digit0Key, 41 => InputSystem.GetDevice<Keyboard>().digit1Key, 42 => InputSystem.GetDevice<Keyboard>().digit2Key, 43 => InputSystem.GetDevice<Keyboard>().digit3Key, 44 => InputSystem.GetDevice<Keyboard>().digit4Key, 45 => InputSystem.GetDevice<Keyboard>().digit5Key, 46 => InputSystem.GetDevice<Keyboard>().digit6Key, 47 => InputSystem.GetDevice<Keyboard>().digit7Key, 48 => InputSystem.GetDevice<Keyboard>().digit7Key, 49 => InputSystem.GetDevice<Keyboard>().digit9Key, 31 => InputSystem.GetDevice<Keyboard>().quoteKey, 36 => InputSystem.GetDevice<Keyboard>().commaKey, 37 => InputSystem.GetDevice<Keyboard>().minusKey, 38 => InputSystem.GetDevice<Keyboard>().periodKey, 39 => InputSystem.GetDevice<Keyboard>().slashKey, 51 => InputSystem.GetDevice<Keyboard>().semicolonKey, 53 => InputSystem.GetDevice<Keyboard>().equalsKey, 83 => InputSystem.GetDevice<Keyboard>().leftBracketKey, 84 => InputSystem.GetDevice<Keyboard>().backslashKey, 85 => InputSystem.GetDevice<Keyboard>().rightBracketKey, 88 => InputSystem.GetDevice<Keyboard>().backquoteKey, 89 => InputSystem.GetDevice<Keyboard>().aKey, 90 => InputSystem.GetDevice<Keyboard>().bKey, 91 => InputSystem.GetDevice<Keyboard>().cKey, 92 => InputSystem.GetDevice<Keyboard>().dKey, 93 => InputSystem.GetDevice<Keyboard>().eKey, 94 => InputSystem.GetDevice<Keyboard>().fKey, 95 => InputSystem.GetDevice<Keyboard>().gKey, 96 => InputSystem.GetDevice<Keyboard>().hKey, 97 => InputSystem.GetDevice<Keyboard>().iKey, 98 => InputSystem.GetDevice<Keyboard>().jKey, 99 => InputSystem.GetDevice<Keyboard>().kKey, 100 => InputSystem.GetDevice<Keyboard>().lKey, 101 => InputSystem.GetDevice<Keyboard>().mKey, 102 => InputSystem.GetDevice<Keyboard>().nKey, 103 => InputSystem.GetDevice<Keyboard>().oKey, 104 => InputSystem.GetDevice<Keyboard>().pKey, 105 => InputSystem.GetDevice<Keyboard>().qKey, 106 => InputSystem.GetDevice<Keyboard>().rKey, 107 => InputSystem.GetDevice<Keyboard>().sKey, 108 => InputSystem.GetDevice<Keyboard>().tKey, 109 => InputSystem.GetDevice<Keyboard>().uKey, 110 => InputSystem.GetDevice<Keyboard>().vKey, 111 => InputSystem.GetDevice<Keyboard>().wKey, 112 => InputSystem.GetDevice<Keyboard>().xKey, 113 => InputSystem.GetDevice<Keyboard>().yKey, 114 => InputSystem.GetDevice<Keyboard>().zKey, 292 => InputSystem.GetDevice<Keyboard>().numLockKey, 293 => InputSystem.GetDevice<Keyboard>().capsLockKey, 294 => InputSystem.GetDevice<Keyboard>().semicolonKey, 295 => InputSystem.GetDevice<Keyboard>().rightShiftKey, 296 => InputSystem.GetDevice<Keyboard>().leftShiftKey, 297 => InputSystem.GetDevice<Keyboard>().rightCtrlKey, 298 => InputSystem.GetDevice<Keyboard>().leftCtrlKey, 299 => InputSystem.GetDevice<Keyboard>().rightAltKey, 300 => InputSystem.GetDevice<Keyboard>().leftAltKey, 302 => InputSystem.GetDevice<Keyboard>().leftMetaKey, 303 => InputSystem.GetDevice<Keyboard>().leftWindowsKey, 301 => InputSystem.GetDevice<Keyboard>().rightMetaKey, 304 => InputSystem.GetDevice<Keyboard>().rightWindowsKey, 308 => InputSystem.GetDevice<Keyboard>().printScreenKey, _ => throw new ArgumentOutOfRangeException("key", key, null), }); } public static ButtonControl GetMouseButtonByKeyCode(KeyCode button) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected I4, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) return (ButtonControl)((button - 323) switch { 0 => InputSystem.GetDevice<Mouse>().leftButton, 1 => InputSystem.GetDevice<Mouse>().rightButton, 2 => InputSystem.GetDevice<Mouse>().middleButton, _ => throw new ArgumentOutOfRangeException("button", button, null), }); } } namespace MRMenuOfficial { public class ModelMenu : MonoBehaviour { public static ModelMenu Instance; public static List<UnlockableSuit> suits; private GameObject quickmenu; private GameObject mainBtns; private GameObject resumeBtn; private GameObject modelBtn; private GameObject modelMenu; private TextMeshProUGUI currentModel; private TextMeshProUGUI selectedModel; private GameObject modelContent; private GameObject modelTemplate; public int selectedSuit; public int currentSuit; private Button switchBtn; private List<Button> modelBtns = new List<Button>(); private TMP_InputField search; private Button back; private void Awake() { Instance = this; } public void Update() { if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) && (Object)(object)modelMenu != (Object)null && InputManager.GetKeyDown((KeyCode)27) && modelMenu.activeSelf) { modelMenu.SetActive(false); } } public void CreateNewMenu() { suits = suits.OrderBy((UnlockableSuit obj) => obj.suitID).ToList(); ((MonoBehaviour)this).StartCoroutine(WaitForMenu()); } public void Menu() { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Expected O, but got Unknown //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Expected O, but got Unknown //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Expected O, but got Unknown //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Expected O, but got Unknown quickmenu = GameObject.Find("Systems/UI/Canvas/QuickMenu"); mainBtns = ((Component)quickmenu.transform.Find("MainButtons")).gameObject; resumeBtn = ((Component)mainBtns.transform.Find("Resume")).gameObject; modelBtn = Object.Instantiate<GameObject>(resumeBtn, mainBtns.transform); ((TMP_Text)((Component)modelBtn.transform.Find("Text (TMP)")).GetComponent<TextMeshProUGUI>()).text = "> Models"; modelBtn.transform.localPosition = new Vector3(modelBtn.transform.localPosition.x, 128f, modelBtn.transform.localPosition.z); modelMenu = Object.Instantiate<GameObject>(Plugin.modelMenu, quickmenu.transform); modelMenu.SetActive(false); search = ((Component)modelMenu.transform.Find("Search/Input")).GetComponent<TMP_InputField>(); back = ((Component)modelMenu.transform.Find("Back")).GetComponent<Button>(); modelContent = ((Component)modelMenu.transform.Find("ModelPanel/View/Viewport/Content")).gameObject; modelTemplate = ((Component)modelContent.transform.Find("ModelTemplate")).gameObject; modelTemplate.SetActive(false); modelMenu.GetComponent<RectTransform>().offsetMax = Vector2.zero; modelMenu.GetComponent<RectTransform>().offsetMin = Vector2.zero; selectedModel = ((Component)modelMenu.transform.Find("Selected")).GetComponent<TextMeshProUGUI>(); currentModel = ((Component)modelMenu.transform.Find("Current")).GetComponent<TextMeshProUGUI>(); modelMenu.GetComponent<RectTransform>().sizeDelta = new Vector2(1920f, 1080f); modelMenu.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); switchBtn = ((Component)modelMenu.transform.Find("Switch")).GetComponent<Button>(); modelBtn.GetComponent<Button>().onClick = new ButtonClickedEvent(); ((UnityEvent)modelBtn.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { modelMenu.SetActive(true); mainBtns.SetActive(false); currentSuit = GameNetworkManager.Instance.localPlayerController.currentSuitID; ((TMP_Text)currentModel).text = "Currently Wearing: " + StartOfRound.Instance.unlockablesList.unlockables[currentSuit].unlockableName; foreach (Button modelBtn in modelBtns) { ((TMP_Text)((Component)((Component)modelBtn).transform.Find("Text")).GetComponent<TextMeshProUGUI>()).text = StartOfRound.Instance.unlockablesList.unlockables[int.Parse(((Object)modelBtn).name)].unlockableName; } }); foreach (UnlockableSuit suit in suits) { GameObject newModel = Object.Instantiate<GameObject>(modelTemplate, modelContent.transform); ((Object)newModel).name = StartOfRound.Instance.unlockablesList.unlockables[suit.suitID].unlockableName; modelBtns.Add(newModel.GetComponent<Button>()); newModel.SetActive(true); ((TMP_Text)((Component)newModel.transform.Find("Text")).GetComponent<TextMeshProUGUI>()).text = StartOfRound.Instance.unlockablesList.unlockables[suit.suitID].unlockableName; ((UnityEvent)newModel.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { ((Selectable)newModel.GetComponent<Button>()).interactable = false; selectedSuit = suit.suitID; ((TMP_Text)selectedModel).text = "Selected Model: " + StartOfRound.Instance.unlockablesList.unlockables[selectedSuit].unlockableName; ((TMP_Text)((Component)newModel.transform.Find("Text")).GetComponent<TextMeshProUGUI>()).text = StartOfRound.Instance.unlockablesList.unlockables[selectedSuit].unlockableName ?? ""; foreach (Button modelBtn2 in modelBtns) { if ((Object)(object)modelBtn2 != (Object)(object)newModel.GetComponent<Button>()) { ((Selectable)modelBtn2).interactable = true; } } }); } ((UnityEvent)switchBtn.onClick).AddListener((UnityAction)delegate { foreach (UnlockableSuit suit2 in suits) { if (suit2.suitID == selectedSuit) { suit2.SwitchSuitToThis(GameNetworkManager.Instance.localPlayerController); break; } } }); ((UnityEvent<string>)(object)search.onValueChanged).AddListener((UnityAction<string>)delegate { if (search.text == string.Empty) { foreach (Button modelBtn3 in modelBtns) { ((Component)modelBtn3).gameObject.SetActive(true); } return; } foreach (Button modelBtn4 in modelBtns) { if (((Object)modelBtn4).name.ToLower().Contains(search.text.ToLower())) { ((Component)modelBtn4).gameObject.SetActive(true); } else { ((Component)modelBtn4).gameObject.SetActive(false); } } }); ((UnityEvent)back.onClick).AddListener((UnityAction)delegate { mainBtns.SetActive(true); modelMenu.SetActive(false); }); } private IEnumerator WaitForMenu() { yield return (object)new WaitForSeconds(5f); Menu(); } } [BepInPlugin("jin.mrmenu", "Model Replacement Menu", "0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public static Plugin Instance; public static ManualLogSource Log; public static GameObject modelMenu; private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("jin.mrmenu"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin jin.mrmenu is loaded!"); AssetBundle bundle = BundleUtilities.LoadBundleFromInternalAssembly("mrmod", Assembly.GetExecutingAssembly()); LoadAssets(bundle); } private void LoadAssets(AssetBundle bundle) { if (Object.op_Implicit((Object)(object)bundle)) { Log.LogInfo((object)"Asset Bundles Loaded!"); modelMenu = bundle.LoadPersistentAsset<GameObject>("Assets/ModelReplacementMenu/ModelMenu.prefab"); if (Object.op_Implicit((Object)(object)modelMenu)) { Log.LogInfo((object)"MODEL MENU EXISTS"); } else { Log.LogError((object)"MODEL MENU DOESNT EXIST!!!"); } } else { Log.LogError((object)"ASSET BUNDLES FAILED TO LOAD!!!!"); } } } } namespace MRMenuOfficial.Patches { public class GameManagerNetworkPatch { [HarmonyPatch(typeof(GameNetworkManager))] public static class StartPatch { [HarmonyPatch("Start")] [HarmonyPostfix] public static void Postfix(GameNetworkManager __instance) { ((Component)__instance).gameObject.AddComponent<ModelMenu>(); } } } [HarmonyPatch(typeof(PlayerControllerB))] public class PlayerControllerBPatch { [HarmonyPatch("Start")] [HarmonyPostfix] public static void StartPatch(PlayerControllerB __instance) { } [HarmonyPatch("ConnectClientToPlayerObject")] [HarmonyPostfix] public static void ConnectClientToPlayerObjectPatch(PlayerControllerB __instance) { if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)__instance) { ModelMenu.suits = Object.FindObjectsOfType<UnlockableSuit>().ToList(); ModelMenu.Instance.CreateNewMenu(); } } } }