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 CustomLevelNames v1.0.6
CustomLevelNames.dll
Decompiled 9 months agousing 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.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("CustomLevelNames")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CustomLevelNames")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("0e110f62-2623-46f1-8b71-a3d267ec3f53")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace CustomLevelNames { internal class ConfigManager { public static ConfigEntry<bool> shuffleEachLevel; public static ConfigEntry<string> levelNames; public static ConfigEntry<string> shopName; public static ConfigEntry<string> arenaName; public static void Init() { shuffleEachLevel = ((BaseUnityPlugin)CustomLevelNamesMod.instance).Config.Bind<bool>("General Settings", "shuffleEachLevel", false, "Shuffles custom names after each individual level instead of each full game."); levelNames = ((BaseUnityPlugin)CustomLevelNamesMod.instance).Config.Bind<string>("Name Settings", "levelNames", "", "The set of custom names for extraction levels. Documentation for this setting can be found in the README."); shopName = ((BaseUnityPlugin)CustomLevelNamesMod.instance).Config.Bind<string>("Name Settings", "shopName", "", "The set of custom names for the shop level. Documentation for this setting can be found in the README."); arenaName = ((BaseUnityPlugin)CustomLevelNamesMod.instance).Config.Bind<string>("Name Settings", "arenaName", "", "The set of custom names for the arena level. Documentation for this setting can be found in the README."); } public static List<string> GetLevelNames(string level) { List<string> list = new List<string>(); if (level == "Arena" && arenaName.Value != "") { list = arenaName.Value.ToUpper().Split(new char[1] { ';' }).ToList(); } else if (level == "Shop" && shopName.Value != "") { list = shopName.Value.ToUpper().Split(new char[1] { ';' }).ToList(); } else { string[] array = (from x in levelNames.Value.Split(new char[1] { ',' }) where x.ToUpper().StartsWith(level.ToUpper() + ":") select x).ToArray(); for (int i = 0; i < array.Length; i++) { array[i] = array[i].ToUpper().Replace(level.ToUpper() + ":", ""); string[] array2 = array[i].Split(new char[1] { ';' }); for (int j = 0; j < array2.Length; j++) { list.Add(array2[j]); } } } return list; } } [BepInPlugin("eXish.CustomLevelNames", "CustomLevelNames", "1.0.6")] public class CustomLevelNamesMod : BaseUnityPlugin { private const string mGUID = "eXish.CustomLevelNames"; private const string mName = "CustomLevelNames"; private const string mVersion = "1.0.6"; private readonly Harmony harmony = new Harmony("eXish.CustomLevelNames"); internal static CustomLevelNamesMod instance; internal static ManualLogSource log; internal static Dictionary<string, string> storedLevelNames = new Dictionary<string, string>(); internal static bool doInitialSetup = true; internal static bool readyToShuffle = true; private void Awake() { if ((Object)(object)instance == (Object)null) { instance = this; } log = ((BaseUnityPlugin)this).Logger; ConfigManager.Init(); harmony.PatchAll(); log.LogInfo((object)"CustomLevelNames-1.0.6 loaded!"); } } } namespace CustomLevelNames.Patches { [HarmonyPatch(typeof(LoadingUI))] internal class LoadingUIPatch { [HarmonyPatch("LevelAnimationStart")] [HarmonyPostfix] private static void LevelAnimationStartPatch(LoadingUI __instance) { if ((SemiFunc.RunIsLevel() || SemiFunc.RunIsArena() || SemiFunc.RunIsShop()) && CustomLevelNamesMod.readyToShuffle) { bool flag = false; CustomLevelNamesMod.log.LogInfo((object)"Shuffling all level names..."); List<string> levelNames = ConfigManager.GetLevelNames("Arena"); List<string> levelNames2 = ConfigManager.GetLevelNames("Shop"); if (levelNames.Count > 0) { string text = CustomLevelNamesMod.storedLevelNames["Disposal Arena"]; CustomLevelNamesMod.storedLevelNames["Disposal Arena"] = levelNames[Random.Range(0, levelNames.Count)]; if (text != CustomLevelNamesMod.storedLevelNames["Disposal Arena"]) { flag = true; CustomLevelNamesMod.log.LogInfo((object)(text + " is now known as " + CustomLevelNamesMod.storedLevelNames["Disposal Arena"] + ".")); } } if (levelNames2.Count > 0) { string text2 = CustomLevelNamesMod.storedLevelNames["Service Station"]; CustomLevelNamesMod.storedLevelNames["Service Station"] = levelNames2[Random.Range(0, levelNames2.Count)]; if (text2 != CustomLevelNamesMod.storedLevelNames["Service Station"]) { flag = true; CustomLevelNamesMod.log.LogInfo((object)(text2 + " is now known as " + CustomLevelNamesMod.storedLevelNames["Service Station"] + ".")); } } for (int i = 0; i < RunManager.instance.levels.Count; i++) { List<string> levelNames3 = ConfigManager.GetLevelNames(RunManager.instance.levels[i].ResourcePath); if (levelNames3.Count > 0) { string text3 = CustomLevelNamesMod.storedLevelNames[RunManager.instance.levels[i].NarrativeName]; CustomLevelNamesMod.storedLevelNames[RunManager.instance.levels[i].NarrativeName] = levelNames3[Random.Range(0, levelNames3.Count)]; if (text3 != CustomLevelNamesMod.storedLevelNames[RunManager.instance.levels[i].NarrativeName]) { flag = true; CustomLevelNamesMod.log.LogInfo((object)(text3 + " is now known as " + CustomLevelNamesMod.storedLevelNames[RunManager.instance.levels[i].NarrativeName] + ".")); } } } if (!flag) { CustomLevelNamesMod.log.LogInfo((object)"No level names were changed."); } if (!ConfigManager.shuffleEachLevel.Value) { CustomLevelNamesMod.readyToShuffle = false; } } if (CustomLevelNamesMod.storedLevelNames.ContainsKey(RunManager.instance.levelCurrent.NarrativeName)) { ((TMP_Text)__instance.levelNameText).text = CustomLevelNamesMod.storedLevelNames[RunManager.instance.levelCurrent.NarrativeName]; } if (SemiFunc.RunIsArena()) { CustomLevelNamesMod.readyToShuffle = true; } } } [HarmonyPatch(typeof(LevelGenerator))] internal class LevelGeneratorPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakePatch() { if (CustomLevelNamesMod.doInitialSetup && (Object)(object)RunManager.instance != (Object)null) { CustomLevelNamesMod.doInitialSetup = false; string[] array = new string[RunManager.instance.levels.Count]; for (int i = 0; i < array.Length; i++) { array[i] = RunManager.instance.levels[i].NarrativeName + " (" + RunManager.instance.levels[i].ResourcePath + ")"; CustomLevelNamesMod.storedLevelNames.Add(RunManager.instance.levels[i].NarrativeName, RunManager.instance.levels[i].NarrativeName.ToUpper()); } CustomLevelNamesMod.storedLevelNames.Add("Disposal Arena", "DISPOSAL ARENA"); CustomLevelNamesMod.storedLevelNames.Add("Service Station", "SERVICE STATION"); CustomLevelNamesMod.log.LogInfo((object)string.Format("Found {0} extraction levels: {1}", array.Length, GeneralExtensions.Join<string>((IEnumerable<string>)array, (Func<string, string>)null, ", "))); } } } }