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 DantorsMentalHospital v1.0.0
BepInEx/plugins/DantorsMentalHospitalDunGen/MentalHospital.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using DunGen.Graph; using HarmonyLib; using LethalLevelLoader; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MentalHospital")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MentalHospital")] [assembly: AssemblyTitle("MentalHospital")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MentalHospital { [BepInPlugin("MentalHospital", "MentalHospital", "1.0.0")] public class MentalHospitalDunGen : BaseUnityPlugin { private const string modGUID = "DantorMentalHospital"; private const string modName = "Dantor's Mental Hospital"; private const string modVersion = "1.0.0"; private static MentalHospitalDunGen Instance; private readonly Harmony harmony = new Harmony("DantorsMentalHospital"); private ConfigEntry<int> configSCPRarity; private ConfigEntry<string> configMoons; private ConfigEntry<bool> configGuaranteedSCP; private ConfigEntry<int> configLengthOverride; internal ManualLogSource mls; public static AssetBundle Assets; private void Awake() { //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Expected O, but got Unknown //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Expected O, but got Unknown //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Expected O, but got Unknown //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Expected O, but got Unknown //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Expected O, but got Unknown //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Expected O, but got Unknown //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Expected O, but got Unknown //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Expected O, but got Unknown if ((Object)(object)Instance == (Object)null) { Instance = this; } Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } mls = Logger.CreateLogSource("MentalHospital"); string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Assets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "hospitalbundle")); if ((Object)(object)Assets == (Object)null) { mls.LogError((object)"Failed to load DantorsMentalHospital assets."); return; } DungeonFlow val = Assets.LoadAsset<DungeonFlow>("Assets/Abandoned_Psychiatric_Hospitals/DunGen Data/HospitalFlow.asset"); if ((Object)(object)val == (Object)null) { mls.LogError((object)"Failed to load DantorsMentalHospital Dungeon Flow."); return; } configSCPRarity = ((BaseUnityPlugin)this).Config.Bind<int>("General", "HospitalRarity", 100, new ConfigDescription("How rare it is for the mental hospital to be chosen. Higher values increases the chance of spawning the mental hospital. Vanillas' main dungeons use a value of 300. Google Weighted Random if you don't know how it works, as that's how Lethal Company rarities function.", (AcceptableValueBase)null, Array.Empty<object>())); configMoons = ((BaseUnityPlugin)this).Config.Bind<string>("General", "HospitalMoonsList", "vanilla", new ConfigDescription("The moon(s) that the hospital can spawn on, in the form of a comma separated list of selectable level names and optionally a weight value by using an '@' and weight value after it (e.g. \"Titan@300,Dine,Rend@10,Secret Labs@9999\")\nThe name matching is lenient and should pick it up if you use the terminal name or internal mod name. If no rarity is specified, the FoundationRarity parameter is used.\nThe following strings: \"all\", \"vanilla\", \"modded\", \"paid\", \"free\" are dynamic presets which add the dungeon to that specified group (string must only contain one of these, or a manual moon name list).\n", (AcceptableValueBase)null, Array.Empty<object>())); configGuaranteedSCP = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HospitalGuaranteed", false, new ConfigDescription("\nIt should work but if it doesn't use a weight of something like '99999'", (AcceptableValueBase)null, Array.Empty<object>())); configLengthOverride = ((BaseUnityPlugin)this).Config.Bind<int>("General", "FoundationLengthOverride", -1, new ConfigDescription(string.Format("If not -1, overrides the hospital length to whatever you'd like. Adjusts how long/large the dungeon generates.\nBe *EXTREMELY* careful not to set this too high (anything too big on a moon with a high dungeon size multipier can cause catastrophic problems, like crashing your computer or worse)\nFor reference, the default value for the current version [{0}] is {1}. If it's too big, make this lower e.g. 6, if it's too small use something like 10 (or higher, but don't go too crazy with it).", "1.0.0", val.Length.Min), (AcceptableValueBase)null, Array.Empty<object>())); if (configLengthOverride.Value != -1) { mls.LogInfo((object)$"Hospital length override has been set to {configLengthOverride.Value}. Be careful with this value."); val.Length.Min = configLengthOverride.Value; val.Length.Max = configLengthOverride.Value; } ExtendedDungeonFlow val2 = ScriptableObject.CreateInstance<ExtendedDungeonFlow>(); val2.contentSourceName = "Dantors Mental Hospital"; val2.dungeonFlow = val; val2.dungeonDefaultRarity = 0; int num = (configGuaranteedSCP.Value ? 99999 : configSCPRarity.Value); switch (configMoons.Value.ToLower()) { case "all": val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Lethal Company", num)); val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Custom", num)); mls.LogInfo((object)"Registered DantorsMentalHospital dungeon for all moons."); break; case "vanilla": val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Lethal Company", num)); mls.LogInfo((object)"Registered DantorsMentalHospital dungeon for all vanilla moons."); break; case "modded": val2.manualContentSourceNameReferenceList.Add(new StringWithRarity("Custom", num)); mls.LogInfo((object)"Registered DantorsMentalHospital dungeon for all modded moons."); break; case "paid": val2.dynamicRoutePricesList.Add(new Vector2WithRarity(new Vector2(1f, 9999f), num)); mls.LogInfo((object)"Registered DantorsMentalHospital dungeon for all paid moons."); break; case "free": val2.dynamicRoutePricesList.Add(new Vector2WithRarity(new Vector2(0f, 0f), num)); mls.LogInfo((object)"Registered DantorsMentalHospital dungeon for all free moons."); break; default: { mls.LogInfo((object)"Registering DantorsMentalHospital dungeon for predefined moon list."); string[] array3 = configMoons.Value.Split(',', StringSplitOptions.RemoveEmptyEntries); List<StringWithRarity> list = new List<StringWithRarity>(); for (int k = 0; k < array3.Length; k++) { string[] array4 = array3[k].Split('@', StringSplitOptions.RemoveEmptyEntries); int num2 = array4.Length; int result; if (num2 > 2) { mls.LogError((object)("Invalid setup for moon rarity config: " + array3[k] + ". Skipping.")); } else if (num2 == 1) { mls.LogInfo((object)$"Registering DantorsMentalHospital dungeon for moon {array3[k]} at default rarity {num}"); list.Add(new StringWithRarity(array3[k], num)); } else if (!int.TryParse(array4[1], out result)) { mls.LogError((object)("Failed to parse rarity value for moon " + array4[0] + ": " + array4[1] + ". Skipping.")); } else { mls.LogInfo((object)$"Registering DantorsMentalHospital dungeon for moon {array3[k]} at default rarity {num}"); list.Add(new StringWithRarity(array4[0], result)); } } val2.manualPlanetNameReferenceList = list; break; } } val2.dungeonSizeMin = 0.6f; val2.dungeonSizeMax = 0.8f; val2.dungeonSizeLerpPercentage = 0f; AssetBundleLoader.RegisterExtendedDungeonFlow(val2); harmony.PatchAll(typeof(MentalHospitalDunGen)); mls.LogInfo((object)"DantorsMentalHospital DunGen for Lethal Company [Version 1.0.0] successfully loaded."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MentalHospital is loaded!"); } } public static class PluginInfo { public const string PLUGIN_GUID = "MentalHospital"; public const string PLUGIN_NAME = "MentalHospital"; public const string PLUGIN_VERSION = "1.0.0"; } }