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 FckUFactory v1.1.0
FckUFactory.dll
Decompiled 8 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using Microsoft.CodeAnalysis; using UnityEngine; [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("FckUFactory")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+eb2e54e2fb204e244ce7f1ac71244455953e5af3")] [assembly: AssemblyProduct("FckUFactory")] [assembly: AssemblyTitle("FckUFactory")] [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 InteriorRarity { [HarmonyPatch(typeof(RoundManager), "GenerateNewFloor")] public static class GenerateFloorPatch { private static readonly Dictionary<string, int[]> OriginalRarities = new Dictionary<string, int[]>(); [HarmonyPrefix] public static void Prefix(RoundManager __instance) { SelectableLevel currentLevel = __instance.currentLevel; if ((Object)(object)currentLevel == (Object)null || currentLevel.dungeonFlowTypes == null || currentLevel.dungeonFlowTypes.Length == 0) { return; } IntWithRarity[] dungeonFlowTypes = currentLevel.dungeonFlowTypes; string text = (string.IsNullOrEmpty(currentLevel.PlanetName) ? ((Object)currentLevel).name : currentLevel.PlanetName); if (!OriginalRarities.TryGetValue(text, out var value)) { value = new int[dungeonFlowTypes.Length]; for (int i = 0; i < dungeonFlowTypes.Length; i++) { value[i] = dungeonFlowTypes[i].rarity; } OriginalRarities[text] = value; } int[] array = new int[dungeonFlowTypes.Length]; string[] array2 = new string[dungeonFlowTypes.Length]; for (int j = 0; j < dungeonFlowTypes.Length; j++) { int id = dungeonFlowTypes[j].id; array[j] = InteriorConfig.GetWeight(friendlyName: array2[j] = InteriorNames.ToFriendly(((Object)__instance.dungeonFlowTypes[id].dungeonFlow).name), cfg: Plugin.Cfg); } int[] array3 = WeightCalculator.Resolve(value, array); for (int k = 0; k < dungeonFlowTypes.Length; k++) { dungeonFlowTypes[k].rarity = array3[k]; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("[InteriorRarity] Lua '").Append(text).Append("': "); for (int l = 0; l < dungeonFlowTypes.Length; l++) { stringBuilder.Append(array2[l]).Append('=').Append(dungeonFlowTypes[l].rarity) .Append(' '); } Plugin.Log.LogInfo((object)stringBuilder.ToString()); } } public static class InteriorNames { private static readonly Dictionary<string, string> Map = new Dictionary<string, string> { { "Level1Flow", "Factory" }, { "Level1Flow3Exits", "Factory" }, { "Level1FlowExtraLarge", "Factory" }, { "Level2Flow", "Manor" }, { "Level3Flow", "Mineshaft" } }; public static string ToFriendly(string technical) { if (!Map.TryGetValue(technical, out var value)) { return technical; } return value; } } public static class InteriorConfig { private const string Section = "Weights"; private static readonly Dictionary<string, int> Defaults = new Dictionary<string, int> { { "Factory", 0 }, { "Manor", 50 }, { "Mineshaft", 50 } }; private static readonly Dictionary<string, ConfigEntry<int>> Entries = new Dictionary<string, ConfigEntry<int>>(); public static IEnumerable<ConfigEntry<int>> BoundEntries => Entries.Values; public static void EnsureBaseEntries(ConfigFile cfg) { foreach (string key in Defaults.Keys) { GetWeight(cfg, key); } } public static int GetWeight(ConfigFile cfg, string friendlyName) { if (!Entries.TryGetValue(friendlyName, out var value)) { int value2; int num = (Defaults.TryGetValue(friendlyName, out value2) ? value2 : 50); value = cfg.Bind<int>("Weights", friendlyName, num, "Peso de spawn do interior '" + friendlyName + "'. 0 = nunca aparece."); Entries[friendlyName] = value; } if (value.Value >= 0) { return value.Value; } return 0; } } [HarmonyPatch(typeof(StartOfRound), "Start")] public static class InteriorTableDumpPatch { private static bool dumped; [HarmonyPostfix] public static void Postfix(StartOfRound __instance) { if (dumped || __instance.levels == null) { return; } dumped = true; RoundManager instance = RoundManager.Instance; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("[FckUFactory] === Pesos PADRAO de interior por lua ==="); SelectableLevel[] levels = __instance.levels; foreach (SelectableLevel val in levels) { if ((Object)(object)val == (Object)null || val.dungeonFlowTypes == null || val.dungeonFlowTypes.Length == 0) { continue; } stringBuilder.Append(" ").Append(val.PlanetName).Append(": "); IntWithRarity[] dungeonFlowTypes = val.dungeonFlowTypes; foreach (IntWithRarity val2 in dungeonFlowTypes) { string value = "id" + val2.id; if ((Object)(object)instance != (Object)null && instance.dungeonFlowTypes != null && val2.id >= 0 && val2.id < instance.dungeonFlowTypes.Length) { value = InteriorNames.ToFriendly(((Object)instance.dungeonFlowTypes[val2.id].dungeonFlow).name); } stringBuilder.Append(value).Append('=').Append(val2.rarity) .Append(" "); } stringBuilder.AppendLine(); } Plugin.Log.LogInfo((object)stringBuilder.ToString()); } } public static class LethalConfigIntegration { public static void Setup() { //IL_0013: 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) //IL_001f: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown foreach (ConfigEntry<int> boundEntry in InteriorConfig.BoundEntries) { IntSliderOptions val = new IntSliderOptions(); ((BaseRangeOptions<int>)val).Min = 0; ((BaseRangeOptions<int>)val).Max = 100; ((BaseOptions)val).RequiresRestart = false; IntSliderOptions val2 = val; LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(boundEntry, val2)); } } } [BepInPlugin("hteo_crew.FckUFactory", "FckUFactory", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "hteo_crew.FckUFactory"; private const string LethalConfigGuid = "ainavt.lc.lethalconfig"; internal static ManualLogSource Log; internal static ConfigFile Cfg; private void Awake() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Cfg = ((BaseUnityPlugin)this).Config; InteriorConfig.EnsureBaseEntries(((BaseUnityPlugin)this).Config); new Harmony("hteo_crew.FckUFactory").PatchAll(); if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig")) { LethalConfigIntegration.Setup(); Log.LogInfo((object)"Integracao com LethalConfig ativada."); } Log.LogInfo((object)"FckUFactory carregado."); } } public static class WeightCalculator { public static int[] Resolve(int[] originalRarities, int[] configuredWeights) { int num = 0; for (int i = 0; i < configuredWeights.Length; i++) { num += configuredWeights[i]; } return (int[])((num <= 0) ? originalRarities : configuredWeights).Clone(); } } }