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 SmallModpackFix v1.1.5
BepInEx\plugins\SmallModpackFix\SmallModpackFix.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LethalLevelLoader; using Microsoft.CodeAnalysis; using MrovLib.Events; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.UI; using WeatherRegistry; using WeatherRegistry.Definitions; using WeatherRegistry.Enums; [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("SuperfaPackRules")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SuperfaPackRules")] [assembly: AssemblyTitle("SuperfaPackRules")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 SuperfaPackRules { internal static class BugFixes { public static void Install(Harmony harmony) { ILogHandler logHandler = Debug.unityLogger.logHandler; if (!(logHandler is NavMeshLogHandler)) { Debug.unityLogger.logHandler = (ILogHandler)(object)new NavMeshLogHandler(logHandler); } Patch(harmony, "LethalCasino.Patches.MenuManagerPatch", "StartPatch", typeof(BugFixes), "SkipBrokenMenuNotice"); Patch(harmony, "LethalModDataLib.Features.ModDataAttributeCollector", "RegisterModDataAttributes", typeof(BugFixes), "RegisterModDataWithoutNullPlugins", Type.EmptyTypes); Patch(harmony, "SolosBodycams.Plugin", "Update", typeof(BugFixes), "BodycamFinalizer", null, finalizer: true); } private static void Patch(Harmony harmony, string typeName, string methodName, Type patchType, string patchName, Type[] parameters = null, bool finalizer = false) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown Type type = AccessTools.TypeByName(typeName); if (type == null) { return; } MethodInfo methodInfo = ((parameters == null) ? AccessTools.Method(type, methodName, (Type[])null, (Type[])null) : AccessTools.Method(type, methodName, parameters, (Type[])null)); if (!(methodInfo == null)) { HarmonyMethod val = new HarmonyMethod(patchType, patchName, (Type[])null); if (finalizer) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null); } else { harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } public static bool SkipBrokenMenuNotice() { return false; } public static bool RegisterModDataWithoutNullPlugins() { Type type = AccessTools.TypeByName("LethalModDataLib.Features.ModDataAttributeCollector"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "RegisterModDataAttributes", new Type[4] { typeof(string), typeof(Type), typeof(object), typeof(string) }, (Type[])null)); MethodInfo loadableTypes = AccessTools.Method("LethalModDataLib.Helpers.AssemblyExtensions:GetLoadableTypes", (Type[])null, (Type[])null); if (methodInfo == null) { return true; } foreach (PluginInfo value in Chainloader.PluginInfos.Values) { if ((Object)(object)((value != null) ? value.Instance : null) == (Object)null || value.Metadata == null) { continue; } Assembly assembly = ((object)value.Instance).GetType().Assembly; foreach (Type item in LoadTypes(loadableTypes, assembly)) { if (!(item == null)) { try { methodInfo.Invoke(null, new object[4] { value.Metadata.GUID, item, null, null }); } catch (TargetInvocationException) { } } } } return false; } private static IEnumerable<Type> LoadTypes(MethodInfo loadableTypes, Assembly assembly) { if (loadableTypes != null && loadableTypes.Invoke(null, new object[1] { assembly }) is IEnumerable<Type> result) { return result; } try { return assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { return ex.Types; } } public static Exception BodycamFinalizer(Exception __exception) { if (__exception is NullReferenceException) { return null; } return __exception; } } [HarmonyPatch(typeof(AssetBundleLoader), "NetworkRegisterDungeonContent")] internal static class SkipBrokenDungeonFlows { private static bool Prefix(ExtendedDungeonFlow extendedDungeonFlow) { if ((Object)(object)extendedDungeonFlow != (Object)null) { return (Object)(object)extendedDungeonFlow.DungeonFlow != (Object)null; } return false; } } [HarmonyPatch(typeof(NetworkPrefabs), "AddPrefabRegistration")] internal static class SkipDuplicateNetworkPrefabs { private static bool Prefix(NetworkPrefabs __instance, NetworkPrefab networkPrefab) { if (networkPrefab == null || __instance?.NetworkPrefabOverrideLinks == null) { return true; } return !__instance.NetworkPrefabOverrideLinks.ContainsKey(networkPrefab.SourcePrefabGlobalObjectIdHash); } } [HarmonyPatch(typeof(Animator), "SetBool", new Type[] { typeof(string), typeof(bool) })] internal static class IgnoreMissingAnimators { private static bool Prefix(Animator __instance) { return (Object)(object)__instance != (Object)null; } } [HarmonyPatch(typeof(CanvasUpdateRegistry), "InternalRegisterCanvasElementForGraphicRebuild")] internal static class SkipCaretRebuildDuringGraphicUpdate { private static readonly FieldInfo PerformingGraphicUpdate = AccessTools.Field(typeof(CanvasUpdateRegistry), "m_PerformingGraphicUpdate"); private static bool Prefix(CanvasUpdateRegistry __instance, ICanvasElement element) { if (PerformingGraphicUpdate == null || __instance == null || element == null) { return true; } if (!(bool)PerformingGraphicUpdate.GetValue(__instance)) { return true; } return ((object)element).GetType().Name != "TMP_SelectionCaret"; } } [HarmonyPatch] internal static class SkipUnreadableNavMeshSources { private static IEnumerable<MethodBase> TargetMethods() { foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(typeof(NavMeshBuilder))) { if (declaredMethod.Name == "UpdateNavMeshData" || declaredMethod.Name == "UpdateNavMeshDataAsync") { yield return declaredMethod; } } } private static void Prefix(List<NavMeshBuildSource> sources) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (sources == null) { return; } for (int num = sources.Count - 1; num >= 0; num--) { NavMeshBuildSource val = sources[num]; Object sourceObject = ((NavMeshBuildSource)(ref val)).sourceObject; Mesh val2 = (Mesh)(object)((sourceObject is Mesh) ? sourceObject : null); if ((Object)(object)val2 != (Object)null && !val2.isReadable) { sources.RemoveAt(num); } } } } internal class NavMeshLogHandler : ILogHandler { private readonly ILogHandler inner; public NavMeshLogHandler(ILogHandler inner) { this.inner = inner; } public void LogFormat(LogType logType, Object context, string format, params object[] args) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) if ((int)logType == 0 || (int)logType == 4) { string message = format; if (args != null && args.Length != 0 && format != null) { try { message = string.Format(format, args); } catch (FormatException) { } } if (NavMeshLogSuppress.ShouldSuppress(message)) { return; } } inner.LogFormat(logType, context, format, args); } public void LogException(Exception exception, Object context) { inner.LogException(exception, context); } } internal static class NavMeshLogSuppress { internal static bool ShouldSuppress(object message) { return (message?.ToString())?.StartsWith("RuntimeNavMeshBuilder:", StringComparison.Ordinal) ?? false; } } [HarmonyPatch(typeof(Debug), "LogError", new Type[] { typeof(object) })] internal static class SuppressUnreadableNavMeshSpamObject { private static bool Prefix(object message) { return !NavMeshLogSuppress.ShouldSuppress(message); } } [HarmonyPatch(typeof(Debug), "LogError", new Type[] { typeof(string) })] internal static class SuppressUnreadableNavMeshSpamString { private static bool Prefix(string message) { return !NavMeshLogSuppress.ShouldSuppress(message); } } [HarmonyPatch(typeof(Debug), "LogError", new Type[] { typeof(object), typeof(Object) })] internal static class SuppressUnreadableNavMeshSpamObjectContext { private static bool Prefix(object message) { return !NavMeshLogSuppress.ShouldSuppress(message); } } internal static class ConfigSync { private static readonly string[] Files = new string[3] { "LethalLevelLoader.cfg", "mrov.WeatherRegistry.cfg", "Index154.RouteRandomRedexed.cfg" }; public static void ApplyIfNewer() { string text = Path.Combine(Paths.BepInExRootPath, "config"); Directory.CreateDirectory(text); string path = Path.Combine(text, "rydr.SuperfaPackRules.configs"); if (File.Exists(path) && File.ReadAllText(path).Trim() == "1.1.5") { return; } Assembly assembly = typeof(ConfigSync).Assembly; string[] files = Files; foreach (string text2 in files) { string name = "SuperfaPackRules.pack_configs." + text2; using Stream stream = assembly.GetManifestResourceStream(name); if (stream == null) { ManualLogSource log = Rules.Log; if (log != null) { log.LogWarning((object)("Missing packed config " + text2)); } } else { using FileStream destination = File.Create(Path.Combine(text, text2)); stream.CopyTo(destination); } } File.WriteAllText(path, "1.1.5"); ManualLogSource log2 = Rules.Log; if (log2 != null) { log2.LogInfo((object)"Wrote pack configs for Lethal Level Loader, Weather Registry, and Route Random. Restart once if this is the first time these files were replaced."); } } } [BepInPlugin("rydr.SuperfaPackRules", "Small Modpack Fix", "1.1.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static Action <0>__ApplyContent; public static Event <1>__DisableFogAndDust; } public const string PluginGuid = "rydr.SuperfaPackRules"; public const string PluginName = "Small Modpack Fix"; public const string PluginVersion = "1.1.5"; internal static Plugin Instance; private void Awake() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown Instance = this; Rules.Log = ((BaseUnityPlugin)this).Logger; ConfigSync.ApplyIfNewer(); Harmony val = new Harmony("rydr.SuperfaPackRules"); val.PatchAll(typeof(Plugin).Assembly); BugFixes.Install(val); Type type = AccessTools.TypeByName("DisplayAllMoons.TerminalPatch"); MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "MakeAllMoonsNotHidden", (Type[])null, (Type[])null)); if (methodInfo != null) { val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(TerminalRefreshPatch), "AfterUnhide", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } if (Plugin.IsSetupComplete) { Rules.ApplyContent(); } else { Plugin.onSetupComplete += Rules.ApplyContent; } WeatherRegistryEvent setupFinished = EventManager.SetupFinished; object obj = <>O.<1>__DisableFogAndDust; if (obj == null) { Event val2 = Rules.DisableFogAndDust; <>O.<1>__DisableFogAndDust = val2; obj = (object)val2; } ((CustomEvent)setupFinished).AddListener((Event)obj); if (WeatherManager.IsSetupFinished) { Rules.DisableFogAndDust(); } MethodInfo methodInfo2 = AccessTools.Method(typeof(StartOfRound), "SetPlanetsWeather", (Type[])null, (Type[])null); if (methodInfo2 != null) { val.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(Rules), "ClearFogAndDustOnMoons", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } Rules.AllowPricedMoonsInRouteRandom(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Superfa Pack Rules loaded."); } } [HarmonyPatch(typeof(Terminal), "Awake")] [HarmonyPriority(0)] internal static class TerminalAwakePatch { private static void Postfix(Terminal __instance) { Rules.ApplyMoons(); Rules.PruneHiddenRoutes(__instance); } } [HarmonyPatch(typeof(Terminal), "Start")] [HarmonyPriority(0)] internal static class TerminalStartPatch { private static void Postfix(Terminal __instance) { Rules.ApplyMoons(); Rules.PruneHiddenRoutes(__instance); } } internal static class TerminalRefreshPatch { public static void AfterUnhide() { Rules.ApplyMoons(); } } internal static class Rules { private static readonly string[] AllowedInteriors = new string[5] { "Art Gallery", "Asten Laboratory", "Carnival", "Deep Sewers", "PlayZone" }; private static readonly string[] BozorosInteriors = new string[2] { "Carnival", "PlayZone" }; private static readonly string[] VisibleVanillaMoons = new string[3] { "March", "Dine", "Artifice" }; private static readonly Dictionary<string, int> Prices = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase) { { "March", 0 }, { "Gloom", 0 }, { "Flicker", 0 }, { "Dine", 0 }, { "Oldred", 0 }, { "Contingency", 0 }, { "Wither", 400 }, { "Budapest", 400 }, { "Defectus", 800 }, { "Artifice", 800 }, { "Lua", 1200 }, { "Bozoros", 0 }, { "Pareidolia", 200 }, { "The Iris", 800 }, { "Iris", 800 } }; internal static ManualLogSource Log; public static void ApplyContent() { ApplyInteriors(); EqualizeEnemies(); ApplyMoons(); AllowPricedMoonsInRouteRandom(); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)"Applied interior pool, enemy weights, moon list, and route prices."); } } public static void ApplyInteriors() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) if (PatchedContent.ExtendedDungeonFlows == null || PatchedContent.ExtendedLevels == null) { return; } foreach (ExtendedDungeonFlow extendedDungeonFlow in PatchedContent.ExtendedDungeonFlows) { if ((Object)(object)extendedDungeonFlow == (Object)null) { continue; } string text = extendedDungeonFlow.DungeonName ?? string.Empty; List<StringWithRarity> list = new List<StringWithRarity>(); foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if (!((Object)(object)extendedLevel == (Object)null) && !string.IsNullOrEmpty(extendedLevel.NumberlessPlanetName)) { list.Add(new StringWithRarity(extendedLevel.NumberlessPlanetName, InteriorWeight(text, extendedLevel.NumberlessPlanetName))); } } Replace(extendedDungeonFlow.manualPlanetNameReferenceList, list); Clear(extendedDungeonFlow.dynamicLevelTagsList); Clear(extendedDungeonFlow.dynamicRoutePricesList); Clear(extendedDungeonFlow.dynamicCurrentWeatherList); Clear(extendedDungeonFlow.manualContentSourceNameReferenceList); LevelMatchingProperties levelMatchingProperties = extendedDungeonFlow.LevelMatchingProperties; if ((Object)(object)levelMatchingProperties != (Object)null) { levelMatchingProperties.planetNames = new List<StringWithRarity>(list); levelMatchingProperties.levelTags = new List<StringWithRarity>(); levelMatchingProperties.currentRoutePrice = new List<Vector2WithRarity>(); levelMatchingProperties.currentWeather = new List<StringWithRarity>(); } if (text.Equals("Deep Sewers", StringComparison.OrdinalIgnoreCase)) { extendedDungeonFlow.enableDynamicDungeonSizeRestriction = true; extendedDungeonFlow.dungeonSizeMin = 1f; extendedDungeonFlow.dungeonSizeMax = 1f; extendedDungeonFlow.dungeonSizeLerpPercentage = 0f; extendedDungeonFlow.IsDynamicDungeonSizeRestrictionEnabled = true; extendedDungeonFlow.DynamicDungeonSizeMinMax = new Vector2(1f, 1f); extendedDungeonFlow.DynamicDungeonSizeLerpRate = 0f; } } } public static void EqualizeEnemies() { if (PatchedContent.ExtendedLevels == null) { return; } foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { SelectableLevel val = ((extendedLevel != null) ? extendedLevel.SelectableLevel : null); if (!((Object)(object)val == (Object)null)) { Equalize(val.Enemies); Equalize(val.OutsideEnemies); Equalize(val.DaytimeEnemies); } } } public static void ApplyMoons() { if (PatchedContent.ExtendedLevels == null) { return; } foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if (!((Object)(object)extendedLevel == (Object)null)) { string obj = extendedLevel.NumberlessPlanetName ?? string.Empty; bool flag = PatchedContent.VanillaExtendedLevels != null && PatchedContent.VanillaExtendedLevels.Contains(extendedLevel); bool flag2 = Matches(obj, VisibleVanillaMoons); extendedLevel.IsRouteHidden = flag && !flag2; if (TryGetPrice(obj, out var price)) { extendedLevel.RoutePrice = price; } } } } public static void PruneHiddenRoutes(Terminal terminal) { if (terminal?.terminalNodes?.allKeywords == null || StartOfRound.Instance?.levels == null) { return; } TerminalKeyword val = ((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword keyword) => (Object)(object)keyword != (Object)null && ((Object)keyword).name == "Route")); if (val?.compatibleNouns == null) { return; } List<CompatibleNoun> list = new List<CompatibleNoun>(); CompatibleNoun[] compatibleNouns = val.compatibleNouns; ExtendedLevel val3 = default(ExtendedLevel); foreach (CompatibleNoun val2 in compatibleNouns) { if (!((Object)(object)val2?.result == (Object)null)) { int num2 = ResolveLevelId(val2); if (num2 < 0 || num2 >= StartOfRound.Instance.levels.Length) { list.Add(val2); } else if (!PatchedContent.TryGetExtendedContent(StartOfRound.Instance.levels[num2], ref val3) || !((Object)(object)val3 != (Object)null) || !val3.IsRouteHidden) { list.Add(val2); } } } val.compatibleNouns = list.ToArray(); } public static void DisableFogAndDust() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (WeatherManager.IsSetupFinished && WeatherManager.Weathers != null) { foreach (Weather weather in WeatherManager.Weathers) { if (weather == null || ((int)weather.VanillaWeatherType != 3 && (int)weather.VanillaWeatherType != 0)) { continue; } ZeroWeatherWeight(weather); weather.LevelFilteringOption = (FilteringOption)0; weather.LevelFilters?.Clear(); weather.LevelWeights?.Clear(); if (PatchedContent.ExtendedLevels == null) { continue; } foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if ((Object)(object)((extendedLevel != null) ? extendedLevel.SelectableLevel : null) != (Object)null) { weather.RemoveFromMoon(extendedLevel.SelectableLevel); } } } } ClearFogAndDustOnMoons(); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)"Disabled Foggy and Dust Clouds."); } } public static void ClearFogAndDustOnMoons() { //IL_0074: 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_0029: 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_0045: Unknown result type (might be due to invalid IL or missing references) SelectableLevel[] array = StartOfRound.Instance?.levels; if (array != null) { SelectableLevel[] array2 = array; foreach (SelectableLevel val in array2) { if (!((Object)(object)val == (Object)null)) { if (IsFogOrDust(val.currentWeather)) { val.currentWeather = (LevelWeatherType)(-1); } if (val.overrideWeather && IsFogOrDust(val.overrideWeatherType)) { val.overrideWeather = false; } } } } if ((Object)(object)TimeOfDay.Instance != (Object)null && IsFogOrDust(TimeOfDay.Instance.currentLevelWeather)) { TimeOfDay.Instance.currentLevelWeather = (LevelWeatherType)(-1); } } private static bool IsFogOrDust(LevelWeatherType weather) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)weather != 3) { return (int)weather == 0; } return true; } private static void ZeroWeatherWeight(Weather weather) { object obj = AccessTools.Field(typeof(Weather), "Config")?.GetValue(weather); if (obj == null) { return; } object obj2 = obj.GetType().GetField("DefaultWeight")?.GetValue(obj); if (obj2 == null) { return; } FieldInfo[] fields = obj2.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType.Name.IndexOf("ConfigEntry", StringComparison.Ordinal) >= 0) { object value = fieldInfo.GetValue(obj2); PropertyInfo propertyInfo = value?.GetType().GetProperty("Value"); if (propertyInfo != null && propertyInfo.PropertyType == typeof(int) && propertyInfo.CanWrite) { propertyInfo.SetValue(value, 0); } } } } public static void AllowPricedMoonsInRouteRandom() { Type type = AccessTools.TypeByName("RouteRandomRedexed.RouteRandomRedexed"); if (((type == null) ? null : AccessTools.Field(type, "ConfigAllowCostlyPlanets"))?.GetValue(null) is ConfigEntry<bool> val && !val.Value) { val.Value = true; } } private static int InteriorWeight(string dungeonName, string planetName) { if (!IsInterior(dungeonName, AllowedInteriors)) { return 0; } if (planetName.IndexOf("Bozoros", StringComparison.OrdinalIgnoreCase) >= 0 && !IsInterior(dungeonName, BozorosInteriors)) { return 0; } return 100; } private static bool IsInterior(string dungeonName, string[] names) { string text = Compact(dungeonName); for (int i = 0; i < names.Length; i++) { if (text.Equals(Compact(names[i]), StringComparison.OrdinalIgnoreCase)) { return true; } } if (text.Equals("funzone", StringComparison.OrdinalIgnoreCase) && MatchesCompact(names, "playzone")) { return true; } return false; } private static bool MatchesCompact(string[] names, string compactName) { for (int i = 0; i < names.Length; i++) { if (Compact(names[i]).Equals(compactName, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private static string Compact(string value) { if (string.IsNullOrEmpty(value)) { return string.Empty; } return value.Replace(" ", string.Empty); } private static bool TryGetPrice(string planetName, out int price) { if (Prices.TryGetValue(planetName, out price)) { return true; } if (planetName.IndexOf("Contingency", StringComparison.OrdinalIgnoreCase) >= 0 || planetName.IndexOf("Bozoros", StringComparison.OrdinalIgnoreCase) >= 0) { price = 0; return true; } if (planetName.IndexOf("Iris", StringComparison.OrdinalIgnoreCase) >= 0) { price = 800; return true; } if (planetName.IndexOf("Pareidolia", StringComparison.OrdinalIgnoreCase) >= 0) { price = 200; return true; } price = 0; return false; } private static bool Matches(string value, string[] names) { for (int i = 0; i < names.Length; i++) { if (value.Equals(names[i], StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private static int ResolveLevelId(CompatibleNoun noun) { int buyRerouteToMoon = noun.result.buyRerouteToMoon; if (buyRerouteToMoon >= 0) { return buyRerouteToMoon; } if (noun.result.terminalOptions == null) { return -1; } CompatibleNoun[] terminalOptions = noun.result.terminalOptions; foreach (CompatibleNoun val in terminalOptions) { if ((Object)(object)val?.result != (Object)null && val.result.buyRerouteToMoon >= 0) { return val.result.buyRerouteToMoon; } } return -1; } private static void Equalize(List<SpawnableEnemyWithRarity> enemies) { if (enemies == null) { return; } for (int i = 0; i < enemies.Count; i++) { if (enemies[i] != null) { enemies[i].rarity = 100; } } } private static void Clear<T>(List<T> list) { list?.Clear(); } private static void Replace(List<StringWithRarity> target, List<StringWithRarity> weights) { if (target != null) { target.Clear(); target.AddRange(weights); } } } }