using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("OddsAndEnds")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OddsAndEnds")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("c6ff218e-780c-48ad-be27-6f6a178b97dd")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace Severon.OddsAndEnds; [HarmonyPatch(typeof(UI_GamemodeSetting), "ToggleSetting")] public static class UI_GamemodeSetting_ToggleSetting_Patch { private static void Postfix() { EndlessConfiguration.UpdateRegions(); } } [HarmonyPatch(typeof(UI_GamemodeScreen_Panel), "LoadGamemode")] public static class UI_GamemodeScreen_Panel_LoadGamemode_Patch { private static void Prefix(UI_GamemodeScreen_Panel __instance) { if ((Object)(object)__instance.GetGamemode() == (Object)(object)EndlessConfiguration.EndlessMode) { EndlessConfiguration.UpdateRegions(); } } } [HarmonyPatch(typeof(UI_GamemodeScreen_Panel), "Initialize")] public static class UI_GamemodeScreen_Panel_ScrollSettings_Patch { private static readonly string Marker = "Custom_Settings_Scroll"; private static void Postfix(UI_GamemodeScreen_Panel __instance) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0093: 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) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0167: 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_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Expected O, but got Unknown Transform settingRoot = __instance.settingRoot; if (!((Object)(object)settingRoot == (Object)null) && !((Object)(object)settingRoot.Find(Marker) != (Object)null)) { RectTransform component = ((Component)settingRoot).GetComponent(); GameObject val = new GameObject(Marker, new Type[4] { typeof(RectTransform), typeof(Image), typeof(Mask), typeof(ScrollRect) }); RectTransform component2 = val.GetComponent(); ((Transform)component2).SetParent(settingRoot.parent, false); component2.anchorMin = component.anchorMin; component2.anchorMax = component.anchorMax; component2.offsetMin = component.offsetMin; component2.offsetMax = component.offsetMax; component2.pivot = component.pivot; Image component3 = val.GetComponent(); ((Behaviour)component3).enabled = false; Mask component4 = val.GetComponent(); component4.showMaskGraphic = false; settingRoot.SetParent(val.transform, false); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0.5f, 1f); component.offsetMin = new Vector2(0f, component.offsetMin.y); component.offsetMax = new Vector2(0f, component.offsetMax.y); VerticalLayoutGroup val2 = ((Component)settingRoot).GetComponent(); if ((Object)(object)val2 == (Object)null) { val2 = ((Component)settingRoot).gameObject.AddComponent(); } ((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)val2).spacing = 0f; ((LayoutGroup)val2).padding = new RectOffset(8, 8, 0, 0); ContentSizeFitter val3 = ((Component)settingRoot).GetComponent(); if ((Object)(object)val3 == (Object)null) { val3 = ((Component)settingRoot).gameObject.AddComponent(); } val3.verticalFit = (FitMode)2; val3.horizontalFit = (FitMode)0; ScrollRect component5 = val.GetComponent(); component5.content = component; component5.horizontal = false; component5.vertical = true; component5.movementType = (MovementType)2; LayoutRebuilder.ForceRebuildLayoutImmediate(component); } } } [HarmonyPatch(typeof(UI_GamemodeScreen_Panel), "LoadGamemodeSave")] public static class UI_GamemodeScreen_Panel_LoadGamemodeSave_Patch { private static void Prefix(UI_GamemodeScreen_Panel __instance) { if ((Object)(object)__instance.GetGamemode() == (Object)(object)EndlessConfiguration.EndlessMode) { EndlessConfiguration.UpdateRegions(); } } } public static class EndlessConfiguration { [HarmonyPatch(typeof(M_Level), "OnLevelActivate")] public static class M_Level_OnLevelActivate_Patch { [HarmonyPrefix] public static void Prefix(M_Level __instance) { if (BEGONE_FOUL_SPIRIT) { DestroyMassInstance(); BEGONE_FOUL_SPIRIT = false; } } } [HarmonyPatch(typeof(M_Level), "OnLevelActivate")] public static class M_Level_OnLevelActivate_Items_Patch { [HarmonyPrefix] public static void Prefix(M_Level __instance) { if (giveStartingItems) { GiveStartingItems(); GiveStartingPerks(); giveStartingItems = false; } } } [HarmonyPatch(typeof(M_Region), "GetLevels")] internal static class TransitionRegionPatch { private static bool Prefix(M_Region __instance, M_Region lastRegion, M_Subregion lastSubregion, ref List __result) { if (!((Object)__instance).name.StartsWith("CustomTransition_")) { return true; } __result = new List(); if (__instance.subregionGroups == null || __instance.subregionGroups.Count == 0) { return false; } SubregionGroup val = __instance.subregionGroups[0]; if (val.subregions == null || val.subregions.Count == 0) { return false; } M_Subregion val2 = val.subregions[0]; if (val2.levelGroups == null || val2.levelGroups.Count == 0) { return false; } if (val2.levelGroups[0].levelReferences == null || val2.levelGroups[0].levelReferences.Count == 0) { return false; } LevelAssetHolder val3 = val2.levelGroups[0].levelReferences[0]; val3.region = __instance; val3.subregion = val2; __result.Add(val3); return false; } } public static M_Gamemode EndlessMode; private static bool added; private static Dictionary regionCache = new Dictionary(); public static bool BEGONE_FOUL_SPIRIT; public static bool giveStartingItems; private static readonly Dictionary SubregionKeywords = new Dictionary { { "Storage", "Deep Storage" }, { "Ventilation", "Air Exchange" }, { "Chambers", "Shattered Chambers" }, { "Drainage", "Drainage System" }, { "Waste", "Waste Heap" }, { "Pipe", "Pipe Organ" }, { "Shaft", "Service Shaft" }, { "LostPier", "Lost Pier" }, { "DeltaLabs", "Delta Labs" }, { "Scaffolds", "Transit Scaffolds" }, { "Handle", "Deadman's Handle" }, { "Gardens", "Hanging Gardens" }, { "HotZone", "Hot Zone" }, { "Infested", "Infested Labs" }, { "Trough", "Feeding Trough" } }; private static readonly Dictionary StartingItemTitles = new Dictionary { { "item_timepiece", "Timepiece" }, { "item_translocator", "Translocator" }, { "item_evaglove", "EVA Glove" }, { "item_rapier", "Rapier" }, { "item_rebar_return", "Rho Spear" }, { "item_remote", "Remote" }, { "item_handgun_kit", "Handgun" }, { "item_flaregun_kit", "Flaregun" }, { "item_flashlight", "Flashlight" } }; private static readonly Dictionary StartingPerkTitles = new Dictionary { { "Perk_U_T1_EmployeeMotivator", "Employee Motivator" }, { "Perk_U_T1_EmployeeRetention", "Employee Retention" }, { "Perk_U_T1_OnlyClimbing", "Only Climbing" }, { "Perk_U_T1_SlowAndSteady", "Slow And Steady" }, { "Perk_U_T2_PitonEnthusiast", "Piton Enthusiast" }, { "Perk_U_T2_PulseBladder", "Pulse Bladder" }, { "Perk_U_T3_ConditionedPolyphagia", "Conditioned Polyphagia" }, { "Perk_U_T4_FunniestTimeline", "Funniest Timeline" }, { "Perk_U_T3_PeripheralBinding", "Peripheral Binding" } }; private static void DestroyMassInstance() { if ((Object)(object)DEN_DeathFloor.instance != (Object)null) { Object.Destroy((Object)(object)((Component)DEN_DeathFloor.instance).gameObject); DEN_DeathFloor.instance = null; } } [HarmonyPatch(typeof(CL_Initializer), "Awake")] [HarmonyPrefix] public static void InitializerAwake(ref CL_Initializer __instance) { //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Expected O, but got Unknown //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_0531: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Expected O, but got Unknown //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05c4: Unknown result type (might be due to invalid IL or missing references) //IL_05d1: Unknown result type (might be due to invalid IL or missing references) //IL_05ed: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_05f8: Unknown result type (might be due to invalid IL or missing references) //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Expected O, but got Unknown //IL_0665: Unknown result type (might be due to invalid IL or missing references) //IL_066a: Unknown result type (might be due to invalid IL or missing references) //IL_0686: Unknown result type (might be due to invalid IL or missing references) //IL_0691: Unknown result type (might be due to invalid IL or missing references) //IL_06ad: Unknown result type (might be due to invalid IL or missing references) //IL_06ae: Unknown result type (might be due to invalid IL or missing references) //IL_06b3: Unknown result type (might be due to invalid IL or missing references) //IL_06b8: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_06cf: Unknown result type (might be due to invalid IL or missing references) //IL_06e0: Expected O, but got Unknown if (added) { return; } M_Gamemode val = __instance.baseDatabase.gamemodeAssets.First((M_Gamemode x) => ((Object)x).name == "GM_Endless_Silos"); foreach (M_Gamemode gamemodeAsset in __instance.baseDatabase.gamemodeAssets) { if (!((Object)(object)gamemodeAsset != (Object)null) || gamemodeAsset.regions == null) { continue; } foreach (M_Region region in gamemodeAsset.regions) { if ((Object)(object)region != (Object)null && !regionCache.ContainsKey(((Object)region).name)) { regionCache[((Object)region).name] = (Object)(object)region; } } } EndlessMode = ScriptableObject.CreateInstance(); EndlessMode.gamemodeName = "Custom Endless"; ((Object)EndlessMode).name = "GM_Custom_Endless"; EndlessMode.introText = "ASCEND"; EndlessMode.newGameText = "Start"; EndlessMode.modeDescription = "Customize your Endless"; EndlessMode.allowAchievements = true; EndlessMode.allowCheatedScores = false; EndlessMode.allowCheats = true; EndlessMode.allowLeaderboardScoring = false; EndlessMode.steamLeaderboardName = ""; EndlessMode.allowHeightAchievements = true; EndlessMode.baseGamemode = true; EndlessMode.useGamemodeSettings = true; EndlessMode.isEndless = true; EndlessMode.hasPerks = val.hasPerks; EndlessMode.hasRevives = val.hasRevives; EndlessMode.modeType = val.modeType; EndlessMode.gamemodeScene = val.gamemodeScene; EndlessMode.capsuleName = ""; EndlessMode.capsuleArt = val.capsuleArt; EndlessMode.screenArt = val.screenArt; EndlessMode.roachEndSprite = val.roachEndSprite; EndlessMode.gamemodePanel = val.gamemodePanel; EndlessMode.roachBankID = val.roachBankID; EndlessMode.loseScreen = val.loseScreen; EndlessMode.winScreen = val.winScreen; EndlessMode.gamemodeColor = val.gamemodeColor; EndlessMode.modeTags = val.modeTags; EndlessMode.unlockAchievement = val.unlockAchievement; EndlessMode.gamemodeModule = val.gamemodeModule; EndlessMode.levelsToGenerate = val.levelsToGenerate; EndlessMode.availableTrinkets = val.availableTrinkets; EndlessMode.playlistLevelAssets = val.playlistLevelAssets; EndlessMode.playlistLevels = val.playlistLevels; EndlessMode.gamemodeObjects = val.gamemodeObjects; EndlessMode.unlockHint = val.unlockHint; EndlessMode.startItems = val.startItems; EndlessMode.regions = val.regions.ToList(); EndlessMode.regions.Clear(); EndlessMode.gamemodeSettings = val.gamemodeSettings; GamemodeSetting val2 = val.gamemodeSettings.FirstOrDefault(); if ((Object)(object)val2 == (Object)null || (Object)(object)val2.unlock == (Object)null) { val2 = __instance.baseDatabase.gamemodeAssets.SelectMany((M_Gamemode x) => x.gamemodeSettings).First((GamemodeSetting x) => (Object)(object)x != (Object)null && (Object)(object)x.unlock != (Object)null); } string[] array = new string[5] { "Silos", "Pipeworks", "Habitation", "Abyss", "Nest" }; string[] array2 = array; foreach (string text in array2) { EndlessMode.gamemodeSettings.Add(new GamemodeSetting { id = text.ToLower() + "_enabled", title = text, description = "Enable " + text, color = Color.gray, exclusiveSettings = new List(), unlock = val2.unlock, gamemodeButtonAsset = val2.gamemodeButtonAsset }); } foreach (KeyValuePair startingItemTitle in StartingItemTitles) { EndlessMode.gamemodeSettings.Add(new GamemodeSetting { id = startingItemTitle.Key + "_enabled", title = startingItemTitle.Value, description = "Start with " + startingItemTitle.Value + ".", color = Color.gray, exclusiveSettings = new List(), unlock = val2.unlock, gamemodeButtonAsset = val2.gamemodeButtonAsset }); } foreach (KeyValuePair startingPerkTitle in StartingPerkTitles) { EndlessMode.gamemodeSettings.Add(new GamemodeSetting { id = startingPerkTitle.Key.ToLower() + "_enabled", title = startingPerkTitle.Value, description = "Start with " + startingPerkTitle.Value + " perk.", color = Color.gray, exclusiveSettings = new List(), unlock = val2.unlock, gamemodeButtonAsset = val2.gamemodeButtonAsset }); } foreach (KeyValuePair subregionKeyword in SubregionKeywords) { EndlessMode.gamemodeSettings.Add(new GamemodeSetting { id = "subregion_" + subregionKeyword.Key + "_disabled", title = "Disable Subregion", description = "Exclude " + subregionKeyword.Value + ".", color = Color.gray, exclusiveSettings = new List(), unlock = val2.unlock, gamemodeButtonAsset = val2.gamemodeButtonAsset }); } __instance.baseDatabase.gamemodeAssets.Add(EndlessMode); added = true; } [HarmonyPatch(typeof(UI_PlayPane), "Start")] [HarmonyPrefix] public static void PlayPaneStart(ref UI_PlayPane __instance) { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown GameObject val = ((IEnumerable)Object.FindObjectsOfType(true)).FirstOrDefault((Func)((GameObject x) => (((Object)x).name == "Other Endless 02" || ((Object)x).name == "Other Endless 01") && ((Object)x.transform.parent.parent.parent).name == "Play Pane - Scroll View Tab - Endless Variant")); if (!((Object)(object)val != (Object)null)) { return; } GameObject val2 = Object.Instantiate(val); ((Object)val2).name = "Custom Endless Tab"; val2.transform.SetParent(val.transform.parent, false); Transform child = val2.transform.GetChild(0); for (int num = 0; num < val2.transform.childCount; num++) { if (num != 0) { Object.Destroy((Object)(object)((Component)val2.transform.GetChild(num)).gameObject); } } GameObject gameObject = ((Component)child).gameObject; ((Object)gameObject).name = "Mode Selection Button - Custom Endless"; ((UnityEventBase)gameObject.GetComponent