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 MapVotePlus v0.0.1
MenuLib.dll
Decompiled 9 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using MenuLib.MonoBehaviors; using MenuLib.Structs; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; 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.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MenuLib")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.5.1")] [assembly: AssemblyInformationalVersion("1.0.0+9d07658e211d54e1f43999840cfec6f71060b241")] [assembly: AssemblyProduct("MenuLib")] [assembly: AssemblyTitle("MenuLib")] [assembly: AssemblyVersion("2.5.1.0")] [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; } } } namespace MenuLib { [BepInPlugin("nickklmao.menulib", "Menu Lib", "2.5.1")] internal sealed class Entry : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static Action<Action<MenuPageMain>, MenuPageMain> <0>__MenuPageMain_StartHook; public static Action<Action<MenuPageSettings>, MenuPageSettings> <1>__MenuPageSettings_StartHook; public static Action<Action<MenuPageColor>, MenuPageColor> <2>__MenuPageColor_StartHook; public static Action<Action<MenuPageEsc>, MenuPageEsc> <3>__MenuPageEsc_StartHook; public static Action<Action<MenuPageRegions>, MenuPageRegions> <4>__MenuPageRegions_StartHook; public static Action<Action<MenuPageServerList>, MenuPageServerList> <5>__MenuPageServerList_StartHook; public static Action<Action<MenuPageLobby>, MenuPageLobby> <6>__MenuPageLobby_StartHook; public static Manipulator <7>__SemiFunc_UIMouseHoverILHook; public static Manipulator <8>__MenuPage_StateClosingILHook; public static Manipulator <9>__ChatManager_StateInactiveILHook; } private const string MOD_NAME = "Menu Lib"; internal static readonly ManualLogSource logger = Logger.CreateLogSource("Menu Lib"); private static void MenuPageMain_StartHook(Action<MenuPageMain> orig, MenuPageMain self) { orig(self); MenuAPI.mainMenuBuilderDelegate?.Invoke(((Component)self).transform); } private static void MenuPageSettings_StartHook(Action<MenuPageSettings> orig, MenuPageSettings self) { orig(self); MenuAPI.settingsMenuBuilderDelegate?.Invoke(((Component)self).transform); } private static void MenuPageColor_StartHook(Action<MenuPageColor> orig, MenuPageColor self) { orig(self); MenuAPI.colorMenuBuilderDelegate?.Invoke(((Component)self).transform); } private static void MenuPageEsc_StartHook(Action<MenuPageEsc> orig, MenuPageEsc self) { orig(self); MenuAPI.escapeMenuBuilderDelegate?.Invoke(((Component)self).transform); } private static void MenuPageRegions_StartHook(Action<MenuPageRegions> orig, MenuPageRegions self) { orig(self); MenuAPI.regionSelectionMenuBuilderDelegate?.Invoke(((Component)self).transform); } private static void MenuPageServerList_StartHook(Action<MenuPageServerList> orig, MenuPageServerList self) { orig(self); MenuAPI.serverListMenuBuilderDelegate?.Invoke(((Component)self).transform); } private static void MenuPageLobby_StartHook(Action<MenuPageLobby> orig, MenuPageLobby self) { orig(self); MenuAPI.lobbyMenuBuilderDelegate?.Invoke(((Component)self).transform); } private static void SemiFunc_UIMouseHoverILHook(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel val4 = default(ILLabel); val.GotoNext(new Func<Instruction, bool>[1] { (Instruction instruction) => ILPatternMatchingExt.MatchBrfalse(instruction, ref val4) && val4.Target.OpCode == OpCodes.Ldarg_1 }); val.Index += 2; val.RemoveRange(27); val.Emit(OpCodes.Ldloc_0); val.EmitDelegate<Func<MenuScrollBox, Vector2, bool>>((Func<MenuScrollBox, Vector2, bool>)delegate(MenuScrollBox menuScrollBox, Vector2 vector) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) RectTransform val3 = (RectTransform)((Transform)menuScrollBox.scroller).parent; float y = ((Transform)val3).position.y; float num = y + val3.sizeDelta.y; return vector.y > y && vector.y < num; }); ILLabel val2 = val.DefineLabel(); val.Emit(OpCodes.Brtrue_S, (object)val2); val.Emit(OpCodes.Ldc_I4_0); val.Emit(OpCodes.Ret); val.MarkLabel(val2); } private static void MenuPage_StateClosingILHook(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.GotoNext(new Func<Instruction, bool>[1] { (Instruction instruction) => ILPatternMatchingExt.MatchLdfld<MenuPage>(instruction, "stateStart") }); val.Index += 2; val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Action<MenuPage>>((Action<MenuPage>)delegate(MenuPage menuPage) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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 (MenuAPI.customMenuPages.TryGetValue(menuPage, out var value2)) { RectTransform val2 = (RectTransform)((Component)menuPage).transform; Vector2 val3 = Vector2.op_Implicit(((Transform)val2).position); Rect rect = val2.rect; float num = 0f - ((Rect)(ref rect)).height; rect = value2.rectTransform.rect; val3.y = num - ((Rect)(ref rect)).height; REPOReflection.menuPage_AnimateAwayPosition.SetValue(menuPage, val3); } }); val.GotoNext(new Func<Instruction, bool>[1] { (Instruction instruction) => ILPatternMatchingExt.MatchCall<Object>(instruction, "Destroy") }); val.Index -= 5; val.RemoveRange(6); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Action<MenuPage>>((Action<MenuPage>)delegate(MenuPage menuPage) { if (MenuAPI.customMenuPages.TryGetValue(menuPage, out var value) && (value.isCachedPage || !value.pageWasActivatedOnce)) { ((Behaviour)menuPage).enabled = false; } else { MenuManager.instance.PageRemove(menuPage); Object.Destroy((Object)(object)((Component)menuPage).gameObject); } }); } private static void MenuScrollBox_UpdateILHook(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.GotoNext(new Func<Instruction, bool>[3] { (Instruction instruction) => ILPatternMatchingExt.MatchLdarg(instruction, 0), (Instruction instruction) => ILPatternMatchingExt.MatchLdarg(instruction, 0), (Instruction instruction) => ILPatternMatchingExt.MatchLdfld<MenuScrollBox>(instruction, "scrollHandleTargetPosition") }); int index = val.Index; val.GotoNext(new Func<Instruction, bool>[1] { (Instruction instruction) => ILPatternMatchingExt.MatchCall<Mathf>(instruction, "Lerp") }); val.GotoPrev(new Func<Instruction, bool>[1] { (Instruction instruction) => ILPatternMatchingExt.MatchStfld<MenuScrollBox>(instruction, "scrollHandleTargetPosition") }); int index2 = val.Index; val.Index = index; val.RemoveRange(index2 - index + 1); ILLabel val2 = val.MarkLabel(); val.GotoPrev(new Func<Instruction, bool>[1] { (Instruction instruction) => instruction.OpCode == OpCodes.Brfalse_S }); val.Remove(); val.Emit(OpCodes.Brfalse_S, (object)val2); val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldarg_0); val.Emit<MenuScrollBox>(OpCodes.Ldfld, "parentPage"); val.EmitDelegate<Action<MenuScrollBox, MenuPage>>((Action<MenuScrollBox, MenuPage>)delegate(MenuScrollBox menuScrollBox, MenuPage menuPage) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) float num3 = SemiFunc.InputMovementY() / 20f; float num4 = SemiFunc.InputScrollY(); float num7; if (MenuAPI.customMenuPages.TryGetValue(menuPage, out var value)) { float? scrollSpeed = value.scrollView.scrollSpeed; if (scrollSpeed.HasValue) { float valueOrDefault = scrollSpeed.GetValueOrDefault(); valueOrDefault *= 10f; float num5 = Mathf.Abs((float)REPOReflection.menuScrollBox_ScrollerEndPosition.GetValue(menuScrollBox) - (float)REPOReflection.menuScrollBox_ScrollerStartPosition.GetValue(menuScrollBox)); float num6 = (num3 + (float)Math.Sign(num4)) * valueOrDefault / num5; Rect rect2 = menuScrollBox.scrollBarBackground.rect; num7 = num6 * ((Rect)(ref rect2)).height; goto IL_00c1; } } float num8 = (float)REPOReflection.menuScrollBox_ScrollHeight.GetValue(menuScrollBox); num7 = num3 / (num8 * 0.01f) + num4 / (num8 * 0.01f); goto IL_00c1; IL_00c1: float num9 = (float)REPOReflection.menuScrollBox_ScrollHandleTargetPosition.GetValue(menuScrollBox); REPOReflection.menuScrollBox_ScrollHandleTargetPosition.SetValue(menuScrollBox, num9 + num7); }); val.GotoNext(new Func<Instruction, bool>[1] { (Instruction instruction) => ILPatternMatchingExt.MatchStfld<MenuScrollBox>(instruction, "scrollAmount") }); val.Index -= 13; val.RemoveRange(14); val.EmitDelegate<Action<MenuScrollBox>>((Action<MenuScrollBox>)delegate(MenuScrollBox instance) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) Rect rect; float num2; if (MenuAPI.customMenuPages.ContainsKey((MenuPage)REPOReflection.menuScrollBox_ParentPage.GetValue(instance))) { float num = ((Transform)instance.scrollHandle).localPosition.y + instance.scrollHandle.sizeDelta.y / 2f; rect = instance.scrollBarBackground.rect; num2 = num / ((Rect)(ref rect)).height; } else { float y = ((Transform)instance.scrollHandle).localPosition.y; rect = instance.scrollBarBackground.rect; num2 = y / ((Rect)(ref rect)).height * 1.1f; } REPOReflection.menuScrollBox_ScrollAmount.SetValue(instance, num2); }); } private static void ChatManager_StateInactiveILHook(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.GotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction instruction) => ILPatternMatchingExt.MatchStfld<ChatManager>(instruction, "chatActive") }); ILLabel val2 = val.DefineLabel(); val.Emit<REPOInputStringSystem>(OpCodes.Ldsfld, "hasAnyFocus"); val.Emit(OpCodes.Brfalse_S, (object)val2); val.Emit(OpCodes.Ret); val.MarkLabel(val2); } private void Awake() { //IL_0040: 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) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Expected O, but got Unknown //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Expected O, but got Unknown //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Expected O, but got Unknown logger.LogDebug((object)"Hooking `MenuPageMain.Start`"); new Hook((MethodBase)AccessTools.Method(typeof(MenuPageMain), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageMain>, MenuPageMain>(MenuPageMain_StartHook)); logger.LogDebug((object)"Hooking `MenuPageSettings.Start`"); new Hook((MethodBase)AccessTools.Method(typeof(MenuPageSettings), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageSettings>, MenuPageSettings>(MenuPageSettings_StartHook)); logger.LogDebug((object)"Hooking `MenuPageColor.Start`"); new Hook((MethodBase)AccessTools.Method(typeof(MenuPageColor), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageColor>, MenuPageColor>(MenuPageColor_StartHook)); logger.LogDebug((object)"Hooking `MenuPageEsc.Start`"); new Hook((MethodBase)AccessTools.Method(typeof(MenuPageEsc), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageEsc>, MenuPageEsc>(MenuPageEsc_StartHook)); logger.LogDebug((object)"Hooking `MenuPageRegions.Start`"); new Hook((MethodBase)AccessTools.Method(typeof(MenuPageRegions), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageRegions>, MenuPageRegions>(MenuPageRegions_StartHook)); logger.LogDebug((object)"Hooking `MenuPageServerList.Start`"); new Hook((MethodBase)AccessTools.Method(typeof(MenuPageServerList), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageServerList>, MenuPageServerList>(MenuPageServerList_StartHook)); logger.LogDebug((object)"Hooking `MenuPageLobby.Start`"); new Hook((MethodBase)AccessTools.Method(typeof(MenuPageLobby), "Start", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageLobby>, MenuPageLobby>(MenuPageLobby_StartHook)); logger.LogDebug((object)"Hooking `SemiFunc.UIMouseHover`"); MethodInfo methodInfo = AccessTools.Method(typeof(SemiFunc), "UIMouseHover", (Type[])null, (Type[])null); object obj = <>O.<7>__SemiFunc_UIMouseHoverILHook; if (obj == null) { Manipulator val = SemiFunc_UIMouseHoverILHook; <>O.<7>__SemiFunc_UIMouseHoverILHook = val; obj = (object)val; } new ILHook((MethodBase)methodInfo, (Manipulator)obj); logger.LogDebug((object)"Hooking `MenuPage.StateClosing`"); MethodInfo methodInfo2 = AccessTools.Method(typeof(MenuPage), "StateClosing", (Type[])null, (Type[])null); object obj2 = <>O.<8>__MenuPage_StateClosingILHook; if (obj2 == null) { Manipulator val2 = MenuPage_StateClosingILHook; <>O.<8>__MenuPage_StateClosingILHook = val2; obj2 = (object)val2; } new ILHook((MethodBase)methodInfo2, (Manipulator)obj2); logger.LogDebug((object)"Hooking `ChatManager.StateInactive`"); MethodInfo methodInfo3 = AccessTools.Method(typeof(ChatManager), "StateInactive", (Type[])null, (Type[])null); object obj3 = <>O.<9>__ChatManager_StateInactiveILHook; if (obj3 == null) { Manipulator val3 = ChatManager_StateInactiveILHook; <>O.<9>__ChatManager_StateInactiveILHook = val3; obj3 = (object)val3; } new ILHook((MethodBase)methodInfo3, (Manipulator)obj3); } } public static class MenuAPI { public delegate void BuilderDelegate(Transform parent); internal static BuilderDelegate mainMenuBuilderDelegate; internal static BuilderDelegate settingsMenuBuilderDelegate; internal static BuilderDelegate colorMenuBuilderDelegate; internal static BuilderDelegate lobbyMenuBuilderDelegate; internal static BuilderDelegate escapeMenuBuilderDelegate; internal static BuilderDelegate regionSelectionMenuBuilderDelegate; internal static BuilderDelegate serverListMenuBuilderDelegate; internal static readonly Dictionary<MenuPage, REPOPopupPage> customMenuPages = new Dictionary<MenuPage, REPOPopupPage>(); private static MenuButtonPopUp menuButtonPopup; public static void AddElementToMainMenu(BuilderDelegate builderDelegate) { mainMenuBuilderDelegate = (BuilderDelegate)Delegate.Combine(mainMenuBuilderDelegate, builderDelegate); } public static void AddElementToSettingsMenu(BuilderDelegate builderDelegate) { settingsMenuBuilderDelegate = (BuilderDelegate)Delegate.Combine(settingsMenuBuilderDelegate, builderDelegate); } public static void AddElementToColorMenu(BuilderDelegate builderDelegate) { colorMenuBuilderDelegate = (BuilderDelegate)Delegate.Combine(colorMenuBuilderDelegate, builderDelegate); } public static void AddElementToLobbyMenu(BuilderDelegate builderDelegate) { lobbyMenuBuilderDelegate = (BuilderDelegate)Delegate.Combine(lobbyMenuBuilderDelegate, builderDelegate); } public static void AddElementToEscapeMenu(BuilderDelegate builderDelegate) { escapeMenuBuilderDelegate = (BuilderDelegate)Delegate.Combine(escapeMenuBuilderDelegate, builderDelegate); } public static void AddElementToRegionSelectionMenu(BuilderDelegate builderDelegate) { regionSelectionMenuBuilderDelegate = (BuilderDelegate)Delegate.Combine(regionSelectionMenuBuilderDelegate, builderDelegate); } public static void AddElementToServerListMenu(BuilderDelegate builderDelegate) { serverListMenuBuilderDelegate = (BuilderDelegate)Delegate.Combine(serverListMenuBuilderDelegate, builderDelegate); } public static void CloseAllPagesAddedOnTop() { MenuManager.instance.PageCloseAllAddedOnTop(); } public static void OpenPopup(string header, Color headerColor, string content, Action onLeftClicked, Action onRightClicked = null) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)menuButtonPopup)) { menuButtonPopup = ((Component)MenuManager.instance).gameObject.AddComponent<MenuButtonPopUp>(); } menuButtonPopup.option1Event = new UnityEvent(); menuButtonPopup.option2Event = new UnityEvent(); if (onLeftClicked != null) { menuButtonPopup.option1Event.AddListener(new UnityAction(onLeftClicked.Invoke)); } if (onRightClicked != null) { menuButtonPopup.option2Event.AddListener(new UnityAction(onRightClicked.Invoke)); } MenuManager.instance.PagePopUpTwoOptions(menuButtonPopup, header, headerColor, content, "Yes", "No", true); } public static REPOButton CreateREPOButton(string text, Action onClick, Transform parent, Vector2 localPosition = default(Vector2)) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.buttonTemplate, parent); ((Object)obj).name = "Button - " + text; ((Transform)obj).localPosition = Vector2.op_Implicit(localPosition); REPOButton rEPOButton = ((Component)obj).gameObject.AddComponent<REPOButton>(); ((TMP_Text)rEPOButton.labelTMP).text = text; rEPOButton.onClick = onClick; return rEPOButton; } public static REPOToggle CreateREPOToggle(string text, Action<bool> onToggle, Transform parent, Vector2 localPosition = default(Vector2), string leftButtonText = "ON", string rightButtonText = "OFF", bool defaultValue = false) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.toggleTemplate, parent); ((Object)obj).name = "Toggle - " + text; ((Transform)obj).localPosition = Vector2.op_Implicit(localPosition); REPOToggle rEPOToggle = ((Component)obj).gameObject.AddComponent<REPOToggle>(); ((TMP_Text)rEPOToggle.labelTMP).text = text; ((TMP_Text)rEPOToggle.leftButtonTMP).text = leftButtonText; ((TMP_Text)rEPOToggle.rightButtonTMP).text = rightButtonText; rEPOToggle.onToggle = onToggle; rEPOToggle.SetState(defaultValue, invokeCallback: false); return rEPOToggle; } public static REPOInputField CreateREPOInputField(string labelText, Action<string> onValueChanged, Transform parent, Vector2 localPosition = default(Vector2), bool onlyNotifyOnSubmit = false, string placeholder = "", string defaultValue = "") { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.toggleTemplate, parent); ((Object)obj).name = "Input Field - " + labelText; ((Transform)obj).localPosition = Vector2.op_Implicit(localPosition); REPOInputField rEPOInputField = ((Component)obj).gameObject.AddComponent<REPOInputField>(); ((TMP_Text)rEPOInputField.labelTMP).text = labelText; rEPOInputField.inputStringSystem.onValueChanged = onValueChanged; rEPOInputField.inputStringSystem.onlyNotifyOnSubmit = onlyNotifyOnSubmit; rEPOInputField.inputStringSystem.placeholder = placeholder; rEPOInputField.inputStringSystem.SetValue(defaultValue, notify: false); return rEPOInputField; } public static REPOSlider CreateREPOSlider(string text, string description, Action<float> onValueChanged, Transform parent, Vector2 localPosition = default(Vector2), float min = 0f, float max = 1f, int precision = 2, float defaultValue = 0f, string prefix = "", string postfix = "", REPOSlider.BarBehavior barBehavior = REPOSlider.BarBehavior.UpdateWithValue) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.sliderTemplate, parent); ((Object)obj).name = "Float Slider - " + text; ((Transform)obj).localPosition = Vector2.op_Implicit(localPosition); REPOSlider rEPOSlider = ((Component)obj).gameObject.AddComponent<REPOSlider>(); ((TMP_Text)rEPOSlider.labelTMP).text = text; ((TMP_Text)rEPOSlider.descriptionTMP).text = description; rEPOSlider.onValueChanged = onValueChanged; rEPOSlider.min = min; rEPOSlider.max = max; rEPOSlider.precision = precision; rEPOSlider.prefix = prefix; rEPOSlider.postfix = postfix; rEPOSlider.barBehavior = barBehavior; rEPOSlider.SetValue(defaultValue, invokeCallback: false); return rEPOSlider; } public static REPOSlider CreateREPOSlider(string text, string description, Action<int> onValueChanged, Transform parent, Vector2 localPosition = default(Vector2), int min = 0, int max = 1, int defaultValue = 0, string prefix = "", string postfix = "", REPOSlider.BarBehavior barBehavior = REPOSlider.BarBehavior.UpdateWithValue) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.sliderTemplate, parent); ((Object)obj).name = "Int Slider - " + text; ((Transform)obj).localPosition = Vector2.op_Implicit(localPosition); REPOSlider rEPOSlider = ((Component)obj).gameObject.AddComponent<REPOSlider>(); ((TMP_Text)rEPOSlider.labelTMP).text = text; ((TMP_Text)rEPOSlider.descriptionTMP).text = description; rEPOSlider.onValueChanged = delegate(float f) { onValueChanged(Convert.ToInt32(f)); }; rEPOSlider.min = min; rEPOSlider.max = max; rEPOSlider.precision = 0; rEPOSlider.prefix = prefix; rEPOSlider.postfix = postfix; rEPOSlider.barBehavior = barBehavior; rEPOSlider.SetValue(defaultValue, invokeCallback: false); return rEPOSlider; } public static REPOSlider CreateREPOSlider(string text, string description, Action<string> onOptionChanged, Transform parent, string[] stringOptions, string defaultOption, Vector2 localPosition = default(Vector2), string prefix = "", string postfix = "", REPOSlider.BarBehavior barBehavior = REPOSlider.BarBehavior.UpdateWithValue) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) RectTransform val = Object.Instantiate<RectTransform>(REPOTemplates.sliderTemplate, parent); ((Object)val).name = "Option Slider - " + text; ((Transform)val).localPosition = Vector2.op_Implicit(localPosition); REPOSlider repoSlider = ((Component)val).gameObject.AddComponent<REPOSlider>(); ((TMP_Text)repoSlider.labelTMP).text = text; ((TMP_Text)repoSlider.descriptionTMP).text = description; repoSlider.onValueChanged = delegate(float f) { onOptionChanged(repoSlider.stringOptions.ElementAtOrDefault(Convert.ToInt32(f)) ?? repoSlider.stringOptions.FirstOrDefault()); }; repoSlider.stringOptions = stringOptions; repoSlider.prefix = prefix; repoSlider.postfix = postfix; repoSlider.barBehavior = barBehavior; int num = Array.IndexOf(stringOptions, defaultOption); if (num == -1) { num = 0; } repoSlider.SetValue(num, invokeCallback: false); return repoSlider; } public static REPOSlider CreateREPOSlider(string text, string description, Action<int> onOptionChanged, Transform parent, string[] stringOptions, string defaultOption, Vector2 localPosition = default(Vector2), string prefix = "", string postfix = "", REPOSlider.BarBehavior barBehavior = REPOSlider.BarBehavior.UpdateWithValue) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.sliderTemplate, parent); ((Object)obj).name = "Option Slider - " + text; ((Transform)obj).localPosition = Vector2.op_Implicit(localPosition); REPOSlider rEPOSlider = ((Component)obj).gameObject.AddComponent<REPOSlider>(); ((TMP_Text)rEPOSlider.labelTMP).text = text; ((TMP_Text)rEPOSlider.descriptionTMP).text = description; rEPOSlider.onValueChanged = delegate(float f) { onOptionChanged(Convert.ToInt32(f)); }; rEPOSlider.stringOptions = stringOptions; rEPOSlider.prefix = prefix; rEPOSlider.postfix = postfix; rEPOSlider.barBehavior = barBehavior; int num = Array.IndexOf(stringOptions, defaultOption); if (num == -1) { num = 0; } rEPOSlider.SetValue(num, invokeCallback: false); return rEPOSlider; } public static REPOLabel CreateREPOLabel(string text, Transform parent, Vector2 localPosition = default(Vector2)) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.labelTemplate, parent); ((Object)obj).name = "Label - " + text; ((Transform)obj).localPosition = Vector2.op_Implicit(localPosition); REPOLabel rEPOLabel = ((Component)obj).gameObject.AddComponent<REPOLabel>(); ((TMP_Text)rEPOLabel.labelTMP).text = text; return rEPOLabel; } public static REPOSpacer CreateREPOSpacer(Transform parent, Vector2 localPosition = default(Vector2), Vector2 size = default(Vector2)) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)new GameObject("Spacer", new Type[1] { typeof(RectTransform) }).transform; ((Transform)val).SetParent(parent); REPOSpacer result = ((Component)val).gameObject.AddComponent<REPOSpacer>(); ((Transform)val).localPosition = Vector2.op_Implicit(localPosition); val.sizeDelta = size; return result; } [Obsolete("Switch to the overload with the 'shouldCachePage' argument!")] public static REPOPopupPage CreateREPOPopupPage(string headerText, REPOPopupPage.PresetSide presetSide, bool pageDimmerVisibility = false, float spacing = 0f) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) return CreateREPOPopupPage(headerText, pageDimmerVisibility, spacing, (presetSide == REPOPopupPage.PresetSide.Left) ? null : new Vector2?(new Vector2(40f, 0f))); } [Obsolete("Switch to the overload with the 'shouldCachePage' argument!")] public static REPOPopupPage CreateREPOPopupPage(string headerText, bool pageDimmerVisibility = false, float spacing = 0f, Vector2? localPosition = null) { return CreateREPOPopupPage(headerText, shouldCachePage: false, pageDimmerVisibility, spacing, localPosition); } public static REPOPopupPage CreateREPOPopupPage(string headerText, REPOPopupPage.PresetSide presetSide, bool shouldCachePage, bool pageDimmerVisibility = false, float spacing = 0f) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return CreateREPOPopupPage(headerText, shouldCachePage, pageDimmerVisibility, spacing, (presetSide == REPOPopupPage.PresetSide.Left) ? null : new Vector2?(new Vector2(40f, 0f))); } public static REPOPopupPage CreateREPOPopupPage(string headerText, bool shouldCachePage, bool pageDimmerVisibility = false, float spacing = 0f, Vector2? localPosition = null) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = Object.Instantiate<RectTransform>(REPOTemplates.popupPageTemplate, ((Component)MenuHolder.instance).transform); ((Object)obj).name = "Menu Page " + headerText; REPOPopupPage rEPOPopupPage = ((Component)obj).gameObject.AddComponent<REPOPopupPage>(); ((Transform)rEPOPopupPage.rectTransform).localPosition = Vector2.op_Implicit((Vector2)(((??)localPosition) ?? new Vector2(-280f, 0f))); ((TMP_Text)rEPOPopupPage.headerTMP).text = headerText; rEPOPopupPage.isCachedPage = shouldCachePage; rEPOPopupPage.pageDimmerVisibility = pageDimmerVisibility; rEPOPopupPage.scrollView.spacing = spacing; return rEPOPopupPage; } public static REPOAvatarPreview CreateREPOAvatarPreview(Transform parent, Vector2 localPosition = default(Vector2), bool enableBackgroundImage = false, Color? backgroundImageColor = null) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) Transform obj = Object.Instantiate<Transform>(REPOTemplates.avatarPreviewTemplate, parent); ((Object)obj).name = "Player Avatar Preview"; REPOAvatarPreview rEPOAvatarPreview = ((Component)obj).gameObject.AddComponent<REPOAvatarPreview>(); ((Transform)rEPOAvatarPreview.rectTransform).localPosition = Vector2.op_Implicit(localPosition); rEPOAvatarPreview.enableBackgroundImage = enableBackgroundImage; rEPOAvatarPreview.backgroundImageColor = (Color)(((??)backgroundImageColor) ?? Color.white); rEPOAvatarPreview.previewSize = new Vector2(184f, 345f); return rEPOAvatarPreview; } public static REPOObjectPreview CreateREPOObjectPreview(Transform parent, GameObject previewObject, Vector2 localPosition = default(Vector2), bool enableBackgroundImage = false, Color? backgroundImageColor = null) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) Transform obj = Object.Instantiate<Transform>(REPOTemplates.avatarPreviewTemplate, parent); ((Object)obj).name = "Object Preview"; REPOObjectPreview rEPOObjectPreview = ((Component)obj).gameObject.AddComponent<REPOObjectPreview>(); ((Transform)rEPOObjectPreview.rectTransform).localPosition = Vector2.op_Implicit(localPosition); rEPOObjectPreview.enableBackgroundImage = enableBackgroundImage; rEPOObjectPreview.backgroundImageColor = (Color)(((??)backgroundImageColor) ?? Color.white); rEPOObjectPreview.previewObject = previewObject; rEPOObjectPreview.previewSize = new Vector2(184f, 345f); return rEPOObjectPreview; } internal static void OpenMenuPage(MenuPage menuPage, bool pageOnTop) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) object? value = REPOReflection.menuManager_CurrentMenuPage.GetValue(MenuManager.instance); MenuPage val = (MenuPage)((value is MenuPage) ? value : null); List<MenuPage> list = REPOReflection.menuManager_AddedPagesOnTop.GetValue(MenuManager.instance) as List<MenuPage>; if (pageOnTop && !Object.op_Implicit((Object)(object)val)) { pageOnTop = false; } if (pageOnTop) { if (list == null || list.Contains(val)) { return; } } else if (Object.op_Implicit((Object)(object)val)) { REPOReflection.menuManager_PageInactiveAdd.Invoke(MenuManager.instance, new object[1] { val }); val.PageStateSet((PageState)3); } ((Component)menuPage).transform.SetAsLastSibling(); ((Behaviour)menuPage).enabled = true; menuPage.ResetPage(); menuPage.PageStateSet((PageState)0); MenuManager.instance.PageAdd(menuPage); ((MonoBehaviour)menuPage).StartCoroutine(REPOReflection.menuPage_LateStart.Invoke(menuPage, null) as IEnumerator); REPOReflection.menuPage_AddedPageOnTop.SetValue(menuPage, false); if (!pageOnTop) { MenuManager.instance.PageSetCurrent(menuPage.menuPageIndex, menuPage); REPOReflection.menuPage_PageIsOnTopOfOtherPage.SetValue(menuPage, true); REPOReflection.menuPage_PageUnderThisPage.SetValue(menuPage, val); } else { REPOReflection.menuPage_ParentPage.SetValue(menuPage, val); list.Add(menuPage); } } internal static void CloseMenuPage(MenuPage menuPage, bool closePagesAddedOnTop) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (closePagesAddedOnTop) { CloseAllPagesAddedOnTop(); } menuPage.PageStateSet((PageState)2); object? value = REPOReflection.menuPage_PageUnderThisPage.GetValue(menuPage); MenuPage val = (MenuPage)((value is MenuPage) ? value : null); if (val != null) { MenuManager.instance.PageSetCurrent(val.menuPageIndex, val); } } } public static class REPOReflection { public static readonly FieldInfo menuManager_CurrentMenuPage = AccessTools.Field(typeof(MenuManager), "currentMenuPage"); public static readonly FieldInfo menuManager_AddedPagesOnTop = AccessTools.Field(typeof(MenuManager), "addedPagesOnTop"); public static readonly FieldInfo menuPage_AddedPageOnTop = AccessTools.Field(typeof(MenuPage), "addedPageOnTop"); public static readonly FieldInfo menuPage_PageUnderThisPage = AccessTools.Field(typeof(MenuPage), "pageUnderThisPage"); public static readonly FieldInfo menuPage_ParentPage = AccessTools.Field(typeof(MenuPage), "parentPage"); public static readonly FieldInfo menuPage_PageIsOnTopOfOtherPage = AccessTools.Field(typeof(MenuPage), "pageIsOnTopOfOtherPage"); public static readonly FieldInfo menuPage_ScrollBoxes = AccessTools.Field(typeof(MenuPage), "scrollBoxes"); public static readonly FieldInfo menuPage_CurrentPageState = AccessTools.Field(typeof(MenuPage), "currentPageState"); public static readonly FieldInfo menuPage_AnimateAwayPosition = AccessTools.Field(typeof(MenuPage), "animateAwayPosition"); public static readonly FieldInfo menuButton_ParentPage = AccessTools.Field(typeof(MenuButton), "parentPage"); public static readonly FieldInfo menuScrollBox_ScrollerEndPosition = AccessTools.Field(typeof(MenuScrollBox), "scrollerEndPosition"); public static readonly FieldInfo menuScrollBox_ScrollerStartPosition = AccessTools.Field(typeof(MenuScrollBox), "scrollerStartPosition"); public static readonly FieldInfo menuScrollBox_ScrollHandleTargetPosition = AccessTools.Field(typeof(MenuScrollBox), "scrollHandleTargetPosition"); public static readonly FieldInfo menuScrollBox_ScrollHeight = AccessTools.Field(typeof(MenuScrollBox), "scrollHeight"); public static readonly FieldInfo menuScrollBox_ScrollAmount = AccessTools.Field(typeof(MenuScrollBox), "scrollAmount"); public static readonly FieldInfo menuScrollBox_ParentPage = AccessTools.Field(typeof(MenuScrollBox), "parentPage"); public static readonly FieldInfo menuSelectableElement_MenuID = AccessTools.Field(typeof(MenuSelectableElement), "menuID"); public static readonly MethodInfo menuManager_PageInactiveAdd = AccessTools.Method(typeof(MenuManager), "PageInactiveAdd", (Type[])null, (Type[])null); public static readonly MethodInfo menuPage_LateStart = AccessTools.Method(typeof(MenuPage), "LateStart", (Type[])null, (Type[])null); } internal static class REPOTemplates { internal static readonly RectTransform pageDimmerTemplate; internal static readonly RectTransform simplePageTemplate; internal static readonly RectTransform buttonTemplate; internal static readonly RectTransform popupPageTemplate; internal static readonly RectTransform toggleTemplate; internal static readonly RectTransform sliderTemplate; internal static readonly RectTransform labelTemplate; internal static readonly Transform avatarPreviewTemplate; static REPOTemplates() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected I4, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown MenuManager instance = MenuManager.instance; if (!Object.op_Implicit((Object)(object)instance)) { throw new NullReferenceException("Error fetching templates... Ensure you're not creating UI elements too early, use \"MenuAPI.AddElementTo...\""); } foreach (MenuPages menuPage in instance.menuPages) { Transform transform = menuPage.menuPage.transform; MenuPageIndex menuPageIndex = menuPage.menuPageIndex; switch ((int)menuPageIndex) { case 0: simplePageTemplate = (RectTransform)transform; buttonTemplate = (RectTransform)((Transform)simplePageTemplate).Find("Menu Button - Quit game"); break; case 2: pageDimmerTemplate = (RectTransform)transform.GetChild(0); break; case 4: popupPageTemplate = (RectTransform)transform; break; case 5: { Transform obj = transform.Find("Menu Scroll Box/Mask/Scroller"); toggleTemplate = (RectTransform)obj.Find("Bool Setting - Push to Talk"); sliderTemplate = (RectTransform)obj.Find("Slider - microphone"); break; } case 6: labelTemplate = (RectTransform)transform.Find("Scroll Box/Mask/Scroller").Find("Header Movement"); break; case 1: avatarPreviewTemplate = transform.Find("Menu Element Player Avatar"); break; } } } } } namespace MenuLib.Structs { public struct Padding { public float left; public float top; public float right; public float bottom; public Padding(float left, float top, float right, float bottom) { this.left = left; this.top = top; this.right = right; this.bottom = bottom; } } } namespace MenuLib.MonoBehaviors { public sealed class REPOAvatarPreview : REPOElement { private PlayerAvatarMenu playerAvatarMenu; private Image backgroundImage; private RectTransform renderTextureRectTransform; public bool enableBackgroundImage { get { return ((Behaviour)backgroundImage).enabled; } set { ((Behaviour)backgroundImage).enabled = value; } } public Color backgroundImageColor { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((Graphic)backgroundImage).color; } set { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Graphic)backgroundImage).color = value; } } public Vector2 previewSize { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return base.rectTransform.sizeDelta; } set { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Vector2 val; if (value.x > value.y) { val = value; val.y = value.x / (8f / 15f); value = val; } else { val = value; val.x = value.y * (8f / 15f); value = val; } RectTransform obj = renderTextureRectTransform; val = (base.rectTransform.sizeDelta = value); obj.sizeDelta = val; ((Transform)renderTextureRectTransform).localPosition = Vector3.zero; } } public PlayerAvatarVisuals playerAvatarVisuals { get; private set; } public Transform rigTransform => playerAvatarVisuals.meshParent.transform; private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) base.rectTransform = ((Component)this).gameObject.AddComponent<RectTransform>(); base.rectTransform.pivot = Vector2.right; RectTransform obj = base.rectTransform; Vector2 anchorMin = (base.rectTransform.anchorMax = Vector2.zero); obj.anchorMin = anchorMin; renderTextureRectTransform = (RectTransform)((Transform)base.rectTransform).GetChild(1); ((Transform)renderTextureRectTransform).localPosition = Vector3.zero; playerAvatarMenu = ((Component)this).GetComponentInChildren<PlayerAvatarMenuHover>().playerAvatarMenu; playerAvatarVisuals = ((Component)playerAvatarMenu).GetComponentInChildren<PlayerAvatarVisuals>(); backgroundImage = ((Component)this).gameObject.AddComponent<Image>(); ((Behaviour)backgroundImage).enabled = false; } private void OnDestroy() { if (Object.op_Implicit((Object)(object)playerAvatarMenu)) { if (Object.op_Implicit((Object)(object)playerAvatarMenu.cameraAndStuff)) { Object.Destroy((Object)(object)((Component)playerAvatarMenu.cameraAndStuff).gameObject); } Object.Destroy((Object)(object)((Component)playerAvatarMenu).gameObject); } } } public sealed class REPOButton : REPOElement { public MenuButton menuButton; public TextMeshProUGUI labelTMP; [Obsolete("Update the button clicked event using the 'onClick' field rather than through the button")] public Button button; public Action onClick; public Vector2? overrideButtonSize; private string previousText; private float previousFontSize; private float previousFontSizeMin; private float previousFontSizeMax; private Vector2? previousOverrideButtonSize; public Vector2 GetLabelSize() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((TMP_Text)labelTMP).GetPreferredValues(); } private void Awake() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown Transform transform = ((Component)this).transform; base.rectTransform = (RectTransform)(object)((transform is RectTransform) ? transform : null); button = ((Component)this).GetComponent<Button>(); menuButton = ((Component)this).GetComponent<MenuButton>(); labelTMP = ((Component)this).GetComponentInChildren<TextMeshProUGUI>(); button.onClick = new ButtonClickedEvent(); ((UnityEvent)button.onClick).AddListener((UnityAction)delegate { onClick?.Invoke(); }); Object.Destroy((Object)(object)((Component)this).GetComponent<MenuButtonPopUp>()); } private void Update() { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (((TMP_Text)labelTMP).text == previousText) { Vector2? val = overrideButtonSize; Vector2? val2 = previousOverrideButtonSize; if (val.HasValue == val2.HasValue && (!val.HasValue || val.GetValueOrDefault() == val2.GetValueOrDefault()) && Math.Abs(((TMP_Text)labelTMP).fontSize - previousFontSize) < float.Epsilon && Math.Abs(((TMP_Text)labelTMP).fontSizeMin - previousFontSizeMin) < float.Epsilon && Math.Abs(((TMP_Text)labelTMP).fontSizeMax - previousFontSizeMax) < float.Epsilon) { return; } } base.rectTransform.sizeDelta = (Vector2)(((??)overrideButtonSize) ?? GetLabelSize()); previousText = ((TMP_Text)labelTMP).text; previousOverrideButtonSize = overrideButtonSize; previousFontSize = ((TMP_Text)labelTMP).fontSize; previousFontSizeMin = ((TMP_Text)labelTMP).fontSizeMin; previousFontSizeMax = ((TMP_Text)labelTMP).fontSizeMax; } private void OnTransformParentChanged() { REPOReflection.menuButton_ParentPage.SetValue(menuButton, ((Component)this).GetComponentInParent<MenuPage>()); } } public class REPOElement : MonoBehaviour { private REPOScrollViewElement _repoScrollViewElement; public RectTransform rectTransform { get; protected set; } public REPOScrollViewElement repoScrollViewElement { get { if (Object.op_Implicit((Object)(object)_repoScrollViewElement)) { return _repoScrollViewElement; } return _repoScrollViewElement = ((Component)this).GetComponent<REPOScrollViewElement>(); } } } public sealed class REPOInputField : REPOElement { public TextMeshProUGUI labelTMP; public REPOInputStringSystem inputStringSystem; private RectTransform inputAreaRectTransform; private MenuPage menuPage; private MenuSelectableElement menuSelectableElement; public Vector2 GetLabelSize() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((TMP_Text)labelTMP).GetPreferredValues(); } private void Awake() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)this).transform; base.rectTransform = (RectTransform)(object)((transform is RectTransform) ? transform : null); menuPage = ((Component)this).GetComponentInParent<MenuPage>(); menuSelectableElement = ((Component)this).GetComponent<MenuSelectableElement>(); labelTMP = ((Component)this).GetComponentInChildren<TextMeshProUGUI>(); RectTransform obj = ((TMP_Text)labelTMP).rectTransform; obj.sizeDelta -= new Vector2(0f, 10f); Vector3 val = Vector3.right * 100f; Transform obj2 = ((Component)this).transform.Find("SliderBG"); obj2.localPosition += val; Transform obj3 = ((Component)this).transform.Find("RawImage"); obj3.localPosition += val; Transform obj4 = ((Component)this).transform.Find("RawImage (1)"); obj4.localPosition += val; RectTransform obj5 = ((TMP_Text)labelTMP).rectTransform; ((Transform)obj5).localPosition = ((Transform)obj5).localPosition + val; TextMeshProUGUI val2 = null; for (int i = 0; i < ((Component)this).transform.childCount; i++) { Transform child = ((Component)this).transform.GetChild(i); switch (((Object)child).name) { case "Option Box": case "Option Box Behind": case "RawImage (2)": Object.Destroy((Object)(object)((Component)child).gameObject); break; case "Button BUTTON": if (!Object.op_Implicit((Object)(object)val2)) { val2 = ((Component)((Component)child).GetComponent<MenuButton>()).GetComponentInChildren<TextMeshProUGUI>(); ((TMP_Text)val2).transform.SetParent(child.parent); } Object.Destroy((Object)(object)((Component)child).gameObject); break; } } ((TMP_Text)val2).rectTransform.pivot = Vector2.zero; ((TMP_Text)val2).fontStyle = (FontStyles)0; ((TMP_Text)val2).enableAutoSizing = false; ((TMP_Text)val2).alignment = (TextAlignmentOptions)513; ((TMP_Text)val2).margin = new Vector4(2f, 2f, 0f, 0f); TextMeshProUGUI obj6 = val2; TextMeshProUGUI obj7 = val2; float num2 = (((TMP_Text)val2).fontSize = 18f); float fontSizeMax = (((TMP_Text)obj7).fontSizeMin = num2); ((TMP_Text)obj6).fontSizeMax = fontSizeMax; GameObject val3 = new GameObject("Input Area"); val3.transform.parent = ((Component)this).transform; inputAreaRectTransform = val3.AddComponent<RectTransform>(); inputAreaRectTransform.sizeDelta = new Vector2(146.5f, 20f); inputAreaRectTransform.pivot = Vector2.zero; ((Transform)inputAreaRectTransform).localPosition = new Vector3(2f, 2.5f, 0f) + val; ((Component)inputAreaRectTransform).gameObject.AddComponent<RectMask2D>(); ((TMP_Text)val2).transform.SetParent((Transform)(object)inputAreaRectTransform); Transform transform2 = ((TMP_Text)val2).transform; Vector2 val5 = (((TMP_Text)val2).rectTransform.sizeDelta = Vector2.op_Implicit(Vector3.zero)); transform2.localPosition = Vector2.op_Implicit(val5); Object.Destroy((Object)(object)((Component)this).GetComponent<MenuSettingElement>()); Object.Destroy((Object)(object)((Component)this).GetComponent<AudioButtonPushToTalk>()); inputStringSystem = ((Component)this).gameObject.AddComponent<REPOInputStringSystem>(); inputStringSystem.inputTMP = (TMP_Text)(object)val2; inputStringSystem.maskRectTransform = inputAreaRectTransform; } private void Update() { inputStringSystem.SetHovering(SemiFunc.UIMouseHover(menuPage, inputAreaRectTransform, (string)REPOReflection.menuSelectableElement_MenuID.GetValue(menuSelectableElement), 2f, 2f)); if (Mouse.current.leftButton.wasPressedThisFrame) { inputStringSystem.isFocused = inputStringSystem.isHovering; } } } public sealed class REPOInputStringSystem : MonoBehaviour { public struct Colors { public Color focusedColor; public Color hoverColor; public Color unfocusedColor; public Color placeholderColor; public Color characterAddedColor; public Color characterRemovedColor; public Colors() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) focusedColor = Color.white; hoverColor = Color.white; unfocusedColor = new Color(0.5f, 0.5f, 0.5f); placeholderColor = new Color(1f, 0.6f, 0.4f); characterAddedColor = new Color(0.5f, 1f, 0.5f); characterRemovedColor = new Color(1f, 0.5f, 0.5f); } } public static bool hasAnyFocus; public TMP_Text inputTMP; public RectTransform maskRectTransform; public Action<string> onValueChanged; public Colors colors = new Colors(); public string placeholder = string.Empty; public bool onlyNotifyOnSubmit; public bool disableMovement = true; private string previousValue; private float timeSinceCharacterAdded = 1f; private float timeSinceCharacterRemoved = 1f; private bool pressedSubmit; private bool _isFocused; public string currentValue { get; private set; } public bool isHovering { get; private set; } public bool isFocused { get { return _isFocused; } set { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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) if (!value) { if (_isFocused) { MoveTMP(reset: true); } } else if (!isFocused) { if (IsTMPInMask()) { MoveTMP(reset: true); } else { float num = 0f - inputTMP.GetPreferredValues(currentValue + "<b>|</b>").x; Rect rect = maskRectTransform.rect; MoveTMP(reset: true, num + ((Rect)(ref rect)).width - 6f); } ((SemiUI)ChatUI.instance).Hide(); } hasAnyFocus = (_isFocused = value); } } private bool shouldUsePlaceholder => string.IsNullOrEmpty(currentValue); public void SetValue(string value, bool notify) { string text2 = (currentValue = value); previousValue = text2; if (notify) { onValueChanged?.Invoke(value); } } public void SetHovering(bool value) { if (value && !isHovering) { MenuManager.instance.MenuEffectHover(SemiFunc.MenuGetPitchFromYPos(inputTMP.rectTransform), -1f); } isHovering = value; } private void Update() { if (!Object.op_Implicit((Object)(object)inputTMP)) { return; } if (disableMovement && isFocused) { InputManager instance = InputManager.instance; if (instance != null) { instance.DisableMovement(); } } HandleInput(); UpdateColors(); if (pressedSubmit) { isFocused = false; pressedSubmit = false; if (onlyNotifyOnSubmit) { onValueChanged?.Invoke(currentValue); } } if (!onlyNotifyOnSubmit && previousValue != currentValue) { onValueChanged?.Invoke(currentValue); } if (isFocused) { inputTMP.text = currentValue; if (timeSinceCharacterAdded < 0.5f || timeSinceCharacterRemoved < 0.5f || Mathf.Sin(Time.time * 10f) > 0f) { TMP_Text obj = inputTMP; obj.text += "<b>|</b>"; } } else { inputTMP.text = (shouldUsePlaceholder ? placeholder : currentValue); } previousValue = currentValue; } private void OnDestroy() { hasAnyFocus = false; } private void HandleInput() { //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) if (timeSinceCharacterAdded < 1f) { timeSinceCharacterAdded += Time.deltaTime; } if (timeSinceCharacterRemoved < 1f) { timeSinceCharacterRemoved += Time.deltaTime; } if (!isFocused) { return; } string previousText = currentValue; if (Keyboard.current.ctrlKey.isPressed) { if (((ButtonControl)Keyboard.current.cKey).wasPressedThisFrame) { GUIUtility.systemCopyBuffer = currentValue; } else if (((ButtonControl)Keyboard.current.xKey).wasPressedThisFrame) { GUIUtility.systemCopyBuffer = currentValue; currentValue = null; timeSinceCharacterRemoved = 0f; MoveTMP(reset: true); } else if (((ButtonControl)Keyboard.current.vKey).wasPressedThisFrame) { currentValue += GUIUtility.systemCopyBuffer.Replace("\n", string.Empty); timeSinceCharacterAdded = 0f; if (IsTMPInMask()) { MoveTMP(reset: true); return; } float num = 0f - inputTMP.GetPreferredValues(currentValue + "<b>|</b>").x; Rect rect = maskRectTransform.rect; MoveTMP(reset: true, num + ((Rect)(ref rect)).width - 6f); } return; } string inputString = Input.inputString; if (!(inputString == "\b")) { if (inputString == "\r") { pressedSubmit = true; } else if (!string.IsNullOrEmpty(inputString)) { currentValue += inputString; timeSinceCharacterAdded = 0f; if (IsTMPInMask()) { MoveTMP(reset: true); } else { MoveTMP(reset: false, 0f - CalculateTMPDifference(previousText, currentValue)); } } } else if (currentValue.Length > 0) { currentValue = currentValue.Remove(currentValue.Length - 1, 1); timeSinceCharacterRemoved = 0f; if (IsTMPInMask()) { MoveTMP(reset: true); } else { MoveTMP(reset: false, 0f - CalculateTMPDifference(previousText, currentValue)); } } } private void UpdateColors() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (timeSinceCharacterAdded < 0.1f) { ((Graphic)inputTMP).color = colors.characterAddedColor; } else if (timeSinceCharacterRemoved < 0.1f) { ((Graphic)inputTMP).color = colors.characterRemovedColor; } else if (isHovering) { ((Graphic)inputTMP).color = colors.hoverColor; } else if (isFocused) { ((Graphic)inputTMP).color = colors.focusedColor; } else { ((Graphic)inputTMP).color = (shouldUsePlaceholder ? colors.placeholderColor : colors.unfocusedColor); } } private void MoveTMP(bool reset, float moveBy = 0f) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (reset) { inputTMP.transform.localPosition = Vector3.zero; } if (moveBy != 0f) { Transform transform = inputTMP.transform; transform.localPosition += Vector3.right * moveBy; } } private float CalculateTMPDifference(string previousText, string newText) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) return inputTMP.GetPreferredValues(newText).x - inputTMP.GetPreferredValues(previousText).x; } private bool IsTMPInMask() { //IL_000c: 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) //IL_0021: Unknown result type (might be due to invalid IL or missing references) float x = inputTMP.GetPreferredValues(currentValue).x; Rect rect = maskRectTransform.rect; return x < ((Rect)(ref rect)).width - 6f; } } public sealed class REPOLabel : REPOElement { public TextMeshProUGUI labelTMP; private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_002e: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) base.rectTransform = (RectTransform)((Component)this).transform; labelTMP = ((Component)this).GetComponentInChildren<TextMeshProUGUI>(); Vector2 sizeDelta = (((TMP_Text)labelTMP).rectTransform.pivot = (base.rectTransform.pivot = Vector2.zero)); RectTransform obj = ((TMP_Text)labelTMP).rectTransform; RectTransform obj2 = base.rectTransform; ((Vector2)(ref sizeDelta))..ctor(200f, 30f); obj2.sizeDelta = sizeDelta; obj.sizeDelta = sizeDelta; ((TMP_Text)labelTMP).fontSize = 30f; TextMeshProUGUI obj3 = labelTMP; bool enableWordWrapping = (((TMP_Text)labelTMP).enableAutoSizing = false); ((TMP_Text)obj3).enableWordWrapping = enableWordWrapping; ((TMP_Text)labelTMP).alignment = (TextAlignmentOptions)513; ((TMP_Text)labelTMP).margin = Vector4.zero; } private void Start() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) ((Transform)((TMP_Text)labelTMP).rectTransform).localPosition = Vector2.op_Implicit(Vector2.zero); } } public sealed class REPOObjectPreview : REPOElement { private PlayerAvatarMenuHover playerAvatarMenuHover; private Image backgroundImage; private RectTransform renderTextureRectTransform; private GameObject _previewObject; public GameObject previewObject { get { return _previewObject; } set { if (!((Object)(object)_previewObject == (Object)(object)value)) { UpdatePreviewGameObject(value); _previewObject = value; } } } public bool enableBackgroundImage { get { return ((Behaviour)backgroundImage).enabled; } set { ((Behaviour)backgroundImage).enabled = value; } } public Color backgroundImageColor { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((Graphic)backgroundImage).color; } set { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Graphic)backgroundImage).color = value; } } public Vector2 previewSize { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return base.rectTransform.sizeDelta; } set { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Vector2 val; if (value.x > value.y) { val = value; val.y = value.x / (8f / 15f); value = val; } else { val = value; val.x = value.y * (8f / 15f); value = val; } RectTransform obj = renderTextureRectTransform; val = (base.rectTransform.sizeDelta = value); obj.sizeDelta = val; ((Transform)renderTextureRectTransform).localPosition = Vector3.zero; } } private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) base.rectTransform = ((Component)this).gameObject.AddComponent<RectTransform>(); base.rectTransform.pivot = Vector2.right; RectTransform obj = base.rectTransform; Vector2 anchorMin = (base.rectTransform.anchorMax = Vector2.zero); obj.anchorMin = anchorMin; renderTextureRectTransform = (RectTransform)((Transform)base.rectTransform).GetChild(1); ((Transform)renderTextureRectTransform).localPosition = Vector3.zero; playerAvatarMenuHover = ((Component)this).GetComponentInChildren<PlayerAvatarMenuHover>(); ((Component)playerAvatarMenuHover.playerAvatarMenu.cameraAndStuff).GetComponentInChildren<Camera>().farClipPlane = 100f; backgroundImage = ((Component)this).gameObject.AddComponent<Image>(); ((Behaviour)backgroundImage).enabled = false; } private void Start() { Transform transform = ((Component)playerAvatarMenuHover.playerAvatarMenu).transform; for (int i = 0; i < 3; i++) { Object.Destroy((Object)(object)((Component)transform.GetChild(i)).gameObject); } } private void OnDestroy() { if (!Object.op_Implicit((Object)(object)playerAvatarMenuHover) || !Object.op_Implicit((Object)(object)playerAvatarMenuHover.playerAvatarMenu)) { return; } PlayerAvatarMenu playerAvatarMenu = playerAvatarMenuHover.playerAvatarMenu; if (Object.op_Implicit((Object)(object)playerAvatarMenu)) { Transform cameraAndStuff = playerAvatarMenu.cameraAndStuff; if (Object.op_Implicit((Object)(object)cameraAndStuff)) { Object.Destroy((Object)(object)((Component)cameraAndStuff).gameObject); } Object.Destroy((Object)(object)((Component)playerAvatarMenu).gameObject); } } private void UpdatePreviewGameObject(GameObject previewGameObject) { if (Object.op_Implicit((Object)(object)previewObject)) { Object.Destroy((Object)(object)previewObject); } previewGameObject.transform.SetParent(((Component)playerAvatarMenuHover.playerAvatarMenu).transform, false); Rigidbody component = previewGameObject.GetComponent<Rigidbody>(); if (component != null) { component.automaticInertiaTensor = false; } } } public sealed class REPOPopupPage : MonoBehaviour { public enum PresetSide { Left, Right } public delegate RectTransform ScrollViewBuilderDelegate(Transform scrollView); public delegate bool ShouldCloseMenuDelegate(); public RectTransform rectTransform; public RectTransform maskRectTransform; public RectTransform scrollBarRectTransform; public MenuPage menuPage; public TextMeshProUGUI headerTMP; public MenuScrollBox menuScrollBox; public REPOScrollView scrollView; [Obsolete("Use onEscapePressed instead.")] public bool closeMenuOnEscape = true; public ShouldCloseMenuDelegate onEscapePressed; internal bool pageWasActivatedOnce; private GameObject pageDimmerGameObject; private RawImage pageDimmerRawImage; private RectTransform scrollBarFillRectTransform; private RectTransform scrollBarOutlineRectTransform; private Vector2 defaultMaskSizeDelta; private Vector2 defaultMaskPosition; private Padding _maskPadding; public bool pageDimmerVisibility { get { return pageDimmerGameObject.gameObject.activeSelf; } set { pageDimmerGameObject.gameObject.SetActive(value); } } public bool isCachedPage { get; internal set; } public float pageDimmerOpacity { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((Graphic)pageDimmerRawImage).color.a; } set { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) RawImage obj = pageDimmerRawImage; Color color = ((Graphic)pageDimmerRawImage).color; color.a = value; ((Graphic)obj).color = color; } } public Padding maskPadding { get { return _maskPadding; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) Vector2 sizeDelta = defaultMaskSizeDelta; Vector2 val = defaultMaskPosition; sizeDelta.x -= value.left + value.right; sizeDelta.y -= value.top + value.bottom; if (value.left != 0f) { val.x += value.left; } if (value.bottom != 0f) { val.y += value.bottom; } maskRectTransform.sizeDelta = sizeDelta; ((Transform)maskRectTransform).localPosition = Vector2.op_Implicit(val); _maskPadding = value; UpdateScrollBarPosition(); } } public void OpenPage(bool openOnTop) { MenuAPI.OpenMenuPage(menuPage, openOnTop); pageWasActivatedOnce = true; scrollView.UpdateElements(); } public void ClosePage(bool closePagesAddedOnTop) { MenuAPI.CloseMenuPage(menuPage, closePagesAddedOnTop); } public void AddElement(MenuAPI.BuilderDelegate builderDelegate) { builderDelegate?.Invoke(((Component)this).transform); } public void AddElement(RectTransform elementRectTransform, Vector2 localPosition = default(Vector2)) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) ((Transform)elementRectTransform).SetParent(((Component)this).transform); ((Transform)elementRectTransform).localPosition = Vector2.op_Implicit(localPosition); } public void AddElementToScrollView(ScrollViewBuilderDelegate scrollViewBuilderDelegate, float topPadding = 0f, float bottomPadding = 0f) { object obj; if (scrollViewBuilderDelegate == null) { obj = null; } else { RectTransform obj2 = scrollViewBuilderDelegate((Transform)(object)menuScrollBox.scroller); obj = ((obj2 != null) ? ((Component)obj2).gameObject.AddComponent<REPOScrollViewElement>() : null); } REPOScrollViewElement rEPOScrollViewElement = (REPOScrollViewElement)obj; if (rEPOScrollViewElement != null) { rEPOScrollViewElement.onSettingChanged = scrollView.UpdateElements; rEPOScrollViewElement.topPadding = topPadding; rEPOScrollViewElement.bottomPadding = bottomPadding; } } public void AddElementToScrollView(RectTransform elementRectTransform, Vector2 localPosition = default(Vector2), float topPadding = 0f, float bottomPadding = 0f) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) REPOScrollViewElement rEPOScrollViewElement = ((Component)elementRectTransform).gameObject.AddComponent<REPOScrollViewElement>(); if (rEPOScrollViewElement != null) { rEPOScrollViewElement.onSettingChanged = scrollView.UpdateElements; ((Transform)elementRectTransform).SetParent((Transform)(object)menuScrollBox.scroller); ((Transform)elementRectTransform).localPosition = Vector2.op_Implicit(localPosition); rEPOScrollViewElement.topPadding = topPadding; rEPOScrollViewElement.bottomPadding = bottomPadding; } } private void Awake() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown menuPage = ((Component)this).GetComponent<MenuPage>(); headerTMP = ((Component)this).GetComponentInChildren<TextMeshProUGUI>(); menuScrollBox = ((Component)this).GetComponentInChildren<MenuScrollBox>(); rectTransform = (RectTransform)new GameObject("Page Content", new Type[1] { typeof(RectTransform) }).transform; ((Transform)rectTransform).SetParent(((Component)this).transform); ((Component)this).transform.Find("Panel").SetParent((Transform)(object)rectTransform); ((TMP_Text)headerTMP).transform.parent.SetParent((Transform)(object)rectTransform); ((Component)menuScrollBox).transform.SetParent((Transform)(object)rectTransform); pageDimmerGameObject = ((Component)Object.Instantiate<RectTransform>(REPOTemplates.pageDimmerTemplate, ((Component)this).transform)).gameObject; pageDimmerGameObject.transform.SetAsFirstSibling(); pageDimmerRawImage = pageDimmerGameObject.GetComponentInChildren<RawImage>(); menuPage.menuPageIndex = (MenuPageIndex)(-1); RectTransform scroller = menuScrollBox.scroller; for (int i = 2; i < ((Transform)scroller).childCount; i++) { Object.Destroy((Object)(object)((Component)((Transform)scroller).GetChild(i)).gameObject); } scrollView = ((Component)scroller).gameObject.AddComponent<REPOScrollView>(); scrollView.popupPage = this; maskRectTransform = (RectTransform)((Transform)scroller).parent; defaultMaskSizeDelta = maskRectTransform.sizeDelta; defaultMaskPosition = Vector2.op_Implicit(((Transform)maskRectTransform).localPosition); menuScrollBox.scroller.sizeDelta = maskRectTransform.sizeDelta; scrollBarRectTransform = (RectTransform)menuScrollBox.scrollBar.transform; scrollBarFillRectTransform = (RectTransform)((Transform)scrollBarRectTransform).Find("Scroll Bar Bg (2)"); scrollBarOutlineRectTransform = (RectTransform)((Transform)scrollBarRectTransform).Find("Scroll Bar Bg (1)"); maskPadding = new Padding(0f, 0f, 0f, 25f); Object.Destroy((Object)(object)((Component)this).GetComponent<MenuPageSettingsPage>()); MenuAPI.customMenuPages.Add(menuPage, this); } private void Start() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) REPOReflection.menuScrollBox_ScrollerEndPosition.SetValue(menuScrollBox, 0); RectTransform scroller = menuScrollBox.scroller; Vector3 localPosition = ((Transform)menuScrollBox.scroller).localPosition; localPosition.y = 0f; ((Transform)scroller).localPosition = localPosition; REPOReflection.menuPage_ScrollBoxes.SetValue(menuPage, 2); if (!pageWasActivatedOnce) { menuPage.PageStateSet((PageState)2); } scrollView.SetScrollPosition(0f); } private void Update() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 if (closeMenuOnEscape) { PageState val = (PageState)REPOReflection.menuPage_CurrentPageState.GetValue(menuPage); if (SemiFunc.InputDown((InputKey)18) && (int)val != 2 && (onEscapePressed == null || onEscapePressed())) { ClosePage(closePagesAddedOnTop: false); } } } private void OnDestroy() { MenuAPI.customMenuPages.Remove(menuPage); } private void UpdateScrollBarPosition() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)scrollBarRectTransform)) { RectTransform obj = scrollBarRectTransform; Vector3 localPosition = ((Transform)scrollBarRectTransform).localPosition; localPosition.y = ((Transform)maskRectTransform).localPosition.y; ((Transform)obj).localPosition = localPosition; Vector2 sizeDelta = scrollBarRectTransform.sizeDelta; sizeDelta.y = maskRectTransform.sizeDelta.y; RectTransform scrollBarBackground = menuScrollBox.scrollBarBackground; RectTransform obj2 = scrollBarFillRectTransform; Vector2 val2 = (scrollBarRectTransform.sizeDelta = sizeDelta); Vector2 sizeDelta2 = (obj2.sizeDelta = val2); scrollBarBackground.sizeDelta = sizeDelta2; scrollBarOutlineRectTransform.sizeDelta = sizeDelta + new Vector2(4f, 4f); } } } public sealed class REPOScrollView : MonoBehaviour { public REPOPopupPage popupPage; public float? scrollSpeed; private REPOScrollViewElement[] scrollViewElements = Array.Empty<REPOScrollViewElement>(); private float _spacing; public float spacing { get { return _spacing; } set { if (!(Math.Abs(_spacing - value) < float.Epsilon)) { _spacing = value; UpdateElements(); } } } public void UpdateElements() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) scrollViewElements = ((Component)this).GetComponentsInChildren<REPOScrollViewElement>(true); float num = 0f; float num2 = popupPage.maskRectTransform.sizeDelta.y; REPOScrollViewElement[] array = scrollViewElements; Rect rect; foreach (REPOScrollViewElement rEPOScrollViewElement in array) { if (rEPOScrollViewElement.visibility) { Vector3 localPosition = ((Transform)rEPOScrollViewElement.rectTransform).localPosition; num2 -= rEPOScrollViewElement.topPadding; float num3 = num2; rect = rEPOScrollViewElement.rectTransform.rect; num2 = num3 - ((Rect)(ref rect)).height; num = (localPosition.y = num2); num2 -= rEPOScrollViewElement.bottomPadding; num2 -= spacing; ((Transform)rEPOScrollViewElement.rectTransform).localPosition = localPosition; } } GameObject gameObject = ((Component)popupPage.scrollBarRectTransform).gameObject; MenuScrollBox menuScrollBox = popupPage.menuScrollBox; RectTransform scroller = menuScrollBox.scroller; float num4 = num; if (!(num4 < 0f)) { if (num4 >= 0f && gameObject.activeSelf) { ((Component)popupPage.scrollBarRectTransform).gameObject.SetActive(false); Vector3 localPosition2 = ((Transform)scroller).localPosition; localPosition2.y = 0f; ((Transform)scroller).localPosition = localPosition2; } } else if (!gameObject.activeSelf) { ((Component)popupPage.scrollBarRectTransform).gameObject.SetActive(true); } FieldInfo menuScrollBox_ScrollerStartPosition = REPOReflection.menuScrollBox_ScrollerStartPosition; float num5 = num; rect = menuScrollBox.scrollHandle.rect; float height = ((Rect)(ref rect)).height; rect = menuScrollBox.scrollBarBackground.rect; menuScrollBox_ScrollerStartPosition.SetValue(menuScrollBox, Math.Abs(num5 / (1f - height / ((Rect)(ref rect)).height))); } public void SetScrollPosition(float normalizedPosition) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) normalizedPosition = Mathf.Clamp(1f - normalizedPosition, 0f, 1f); Rect rect = popupPage.menuScrollBox.scrollBarBackground.rect; float height = ((Rect)(ref rect)).height; float num = normalizedPosition * height; float num2 = popupPage.menuScrollBox.scrollHandle.sizeDelta.y / 2f; if (num < num2) { num = num2; } else if (num > height - num2) { num = height - num2; } REPOReflection.menuScrollBox_ScrollHandleTargetPosition.SetValue(popupPage.menuScrollBox, num); } private void OnTransformChildrenChanged() { UpdateElements(); } private void Update() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) RectTransform maskRectTransform = popupPage.maskRectTransform; REPOScrollViewElement[] array = scrollViewElements; foreach (REPOScrollViewElement rEPOScrollViewElement in array) { if (!rEPOScrollViewElement.visibility) { continue; } Vector3 position = ((Component)rEPOScrollViewElement).transform.position; bool num = position.y <= ((Transform)maskRectTransform).position.y + maskRectTransform.sizeDelta.y + 50f && position.y >= ((Transform)maskRectTransform).position.y - 50f; GameObject gameObject = ((Component)rEPOScrollViewElement).gameObject; if (!num) { if (gameObject.activeSelf) { gameObject.SetActive(false); } } else if (!gameObject.activeSelf) { gameObject.SetActive(true); } } } } public sealed class REPOScrollViewElement : MonoBehaviour { public RectTransform rectTransform; internal Action onSettingChanged; private bool _visibility = true; private float _topPadding; private float _bottomPadding; public float topPadding { get { return _topPadding; } set { if (!(Math.Abs(_topPadding - value) < float.Epsilon)) { _topPadding = value; onSettingChanged?.Invoke(); } } } public float bottomPadding { get { return _bottomPadding; } set { if (!(Math.Abs(_bottomPadding - value) < float.Epsilon)) { _bottomPadding = value; onSettingChanged?.Invoke(); } } } public bool visibility { get { return _visibility; } set { if (_visibility != value) { _visibility = value; ((Component)this).gameObject.SetActive(value); onSettingChanged?.Invoke(); } } } private void Awake() { ref RectTransform reference = ref rectTransform; Transform transform = ((Component)this).transform; reference = (RectTransform)(object)((transform is RectTransform) ? transform : null); } private void OnRectTransformDimensionsChange() { onSettingChanged?.Invoke(); } } public sealed class REPOSlider : REPOElement { public enum BarBehavior { UpdateWithValue, StaticAtMinimum, StaticAtMaximum } public TextMeshProUGUI labelTMP; public TextMeshProUGUI descriptionTMP; public REPOTextScroller repoTextScroller; public Action<float> onValueChanged; public BarBehavior barBehavior; public float value; public string prefix; public string postfix; private RectTransform barRectTransform; private RectTransform barSizeRectTransform; private RectTransform barPointerRectTransform; private RectTransform barMaskRectTransform; private RectTransform sliderBackgroundRectTransform; private RectTransform backgroundFillRectTransform; private RectTransform backgroundOutlineRectTransform; private TextMeshProUGUI valueTMP; private TextMeshProUGUI maskedValueTMP; private MenuPage menuPage; private MenuSelectableElement menuSelectableElement; private float _min; private float _max = 1f; private float previousValue; private float _precisionDecimal = 0.01f; private int _precision = 2; private string[] _stringOptions = Array.Empty<string>(); private string currentDescription; private bool isHovering; public float min { get { string[] array = stringOptions; if (array == null || array.Length == 0) { return _min; } return 0f; } set { _min = value; } } public float max { get { string[] array = stringOptions; if (array == null || array.Length == 0) { return _max; } return stringOptions.Length - 1; } set { _max = value; } } public string[] stringOptions { get { return _stringOptions; } set { _stringOptions = value; UpdateBarText(); } } public int precision { get { string[] array = stringOptions; if (array == null || array.Length == 0) { return _precision; } return 0; } set { precisionDecimal = ((value == 0) ? 1f : Mathf.Pow(10f, (float)(-value))); _precision = value; } } public float precisionDecimal { get { string[] array = stringOptions; if (array == null || array.Length == 0) { return _precisionDecimal; } return 1f; } set { _precisionDecimal = value; } } private float normalizedValue => (value - min) / (max - min); private bool hasValueChanged => Math.Abs(value - previousValue) > float.Epsilon; public void SetValue(float newValue, bool invokeCallback) { newValue = Mathf.Clamp(newValue, min, max); if (invokeCallback && Math.Abs(value - newValue) > float.Epsilon) { onValueChanged(newValue); } previousValue = (value = newValue); UpdateBarVisual(); UpdateBarText(); } public void Decrement() { float num = value - precisionDecimal; if (Math.Abs(value - min) < float.Epsilon) { num = max; } else if (num < min) { num = min; } SetValue(num, invokeCallback: true); } public void Increment() { float num = value + precisionDecimal; if (Math.Abs(max - value) < float.Epsilon) { num = min; } else if (num > max) { num = max; } SetValue(num, invokeCallback: true); } private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_01e2: Unknown result type (might be due to invalid IL or missi
REPOLib.dll
Decompiled 9 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using REPOLib.Extensions; using REPOLib.Modules; using REPOLib.Objects; using REPOLib.Objects.Sdk; using REPOLib.Patches; using TMPro; using UnityEngine; using UnityEngine.Audio; 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("Zehs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2025 Zehs")] [assembly: AssemblyDescription("Library for adding content to R.E.P.O.")] [assembly: AssemblyFileVersion("3.0.2.0")] [assembly: AssemblyInformationalVersion("3.0.2+d7d9f6f839c1382b8be7fabbafc5a78730321381")] [assembly: AssemblyProduct("REPOLib")] [assembly: AssemblyTitle("REPOLib")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ZehsTeam/REPOLib")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("3.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.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; } } [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; } } } namespace REPOLib { public static class BundleLoader { private class LoadOperation { public enum State { LoadingBundle, LoadingContent } public string Path { get; } public DateTime StartTime { get; } public State CurrentState { get; set; } public bool LoadContents { get; } public Func<AssetBundle, IEnumerator>? OnBundleLoaded { get; } public AssetBundleCreateRequest BundleRequest { get; } public TimeSpan ElapsedTime => DateTime.Now - StartTime; public string FileName => System.IO.Path.GetFileNameWithoutExtension(Path); public LoadOperation(string path, Func<AssetBundle, IEnumerator>? onBundleLoaded = null, bool loadContents = true) { Path = path; StartTime = DateTime.Now; LoadContents = loadContents; OnBundleLoaded = onBundleLoaded; BundleRequest = AssetBundle.LoadFromFileAsync(path); base..ctor(); } } [CompilerGenerated] private sealed class <>c__DisplayClass10_0 { public Action<AssetBundle> onLoaded; public string path; } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct <>c__DisplayClass14_0 { public LoadOperation operation; } [CompilerGenerated] private sealed class <FinishLoadOperation>d__14 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public LoadOperation operation; private <>c__DisplayClass14_0 <>8__1; private AssetBundle <bundle>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FinishLoadOperation>d__14(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = default(<>c__DisplayClass14_0); <bundle>5__2 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1.operation = operation; <>2__current = <>8__1.operation.BundleRequest; <>1__state = 1; return true; case 1: <>1__state = -1; <bundle>5__2 = <>8__1.operation.BundleRequest.assetBundle; if ((Object)(object)<bundle>5__2 == (Object)null) { Logger.LogError("Failed to load bundle " + <>8__1.operation.FileName + "!"); <FinishLoadOperation>g__Finish|14_0(ref <>8__1); return false; } if (<>8__1.operation.LoadContents) { <>2__current = LoadBundleContent(<>8__1.operation, <bundle>5__2); <>1__state = 2; return true; } goto IL_00f6; case 2: <>1__state = -1; goto IL_00f6; case 3: { <>1__state = -1; break; } IL_00f6: if (<>8__1.operation.OnBundleLoaded != null) { <>2__current = <>8__1.operation.OnBundleLoaded(<bundle>5__2); <>1__state = 3; return true; } break; } if (ConfigManager.ExtendedLogging.Value) { Logger.LogInfo($"Loaded bundle {<>8__1.operation.FileName} in {<>8__1.operation.ElapsedTime.TotalSeconds:N1}s"); } <FinishLoadOperation>g__Finish|14_0(ref <>8__1); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <FinishLoadOperationsRoutine>d__13 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MonoBehaviour behaviour; private float <lastUpdate>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FinishLoadOperationsRoutine>d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: { <>1__state = -1; AllBundlesLoaded = false; LoadOperation[] array = _operations.ToArray(); foreach (LoadOperation operation in array) { behaviour.StartCoroutine(FinishLoadOperation(operation)); } BundleLoaderLoadingText.Create(); <lastUpdate>5__2 = Time.time; break; } case 2: <>1__state = -1; break; } while (_operations.Count > 0) { if (Time.time - <lastUpdate>5__2 > 1f) { <lastUpdate>5__2 = Time.time; string arg = ((_operations.Count == 1) ? "bundle" : "bundles"); BundleLoaderLoadingText.SetText($"REPOLib: Waiting for {_operations.Count} {arg} to load..."); if (!ConfigManager.ExtendedLogging.Value) { continue; } foreach (LoadOperation operation2 in _operations) { string text = $"Loading {operation2.FileName}: {operation2.CurrentState}"; float? num = ((operation2.CurrentState != 0) ? null : new float?(((AsyncOperation)operation2.BundleRequest).progress)); float? num2 = num; if (num2.HasValue) { text += $" {num2.Value:P0}"; } Logger.LogDebug(text); } } <>2__current = null; <>1__state = 2; return true; } Logger.LogInfo("Finished loading bundles."); BundleLoaderLoadingText.Hide(); AllBundlesLoaded = true; Utilities.SafeInvokeEvent(BundleLoader.OnAllBundlesLoaded); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadBundleContent>d__15 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public LoadOperation operation; public AssetBundle bundle; private AssetBundleRequest <assetRequest>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadBundleContent>d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <assetRequest>5__2 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; operation.CurrentState = LoadOperation.State.LoadingContent; <assetRequest>5__2 = bundle.LoadAllAssetsAsync<ScriptableObject>(); <>2__current = <assetRequest>5__2; <>1__state = 1; return true; case 1: { <>1__state = -1; Object[] allAssets = <assetRequest>5__2.allAssets; Mod[] array = allAssets.OfType<Mod>().ToArray(); int num = array.Length; if (num <= 1) { if (num == 0) { Logger.LogError("Bundle " + operation.FileName + " contains no mods!"); return false; } Mod mod = array[0]; foreach (Content item in allAssets.OfType<Content>()) { try { item.Initialize(mod); } catch (Exception ex) { Logger.LogError($"Failed to load {item.Name} ({((object)item).GetType().Name}) from bundle {operation.FileName} ({mod.Identifier}): {ex}"); } } return false; } Logger.LogError("Bundle " + operation.FileName + " contains more than one mod!"); return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly List<LoadOperation> _operations = new List<LoadOperation>(); internal static bool AllBundlesLoaded { get; private set; } public static event Action? OnAllBundlesLoaded; internal static void LoadAllBundles(string root, string withExtension) { Logger.LogInfo("Loading all bundles with extension " + withExtension + " from root " + root, extended: true); string[] files = Directory.GetFiles(root, "*" + withExtension, SearchOption.AllDirectories); string[] array = files; foreach (string path in array) { LoadBundleAndContent(path); } } public static void LoadBundleAndContent(string path) { LoadBundle(path, (Func<AssetBundle, IEnumerator>?)null, loadContents: true); } public static void LoadBundle(string path, Action<AssetBundle> onLoaded, bool loadContents = false) { <>c__DisplayClass10_0 CS$<>8__locals0 = new <>c__DisplayClass10_0(); CS$<>8__locals0.onLoaded = onLoaded; CS$<>8__locals0.path = path; LoadBundle(CS$<>8__locals0.path, (Func<AssetBundle, IEnumerator>?)OnLoaded, loadContents); [IteratorStateMachine(typeof(<>c__DisplayClass10_0.<<LoadBundle>g__OnLoaded|0>d))] IEnumerator OnLoaded(AssetBundle bundle) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <>c__DisplayClass10_0.<<LoadBundle>g__OnLoaded|0>d(0) { <>4__this = CS$<>8__locals0, bundle = bundle }; } } public static void LoadBundle(string path, Func<AssetBundle, IEnumerator>? onLoaded = null, bool loadContents = false) { Logger.LogInfo("Loading bundle at " + path + "..."); _operations.Add(new LoadOperation(path, onLoaded, loadContents)); } internal static void FinishLoadOperations(MonoBehaviour behaviour) { behaviour.StartCoroutine(FinishLoadOperationsRoutine(behaviour)); } [IteratorStateMachine(typeof(<FinishLoadOperationsRoutine>d__13))] private static IEnumerator FinishLoadOperationsRoutine(MonoBehaviour behaviour) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FinishLoadOperationsRoutine>d__13(0) { behaviour = behaviour }; } [IteratorStateMachine(typeof(<FinishLoadOperation>d__14))] private static IEnumerator FinishLoadOperation(LoadOperation operation) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FinishLoadOperation>d__14(0) { operation = operation }; } [IteratorStateMachine(typeof(<LoadBundleContent>d__15))] private static IEnumerator LoadBundleContent(LoadOperation operation, AssetBundle bundle) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadBundleContent>d__15(0) { operation = operation, bundle = bundle }; } [Obsolete("Use LoadBundleAndContent instead")] public static void LoadBundle(string path, string relativePath) { LoadBundleAndContent(path); } [CompilerGenerated] internal static void <FinishLoadOperation>g__Finish|14_0(ref <>c__DisplayClass14_0 P_0) { _operations.Remove(P_0.operation); } } internal static class BundleLoaderLoadingText { private static TMP_Text? _text; public static void Create() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_008c: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("HUD Canvas"); TMP_Text val2 = Object.FindObjectOfType<TMP_Text>(); _text = Object.Instantiate<TMP_Text>(val2, val.transform); ((Object)((Component)_text).gameObject).name = "REPOLibText"; ((Graphic)_text).color = Color.white; _text.fontStyle = (FontStyles)1; _text.alignment = (TextAlignmentOptions)514; RectTransform component = ((Component)_text).GetComponent<RectTransform>(); component.anchoredPosition = Vector2.zero; component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.sizeDelta = Vector2.zero; ((Component)_text).gameObject.SetActive(false); SetText("REPOLib is loading bundles... Hang tight!"); } public static void Show() { VideoOverlay.Instance.Override(999f, 0.02f, 2f); TMP_Text? text = _text; if (text != null) { ((Component)text).gameObject.SetActive(true); } } public static void Hide() { VideoOverlay.Instance.Override(0f, 0.02f, 2f); TMP_Text? text = _text; if (text != null) { ((Component)text).gameObject.SetActive(false); } } public static void SetText(string value) { if (!((Object)(object)_text == (Object)null)) { _text.text = value; } } } internal static class ConfigManager { public static ConfigFile ConfigFile { get; private set; } public static ConfigEntry<bool> ExtendedLogging { get; private set; } public static ConfigEntry<bool> DeveloperMode { get; private set; } public static ConfigEntry<bool> VanillaDeveloperMode { get; private set; } public static void Initialize(ConfigFile configFile) { ConfigFile = configFile; BindConfigs(); } private static void BindConfigs() { ExtendedLogging = ConfigFile.Bind<bool>("General", "ExtendedLogging", false, "Enable extended logging."); DeveloperMode = ConfigFile.Bind<bool>("General", "DeveloperMode", false, "Enable developer mode chat commands for testing."); VanillaDeveloperMode = ConfigFile.Bind<bool>("General", "VanillaDeveloperMode", false, "Enable vanilla developer mode cheats and chat commands for testing."); VanillaDeveloperMode.SettingChanged += delegate { SteamManagerPatch.UpdateDeveloperMode(); }; } } internal static class Logger { public static ManualLogSource ManualLogSource { get; private set; } public static void Initialize(ManualLogSource manualLogSource) { ManualLogSource = manualLogSource; } public static void LogDebug(object data) { Log((LogLevel)32, data); } public static void LogInfo(object data, bool extended = false) { Log((LogLevel)16, data, extended); } public static void LogMessage(object data, bool extended = false) { Log((LogLevel)8, data, extended); } public static void LogWarning(object data, bool extended = false) { Log((LogLevel)4, data, extended); } public static void LogError(object data, bool extended = false) { Log((LogLevel)2, data, extended); } public static void LogFatal(object data, bool extended = false) { Log((LogLevel)1, data, extended); } public static void Log(LogLevel logLevel, object data, bool extended = false) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!extended || IsExtendedLoggingEnabled()) { ManualLogSource manualLogSource = ManualLogSource; if (manualLogSource != null) { manualLogSource.Log(logLevel, data); } } } public static bool IsExtendedLoggingEnabled() { return ConfigManager.ExtendedLogging?.Value ?? false; } } [BepInPlugin("REPOLib", "REPOLib", "3.0.2")] public class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("REPOLib"); public static Plugin Instance { get; private set; } private void Awake() { Instance = this; Logger.Initialize(Logger.CreateLogSource("REPOLib")); Logger.LogInfo("REPOLib has awoken!"); _harmony.PatchAll(typeof(RunManagerPatch)); _harmony.PatchAll(typeof(EnemyDirectorPatch)); _harmony.PatchAll(typeof(StatsManagerPatch)); _harmony.PatchAll(typeof(SemiFuncPatch)); _harmony.PatchAll(typeof(AudioManagerPatch)); _harmony.PatchAll(typeof(SteamManagerPatch)); _harmony.PatchAll(typeof(PlayerControllerPatch)); _harmony.PatchAll(typeof(DebugCommandHandlerPatch)); _harmony.PatchAll(typeof(DefaultPoolPatch)); _harmony.PatchAll(typeof(PrefabRefPatch)); _harmony.PatchAll(typeof(SplashScreenPatch)); ConfigManager.Initialize(((BaseUnityPlugin)this).Config); Upgrades.Initialize(); BundleLoader.LoadAllBundles(Paths.PluginPath, ".repobundle"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "REPOLib"; public const string PLUGIN_NAME = "REPOLib"; public const string PLUGIN_VERSION = "3.0.2"; } } namespace REPOLib.Patches { [HarmonyPatch(typeof(AudioManager))] internal static class AudioManagerPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPatch() { Utilities.FixAudioMixerGroupsOnPrefabs(); LevelAmbiences.RegisterLevelAmbiences(); } } [HarmonyPatch(typeof(DebugCommandHandler))] internal static class DebugCommandHandlerPatch { [HarmonyPatch("Start")] [HarmonyPrefix] private static void StartPatch() { Commands.RegisterCommands(); } } [HarmonyPatch(typeof(DefaultPool))] internal static class DefaultPoolPatch { [HarmonyPatch("Instantiate")] [HarmonyPrefix] private static bool InstantiatePatch(string prefabId, Vector3 position, Quaternion rotation, ref GameObject __result) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!NetworkPrefabs.TryGetNetworkPrefab(prefabId, out GameObject prefab)) { return true; } bool activeSelf = prefab.activeSelf; if (activeSelf) { prefab.SetActive(false); } __result = Object.Instantiate<GameObject>(prefab, position, rotation); if (activeSelf) { prefab.SetActive(true); } return false; } } [HarmonyPatch(typeof(EnemyDirector))] internal static class EnemyDirectorPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakePatch() { Enemies.RegisterEnemies(); } } [HarmonyPatch(typeof(PlayerController))] internal static class PlayerControllerPatch { [CompilerGenerated] private sealed class <LateStartTranspiler>d__0 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable<CodeInstruction> instructions; public IEnumerable<CodeInstruction> <>3__instructions; private bool <found>5__2; private List<CodeInstruction>.Enumerator <>7__wrap2; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LateStartTranspiler>d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap2 = default(List<CodeInstruction>.Enumerator); <>1__state = -2; } private bool MoveNext() { //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerController), "playerAvatarScript"); MethodInfo methodInfo = AccessTools.Method(typeof(SemiFunc), "PlayerGetSteamID", new Type[1] { typeof(PlayerAvatar) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(Upgrades), "InvokeStartActions", new Type[1] { typeof(string) }, (Type[])null); <found>5__2 = false; int num = 0; List<CodeInstruction> list = new List<CodeInstruction>(); foreach (CodeInstruction instruction in instructions) { list.Add(instruction); if (num switch { 0 => instruction.opcode == OpCodes.Ldloc_1, 1 => instruction.opcode == OpCodes.Ldfld && CodeInstructionExtensions.LoadsField(instruction, fieldInfo, false), 2 => instruction.opcode == OpCodes.Call && CodeInstructionExtensions.Calls(instruction, methodInfo), 3 => instruction.opcode == OpCodes.Stloc_2, _ => false, }) { num++; if (num > 3) { <found>5__2 = true; num = 0; list.Add(new CodeInstruction(OpCodes.Ldloc_2, (object)null)); list.Add(new CodeInstruction(OpCodes.Call, (object)methodInfo2)); } } else { num = 0; } } <>7__wrap2 = list.GetEnumerator(); <>1__state = -3; break; } case 1: <>1__state = -3; break; } if (<>7__wrap2.MoveNext()) { CodeInstruction current2 = <>7__wrap2.Current; <>2__current = current2; <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap2 = default(List<CodeInstruction>.Enumerator); if (!<found>5__2) { Logger.LogWarning("Failed to patch PlayerController.LateStart!"); } return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap2).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { <LateStartTranspiler>d__0 <LateStartTranspiler>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <LateStartTranspiler>d__ = this; } else { <LateStartTranspiler>d__ = new <LateStartTranspiler>d__0(0); } <LateStartTranspiler>d__.instructions = <>3__instructions; return <LateStartTranspiler>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } [IteratorStateMachine(typeof(<LateStartTranspiler>d__0))] [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> LateStartTranspiler(IEnumerable<CodeInstruction> instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LateStartTranspiler>d__0(-2) { <>3__instructions = instructions }; } } [HarmonyPatch(typeof(PrefabRef))] internal static class PrefabRefPatch { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] private static bool PrefabPatch(PrefabRef __instance, ref GameObject __result) { if (NetworkPrefabs.TryGetNetworkPrefab(__instance.resourcePath, out GameObject prefab)) { __result = prefab; return false; } return true; } } [HarmonyPatch(typeof(RunManager))] internal static class RunManagerPatch { private static bool _patchedAwake; [HarmonyPatch("Awake")] [HarmonyPostfix] [HarmonyPriority(0)] private static void AwakePatch(RunManager __instance) { if (!_patchedAwake) { _patchedAwake = true; NetworkingEvents.Initialize(); ValuablePresets.Initialize(); Levels.RegisterInitialLevels(); Valuables.RegisterInitialValuables(); BundleLoader.FinishLoadOperations((MonoBehaviour)(object)__instance); } } } [HarmonyPatch(typeof(SemiFunc))] internal static class SemiFuncPatch { [HarmonyPatch("DebugTester")] [HarmonyPrefix] private static bool DebugTesterPatch(ref bool __result) { if (ConfigManager.DeveloperMode.Value) { __result = true; return false; } return true; } [HarmonyPatch("EnemySpawn")] [HarmonyPrefix] private static bool EnemySpawnPatch(ref bool __result) { if (Enemies.SpawnNextEnemiesNotDespawned > 0) { Enemies.SpawnNextEnemiesNotDespawned--; __result = true; return false; } return true; } } [HarmonyPatch(typeof(SplashScreen))] internal static class SplashScreenPatch { private static bool _showedBundleLoaderLoadingText; [HarmonyPatch("StateWarning")] [HarmonyPostfix] private static void StateWarningPatch(SplashScreen __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)__instance.state == 3) { ((Component)SplashScreenUI.instance.warningTransform).gameObject.SetActive(false); } } [HarmonyPatch("StateDone")] [HarmonyPrefix] private static bool StateDonePatch() { if (BundleLoader.AllBundlesLoaded) { return true; } if (_showedBundleLoaderLoadingText) { return false; } _showedBundleLoaderLoadingText = true; int childCount = ((Component)SplashScreenUI.instance).transform.childCount; for (int i = 1; i < childCount; i++) { Transform child = ((Component)SplashScreenUI.instance).transform.GetChild(i); ((Component)child).gameObject.SetActive(false); } BundleLoaderLoadingText.Show(); return false; } } [HarmonyPatch(typeof(StatsManager))] internal static class StatsManagerPatch { [HarmonyPatch("RunStartStats")] [HarmonyPostfix] private static void RunStartStatsPatch() { Items.RegisterItems(); Upgrades.RegisterUpgrades(); } } [HarmonyPatch(typeof(SteamManager))] internal static class SteamManagerPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] public static void AwakePatch(SteamManager __instance) { UpdateDeveloperMode(); } public static void UpdateDeveloperMode() { if (ConfigManager.VanillaDeveloperMode == null || (Object)(object)SteamManager.instance == (Object)null) { return; } bool value = ConfigManager.VanillaDeveloperMode.Value; if (SteamManager.instance.developerMode != value) { if (value) { Logger.LogInfo("Enabling vanilla developer mode."); } else { Logger.LogInfo("Disabling vanilla developer mode."); } } SteamManager.instance.developerMode = value; } } } namespace REPOLib.Objects { internal class PrefabRefComparer : IEqualityComparer<PrefabRef> { public StringComparison ComparisonType { get; } public PrefabRefComparer(StringComparison comparisonType = StringComparison.OrdinalIgnoreCase) { ComparisonType = comparisonType; } public bool Equals(PrefabRef x, PrefabRef y) { if (x == y) { return true; } if (x == null || y == null) { return false; } if (string.Equals(x.PrefabName, y.PrefabName, ComparisonType)) { return string.Equals(x.ResourcePath, y.ResourcePath, ComparisonType); } return false; } public int GetHashCode(PrefabRef obj) { if (obj == null) { return 0; } int num = 17; num = num * 23 + (obj.PrefabName?.GetHashCode(StringComparison.OrdinalIgnoreCase) ?? 0); return num * 23 + (obj.ResourcePath?.GetHashCode(StringComparison.OrdinalIgnoreCase) ?? 0); } } internal enum PrefabRefResult { Success, PrefabIdNullOrEmpty, PrefabNull, PrefabAlreadyRegistered, DifferentPrefabAlreadyRegistered } internal struct PrefabRefResponse { public PrefabRefResult Result { get; set; } public PrefabRef? PrefabRef { get; set; } public PrefabRefResponse(PrefabRefResult result, PrefabRef? prefabRef) { Result = result; PrefabRef = prefabRef; } } internal class UnityObjectNameComparer<T> : IEqualityComparer<T> where T : Object { public StringComparison ComparisonType { get; private set; } public UnityObjectNameComparer(StringComparison comparisonType = StringComparison.OrdinalIgnoreCase) { ComparisonType = comparisonType; } public bool Equals(T x, T y) { if ((Object)(object)x == (Object)(object)y) { return true; } if ((Object)(object)x == (Object)null || (Object)(object)y == (Object)null) { return false; } return ((Object)x).name.Equals(((Object)y).name, ComparisonType); } public int GetHashCode(T obj) { if (!((Object)(object)obj != (Object)null)) { return 0; } return ((Object)obj).name.GetHashCode(); } } } namespace REPOLib.Objects.Sdk { public abstract class Content : ScriptableObject { public abstract string Name { get; } public abstract void Initialize(Mod mod); } [CreateAssetMenu(menuName = "REPOLib/Enemy", order = 3, fileName = "New Enemy")] public class EnemyContent : Content { [SerializeField] private EnemySetup? _setup; [SerializeField] private List<GameObject> _spawnObjects = new List<GameObject>(); public EnemySetup? Setup => _setup; public List<GameObject> SpawnObjects => _spawnObjects; public override string Name { get { EnemySetup? setup = Setup; return ((setup != null) ? ((Object)setup).name : null) ?? string.Empty; } } public override void Initialize(Mod mod) { Enemies.RegisterEnemy(this); } } [CreateAssetMenu(menuName = "REPOLib/Item", order = 2, fileName = "New Item")] public class ItemContent : Content { [SerializeField] private ItemAttributes? _prefab; public ItemAttributes? Prefab => _prefab; public override string Name { get { ItemAttributes? prefab = Prefab; return ((prefab != null) ? ((Object)prefab).name : null) ?? string.Empty; } } public override void Initialize(Mod mod) { Items.RegisterItem(this); } } [CreateAssetMenu(menuName = "REPOLib/Level", order = 4, fileName = "New Level")] public class LevelContent : Content { [SerializeField] private Level? _level; [SerializeField] private GameObject? _connectObject; [SerializeField] private GameObject? _blockObject; [SerializeField] private List<GameObject> _startRooms = new List<GameObject>(); [Space] [Header("Difficulty 1")] [SerializeField] private List<GameObject> _modulesNormal1 = new List<GameObject>(); [SerializeField] private List<GameObject> _modulesPassage1 = new List<GameObject>(); [SerializeField] private List<GameObject> _modulesDeadEnd1 = new List<GameObject>(); [SerializeField] private List<GameObject> _modulesExtraction1 = new List<GameObject>(); [Space] [Header("Difficulty 2")] [SerializeField] private List<GameObject> _modulesNormal2 = new List<GameObject>(); [SerializeField] private List<GameObject> _modulesPassage2 = new List<GameObject>(); [SerializeField] private List<GameObject> _modulesDeadEnd2 = new List<GameObject>(); [SerializeField] private List<GameObject> _modulesExtraction2 = new List<GameObject>(); [Space] [Header("Difficulty 3")] [SerializeField] private List<GameObject> _modulesNormal3 = new List<GameObject>(); [SerializeField] private List<GameObject> _modulesPassage3 = new List<GameObject>(); [SerializeField] private List<GameObject> _modulesDeadEnd3 = new List<GameObject>(); [SerializeField] private List<GameObject> _modulesExtraction3 = new List<GameObject>(); public Level? Level => _level; public override string Name { get { Level? level = Level; return ((level != null) ? ((Object)level).name : null) ?? string.Empty; } } public GameObject? ConnectObject => _connectObject; public GameObject? BlockObject => _blockObject; public List<GameObject> StartRooms => _startRooms; public List<GameObject> ModulesNormal1 => _modulesNormal1; public List<GameObject> ModulesPassage1 => _modulesPassage1; public List<GameObject> ModulesDeadEnd1 => _modulesDeadEnd1; public List<GameObject> ModulesExtraction1 => _modulesExtraction1; public List<GameObject> ModulesNormal2 => _modulesNormal2; public List<GameObject> ModulesPassage2 => _modulesPassage2; public List<GameObject> ModulesDeadEnd2 => _modulesDeadEnd2; public List<GameObject> ModulesExtraction2 => _modulesExtraction2; public List<GameObject> ModulesNormal3 => _modulesNormal3; public List<GameObject> ModulesPassage3 => _modulesPassage3; public List<GameObject> ModulesDeadEnd3 => _modulesDeadEnd3; public List<GameObject> ModulesExtraction3 => _modulesExtraction3; public override void Initialize(Mod mod) { Levels.RegisterLevel(this); } } [CreateAssetMenu(menuName = "REPOLib/Mod", order = 0, fileName = "New Mod")] public class Mod : ScriptableObject { [SerializeField] private string _name; [SerializeField] private string _author; [SerializeField] private string _version = "1.0.0"; [SerializeField] private string _description; [SerializeField] private string _websiteUrl; [SerializeField] private string[] _dependencies = new string[1] { "Zehs-REPOLib-3.0.2" }; [SerializeField] private Sprite? _icon; [SerializeField] private TextAsset? _readme; public string Name => _name; public string Author => _author; public string Version => _version; public string Description => _description; public string WebsiteUrl => _websiteUrl; public IReadOnlyList<string> Dependencies => _dependencies; public Sprite? Icon => _icon; public TextAsset? Readme => _readme; public string FullName => Author + "-" + Name; public string Identifier => Author + "-" + Name + "-" + Version; } [CreateAssetMenu(menuName = "REPOLib/Valuable", order = 1, fileName = "New Valuable")] public class ValuableContent : Content { [SerializeField] private ValuableObject? _prefab; [SerializeField] private string[] _valuablePresets = new string[1] { "Valuables - Generic" }; public ValuableObject? Prefab => _prefab; public IReadOnlyList<string> ValuablePresets => _valuablePresets; public override string Name { get { ValuableObject? prefab = Prefab; return ((prefab != null) ? ((Object)prefab).name : null) ?? string.Empty; } } public override void Initialize(Mod mod) { Valuables.RegisterValuable(this); } } } namespace REPOLib.Modules { public static class Commands { private static readonly List<ChatCommand> _commandsToRegister = new List<ChatCommand>(); private static readonly List<ChatCommand> _commandsRegistered = new List<ChatCommand>(); public static IReadOnlyList<ChatCommand> AllCommands => GetCommands(); public static IReadOnlyList<ChatCommand> RegisteredCommands => _commandsRegistered; internal static void RegisterCommands() { if ((Object)(object)DebugCommandHandler.instance == (Object)null) { Logger.LogError("Failed to register commands. DebugCommandHandler instance is null."); return; } Logger.LogInfo("Adding commands."); _commandsRegistered.Clear(); foreach (ChatCommand item in _commandsToRegister) { DebugCommandHandler.instance.Register(item); _commandsRegistered.Add(item); } } public static void RegisterCommand(ChatCommand chatCommand) { ChatCommand chatCommand2 = chatCommand; if (chatCommand2 == null) { throw new ArgumentException("Failed to register command. ChatCommand is null."); } if (chatCommand2.Execute == null) { Logger.LogError("Failed to register command \"" + chatCommand2.Name + "\". Execute method is null."); } else if (_commandsToRegister.Contains(chatCommand2)) { Logger.LogError("Failed to register command \"" + chatCommand2.Name + "\". Command is already registered!"); } else if (_commandsToRegister.Any((ChatCommand x) => x.Name == chatCommand2.Name)) { Logger.LogError("Failed to register command \"" + chatCommand2.Name + "\". Command already exists with the same name."); } else { _commandsToRegister.Add(chatCommand2); } } private static IReadOnlyList<ChatCommand> GetCommands() { if ((Object)(object)DebugCommandHandler.instance == (Object)null) { return Array.Empty<ChatCommand>(); } return DebugCommandHandler.instance._commands.Values.ToList(); } } public static class Enemies { internal static int SpawnNextEnemiesNotDespawned = 0; private static readonly List<EnemySetup> _enemiesToRegister = new List<EnemySetup>(); public static IReadOnlyList<EnemySetup> AllEnemies => EnemyDirector.instance?.GetEnemies() ?? new List<EnemySetup>(); public static IReadOnlyList<EnemySetup> RegisteredEnemies => _enemiesToRegister; internal static void RegisterEnemies() { Logger.LogInfo("Adding enemies."); foreach (EnemySetup item in _enemiesToRegister) { RegisterEnemyWithGame(item); } } private static void RegisterEnemyWithGame(EnemySetup enemySetup) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (!enemySetup.TryGetEnemyParent(out EnemyParent enemyParent)) { Logger.LogError("Failed to register enemy \"" + ((Object)enemySetup).name + "\" to game. Could not find EnemyParent component."); } else if (EnemyDirector.instance.AddEnemy(enemySetup)) { Logger.LogInfo($"Added enemy \"{enemyParent.enemyName}\" to difficulty {enemyParent.difficulty}", extended: true); } } public static void RegisterEnemy(EnemyContent? enemyContent) { if ((Object)(object)enemyContent == (Object)null) { Logger.LogError("Failed to register enemy. EnemyContent is null."); return; } EnemySetup enemySetup = enemyContent.Setup; List<GameObject> spawnObjects = enemyContent.SpawnObjects; if ((Object)(object)enemySetup == (Object)null) { Logger.LogError("Failed to register enemy. EnemySetup is null."); return; } if (spawnObjects == null || spawnObjects.Count == 0) { Logger.LogError("Failed to register enemy \"" + enemyContent.Name + "\". No spawn objects found."); return; } if (_enemiesToRegister.Contains(enemySetup)) { Logger.LogError("Failed to register enemy \"" + enemyContent.Name + "\". Enemy is already registered!"); return; } if (_enemiesToRegister.Any((EnemySetup x) => ((Object)x).name == ((Object)enemySetup).name)) { Logger.LogError("Failed to register enemy \"" + enemyContent.Name + "\". Enemy already exists with the same name."); return; } List<PrefabRef> list = new List<PrefabRef>(); foreach (GameObject item in spawnObjects) { if ((Object)(object)item == (Object)null) { Logger.LogWarning("Enemy \"" + enemyContent.Name + "\" has a null spawn object."); continue; } string prefabId = "Enemies/" + ((Object)item).name; PrefabRefResponse prefabRefResponse = NetworkPrefabs.RegisterNetworkPrefabInternal(prefabId, item); PrefabRef prefabRef = prefabRefResponse.PrefabRef; if (prefabRefResponse.Result == PrefabRefResult.DifferentPrefabAlreadyRegistered) { Logger.LogError("Failed to register enemy \"" + enemyContent.Name + "\" spawn object. A prefab is already registered with the same name."); continue; } if (prefabRefResponse.Result != 0 && prefabRefResponse.Result != PrefabRefResult.PrefabAlreadyRegistered) { Logger.LogError($"Failed to register enemy \"{enemyContent.Name}\" spawn object. (Reason: {prefabRefResponse.Result})"); continue; } if (prefabRef == null) { Logger.LogError("Failed to register enemy \"" + enemyContent.Name + "\" spawn object. PrefabRef is null."); continue; } if (prefabRefResponse.Result == PrefabRefResult.Success) { Utilities.FixAudioMixerGroups(item); } list.Add(prefabRef); } if (list.Count == 0) { Logger.LogError("Failed to register enemy \"" + enemyContent.Name + "\". No valid spawn objects found."); return; } enemySetup.spawnObjects = list; _enemiesToRegister.Add(enemySetup); } public static List<EnemyParent>? SpawnEnemy(EnemySetup? enemySetup, Vector3 position, Quaternion rotation, bool spawnDespawned = false) { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enemySetup == (Object)null) { Logger.LogError("Failed to spawn enemy. EnemySetup is null."); return null; } if (!enemySetup.TryGetEnemyParent(out EnemyParent enemyParent)) { Logger.LogError("Failed to spawn enemy. EnemyParent is null."); return null; } if ((Object)(object)LevelGenerator.Instance == (Object)null) { Logger.LogError("Failed to spawn enemy \"" + enemyParent.enemyName + "\". EnemySetup instance is null."); return null; } if ((Object)(object)RunManager.instance == (Object)null) { Logger.LogError("Failed to spawn enemy \"" + enemyParent.enemyName + "\". RunManager instance is null."); return null; } if ((Object)(object)EnemyDirector.instance == (Object)null) { Logger.LogError("Failed to spawn enemy \"" + enemyParent.enemyName + "\". EnemyDirector instance is null."); return null; } RunManager.instance.EnemiesSpawnedRemoveStart(); List<EnemyParent> list = new List<EnemyParent>(); EnemyParent val2 = default(EnemyParent); foreach (PrefabRef spawnObject in enemySetup.spawnObjects) { GameObject prefab = spawnObject.Prefab; if ((Object)(object)prefab == (Object)null) { Logger.LogError("Failed to spawn enemy \"" + enemyParent.enemyName + "\" spawn object. GameObject is null."); continue; } GameObject val = NetworkPrefabs.SpawnNetworkPrefab(spawnObject, position, rotation, 0); if ((Object)(object)val == (Object)null) { Logger.LogError("Failed to spawn enemy \"" + enemyParent.enemyName + "\" spawn object \"" + ((Object)prefab).name + "\""); } else if (val.TryGetComponent<EnemyParent>(ref val2)) { list.Add(val2); if (!spawnDespawned) { SpawnNextEnemiesNotDespawned++; } val2.SetupDone = true; Enemy componentInChildren = val.GetComponentInChildren<Enemy>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.EnemyTeleported(position); } else { Logger.LogError("Enemy \"" + enemyParent.enemyName + "\" spawn object \"" + ((Object)prefab).name + "\" does not have an enemy component."); } val2.firstSpawnPointUsed = true; LevelGenerator instance = LevelGenerator.Instance; instance.EnemiesSpawnTarget++; EnemyDirector.instance.FirstSpawnPointAdd(val2); } } RunManager.instance.EnemiesSpawnedRemoveEnd(); if (list.Count == 0) { Logger.LogInfo("Failed to spawn enemy \"" + enemyParent.enemyName + "\". No spawn objects where spawned."); return list; } Logger.LogInfo($"Spawned enemy \"{enemyParent.enemyName}\" at position {position}", extended: true); return list; } [Obsolete("This is no longer supported. Use AllEnemies or RegisteredEnemies instead.", true)] public static IReadOnlyList<EnemySetup> GetEnemies() { return AllEnemies; } [Obsolete("This is no longer supported. Use AllEnemies or RegisteredEnemies instead.", true)] public static bool TryGetEnemyByName(string name, [NotNullWhen(true)] out EnemySetup? enemySetup) { enemySetup = null; return false; } [Obsolete("This is no longer supported. Use AllEnemies or RegisteredEnemies instead.", true)] public static EnemySetup? GetEnemyByName(string name) { return null; } [Obsolete("This is no longer supported. Use AllEnemies or RegisteredEnemies instead.", true)] public static bool TryGetEnemyThatContainsName(string name, [NotNullWhen(true)] out EnemySetup? enemySetup) { enemySetup = null; return false; } [Obsolete("This is no longer supported. Use AllEnemies or RegisteredEnemies instead.", true)] public static EnemySetup? GetEnemyThatContainsName(string name) { return null; } } public static class Items { private static readonly List<Item> _itemsToRegister = new List<Item>(); private static readonly List<Item> _itemsRegistered = new List<Item>(); private static bool _initialItemsRegistered; public static IReadOnlyList<Item> AllItems => StatsManager.instance?.GetItems() ?? new List<Item>(); public static IReadOnlyList<Item> RegisteredItems => _itemsRegistered; internal static void RegisterItems() { Logger.LogInfo("Adding items."); foreach (Item item in _itemsToRegister) { RegisterItemWithGame(item); } _initialItemsRegistered = true; } private static void RegisterItemWithGame(Item item) { if (StatsManager.instance.AddItem(item)) { if (!_itemsRegistered.Contains(item)) { _itemsRegistered.Add(item); } Logger.LogInfo("Added item \"" + item.itemName + "\" to StatsManager.", extended: true); } else { Logger.LogWarning("Failed to add item \"" + item.itemName + "\" to StatsManager.", extended: true); } } public static PrefabRef? RegisterItem(ItemAttributes? itemAttributes) { if ((Object)(object)itemAttributes == (Object)null) { Logger.LogError("Failed to register item. ItemAttributes is null."); return null; } Item item = itemAttributes.item; if ((Object)(object)item == (Object)null) { Logger.LogError("Failed to register item. Item is null."); return null; } GameObject gameObject = ((Component)itemAttributes).gameObject; string prefabId = "Items/" + ((Object)gameObject).name; PrefabRefResponse prefabRefResponse = NetworkPrefabs.RegisterNetworkPrefabInternal(prefabId, gameObject); PrefabRef prefabRef = prefabRefResponse.PrefabRef; if (prefabRefResponse.Result == PrefabRefResult.PrefabAlreadyRegistered) { Logger.LogWarning("Failed to register item \"" + item.itemName + "\". Item is already registered!"); return null; } if (prefabRefResponse.Result == PrefabRefResult.DifferentPrefabAlreadyRegistered) { Logger.LogError("Failed to register item \"" + item.itemName + "\". A item prefab is already registered with the same name."); return null; } if (prefabRefResponse.Result != 0) { Logger.LogError($"Failed to register item \"{((Object)gameObject).name}\". (Reason: {prefabRefResponse.Result})"); return null; } if (prefabRef == null) { Logger.LogError("Failed to register item \"" + ((Object)gameObject).name + "\". PrefabRef is null."); return null; } item.prefab = prefabRef; Utilities.FixAudioMixerGroups(gameObject); _itemsToRegister.Add(item); if (_initialItemsRegistered) { RegisterItemWithGame(item); } return prefabRef; } public static PrefabRef? RegisterItem(ItemContent? itemContent) { if ((Object)(object)itemContent == (Object)null) { Logger.LogError("Failed to register item. ItemContent is null."); return null; } return RegisterItem(itemContent.Prefab); } public static GameObject? SpawnItem(Item? item, Vector3 position, Quaternion rotation) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null) { Logger.LogError("Failed to spawn item. Item is null."); return null; } if (!item.prefab.IsValid()) { Logger.LogError("Failed to spawn item \"" + item.itemName + "\". PrefabRef is not valid."); return null; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { Logger.LogError("Failed to spawn item \"" + item.itemName + "\". You are not the host."); return null; } GameObject val = NetworkPrefabs.SpawnNetworkPrefab(item.prefab, position, rotation, 0); if ((Object)(object)val == (Object)null) { Logger.LogError("Failed to spawn item \"" + item.itemName + "\". Spawned GameObject is null."); return null; } Logger.LogInfo($"Spawned item \"{item.itemName}\" at position {position}, rotation: {((Quaternion)(ref rotation)).eulerAngles}", extended: true); return val; } [Obsolete("This is no longer supported. Use AllItems or RegisteredItems instead.", true)] public static IReadOnlyList<Item> GetItems() { return AllItems; } [Obsolete("This is no longer supported. Use AllItems or RegisteredItems instead.", true)] public static bool TryGetItemByName(string name, [NotNullWhen(true)] out Item? item) { item = null; return false; } [Obsolete("This is no longer supported. Use AllItems or RegisteredItems instead.", true)] public static Item? GetItemByName(string name) { return null; } [Obsolete("This is no longer supported. Use AllItems or RegisteredItems instead.", true)] public static bool TryGetItemThatContainsName(string name, [NotNullWhen(true)] out Item? item) { item = null; return false; } [Obsolete("This is no longer supported. Use AllItems or RegisteredItems instead.", true)] public static Item? GetItemThatContainsName(string name) { return null; } } internal static class LevelAmbiences { private static readonly List<LevelAmbience> _levelAmbiencesRegistered = new List<LevelAmbience>(); private static readonly List<Level> _levelToProcess = new List<Level>(); private static readonly List<Level> _levelsProcessed = new List<Level>(); private static bool _initialLevelAmbiencesRegistered; public static IReadOnlyList<LevelAmbience> AllLevelAmbiences => AudioManager.instance?.levelAmbiences ?? new List<LevelAmbience>(); public static IReadOnlyList<LevelAmbience> RegisteredLevelAmbiences => _levelAmbiencesRegistered; internal static void RegisterLevelAmbiences() { if (_initialLevelAmbiencesRegistered) { foreach (LevelAmbience item in _levelAmbiencesRegistered) { AddLevelAmbienceToAudioManager(item); } return; } Logger.LogInfo("Adding level ambiences."); foreach (Level item2 in _levelToProcess) { RegisterLevelAmbiencesWithGame(item2); } _initialLevelAmbiencesRegistered = true; } private static void AddLevelAmbienceToAudioManager(LevelAmbience levelAmbience) { if (!AllLevelAmbiences.Contains(levelAmbience)) { AudioManager.instance.levelAmbiences.Add(levelAmbience); Logger.LogInfo("Added level ambience \"" + ((Object)levelAmbience).name + "\" to AudioManager.", extended: true); } } private static void RegisterLevelAmbiencesWithGame(Level level) { if (_levelsProcessed.Contains(level)) { return; } for (int i = 0; i < level.AmbiencePresets.Count; i++) { LevelAmbience val = level.AmbiencePresets[i]; if (!AudioManager.instance.levelAmbiences.Contains(val)) { if (TryGetLevelAmbience(((Object)val).name, out LevelAmbience levelAmbience)) { level.AmbiencePresets[i] = levelAmbience; Logger.LogInfo("Replaced existing level ambience \"" + ((Object)val).name + "\" in level \"" + ((Object)level).name + "\"", extended: true); } else { AddLevelAmbienceToAudioManager(val); _levelAmbiencesRegistered.Add(val); Logger.LogInfo("Registered level ambience \"" + ((Object)val).name + "\" from level \"" + ((Object)level).name + "\"", extended: true); } } } _levelsProcessed.Add(level); } public static void RegisterLevelAmbience(Level? level) { if ((Object)(object)level == (Object)null) { Logger.LogError("Failed to register level ambience for level. Level is null."); return; } if (_levelToProcess.Contains(level)) { Logger.LogWarning("Failed to register level ambience for level \"" + ((Object)level).name + "\". Level has already been processed!"); return; } _levelToProcess.Add(level); if (_initialLevelAmbiencesRegistered) { RegisterLevelAmbiencesWithGame(level); } } private static bool TryGetLevelAmbience(string name, [NotNullWhen(true)] out LevelAmbience? levelAmbience) { string name2 = name; levelAmbience = ((IEnumerable<LevelAmbience>)AllLevelAmbiences).FirstOrDefault((Func<LevelAmbience, bool>)((LevelAmbience x) => ((Object)x).name == name2)); return (Object)(object)levelAmbience != (Object)null; } } public static class Levels { private enum ModuleType { StartRoom, Normal, Passage, DeadEnd, Extraction } private static readonly List<Level> _levelsToRegister = new List<Level>(); private static readonly List<Level> _levelsRegistered = new List<Level>(); private static bool _initialLevelsRegistered; public static IReadOnlyList<Level> AllLevels => RunManager.instance?.levels ?? new List<Level>(); public static IReadOnlyList<Level> RegisteredLevels => _levelsRegistered; internal static void RegisterInitialLevels() { if (_initialLevelsRegistered) { return; } Logger.LogInfo("Adding levels."); foreach (Level item in _levelsToRegister) { RegisterLevelWithGame(item); } _initialLevelsRegistered = true; } private static void RegisterLevelWithGame(Level level) { if (!_levelsRegistered.Contains(level)) { RegisterLevelValuablePresets(level); LevelAmbiences.RegisterLevelAmbience(level); RunManager.instance.levels.Add(level); Logger.LogInfo("Added level \"" + ((Object)level).name + "\"", extended: true); _levelsRegistered.Add(level); } } private static void RegisterLevelValuablePresets(Level level) { if (level.ValuablePresets.Count == 0) { Logger.LogWarning("Level \"" + ((Object)level).name + "\" does not have any valuable presets! Adding generic preset."); level.ValuablePresets.Add(ValuablePresets.GenericValuablePreset); return; } for (int i = 0; i < level.ValuablePresets.Count; i++) { LevelValuables val = level.ValuablePresets[i]; if (!ValuablePresets.AllValuablePresets.Values.Contains(val)) { if (ValuablePresets.AllValuablePresets.TryGetValue(((Object)val).name, out LevelValuables value)) { level.ValuablePresets[i] = value; Logger.LogInfo("Replaced proxy valuable preset \"" + ((Object)val).name + "\" in level \"" + ((Object)level).name + "\"", extended: true); } else { ValuablePresets.RegisterValuablePreset(val); Logger.LogInfo("Registered valuable preset \"" + ((Object)val).name + "\" from level \"" + ((Object)level).name + "\"", extended: true); } } } } public static void RegisterLevel(LevelContent? levelContent) { if ((Object)(object)levelContent == (Object)null) { Logger.LogError("Failed to register level. LevelContent is null."); return; } Level level = levelContent.Level; if ((Object)(object)level == (Object)null) { Logger.LogError("Failed to register level. Level is null."); return; } if (_levelsToRegister.Contains(level)) { Logger.LogWarning("Failed to register level \"" + ((Object)level).name + "\". Level is already registered!"); return; } if (_levelsToRegister.Any((Level x) => ((Object)x).name.Equals(((Object)level).name, StringComparison.OrdinalIgnoreCase))) { Logger.LogError("Failed to register level \"" + ((Object)level).name + "\". Level already exists with the same name."); return; } GameObject connectObject = levelContent.ConnectObject; if ((Object)(object)connectObject != (Object)null) { RegisterLevelPrefab("Level/" + level.ResourcePath + "/Other/" + ((Object)connectObject).name, connectObject); level.ConnectObject = connectObject; } GameObject blockObject = levelContent.BlockObject; if ((Object)(object)blockObject != (Object)null) { RegisterLevelPrefab("Level/" + level.ResourcePath + "/Other/" + ((Object)blockObject).name, blockObject); level.BlockObject = blockObject; } level.StartRooms = RegisterLevelModules(level, ModuleType.StartRoom, levelContent.StartRooms); level.ModulesNormal1 = RegisterLevelModules(level, ModuleType.Normal, levelContent.ModulesNormal1); level.ModulesPassage1 = RegisterLevelModules(level, ModuleType.Passage, levelContent.ModulesPassage1); level.ModulesDeadEnd1 = RegisterLevelModules(level, ModuleType.DeadEnd, levelContent.ModulesDeadEnd1); level.ModulesExtraction1 = RegisterLevelModules(level, ModuleType.Extraction, levelContent.ModulesExtraction1); level.ModulesNormal2 = RegisterLevelModules(level, ModuleType.Normal, levelContent.ModulesNormal2); level.ModulesPassage2 = RegisterLevelModules(level, ModuleType.Passage, levelContent.ModulesPassage2); level.ModulesDeadEnd2 = RegisterLevelModules(level, ModuleType.DeadEnd, levelContent.ModulesDeadEnd2); level.ModulesExtraction2 = RegisterLevelModules(level, ModuleType.Extraction, levelContent.ModulesExtraction2); level.ModulesNormal3 = RegisterLevelModules(level, ModuleType.Normal, levelContent.ModulesNormal3); level.ModulesPassage3 = RegisterLevelModules(level, ModuleType.Passage, levelContent.ModulesPassage3); level.ModulesDeadEnd3 = RegisterLevelModules(level, ModuleType.DeadEnd, levelContent.ModulesDeadEnd3); level.ModulesExtraction3 = RegisterLevelModules(level, ModuleType.Extraction, levelContent.ModulesExtraction3); _levelsToRegister.Add(level); if (_initialLevelsRegistered) { RegisterLevelWithGame(level); } } private static List<PrefabRef> RegisterLevelModules(Level level, ModuleType moduleType, List<GameObject> modules) { List<PrefabRef> list = new List<PrefabRef>(); foreach (GameObject module in modules) { string prefabId = $"Level/{((Object)level).name}/{moduleType}/{((Object)module).name}"; PrefabRef val = RegisterLevelPrefab(prefabId, module); if (val != null) { list.Add(val); } } return list; } private static PrefabRef? RegisterLevelPrefab(string prefabId, GameObject prefab) { PrefabRefResponse prefabRefResponse = NetworkPrefabs.RegisterNetworkPrefabInternal(prefabId, prefab); if (prefabRefResponse.Result == PrefabRefResult.Success) { Utilities.FixAudioMixerGroups(prefab); return prefabRefResponse.PrefabRef; } if (prefabRefResponse.Result == PrefabRefResult.PrefabAlreadyRegistered) { return prefabRefResponse.PrefabRef; } if (prefabRefResponse.Result == PrefabRefResult.DifferentPrefabAlreadyRegistered) { Logger.LogError("Failed to register level network prefab \"" + prefabId + "\". A prefab is already registered with the same prefab ID."); return null; } Logger.LogError($"Failed to register level network prefab \"{prefabId}\". (Reason: {prefabRefResponse.Result})"); return null; } [Obsolete("This is no longer supported. Use AllLevels or RegisteredLevels instead.", true)] public static IReadOnlyList<Level> GetLevels() { return AllLevels; } [Obsolete("This is no longer supported. Use AllLevels or RegisteredLevels instead.", true)] public static bool TryGetLevelByName(string name, [NotNullWhen(true)] out Level? level) { level = null; return false; } [Obsolete("This is no longer supported. Use AllLevels or RegisteredLevels instead.", true)] public static Level? GetLevelByName(string name) { return null; } [Obsolete("This is no longer supported. Use AllLevels or RegisteredLevels instead.", true)] public static bool TryGetLevelThatContainsName(string name, [NotNullWhen(true)] out Level? level) { level = null; return false; } [Obsolete("This is no longer supported. Use AllLevels or RegisteredLevels instead.", true)] public static Level? GetLevelThatContainsName(string name) { return null; } } public static class NetworkingEvents { public static readonly byte[] ReservedEventCodes = new byte[3] { 0, 1, 2 }; private static readonly List<NetworkedEvent> _customEvents = new List<NetworkedEvent>(); public static readonly RaiseEventOptions RaiseAll = new RaiseEventOptions { Receivers = (ReceiverGroup)1 }; public static readonly RaiseEventOptions RaiseOthers = new RaiseEventOptions { Receivers = (ReceiverGroup)0 }; public static readonly RaiseEventOptions RaiseMasterClient = new RaiseEventOptions { Receivers = (ReceiverGroup)2 }; public static IReadOnlyList<NetworkedEvent> CustomEvents => _customEvents; internal static void Initialize() { PhotonNetwork.NetworkingClient.EventReceived += OnEvent; Application.quitting += delegate { PhotonNetwork.NetworkingClient.EventReceived -= OnEvent; }; } internal static void AddCustomEvent(NetworkedEvent networkedEvent) { if (!_customEvents.Contains(networkedEvent)) { _customEvents.Add(networkedEvent); } } private static void OnEvent(EventData photonEvent) { EventData photonEvent2 = photonEvent; _customEvents.FirstOrDefault((NetworkedEvent e) => e.EventCode == photonEvent2.Code)?.EventAction?.Invoke(photonEvent2); } internal static bool TryGetUniqueEventCode(out byte eventCode) { eventCode = 0; while (IsEventCodeTaken(eventCode) && eventCode < 200) { eventCode++; } if (eventCode > 200 || (eventCode == 200 && IsEventCodeTaken(eventCode))) { eventCode = 0; return false; } return true; } public static bool IsEventCodeTaken(byte eventCode) { if (ReservedEventCodes.Any((byte x) => x == eventCode)) { return true; } if (_customEvents.Any((NetworkedEvent x) => x.EventCode == eventCode)) { return true; } return false; } } public class NetworkedEvent { public string Name { get; private set; } public byte EventCode { get; private set; } public Action<EventData> EventAction { get; private set; } public NetworkedEvent(string name, Action<EventData> eventAction) { Name = name; EventAction = eventAction; if (NetworkingEvents.TryGetUniqueEventCode(out var eventCode)) { EventCode = eventCode; NetworkingEvents.AddCustomEvent(this); Logger.LogInfo($"Registered NetworkedEvent \"{Name}\" with event code: {EventCode}", extended: true); } else { Logger.LogError("Failed to register NetworkedEvent \"" + Name + "\". Could not get unique event code."); } } public void RaiseEvent(object eventContent, RaiseEventOptions raiseEventOptions, SendOptions sendOptions) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMultiplayer()) { PhotonNetwork.RaiseEvent(EventCode, eventContent, raiseEventOptions, sendOptions); } else if ((int)raiseEventOptions.Receivers != 0) { RaiseEventSingleplayer(eventContent); } } private void RaiseEventSingleplayer(object eventContent) { //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_001a: Expected O, but got Unknown if (!SemiFunc.IsMultiplayer()) { EventData val = new EventData { Code = EventCode }; val.Parameters[val.CustomDataKey] = eventContent; val.Parameters[val.SenderKey] = 1; EventAction?.Invoke(val); } } } public static class NetworkPrefabs { private static readonly Dictionary<string, GameObject> _prefabs = new Dictionary<string, GameObject>(); private static readonly Dictionary<string, PrefabRef> _prefabRefs = new Dictionary<string, PrefabRef>(); public static IReadOnlyDictionary<string, GameObject> Prefabs => _prefabs; public static IReadOnlyDictionary<string, PrefabRef> PrefabRefs => _prefabRefs; public static PrefabRef? RegisterNetworkPrefab(GameObject prefab) { return RegisterNetworkPrefab(((Object)prefab).name, prefab); } public static PrefabRef? RegisterNetworkPrefab(string prefabId, GameObject prefab) { PrefabRefResponse prefabRefResponse = RegisterNetworkPrefabInternal(prefabId, prefab); switch (prefabRefResponse.Result) { case PrefabRefResult.Success: return prefabRefResponse.PrefabRef; case PrefabRefResult.PrefabIdNullOrEmpty: Logger.LogError("Failed to register network prefab. PrefabId is null."); return null; case PrefabRefResult.PrefabNull: Logger.LogError("Failed to register network prefab. Prefab is null."); return null; case PrefabRefResult.PrefabAlreadyRegistered: Logger.LogWarning("Failed to register network prefab \"" + prefabId + "\". Prefab is already registered."); return prefabRefResponse.PrefabRef; case PrefabRefResult.DifferentPrefabAlreadyRegistered: Logger.LogError("Failed to register network prefab \"" + prefabId + "\". A prefab is already registered with the same ID. (GameObject: \"" + ((Object)prefabRefResponse.PrefabRef.Prefab).name + "\")"); return null; default: return prefabRefResponse.PrefabRef; } } internal static PrefabRefResponse RegisterNetworkPrefabInternal(string prefabId, GameObject prefab) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown if (string.IsNullOrEmpty(prefabId)) { return new PrefabRefResponse(PrefabRefResult.PrefabIdNullOrEmpty, null); } if ((Object)(object)prefab == (Object)null) { return new PrefabRefResponse(PrefabRefResult.PrefabNull, null); } PrefabRef networkPrefabRef = GetNetworkPrefabRef(prefabId); if (networkPrefabRef != null) { GameObject prefab2 = networkPrefabRef.Prefab; if ((Object)(object)prefab == (Object)(object)prefab2) { return new PrefabRefResponse(PrefabRefResult.PrefabAlreadyRegistered, networkPrefabRef); } return new PrefabRefResponse(PrefabRefResult.DifferentPrefabAlreadyRegistered, networkPrefabRef); } PrefabRef val = new PrefabRef { prefabName = ((Object)prefab).name, resourcePath = prefabId }; _prefabs.Add(prefabId, prefab); _prefabRefs.Add(prefabId, val); return new PrefabRefResponse(PrefabRefResult.Success, val); } public static bool HasNetworkPrefab(string prefabId) { return _prefabs.ContainsKey(prefabId); } public static PrefabRef? GetNetworkPrefabRef(string prefabId) { return _prefabRefs.GetValueOrDefault(prefabId); } public static bool TryGetNetworkPrefabRef(string prefabId, [NotNullWhen(true)] out PrefabRef? prefabRef) { prefabRef = GetNetworkPrefabRef(prefabId); return prefabRef != null; } internal static bool TryGetNetworkPrefab(string prefabId, [NotNullWhen(true)] out GameObject? prefab) { prefab = _prefabs.GetValueOrDefault(prefabId); return (Object)(object)prefab != (Object)null; } public static GameObject? SpawnNetworkPrefab(PrefabRef prefabRef, Vector3 position, Quaternion rotation, byte group = 0, object[]? data = null) { //IL_0057: 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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (!prefabRef.IsValid()) { Logger.LogError("Failed to spawn network prefab. PrefabRef is not valid."); return null; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { Logger.LogError("Failed to spawn network prefab \"" + prefabRef.PrefabName + "\". You are not the host."); return null; } if (SemiFunc.IsMultiplayer()) { return PhotonNetwork.InstantiateRoomObject(prefabRef.ResourcePath, position, rotation, group, data); } return Object.Instantiate<GameObject>(prefabRef.Prefab, position, rotation); } } public static class Upgrades { private static readonly Dictionary<string, PlayerUpgrade> _playerUpgrades = new Dictionary<string, PlayerUpgrade>(); private static NetworkedEvent? _upgradeEvent; public static IReadOnlyList<PlayerUpgrade> PlayerUpgrades => _playerUpgrades.Values.ToList(); internal static void Initialize() { _upgradeEvent = new NetworkedEvent("REPOLib Upgrade", HandleUpgradeEvent); } internal static void RegisterUpgrades() { if ((Object)(object)StatsManager.instance == (Object)null) { Logger.LogError("Upgrades: Failed to register upgrades. StatsManager instance is null."); return; } foreach (KeyValuePair<string, PlayerUpgrade> playerUpgrade in _playerUpgrades) { string text = "playerUpgrade" + playerUpgrade.Key; Dictionary<string, int> playerDictionary = playerUpgrade.Value.PlayerDictionary; if (StatsManager.instance.dictionaryOfDictionaries.TryGetValue(text, out var value)) { playerDictionary = value; Logger.LogInfo("Upgrades: Loaded upgrade \"" + text + "\" from StatsManager.", extended: true); } else { playerDictionary.Clear(); StatsManager.instance.dictionaryOfDictionaries.Add(text, playerDictionary); Logger.LogInfo("Upgrades: Added upgrade \"" + text + "\" to StatsManager.", extended: true); } } } internal static void InvokeStartActions(string steamId) { PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(steamId); if ((Object)(object)val == (Object)null) { return; } string arg = SemiFunc.PlayerGetName(val); foreach (PlayerUpgrade playerUpgrade in PlayerUpgrades) { if (playerUpgrade.StartAction != null) { try { int level = playerUpgrade.GetLevel(steamId); playerUpgrade.StartAction(val, level); Logger.LogDebug($"Upgrades: Invoked start action for upgrade \"{playerUpgrade.UpgradeId}\" on player \"{arg}\" at level {level}"); } catch (Exception arg2) { Logger.LogError($"Upgrades: Failed to invoke start action for upgrade \"{playerUpgrade.UpgradeId}\" on player \"{arg}\". {arg2}"); } } } } internal static void RaiseUpgradeEvent(string upgradeId, string steamId, int level) { //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_0019: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0037: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (_upgradeEvent != null) { Hashtable val = new Hashtable(); ((Dictionary<object, object>)val).Add((object)"UpgradeId", (object)upgradeId); ((Dictionary<object, object>)val).Add((object)"SteamId", (object)steamId); ((Dictionary<object, object>)val).Add((object)"Level", (object)level); Hashtable eventContent = val; _upgradeEvent.RaiseEvent(eventContent, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } private static void HandleUpgradeEvent(EventData eventData) { object customData = eventData.CustomData; Hashtable val = (Hashtable)((customData is Hashtable) ? customData : null); if (val != null) { string upgradeId = (string)val[(object)"UpgradeId"]; string steamId = (string)val[(object)"SteamId"]; int level = (int)val[(object)"Level"]; if (TryGetUpgrade(upgradeId, out PlayerUpgrade playerUpgrade)) { playerUpgrade.ApplyUpgrade(steamId, level); } } } public static PlayerUpgrade? RegisterUpgrade(string upgradeId, Item? item, Action<PlayerAvatar, int>? startAction, Action<PlayerAvatar, int>? upgradeAction) { if (_playerUpgrades.ContainsKey(upgradeId)) { Logger.LogError("Failed to register upgrade \"" + upgradeId + "\". An upgrade with this UpgradeId has already been registered."); return null; } PlayerUpgrade playerUpgrade = new PlayerUpgrade(upgradeId, item, startAction, upgradeAction); _playerUpgrades.Add(upgradeId, playerUpgrade); return playerUpgrade; } public static PlayerUpgrade? GetUpgrade(string upgradeId) { if (_playerUpgrades.TryGetValue(upgradeId, out PlayerUpgrade value)) { return value; } return null; } public static bool TryGetUpgrade(string upgradeId, [NotNullWhen(true)] out PlayerUpgrade? playerUpgrade) { playerUpgrade = GetUpgrade(upgradeId); return playerUpgrade != null; } } public class PlayerUpgrade { public readonly string UpgradeId; public readonly Item? Item; public Dictionary<string, int> PlayerDictionary = new Dictionary<string, int>(); internal readonly Action<PlayerAvatar, int>? StartAction; private readonly Action<PlayerAvatar, int>? _upgradeAction; internal PlayerUpgrade(string upgradeId, Item? item, Action<PlayerAvatar, int>? startAction, Action<PlayerAvatar, int>? upgradeAction) { UpgradeId = upgradeId; Item = item; StartAction = startAction; _upgradeAction = upgradeAction; } public int GetLevel(PlayerAvatar playerAvatar) { if ((Object)(object)playerAvatar == (Object)null) { return 0; } return GetLevel(playerAvatar.steamID); } public int GetLevel(string steamId) { if (PlayerDictionary.TryGetValue(steamId, out var value)) { return value; } return 0; } public int AddLevel(PlayerAvatar playerAvatar, int amount = 1) { if ((Object)(object)playerAvatar == (Object)null) { return 0; } return AddLevel(playerAvatar.steamID, amount); } public int AddLevel(string steamId, int amount = 1) { return ChangeLevelBy(steamId, amount); } public int RemoveLevel(PlayerAvatar playerAvatar, int amount = 1) { if ((Object)(object)playerAvatar == (Object)null) { return 0; } return RemoveLevel(playerAvatar.steamID, amount); } public int RemoveLevel(string steamId, int amount = 1) { return ChangeLevelBy(steamId, -amount); } public int SetLevel(PlayerAvatar playerAvatar, int level) { if ((Object)(object)playerAvatar == (Object)null) { return 0; } return SetLevel(playerAvatar.steamID, level); } public int SetLevel(string steamId, int level) { level = Mathf.Max(level, 0); PlayerDictionary[steamId] = level; ApplyUpgrade(steamId, level); Upgrades.RaiseUpgradeEvent(UpgradeId, steamId, level); return level; } private int ChangeLevelBy(string steamId, int amount) { int level = GetLevel(steamId); level += amount; return SetLevel(steamId, level); } internal void ApplyUpgrade(string steamId, int level) { PlayerDictionary[steamId] = level; if (_upgradeAction == null) { return; } PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(steamId); if ((Object)(object)val == (Object)null) { return; } string arg = SemiFunc.PlayerGetName(val); try { _upgradeAction(val, GetLevel(steamId)); Logger.LogDebug($"PlayerUpgrade: Invoked upgrade action for upgrade \"{UpgradeId}\" on player \"{arg}\" at level {level}"); } catch (Exception arg2) { Logger.LogError($"PlayerUpgrade: Failed to invoke upgrade action for upgrade \"{UpgradeId}\" on player \"{arg}\". {arg2}"); } } } public class REPOLibItemUpgrade : MonoBehaviour { [SerializeField] private string _upgradeId; private ItemToggle _itemToggle; public string UpgradeId => _upgradeId; private void Start() { _itemToggle = ((Component)this).GetComponent<ItemToggle>(); } public void Upgrade() { if ((Object)(object)_itemToggle == (Object)null) { Logger.LogError("REPOLibItemUpgrade: Failed to upgrade \"" + UpgradeId + "\". ItemToggle is null."); return; } int playerTogglePhotonID = _itemToggle.playerTogglePhotonID; PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(playerTogglePhotonID); if ((Object)(object)val == (Object)null) { Logger.LogError($"REPOLibItemUpgrade: Failed to upgrade \"{UpgradeId}\". Could not find PlayerAvatar from ItemToggle's playerTogglePhotonID {playerTogglePhotonID}."); } else if (val.isLocal) { if (!Upgrades.TryGetUpgrade(UpgradeId, out PlayerUpgrade playerUpgrade)) { Logger.LogError("REPOLibItemUpgrade: Failed to upgrade \"" + UpgradeId + "\". Could not find PlayerUpgrade from UpgradeId."); } else { playerUpgrade.AddLevel(val); } } } } public static class Utilities { private static readonly List<GameObject> _prefabsToFix = new List<GameObject>(); private static readonly List<GameObject> _fixedPrefabs = new List<GameObject>(); internal static void FixAudioMixerGroupsOnPrefabs() { foreach (GameObject item in _prefabsToFix) { item.FixAudioMixerGroups(); _fixedPrefabs.Add(item); } _prefabsToFix.Clear(); } public static void FixAudioMixerGroups(GameObject prefab) { if (!((Object)(object)prefab == (Object)null) && !_prefabsToFix.Contains(prefab) && !_fixedPrefabs.Contains(prefab)) { if ((Object)(object)AudioManager.instance == (Object)null) { _prefabsToFix.Add(prefab); return; } prefab.FixAudioMixerGroups(); _fixedPrefabs.Add(prefab); } } internal static void SafeInvokeEvent(Action? action) { try { action?.Invoke(); } catch (Exception arg) { Logger.LogError($"Exception occured while invoking event: {arg}"); } } } public static class ValuablePresets { private static readonly Dictionary<string, LevelValuables> _valuablePresets = new Dictionary<string, LevelValuables>(); public const string GenericValuablePresetName = "Valuables - Generic"; public static IReadOnlyDictionary<string, LevelValuables> AllValuablePresets => _valuablePresets; public static LevelValuables GenericValuablePreset => AllValuablePresets.GetValueOrDefault("Valuables - Generic"); [Obsolete("Use GenericValuablePreset instead.", true)] public static LevelValuables GenericPreset => GenericValuablePreset; internal static void Initialize() { if ((Object)(object)RunManager.instance == (Object)null) { Logger.LogError("Failed to initialize ValuablePresets. RunManager instance is null."); return; } AddValuablePresets(RunManager.instance.levelArena.ValuablePresets); foreach (Level level in RunManager.instance.levels) { AddValuablePresets(level.ValuablePresets); } AddGenericValuablePresetToVanillaLevels(); } private static void AddGenericValuablePresetToVanillaLevels() { LevelValuables genericValuablePreset = GenericValuablePreset; if ((Object)(object)genericValuablePreset == (Object)null) { Logger.LogError("Failed to add \"Valuables - Generic\" valuable preset to vanilla levels. Valuable preset is null."); return; } genericValuablePreset.tiny.Clear(); genericValuablePreset.small.Clear(); genericValuablePreset.medium.Clear(); genericValuablePreset.big.Clear(); genericValuablePreset.wide.Clear(); genericValuablePreset.tall.Clear(); genericValuablePreset.veryTall.Clear(); foreach (Level level in RunManager.instance.levels) { if (level.ValuablePresets.Contains(genericValuablePreset)) { Logger.LogInfo("Level \"" + ((Object)level).name + "\" already has the valuable preset \"" + ((Object)genericValuablePreset).name + "\"", extended: true); } else { level.ValuablePresets.Add(genericValuablePreset); Logger.LogInfo("Added valuable preset \"" + ((Object)genericValuablePreset).name + "\" to level \"" + ((Object)level).name + "\"", extended: true); } } } private static void AddValuablePresets(List<LevelValuables> valuablePresets) { foreach (LevelValuables valuablePreset in valuablePresets) { _valuablePresets.TryAdd(((Object)valuablePreset).name, valuablePreset); } } internal static void RegisterValuablePreset(LevelValuables valuablePreset) { RemoveMissingValuables(valuablePreset, valuablePreset.tiny); RemoveMissingValuables(valuablePreset, valuablePreset.small); RemoveMissingValuables(valuablePreset, valuablePreset.medium); RemoveMissingValuables(valuablePreset, valuablePreset.big); RemoveMissingValuables(valuablePreset, valuablePreset.wide); RemoveMissingValuables(valuablePreset, valuablePreset.tall); RemoveMissingValuables(valuablePreset, valuablePreset.veryTall); _valuablePresets.Add(((Object)valuablePreset).name, valuablePreset); } private static void RemoveMissingValuables(LevelValuables valuablePreset, List<PrefabRef> prefabRefs) { int count = prefabRefs.Count; for (int num = count - 1; num >= 0; num--) { PrefabRef val = prefabRefs[num]; if (!val.IsValid() || (Object)(object)Resources.Load<GameObject>(val.ResourcePath) == (Object)null) { Logger.LogWarning($"Valuable preset \"{((Object)valuablePreset).name}\" has an invalid vanilla valuable PrefabRef at index {num} (PrefabName: \"{val.PrefabName}\", ResourcePath: \"{val.ResourcePath}\")"); prefabRefs.RemoveAt(num); } } } } public static class Valuables { private static readonly Dictionary<PrefabRef, List<string>> _valuablesToRegister = new Dictionary<PrefabRef, List<string>>(); private static readonly List<PrefabRef> _valuablesRegistered = new List<PrefabRef>(); private static bool _initialValuablesRegistered; public static IReadOnlyList<PrefabRef> AllValuables { get { if ((Object)(object)RunManager.instance == (Object)null) { return Array.Empty<PrefabRef>(); } return ValuablePresets.AllValuablePresets.Values.Select((LevelValuables levelValuables) => levelValuables.GetCombinedList()).SelectMany((List<PrefabRef> list) => list).Distinct() .ToList(); } } public static IReadOnlyList<PrefabRef> RegisteredValuables => _valuablesRegistered; internal static void RegisterInitialValuables() { if (_initialValuablesRegistered) { return; } Logger.LogInfo("Adding valuables to valuable presets."); foreach (PrefabRef key in _valuablesToRegister.Keys) { RegisterValuableWithGame(key); } _valuablesToRegister.Clear(); _initialValuablesRegistered = true; } private static void RegisterValuableWithGame(PrefabRef prefabRef) { if (_valuablesRegistered.Contains(prefabRef)) { return; } List<string> list = _valuablesToRegister[prefabRef]; if (!list.Any((string x) => ValuablePresets.AllValuablePresets.Keys.Any((string y) => x == y))) { Logger.LogWarning("Valuable \"" + prefabRef.PrefabName + "\" does not have any valid valuable preset names set. Adding generic valuable preset name."); list = new List<string>(1) { "Valuables - Generic" }; } foreach (string item in list) { if (item == null || !ValuablePresets.AllValuablePresets.ContainsKey(item)) { Logger.LogWarning("Failed to add valuable \"" + prefabRef.PrefabName + "\" to valuable preset \"" + item + "\". The valuable preset does not exist."); } else if (ValuablePresets.AllValuablePresets[item].AddValuable(prefabRef)) { _valuablesRegistered.Add(prefabRef); Logger.LogDebug("Added valuable \"" + prefabRef.PrefabName + "\" to valuable preset \"" + item + "\""); } else { Logger.LogWarning("Failed to add valuable \"" + prefabRef.PrefabName + "\" to valuable preset \"" + item + "\"", extended: true); } } } public static PrefabRef? RegisterValuable(ValuableObject? valuableObject, List<string> presetNames) { if ((Object)(object)valuableObject == (Object)null) { Logger.LogError("Failed to register valuable. ValuableObject is null."); return null; } GameObject gameObject = ((Component)valuableObject).gameObject; string prefabId = "Valuables/" + ((Object)gameObject).name; if (presetNames == null || presetNames.Count == 0) { Logger.LogWarning("Valuable \"" + ((Object)gameObject).name + "\" does not have any valid valuable preset names set. Adding generic valuable preset name.", extended: true); presetNames = new List<string>(1) { "Valuables - Generic" }; } PrefabRefResponse prefabRefResponse = NetworkPrefabs.RegisterNetworkPrefabInternal(prefabId, gameObject); PrefabRef prefabRef = prefabRefResponse.PrefabRef; if (prefabRefResponse.Result == PrefabRefResult.PrefabAlreadyRegistered) { Logger.LogWarning("Failed to register valuable \"" + ((Object)gameObject).name + "\". Valuable is already registered!"); return null; } if (prefabRefResponse.Result == PrefabRefResult.DifferentPrefabAlreadyRegistered) { Logger.LogError("Failed to register valuable \"" + ((Object)gameObject).name + "\". A valuable prefab is already registered with the same name."); return null; } if (prefabRefResponse.Result != 0) { Logger.LogError($"Failed to register valuable \"{((Object)gameObject).name}\". (Reason: {prefabRefResponse.Result})"); return null; } if (prefabRef == null) { Logger.LogError("Failed to register valuable \"" + ((Object)gameObject).name + "\". PrefabRef is null."); return null; } Utilities.FixAudioMixerGroups(gameObject); _valuablesToRegister.Add(prefabRef, presetNames); if (_initialValuablesRegistered) { RegisterValuableWithGame(prefabRef); } return prefabRef; } public static PrefabRef? RegisterValuable(ValuableObject? valuableObject) { return RegisterValuable(valuableObject, new List<string>()); } public static PrefabRef? RegisterValuable(ValuableObject? valuableObject, List<LevelValuables> presets) { return RegisterValuable(valuableObject, presets.Select((LevelValuables preset) => ((Object)preset).name).ToList()); } public static PrefabRef? RegisterValuable(ValuableContent? valuableContent) { if ((Object)(object)valuableContent == (Object)null) { Logger.LogError("Failed to register valuable. ValuableContent is null."); return null; } return RegisterValuable(valuableContent.Prefab, valuableContent.ValuablePresets.ToList()); } public static PrefabRef? RegisterValuable(GameObject? prefab, List<string> presetNames) { if ((Object)(object)prefab == (Object)null) { Logger.LogError("Failed to register valuable. Prefab is null."); return null; } ValuableObject valuableObject = default(ValuableObject); if (!prefab.TryGetComponent<ValuableObject>(ref valuableObject)) { Logger.LogError("Failed to register valuable \"" + ((Object)prefab).name + "\". Prefab does not have a ValuableObject component."); return null; } return RegisterValuable(valuableObject, presetNames); } public static PrefabRef? RegisterValuable(GameObject? prefab, List<LevelValuables> presets) { return RegisterValuable(prefab, presets.Select((LevelValuables preset) => ((Object)preset).name).ToList()); } public static PrefabRef? RegisterValuable(GameObject? prefab) { return RegisterValuable(prefab, new List<string>()); } public static GameObject? SpawnValuable(PrefabRef? prefabRef, Vector3 position, Quaternion rotation) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (prefabRef == null) { Logger.LogError("Failed to spawn valuable. PrefabRef is null."); return null; } if (!prefabRef.IsValid()) { Logger.LogError("Failed to spawn valuable. PrefabRef is not valid."); return null; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { Logger.LogError("Failed to spawn valuable \"" + prefabRef.PrefabName + "\". You are not the host."); return null; } GameObject val = NetworkPrefabs.SpawnNetworkPrefab(prefabRef, position, rotation, 0); if ((Object)(object)val == (Object)null) { Logger.LogError("Failed to spawn valuable \"" + prefabRef.prefabName + "\". Spawned GameObject is null."); return null; } Logger.LogInfo($"Spawned valuable \"{prefabRef.prefabName}\" at position {position}, rotation: {((Quaternion)(ref rotation)).eulerAngles}", extended: true); return val; } [Obsolete("This is no longer supported. Use AllValuables or RegisteredValuables instead.", true)] public static IReadOnlyList<GameObject> GetValuables() { return Array.Empty<GameObject>(); } [Obsolete("This is no longer supported. Use AllValuables or RegisteredValuables instead.", true)] public static bool TryGetValuableByName(string name, [NotNullWhen(true)] out PrefabRef? prefabRef) { prefabRef = null; return false; } [Obsolete("This is no longer supported. Use AllValuables or RegisteredValuables instead.", true)] public static PrefabRef? GetValuableByName(string name) { return null; } [Obsolete("This is no longer supported. Use AllValuables or RegisteredValuables instead.", true)] public static bool TryGetValuableThatContainsName(string name, [NotNullWhen(true)] out PrefabRef? prefabRef) { prefabRef = null; return false; } [Obsolete("This is no longer supported. Use AllValuables or RegisteredValuables instead.", true)] public static PrefabRef? GetValuableThatContainsName(string name) { return null; } } } namespace REPOLib.Extensions { internal static class AudioSourceExtensions { public static void FixAudioMixerGroup(this AudioSource audioSource) { audioSource.FixAudioMixerGroup(((Component)audioSource).gameObject); } public static void FixAudioMixerGroup(this AudioSource audioSource, GameObject rootObject) { if ((Object)(object)audioSource == (Object)null) { return; } string text = ((!((Object)(object)rootObject == (Object)(object)((Component)audioSource).gameObject)) ? (((Object)rootObject).name + "/" + ((Object)((Component)audioSource).gameObject).name) : ((Object)((Component)audioSource).gameObject).name); if ((Object)(object)AudioManager.instance == (Object)null) { Logger.LogWarning("Failed to fix AudioMixerGroup on GameObject \"" + text + "\". AudioManager instance is null."); return; } if ((Object)(object)audioSource.outputAudioMixerGroup == (Object)null) { Logger.LogWarning("Failed to fix AudioMixerGroup on GameObject \"" + text + "\". No AudioMixerGroup is assigned."); return; } AudioMixer val = (AudioMixer)(((Object)audioSource.outputAudioMixerGroup.audioMixer).name switch { "Master" => AudioManager.instance.MasterMixer, "Music" => AudioManager.instance.MusicMasterGroup.audioMixer, "Sound" => AudioManager.instance.SoundMasterGroup.audioMixer, "Spectate" => AudioManager.instance.MicrophoneSpectateGroup.audioMixer, _ => AudioManager.instance.SoundMasterGroup.audioMixer, }); AudioMixerGroup[] array = val.FindMatchingGroups(((Object)audioSource.outputAudioMixerGroup).name); AudioMixerGroup val2; if (array.Length >= 1) { val2 = array[0]; } else { val = AudioManager.instance.SoundMasterGroup.audioMixer; val2 = val.FindMatchingGroups("Sound Effects")[0]; Logger.LogWarning("Could not find matching AudioMixerGroup for GameObject \"" + text + "\". Using default AudioMixerGroup \"" + ((Object)val).name + "/" + ((Object)val2).name + "\"", extended: true); } audioSource.outputAudioMixerGroup = val2; Logger.LogDebug("Fixed AudioMixerGroup on GameObject \"" + text + "\". AudioMixerGroup \"" + ((Object)val).name + "/" + ((Object)val2).name + "\""); } } internal static class EnemyDirectorExtensions { public static bool HasEnemy(this EnemyDirector enemyDirector, EnemySetup enemySetup) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enemySetup == (Object)null || enemySetup.spawnObjects.Count == 0) { return false; } if (!enemySetup.TryGetEnemyParent(out EnemyParent enemyParent)) { return false; } if (!enemyDirector.TryGetList(enemyParent.difficulty, out List<EnemySetup> list)) { return false; } return list.Contains(enemySetup); } internal static bool AddEnemy(this EnemyDirector enemyDirector, EnemySetup enemySetup) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enemySetup == (Object)null) { return false; } if (!enemySetup.TryGetEnemyParent(out EnemyParent enemyParent)) { return false; } if (!enemyDirector.TryGetList(enemyParent.difficulty, out List<EnemySetup> list)) { return false; } if (list.Contains(enemySetup)) { return false; } list.Add(enemySetup); return true; } public static bool TryGetList(this EnemyDirector enemyDirector, Difficulty difficultyType, [NotNullWhen(true)] out List<EnemySetup>? list) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected I4, but got Unknown list = (int)difficultyType switch { 0 => enemyDirector.enemiesDifficulty1, 1 => enemyDirector.enemiesDifficulty2, 2 => enemyDirector.enemiesDifficulty3, _ => null, }; return list != null; } public static List<EnemySetup> GetEnemies(this EnemyDirector enemyDirector) { List<EnemySetup> enemiesDifficulty = enemyDirector.enemiesDifficulty1; List<EnemySetup> enemiesDifficulty2 = enemyDirector.enemiesDifficulty2; List<EnemySetup> enemiesDifficulty3 = enemyDirector.enemiesDifficulty3; List<EnemySetup> list = new List<EnemySetup>(enemiesDifficulty.Count + enemiesDifficulty2.Count + enemiesDifficulty3.Count); list.AddRange(enemiesDifficulty); list.AddRange(enemiesDifficulty2); list.AddRange(enemiesDifficulty3); return list; } } internal static class EnemySetupExtensions { public static List<PrefabRef> GetDistinctSpawnObjects(this EnemySetup enemySetup) { return enemySetup.spawnObjects.Where((PrefabRef x) => x != null).Distinct(new PrefabRefComparer()).ToList(); } public static EnemyParent? GetEnemyParent(this EnemySetup enemySetup) { EnemyParent result = default(EnemyParent); foreach (PrefabRef distinctSpawnObject in enemySetup.GetDistinctSpawnObjects()) { if (distinctSpawnObject.Prefab.TryGetComponent<EnemyParent>(ref result)) { return result; } } return null; } public static bool TryGetEnemyParent(this EnemySetup enemySetup, [NotNullWhen(true)] out EnemyParent? enemyParent) { enemyParent = enemySetup.GetEnemyParent(); return (Object)(object)enemyParent != (Object)null; } } internal static class GameObjectExtensions { public static void FixAudioMixerGroups(this GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } if ((Object)(object)AudioManager.instance == (Object)null) { Logger.LogWarning("Failed to fix audio mixer groups on GameObject \"" + ((Object)gameObject).name + "\". AudioManager instance is null."); return; } AudioSource[] componentsInChildren = gameObject.GetComponentsInChildren<AudioSource>(); foreach (AudioSource audioSource in componentsInChildren) { audioSource.FixAudioMixerGroup(gameObject); } } } internal static class LevelValuablesExtensions { public static bool AddValuable(this LevelValuables levelValuables, PrefabRef prefabRef) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = prefabRef.Prefab; if ((Object)(object)prefab == (Object)null) { return false; } ValuableObject val = default(ValuableObject); if (!prefab.TryGetComponent<ValuableObject>(ref val)) { return false; } if (!levelValuables.TryGetList(val.volumeType, out List<PrefabRef> list)) { return false; } if (list.Contains(prefabRef)) { return false; } list.Add(prefabRef); return true; } public static bool TryGetList(this LevelValuables levelValuables, Type volumeType, [NotNullWhen(true)] out List<PrefabRef>? list) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected I4, but got Unknown list = (int)volumeType switch { 0 => levelValuables.tiny, 1 => levelValuables.small, 2 => levelValuables.medium, 3 => levelValuables.big, 4 => levelValuables.wide, 5 => levelValuables.tall, 6 => levelValuables.veryTall, _ => null, }; return list != null; } public static bool TryGetCombinedList(this LevelValuables levelValuables, out List<PrefabRef> list) { List<List<PrefabRef>> source = new List<List<PrefabRef>> { levelValuables.tiny, levelValuables.small, levelValuables.medium, levelValuables.big, levelValuables.wide, levelValuables.tall, levelValuables.veryTall }; list = (from x in source.SelectMany((List<PrefabRef> valuables) => valuables) where x != null select x).Distinct().ToList(); return list != null; } public static List<PrefabRef> GetCombinedList(this LevelValuables levelValuables) { if (levelValuables.TryGetCombinedList(out List<PrefabRef> list)) { return list; } return new List<PrefabRef>(); } } internal static class StatsManagerExtensions { public static bool HasItem(this StatsManager statsManager, Item item) { if ((Object)(object)item == (Object)null) { return false; } return statsManager.itemDictionary.ContainsKey(((Object)item).name); } internal static bool AddItem(this StatsManager statsManager, Item item) { if (!statsManager.itemDictionary.ContainsKey(((Object)item).name)) { statsManager.itemDictionary.Add(((Object)item).name, item); } foreach (Dictionary<string, int> item2 in statsManager.AllDictionariesWithPrefix("item")) { item2[((Object)item).name] = 0; } return true; } public static List<Item> GetItems(this
xxSShadow.MapVote.dll
Decompiled 9 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using MenuLib; using MenuLib.MonoBehaviors; using Microsoft.CodeAnalysis; using MonoMod.RuntimeDetour; using REPOLib.Modules; using Sirenix.Serialization.Utilities; using TMPro; using Unity.VisualScripting; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Discord.Sdk")] [assembly: IgnoresAccessChecksTo("Domain_Reload")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.MemoryProfiler")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Splines")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: AssemblyCompany("xxSShadow")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Mod to vote for and rename specific R.E.P.O. maps")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyInformationalVersion("1.1.1+8e4312b9e0f7a607b815c242e0a8e2e6008f2653")] [assembly: AssemblyProduct("MapVote")] [assembly: AssemblyTitle("xxSShadow.MapVote")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/pneben/Repo-LevelRenamer")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.1.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.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; } } [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; } } } namespace MapVote { public static class MyPluginInfo { public const string PLUGIN_GUID = "xxSShadow.MapVote"; public const string PLUGIN_NAME = "MapVote"; public const string PLUGIN_VERSION = "1.1.1"; } } namespace LevelRenamer { internal class CompatibilityPatches { private static Dictionary<string, Action> Patches = new Dictionary<string, Action>(); public static void PopulatePatches() { Patches.Add("ViViKo.StartInShop", delegate { Main.HideInMenu.Value = true; }); } public static void RunPatches(List<string> pluginGUIDs) { List<string> pluginGUIDs2 = pluginGUIDs; PopulatePatches(); LinqExtensions.ForEach<KeyValuePair<string, Action>>(Patches.Where<KeyValuePair<string, Action>>((KeyValuePair<string, Action> x) => pluginGUIDs2.Contains(x.Key)), (Action<KeyValuePair<string, Action>>)delegate(KeyValuePair<string, Action> plugin) { plugin.Value(); Main.Logger.LogInfo((object)("Ran Compatibility Patch for " + plugin.Key)); }); } } internal class ConfigManager { public static ConfigEntry<bool> shuffleEachLevel; public static ConfigEntry<string> shopName; public static ConfigEntry<string> arenaName; public static Dictionary<string, ConfigEntry<string>> levelNames = new Dictionary<string, ConfigEntry<string>>(); public static Dictionary<string, ConfigEntry<string>> levelColors = new Dictionary<string, ConfigEntry<string>>(); public static Dictionary<string, string> colorDictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "Random", "#E79F0E" }, { "Level - Manor", "#E79F0E" }, { "Level - Arctic", "#75DCD9" }, { "Level - Wizard", "#CB11CE" }, { "Level - Museum", "#915829" }, { "Level - TSP", "#585542" } }; public static string GetColor(string key) { string value; return colorDictionary.TryGetValue(key, out value) ? value : "#FFFFFF"; } public static void Init() { shuffleEachLevel = ((BaseUnityPlugin)Main.Instance).Config.Bind<bool>("Settings", "Shuffle Each Level", false, "Shuffles custom names after each individual level instead of each full game"); shopName = ((BaseUnityPlugin)Main.Instance).Config.Bind<string>("Settings", "Shop Name", "", "The set of custom names for the shop level. Documentation for this setting can be found in the README"); arenaName = ((BaseUnityPlugin)Main.Instance).Config.Bind<string>("Settings", "Arena Name", "", "The set of custom names for the arena level. Documentation for this setting can be found in the README"); foreach (Level level in RunManager.instance.levels) { try { if (!((Object)(object)level == (Object)null)) { ConfigEntry<string> val = ((BaseUnityPlugin)Main.Instance).Config.Bind<string>(((Object)level).name, "Name", level.NarrativeName ?? string.Empty, "Custom name for '" + ((Object)level).name + "'"); ConfigEntry<string> val2 = ((BaseUnityPlugin)Main.Instance).Config.Bind<string>(((Object)level).name, "Color", GetColor(((Object)level).name), "Custom color for '" + ((Object)level).name + "'"); levelNames[((Object)level).name] = val; levelColors[((Object)level).name] = val2; Main.Logger.LogInfo((object)("Created config entries for level '" + ((Object)level).name + "'")); Main.storedLevelNames[((Object)level).name] = "<color=" + val2.Value + ">" + val.Value + "</color>"; } } catch (Exception ex) { Main.Logger.LogError((object)("Failed to create config entries for level '" + (((level != null) ? ((Object)level).name : null) ?? "<null>") + "': " + ex.GetType().Name + ": " + ex.Message)); } } } public static List<string> GetLevelNames(string levelKey) { List<string> result = new List<string>(); if (levelKey == "Arena" && !string.IsNullOrWhiteSpace(arenaName.Value)) { return (from s in arenaName.Value.Split(';', StringSplitOptions.RemoveEmptyEntries) select s.Trim()).ToList(); } if (levelKey == "Shop" && !string.IsNullOrWhiteSpace(shopName.Value)) { return (from s in shopName.Value.Split(';', StringSplitOptions.RemoveEmptyEntries) select s.Trim()).ToList(); } if (levelNames.TryGetValue(levelKey, out ConfigEntry<string> value) && !string.IsNullOrWhiteSpace(value.Value)) { return (from s in value.Value.Split(';', StringSplitOptions.RemoveEmptyEntries) select s.Trim()).ToList(); } return result; } } internal class DebugManager { public static void InitializeDebug() { PopulateMockData(); } private static void PopulateMockData() { Main.CurrentVotes[10] = "Level - Arctic"; Main.CurrentVotes[11] = "Level - Manor"; Main.CurrentVotes[12] = "Level - Wizard"; Main.CurrentVotes[13] = "Level - Wizard"; Main.CurrentVotes[14] = "Level - Wizard"; Main.CurrentVotes[15] = "Random"; } } [HarmonyPatch(typeof(HealthUI))] public class HealthUIPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void PostfixStart(HealthUI __instance) { if (((Object)RunManager.instance.levelCurrent).name == "Level - Lobby") { ((MonoBehaviour)Main.Instance).StartCoroutine(Main.WaitForVote()); Main.CreateVotePopup(); } } } [HarmonyPatch(typeof(LevelGenerator))] internal class LevelGeneratorPatch { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePatch() { if (!Main.doInitialSetup || !((Object)(object)RunManager.instance != (Object)null)) { return; } ConfigManager.Init(); Main.doInitialSetup = false; string[] array = new string[RunManager.instance.levels.Count]; for (int i = 0; i < array.Length; i++) { array[i] = ((Object)RunManager.instance.levels[i]).name + " (" + RunManager.instance.levels[i].ResourcePath + ")"; if (!Main.storedLevelNames.ContainsKey(((Object)RunManager.instance.levels[i]).name)) { Main.storedLevelNames.Add(((Object)RunManager.instance.levels[i]).name, ((Object)RunManager.instance.levels[i]).name.ToUpper()); } } if (!Main.storedLevelNames.ContainsKey("Random")) { Main.storedLevelNames.Add("Random", "RANDOM"); } if (!Main.storedLevelNames.ContainsKey("Disposal Arena")) { Main.storedLevelNames.Add("Disposal Arena", "DISPOSAL ARENA"); } if (!Main.storedLevelNames.ContainsKey("Service Station")) { Main.storedLevelNames.Add("Service Station", "SERVICE STATION"); } Main.Logger.LogInfo((object)string.Format("Found {0} extraction levels: {1}", array.Length, GeneralExtensions.Join<string>((IEnumerable<string>)array, (Func<string, string>)null, ", "))); } } [HarmonyPatch(typeof(LoadingUI))] internal class LoadingUIPatch { [HarmonyPostfix] [HarmonyPatch("LevelAnimationStart")] private static void LevelAnimationStartPatch(LoadingUI __instance) { //IL_0320: Unknown result type (might be due to invalid IL or missing references) if ((SemiFunc.RunIsLevel() || SemiFunc.RunIsArena() || SemiFunc.RunIsShop()) && Main.readyToShuffle) { bool flag = false; Main.Logger.LogInfo((object)"Shuffling all level names..."); List<string> levelNames = ConfigManager.GetLevelNames("Arena"); List<string> levelNames2 = ConfigManager.GetLevelNames("Shop"); if (levelNames.Count > 0) { string text = Main.storedLevelNames["Disposal Arena"]; Main.storedLevelNames["Disposal Arena"] = levelNames[Random.Range(0, levelNames.Count)]; if (text != Main.storedLevelNames["Disposal Arena"]) { flag = true; Main.Logger.LogInfo((object)(text + " is now known as " + Main.storedLevelNames["Disposal Arena"] + ".")); } } if (levelNames2.Count > 0) { string text2 = Main.storedLevelNames["Service Station"]; Main.storedLevelNames["Service Station"] = levelNames2[Random.Range(0, levelNames2.Count)]; if (text2 != Main.storedLevelNames["Service Station"]) { flag = true; Main.Logger.LogInfo((object)(text2 + " is now known as " + Main.storedLevelNames["Service Station"] + ".")); } } for (int i = 0; i < RunManager.instance.levels.Count; i++) { Level val = RunManager.instance.levels[i]; List<string> levelNames3 = ConfigManager.GetLevelNames(((Object)val).name); if (levelNames3.Count > 0) { string text3 = Main.storedLevelNames[((Object)val).name]; Main.storedLevelNames[((Object)val).name] = levelNames3[Random.Range(0, levelNames3.Count)]; if (text3 != Main.storedLevelNames[((Object)val).name]) { flag = true; Main.Logger.LogInfo((object)(text3 + " is now known as " + Main.storedLevelNames[((Object)val).name] + ".")); } } } if (!flag) { Main.Logger.LogInfo((object)"No level names were changed."); } if (!ConfigManager.shuffleEachLevel.Value) { Main.readyToShuffle = false; } } if (Main.storedLevelNames.ContainsKey(((Object)RunManager.instance.levelCurrent).name)) { ((TMP_Text)__instance.levelNameText).text = Main.storedLevelNames[((Object)RunManager.instance.levelCurrent).name]; } string name = ((Object)RunManager.instance.levelCurrent).name; if (ConfigManager.levelColors.TryGetValue(name, out ConfigEntry<string> value)) { string value2 = value.Value; Color color = default(Color); if (ColorUtility.TryParseHtmlString(value2, ref color)) { ((Graphic)__instance.levelNameText).color = color; } else { Main.Logger.LogWarning((object)("Invalid color '" + value2 + "' for level '" + name + "'. Expected HTML hex format such as #RRGGBB.")); } } if (SemiFunc.RunIsArena()) { Main.readyToShuffle = true; } } } [BepInPlugin("eXish.CustomLevelNames", "CustomLevelNames", "1.0.6")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal sealed class Main : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Predicate<Level> <>9__36_0; public static Func<KeyValuePair<string, PluginInfo>, string> <>9__40_0; public static Action <>9__43_1; public static BuilderDelegate <>9__43_0; public static Action<KeyValuePair<int, string>> <>9__48_0; public static Func<VoteOptionButton, global::<>f__AnonymousType0<VoteOptionButton, int>> <>9__51_0; public static Func<global::<>f__AnonymousType0<VoteOptionButton, int>, int> <>9__51_1; public static Func<global::<>f__AnonymousType0<VoteOptionButton, int>, VoteOptionButton> <>9__51_2; public static Action <>9__55_2; public static ScrollViewBuilderDelegate <>9__55_0; public static Func<Level, int, (Level level, int index)> <>9__55_3; public static Action<VoteOptionButton> <>9__56_0; public static Predicate<VoteOptionButton> <>9__57_0; public static Func<VoteOptionButton, int> <>9__57_1; public static Func<IGrouping<int, VoteOptionButton>, int> <>9__57_2; public static Predicate<VoteOptionButton> <>9__57_5; public static Predicate<VoteOptionButton> <>9__57_3; public static Predicate<VoteOptionButton> <>9__57_6; public static Predicate<VoteOptionButton> <>9__57_4; internal bool <HookRunManagerSetRunLevel>b__36_0(Level x) { return ((Object)x).name == WonMap; } internal string <Awake>b__40_0(KeyValuePair<string, PluginInfo> x) { return x.Key; } internal void <Initialize>b__43_0(Transform parent) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("Map Vote", (Action)delegate { CreateVotePopup(isInMenu: true); }, parent, new Vector2(175.2f, 62.8f)); } internal void <Initialize>b__43_1() { CreateVotePopup(isInMenu: true); } internal void <HandleOnSyncVotes>b__48_0(KeyValuePair<int, string> x) { CurrentVotes[x.Key] = x.Value; } internal global::<>f__AnonymousType0<VoteOptionButton, int> <GetSortedVoteOptions>b__51_0(VoteOptionButton b) { return new { Item = b, Count = b.GetVotes(CurrentVotes.Values) }; } internal int <GetSortedVoteOptions>b__51_1(global::<>f__AnonymousType0<VoteOptionButton, int> b) { return b.Count; } internal VoteOptionButton <GetSortedVoteOptions>b__51_2(global::<>f__AnonymousType0<VoteOptionButton, int> b) { return b.Item; } internal RectTransform <CreateVotePopup>b__55_0(Transform parent) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) REPOButton val = MenuAPI.CreateREPOButton((string)null, (Action)delegate { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!DisableInput) { OwnVoteLevel = "Random"; NetworkedEvent? onVoteEvent = OnVoteEvent; if (onVoteEvent != null) { onVoteEvent.RaiseEvent((object)"Random", NetworkingEvents.RaiseAll, SendOptions.SendReliable); } } }, parent, default(Vector2)); HorizontalLayoutGroup val2 = ComponentHolderProtocol.AddComponent<HorizontalLayoutGroup>((Object)(object)val); ((HorizontalOrVerticalLayoutGroup)val2).spacing = 235f; GameObject val3 = Object.Instantiate<GameObject>(((Component)val.labelTMP).gameObject, ((Component)val).transform); TextMeshProUGUI component = val3.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).horizontalAlignment = (HorizontalAlignmentOptions)4; VoteOptionButtons.Add(new VoteOptionButton("Random", 0, val, _isRandomButton: true)); return ((REPOElement)val).rectTransform; } internal void <CreateVotePopup>b__55_2() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!DisableInput) { OwnVoteLevel = "Random"; NetworkedEvent? onVoteEvent = OnVoteEvent; if (onVoteEvent != null) { onVoteEvent.RaiseEvent((object)"Random", NetworkingEvents.RaiseAll, SendOptions.SendReliable); } } } internal (Level level, int index) <CreateVotePopup>b__55_3(Level level, int index) { return (level, index); } internal void <UpdateButtonLabels>b__56_0(VoteOptionButton b) { b.UpdateLabel(_highlight: false, HasBeenLastPlayed(b.Level)); } internal bool <GetEligibleOptions>b__57_0(VoteOptionButton x) { return !x.IsRandomButton; } internal int <GetEligibleOptions>b__57_1(VoteOptionButton x) { return x.GetVotes(CurrentVotes.Values); } internal int <GetEligibleOptions>b__57_2(IGrouping<int, VoteOptionButton> x) { return x.Key; } internal bool <GetEligibleOptions>b__57_5(VoteOptionButton x) { return x.Level == "Random"; } internal bool <GetEligibleOptions>b__57_3(VoteOptionButton x) { return !HasBeenLastPlayed(x.Level); } internal bool <GetEligibleOptions>b__57_6(VoteOptionButton x) { return !x.IsRandomButton; } internal bool <GetEligibleOptions>b__57_4(VoteOptionButton x) { return x.IsRandomButton; } } [CompilerGenerated] private sealed class <>c__DisplayClass59_0 { public string winningMap; internal bool <OnVotingDone>b__0(VoteOptionButton x) { return x.Level == winningMap; } } [CompilerGenerated] private sealed class <BlinkButton>d__60 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public VoteOptionButton voteOption; private int <maxBlinks>5__1; private int <currentBlink>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <BlinkButton>d__60(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <maxBlinks>5__1 = (int)Mathf.Ceil(6f); <currentBlink>5__2 = 0; break; case 1: <>1__state = -1; voteOption.UpdateLabel(); <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 2; return true; case 2: <>1__state = -1; <currentBlink>5__2++; break; } if (<currentBlink>5__2 < <maxBlinks>5__1) { voteOption.UpdateLabel(_highlight: true); <>2__current = (object)new WaitForSeconds(0.25f); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <OnVotingDone>d__59 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string winningMap; private <>c__DisplayClass59_0 <>8__1; private List<VoteOptionButton> <eligibleOptions>5__2; private int <winningIndex>5__3; private VoteOptionButton <wonOption>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <OnVotingDone>d__59(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <eligibleOptions>5__2 = null; <wonOption>5__4 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass59_0(); <>8__1.winningMap = winningMap; DisableInput = true; ShouldHookRunMangerSetRunLevel = true; WonMap = <>8__1.winningMap; <eligibleOptions>5__2 = GetEligibleOptions(); if (<eligibleOptions>5__2.Count > 1) { <winningIndex>5__3 = <eligibleOptions>5__2.FindIndex((VoteOptionButton x) => x.Level == <>8__1.winningMap); <>2__current = ((MonoBehaviour)Instance).StartCoroutine(SpinWheelOptions(<eligibleOptions>5__2, <winningIndex>5__3)); <>1__state = 1; return true; } <wonOption>5__4 = <eligibleOptions>5__2.FirstOrDefault(); if (<wonOption>5__4 != null) { <>2__current = ((MonoBehaviour)Instance).StartCoroutine(BlinkButton(<wonOption>5__4)); <>1__state = 3; return true; } goto IL_016b; case 1: <>1__state = -1; <>2__current = ((MonoBehaviour)Instance).StartCoroutine(BlinkButton(<eligibleOptions>5__2[<winningIndex>5__3])); <>1__state = 2; return true; case 2: <>1__state = -1; break; case 3: { <>1__state = -1; goto IL_016b; } IL_016b: <wonOption>5__4 = null; break; } DisableInput = false; if (SemiFunc.RunIsLobby()) { CreateNextMapLabel(WonMap); if ((Object)(object)VotePopup != (Object)null) { VotePopup.ClosePage(true); } MenuAPI.CloseAllPagesAddedOnTop(); } if (SemiFunc.IsMasterClient() && SemiFunc.RunIsLobbyMenu()) { MenuPageLobby.instance.ButtonStart(); } Reset(); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <SpinWheelOptions>d__61 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public List<VoteOptionButton> eligibleOptions; public int winningIndex; private float <delay>5__1; private int <index>5__2; private int <endIndex>5__3; private int <recentIndex>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SpinWheelOptions>d__61(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; if (<delay>5__1 > 0.4f && <index>5__2 == <endIndex>5__3) { goto IL_0136; } <delay>5__1 *= 1.15f; <recentIndex>5__4 = <index>5__2; <index>5__2 = (<index>5__2 + 1) % eligibleOptions.Count; } else { <>1__state = -1; <delay>5__1 = 0.05f; <index>5__2 = 0; <endIndex>5__3 = winningIndex; <recentIndex>5__4 = -1; } if (<index>5__2 != <endIndex>5__3 || <delay>5__1 < 0.5f) { eligibleOptions[<index>5__2].UpdateLabel(_highlight: true); if (<recentIndex>5__4 >= 0) { eligibleOptions[<recentIndex>5__4].UpdateLabel(); } <>2__current = (object)new WaitForSeconds(<delay>5__1); <>1__state = 1; return true; } goto IL_0136; IL_0136: eligibleOptions[<recentIndex>5__4].UpdateLabel(); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <StartCountdown>d__54 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private string <format>5__1; private NumberFormatInfo <nfi>5__2; private string <map>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <StartCountdown>d__54(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <format>5__1 = null; <nfi>5__2 = null; <map>5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (SemiFunc.IsMasterClientOrSingleplayer()) { VotingTimeLeft = VotingTime.Value; NetworkedEvent? onStartCountdown = OnStartCountdown; if (onStartCountdown != null) { onStartCountdown.RaiseEvent((object)VotingTimeLeft, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } <format>5__1 = "00.00"; <nfi>5__2 = new NumberFormatInfo { NumberDecimalSeparator = ":" }; break; case 1: <>1__state = -1; break; } if (VotingTimeLeft > 0f) { VotingTimeLeft -= Time.deltaTime; if ((Object)(object)VotingTimeLabel != (Object)null) { ((TMP_Text)VotingTimeLabel.labelTMP).text = "<mspace=0.5em>" + VotingTimeLeft.ToString(<format>5__1, <nfi>5__2) + "</mspace> Seconds Left"; } <>2__current = null; <>1__state = 1; return true; } if ((Object)(object)VotingTimeLabel != (Object)null && (Object)(object)((Component)VotingTimeLabel).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)VotingTimeLabel).gameObject); } if (SemiFunc.IsMasterClientOrSingleplayer()) { <map>5__3 = GetWinningMap(); NetworkedEvent? onVoteEndedEvent = OnVoteEndedEvent; if (onVoteEndedEvent != null) { onVoteEndedEvent.RaiseEvent((object)<map>5__3, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } ((MonoBehaviour)Instance).StartCoroutine(OnVotingDone(<map>5__3)); <map>5__3 = null; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <WaitForVote>d__53 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForVote>d__53(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if (CurrentVotes.Values.Count <= 0) { UpdateButtonLabels(); <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { return false; } ((MonoBehaviour)Instance).StartCoroutine(StartCountdown()); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private const string mGUID = "eXish.CustomLevelNames"; private const string mName = "CustomLevelNames"; private const string mVersion = "1.0.6"; public const string VOTE_RANDOM_LABEL = "Random"; public const string TRUCK_LEVEL_NAME = "Level - Lobby"; public const string SHOP_LEVEL_NAME = "Level - Shop"; public const string REQUEST_VOTE_LEVEL = "Level - Lobby"; internal static Main Instance; internal static Dictionary<string, string> storedLevelNames = new Dictionary<string, string>(); internal static bool doInitialSetup = true; internal static bool readyToShuffle = true; public const bool IS_DEBUG = false; internal static readonly ManualLogSource Logger = Logger.CreateLogSource("CustomLevelNames"); public static NetworkedEvent? OnVoteEvent; public static NetworkedEvent? OnVoteEndedEvent; public static NetworkedEvent? OnSyncVotes; public static NetworkedEvent? OnSyncLastMapPlayed; public static NetworkedEvent? OnStartCountdown; public static ConfigEntry<int> VotingTime; public static ConfigEntry<bool> HideInMenu; public static ConfigEntry<bool> NoRepeatedMaps; public static VotesDictionary CurrentVotes = new VotesDictionary(); public static readonly List<VoteOptionButton> VoteOptionButtons = new List<VoteOptionButton>(); public static string? OwnVoteLevel; public static string? WonMap; public static REPOPopupPage? VotePopup; public static float VotingTimeLeft = 0f; public static REPOLabel? VotingTimeLabel; public static bool DisableInput = false; public static bool ShouldHookRunMangerSetRunLevel = false; public static string? LastMapPlayed; private static Hook RunManagerSetRunLevelHook = new Hook((MethodBase)AccessTools.DeclaredMethod(typeof(RunManager), "SetRunLevel", (Type[])null, (Type[])null), (Delegate)new Action<Action<RunManager>, RunManager>(HookRunManagerSetRunLevel)); private static int ButtonStartHookRunAmount = 0; private static Hook ButtonStartHook = new Hook((MethodBase)AccessTools.DeclaredMethod(typeof(MenuPageLobby), "ButtonStart", (Type[])null, (Type[])null), (Delegate)new Action<Action<MenuPageLobby>, MenuPageLobby>(HookButtonStart)); internal Harmony? Harmony { get; set; } private static void HookRunManagerSetRunLevel(Action<RunManager> orig, RunManager self) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer() && ShouldHookRunMangerSetRunLevel) { self.levelCurrent = self.levels.Find((Level x) => ((Object)x).name == WonMap); ShouldHookRunMangerSetRunLevel = false; LastMapPlayed = WonMap; NetworkedEvent? onSyncLastMapPlayed = OnSyncLastMapPlayed; if (onSyncLastMapPlayed != null) { onSyncLastMapPlayed.RaiseEvent((object)LastMapPlayed, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } Reset(); WonMap = null; } else { orig(self); } } private static void HookButtonStart(Action<MenuPageLobby> orig, MenuPageLobby self) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (DisableInput) { return; } if (ButtonStartHookRunAmount > 0 || HideInMenu.Value) { ButtonStartHookRunAmount = 0; orig(self); return; } ButtonStartHookRunAmount++; string winningMap = GetWinningMap(); NetworkedEvent? onVoteEndedEvent = OnVoteEndedEvent; if (onVoteEndedEvent != null) { onVoteEndedEvent.RaiseEvent((object)winningMap, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } ((MonoBehaviour)Instance).StartCoroutine(OnVotingDone(winningMap)); } public void Awake() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); VotingTime = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Voting Time", 10, new ConfigDescription("The amount of seconds until the voting ends, after the first player voted.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(3, 30), Array.Empty<object>())); HideInMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Hide in Menu", false, new ConfigDescription("When true - hides the Menu in the lobby menu and randomly selects a random map - Voting is still enabled in the truck", (AcceptableValueBase)null, Array.Empty<object>())); NoRepeatedMaps = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "No Repeated Maps", false, new ConfigDescription("When true - disallows votes for the most recently played map - You won't play the same map twice in a row", (AcceptableValueBase)null, Array.Empty<object>())); CompatibilityPatches.RunPatches(Chainloader.PluginInfos.Select((KeyValuePair<string, PluginInfo> x) => x.Key).ToList()); Initialize(); Logger.LogDebug((object)"Loaded CustomLevelNames V1.0.6!"); } internal void Patch() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0027: Expected O, but got Unknown try { if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } catch (Exception ex) { Logger.LogError((object)ex); } } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static void Initialize() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown OnVoteEvent = new NetworkedEvent("OnVoteEvent", (Action<EventData>)HandleOnVoteEvent); OnVoteEndedEvent = new NetworkedEvent("OnVoteEndedEvent", (Action<EventData>)HandleOnVoteEndEvent); OnSyncVotes = new NetworkedEvent("OnSyncVotes", (Action<EventData>)HandleOnSyncVotes); OnSyncLastMapPlayed = new NetworkedEvent("OnSyncLastMapPlayed", (Action<EventData>)HandleOnSyncLastMapPlayed); OnStartCountdown = new NetworkedEvent("OnStartCountdown", (Action<EventData>)HandleOnStartCountdown); if (HideInMenu.Value) { return; } object obj = <>c.<>9__43_0; if (obj == null) { BuilderDelegate val = delegate(Transform parent) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) MenuAPI.CreateREPOButton("Map Vote", (Action)delegate { CreateVotePopup(isInMenu: true); }, parent, new Vector2(175.2f, 62.8f)); }; <>c.<>9__43_0 = val; obj = (object)val; } MenuAPI.AddElementToLobbyMenu((BuilderDelegate)obj); } public static bool HasBeenLastPlayed(string? level) { if (level == null || !NoRepeatedMaps.Value) { return false; } return LastMapPlayed == level && LastMapPlayed != WonMap; } public static void Reset() { CurrentVotes.Values.Clear(); VoteOptionButtons.Clear(); OwnVoteLevel = null; UpdateButtonLabels(); } private static void HandleOnSyncLastMapPlayed(EventData data) { string lastMapPlayed = (string)data.CustomData; LastMapPlayed = lastMapPlayed; WonMap = null; } private static void HandleOnStartCountdown(EventData data) { if (!SemiFunc.IsMasterClient()) { float votingTimeLeft = (float)data.CustomData; VotingTimeLeft = votingTimeLeft; ((MonoBehaviour)Instance).StartCoroutine(StartCountdown()); } } private static void HandleOnSyncVotes(EventData data) { if (SemiFunc.IsMasterClient()) { UpdateButtonLabels(); return; } Dictionary<int, string> dictionary = (Dictionary<int, string>)data.CustomData; if (dictionary != null) { Reset(); WonMap = null; LinqExtensions.ForEach<KeyValuePair<int, string>>((IEnumerable<KeyValuePair<int, string>>)dictionary, (Action<KeyValuePair<int, string>>)delegate(KeyValuePair<int, string> x) { CurrentVotes[x.Key] = x.Value; }); UpdateButtonLabels(); } } private static void HandleOnVoteEvent(EventData data) { string value = (string)data.CustomData; CurrentVotes[data.sender] = value; } private static void HandleOnVoteEndEvent(EventData data) { string winningMap = (string)data.CustomData; ((MonoBehaviour)Instance).StartCoroutine(OnVotingDone(winningMap)); } public static List<VoteOptionButton> GetSortedVoteOptions() { return (from b in VoteOptionButtons select new { Item = b, Count = b.GetVotes(CurrentVotes.Values) } into b orderby b.Count descending select b.Item).ToList(); } public static void CreateNextMapLabel(string mapName) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) REPOLabel val = MenuAPI.CreateREPOLabel((string)null, GameObject.Find("Game Hud").transform, new Vector2(-100f, 110f)); ((TMP_Text)val.labelTMP).horizontalAlignment = (HorizontalAlignmentOptions)2; if (storedLevelNames.ContainsKey(((Object)RunManager.instance.levelCurrent).name)) { ((TMP_Text)val.labelTMP).text = "Next Map: <color=" + ConfigManager.GetColor(mapName) + "><size=32>" + storedLevelNames[mapName] + "</size></color>"; } } [IteratorStateMachine(typeof(<WaitForVote>d__53))] public static IEnumerator WaitForVote() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForVote>d__53(0); } [IteratorStateMachine(typeof(<StartCountdown>d__54))] public static IEnumerator StartCountdown() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <StartCountdown>d__54(0); } public static void CreateVotePopup(bool isInMenu = false) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown MenuAPI.CloseAllPagesAddedOnTop(); VoteOptionButtons.Clear(); if ((Object)(object)VotePopup != (Object)null) { VotePopup.ClosePage(true); VotePopup = null; } if (((Object)RunManager.instance.levelCurrent).name == "Level - Lobby") { GameDirector.instance.DisableInput = true; } VotePopup = MenuAPI.CreateREPOPopupPage("Next map", true, !isInMenu, 0f, (Vector2?)(isInMenu ? new Vector2(40f, 0f) : new Vector2(-100f, 0f))); RunManager val = Object.FindObjectOfType<RunManager>(); List<Level> levels = val.levels; REPOPopupPage? votePopup = VotePopup; object obj = <>c.<>9__55_0; if (obj == null) { ScrollViewBuilderDelegate val2 = delegate(Transform parent) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) REPOButton val6 = MenuAPI.CreateREPOButton((string)null, (Action)delegate { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!DisableInput) { OwnVoteLevel = "Random"; NetworkedEvent? onVoteEvent2 = OnVoteEvent; if (onVoteEvent2 != null) { onVoteEvent2.RaiseEvent((object)"Random", NetworkingEvents.RaiseAll, SendOptions.SendReliable); } } }, parent, default(Vector2)); HorizontalLayoutGroup val7 = ComponentHolderProtocol.AddComponent<HorizontalLayoutGroup>((Object)(object)val6); ((HorizontalOrVerticalLayoutGroup)val7).spacing = 235f; GameObject val8 = Object.Instantiate<GameObject>(((Component)val6.labelTMP).gameObject, ((Component)val6).transform); TextMeshProUGUI component2 = val8.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component2).horizontalAlignment = (HorizontalAlignmentOptions)4; VoteOptionButtons.Add(new VoteOptionButton("Random", 0, val6, _isRandomButton: true)); return ((REPOElement)val6).rectTransform; }; <>c.<>9__55_0 = val2; obj = (object)val2; } votePopup.AddElementToScrollView((ScrollViewBuilderDelegate)obj, 0f, 0f); foreach (var item3 in levels.Select((Level level, int index) => (level, index))) { Level item = item3.Item1; int item2 = item3.Item2; string name = ((Object)item).name; VotePopup.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform parent) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) REPOButton val3 = MenuAPI.CreateREPOButton((string)null, (Action)delegate { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!DisableInput) { OwnVoteLevel = name; NetworkedEvent? onVoteEvent = OnVoteEvent; if (onVoteEvent != null) { onVoteEvent.RaiseEvent((object)name, NetworkingEvents.RaiseAll, SendOptions.SendReliable); } } }, parent, default(Vector2)); if (HasBeenLastPlayed(name)) { ((Component)val3).gameObject.GetComponent<MenuButton>().disabled = true; } HorizontalLayoutGroup val4 = ComponentHolderProtocol.AddComponent<HorizontalLayoutGroup>((Object)(object)val3); ((HorizontalOrVerticalLayoutGroup)val4).spacing = 235f; GameObject val5 = Object.Instantiate<GameObject>(((Component)val3.labelTMP).gameObject, ((Component)val3).transform); TextMeshProUGUI component = val5.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).horizontalAlignment = (HorizontalAlignmentOptions)4; VoteOptionButtons.Add(new VoteOptionButton(name, 0, val3)); return ((REPOElement)val3).rectTransform; }, 0f, 0f); } VotePopup.AddElement((BuilderDelegate)delegate(Transform parent) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) VotingTimeLabel = MenuAPI.CreateREPOLabel((string)null, parent, new Vector2(isInMenu ? 394f : 254f, 30f)); }); VotePopup.OpenPage(true); UpdateButtonLabels(); ((Component)VotePopup).GetComponent<MenuPage>().PageStateSet((PageState)1); } public static void UpdateButtonLabels() { VoteOptionButtons.ForEach(delegate(VoteOptionButton b) { b.UpdateLabel(_highlight: false, HasBeenLastPlayed(b.Level)); }); } public static List<VoteOptionButton> GetEligibleOptions() { if (CurrentVotes.Values.Count == 0) { return VoteOptionButtons.FindAll((VoteOptionButton x) => !x.IsRandomButton); } List<VoteOptionButton> list = new List<VoteOptionButton>(); List<VoteOptionButton> sortedVoteOptions = GetSortedVoteOptions(); List<VoteOptionButton> list2 = (from x in sortedVoteOptions group x by x.GetVotes(CurrentVotes.Values) into x orderby x.Key descending select x).FirstOrDefault().ToList(); list = ((list2.Find((VoteOptionButton x) => x.Level == "Random") == null) ? (list2 ?? list) : VoteOptionButtons); if (NoRepeatedMaps.Value) { list = list.FindAll((VoteOptionButton x) => !HasBeenLastPlayed(x.Level)); } if (list.FindAll((VoteOptionButton x) => !x.IsRandomButton).Count <= 0) { list = VoteOptionButtons; } list.RemoveAll((VoteOptionButton x) => x.IsRandomButton); return list; } public static string GetWinningMap() { List<VoteOptionButton> eligibleOptions = GetEligibleOptions(); int index = Random.RandomRangeInt(0, eligibleOptions.Count); return eligibleOptions[index].Level; } [IteratorStateMachine(typeof(<OnVotingDone>d__59))] public static IEnumerator OnVotingDone(string winningMap) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <OnVotingDone>d__59(0) { winningMap = winningMap }; } [IteratorStateMachine(typeof(<BlinkButton>d__60))] public static IEnumerator BlinkButton(VoteOptionButton voteOption) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <BlinkButton>d__60(0) { voteOption = voteOption }; } [IteratorStateMachine(typeof(<SpinWheelOptions>d__61))] public static IEnumerator SpinWheelOptions(List<VoteOptionButton> eligibleOptions, int winningIndex) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <SpinWheelOptions>d__61(0) { eligibleOptions = eligibleOptions, winningIndex = winningIndex }; } } [HarmonyPatch(typeof(MenuManager))] internal class MenuManagerPatch { [HarmonyPatch("PageOpen")] [HarmonyPostfix] private static void PageOpenPostfix(MenuPageIndex menuPageIndex) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)menuPageIndex == 8) { if (SemiFunc.IsMasterClientOrSingleplayer()) { Main.Reset(); Main.WonMap = null; } if (!Main.HideInMenu.Value) { Main.CreateVotePopup(isInMenu: true); } bool flag = false; } } } [HarmonyPatch(typeof(MenuPageLobby))] internal class SteamManagerPatch { [HarmonyPatch("PlayerAdd")] [HarmonyPostfix] public static void PostfixJoiningPlayer() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClient()) { NetworkedEvent? onSyncVotes = Main.OnSyncVotes; if (onSyncVotes != null) { onSyncVotes.RaiseEvent((object)Main.CurrentVotes.Values, NetworkingEvents.RaiseAll, SendOptions.SendReliable); } NetworkedEvent? onSyncLastMapPlayed = Main.OnSyncLastMapPlayed; if (onSyncLastMapPlayed != null) { onSyncLastMapPlayed.RaiseEvent((object)Main.LastMapPlayed, NetworkingEvents.RaiseOthers, SendOptions.SendReliable); } } } } internal sealed class Utilities { public static string ColorString(string text, string colorHex) { return "<color=#" + colorHex + ">" + text + "</color>"; } public static string ColorString(string text, Color color) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) return "<color=#" + XColor.ToHexString(color) + ">" + text + "</color>"; } public static string RemoveLevelPrefix(string text) { return text.Replace("Level - ", ""); } } internal sealed class VoteOptionButton { public string Level { get; set; } public REPOButton Button { get; set; } public bool IsRandomButton { get; set; } public VoteOptionButton(string _level, int _votes, REPOButton _button, bool _isRandomButton = false) { Level = _level; Button = _button; IsRandomButton = _isRandomButton; } public int GetVotes(Dictionary<int, string> votes) { int num = 0; foreach (KeyValuePair<int, string> vote in votes) { if (vote.Value == Level) { num++; } } return num; } public void UpdateLabel(bool _highlight = false, bool _disabled = false) { //IL_0060: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) Dictionary<int, string> values = Main.CurrentVotes.Values; bool flag = Main.OwnVoteLevel == Level; int num = Math.Max(Math.Min(GameDirector.instance.PlayerList.Count, 12), 4); int votes = GetVotes(values); Color color = (_disabled ? Color.gray : (_highlight ? Color.green : (flag ? Color.yellow : Color.white))); StringBuilder stringBuilder = new StringBuilder(); if (_disabled) { stringBuilder.Append("<s>"); } stringBuilder.Append("<mspace=0.25em>[" + Utilities.ColorString((flag || _highlight) ? "X" : " ", color) + "]</mspace> "); if (!_disabled) { stringBuilder.Append("<color=" + ConfigManager.GetColor(Level) + ">"); } if (!Main.storedLevelNames.TryGetValue(Level, out string value)) { Main.Logger.LogWarning((object)("Missing storedLevelName for '" + Level + "'")); value = Level; } stringBuilder.Append(IsRandomButton ? "Random" : value); if (!_disabled) { stringBuilder.Append("</color>"); } if (_disabled) { stringBuilder.Append("</s>"); } Transform child = ((Component)Button).transform.GetChild(1); ((TMP_Text)((Component)child).GetComponent<TextMeshProUGUI>()).text = Utilities.ColorString(new string('I', votes), Color.green) + Utilities.ColorString(new string('I', num - votes), Color.white); ((TMP_Text)Button.labelTMP).text = stringBuilder.ToString() ?? ""; } } public class VotesDictionary { public readonly Dictionary<int, string> Values = new Dictionary<int, string>(); public string this[int key] { get { return Values[key]; } set { Values[key] = value; Main.UpdateButtonLabels(); } } } }