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 Tyrs Favour Biome Raid Director v1.0.0
TyrsFavour.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; 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: AssemblyVersion("0.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 TyrsFavour { public static class ConfigManager { private static ConfigFile _config; private static bool _initialized = false; public static Dictionary<Biome, Dictionary<string, ConfigEntry<bool>>> BiomeEventConfigs = new Dictionary<Biome, Dictionary<string, ConfigEntry<bool>>>(); public static void Init(ConfigFile config) { _config = config; } public static void InitializeEvents(List<RandomEvent> allEvents) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Invalid comparison between Unknown and I4 //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Expected O, but got Unknown //IL_023c: Unknown result type (might be due to invalid IL or missing references) if (_initialized) { return; } _initialized = true; Dictionary<Biome, string> dictionary = new Dictionary<Biome, string> { { (Biome)1, "1. Meadows" }, { (Biome)8, "2. Black Forest" }, { (Biome)2, "3. Swamp" }, { (Biome)4, "4. Mountain" }, { (Biome)16, "5. Plains" }, { (Biome)256, "6. Ocean" }, { (Biome)512, "7. Mistlands" }, { (Biome)32, "8. Ashlands" }, { (Biome)64, "9. Deep North" } }; foreach (KeyValuePair<Biome, string> item in dictionary) { Biome key = item.Key; string value = item.Value; BiomeEventConfigs[key] = new Dictionary<string, ConfigEntry<bool>>(); HashSet<string> hashSet = new HashSet<string>(); foreach (RandomEvent allEvent in allEvents) { if (allEvent.m_enabled && allEvent.m_random && ((int)allEvent.m_biome == 0 || (allEvent.m_biome & key) != 0)) { bool flag = true; string name = allEvent.m_name; string englishEventName = GetEnglishEventName(name, allEvent); string text = englishEventName; if (hashSet.Contains(text)) { text = englishEventName + " (" + name + ")"; } hashSet.Add(text); string text2 = text.Replace("=", "").Replace("\n", "").Replace("\t", "") .Replace("\\", "") .Replace("\"", "") .Replace("'", "") .Replace("[", "") .Replace("]", ""); string text3 = $"Allow '{englishEventName}' in {key}?\n(Internal ID: {name})"; ConfigEntry<bool> value2 = _config.Bind<bool>(value, text2, flag, new ConfigDescription(text3, (AcceptableValueBase)null, Array.Empty<object>())); BiomeEventConfigs[key][name] = value2; } } } } private static string GetEnglishEventName(string eventName, RandomEvent ev) { if (ev.m_startMessage != null && ev.m_startMessage.StartsWith("$") && Localization.instance != null) { string text = Localization.instance.Localize(ev.m_startMessage); if (!string.IsNullOrEmpty(text) && !text.StartsWith("$")) { return text; } } return eventName switch { "army_eikthyr" => "Eikthyr rallies the creatures of the forest", "army_theelder" => "The forest is moving...", "army_bonemass" => "A foul smell from the swamp", "army_moder" => "A cold wind blows from the mountains", "army_goblins" => "The horde is attacking", "foresttrolls" => "The ground is shaking", "blobs" => "A foul smell from the swamp", "skeletons" => "Skeleton Surprise", "surtlings" => "There's a smell of sulfur in the air", "wolves" => "You are being hunted", "bats" => "You stirred the cauldron", "army_seekers" => "They sought you out", "boss_seekers" => "The seekers are demanding a champion", _ => eventName, }; } } public static class Consts { public const string ModName = "Tyr's Favour (Biome Raid Director)"; public const string ModAuthor = "zeecamelsnake"; public const string ModVersion = "1.0.0"; public const string ModGuid = "com.zeecamelsnake.TyrsFavourBiomeRaidDirector"; } [HarmonyPatch(typeof(RandEventSystem))] public static class Patch { private static bool initialized; [HarmonyPatch(typeof(Player), "OnSpawned")] [HarmonyPostfix] public static void Player_OnSpawned_Postfix() { if (!initialized && (Object)(object)RandEventSystem.instance != (Object)null && RandEventSystem.instance.m_events != null) { ConfigManager.InitializeEvents(RandEventSystem.instance.m_events); initialized = true; Plugin.Logger.LogInfo((object)$"[Tyr's Favour] Initialized config with {RandEventSystem.instance.m_events.Count} events!"); } } [HarmonyPatch("InValidBiome")] [HarmonyPostfix] public static void RandEventSystem_InValidBiome_Postfix(RandomEvent ev, Vector3 point, ref bool __result) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_007c: Unknown result type (might be due to invalid IL or missing references) if (__result && ev != null && !string.IsNullOrEmpty(ev.m_name)) { Biome biome = WorldGenerator.instance.GetBiome(point); if (ConfigManager.BiomeEventConfigs.TryGetValue(biome, out var value) && value.TryGetValue(ev.m_name, out var value2) && !value2.Value) { Plugin.Logger.LogDebug((object)$"[Tyr's Favour] Blocked event '{ev.m_name}' in biome '{biome}'."); __result = false; } } } } [BepInPlugin("com.zeecamelsnake.TyrsFavourBiomeRaidDirector", "Tyr's Favour (Biome Raid Director)", "1.0.0")] public class Plugin : BaseUnityPlugin { public static ManualLogSource Logger { get; private set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; ConfigManager.Init(((BaseUnityPlugin)this).Config); Harmony.CreateAndPatchAll(typeof(Patch), "com.zeecamelsnake.TyrsFavourBiomeRaidDirector"); Logger.LogInfo((object)"Tyr's Favour (Biome Raid Director) v1.0.0 loaded successfully."); } } }