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 ActuallyPeacefulMeadows v1.0.0
ActuallyPeacefulMeadows.dll
Decompiled 15 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("ActuallyPeacefulMeadows")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ActuallyPeacefulMeadows")] [assembly: AssemblyTitle("ActuallyPeacefulMeadows")] [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 ActuallyPeacefulMeadows { [BepInPlugin("com.actuallypeacefulmeadows", "ActuallyPeacefulMeadows", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "com.actuallypeacefulmeadows"; public const string PluginName = "ActuallyPeacefulMeadows"; public const string PluginVersion = "1.0.0"; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<string> Allowed; internal static ConfigEntry<bool> BlockRaids; internal static ConfigEntry<bool> AllMeadows; private static readonly HashSet<string> AllowedNames = new HashSet<string>(); private static string _allowedFor; private const string PeacefulName = "Peaceful Meadows"; private void Awake() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, new ConfigDescription("Nothing hostile ever spawns in the Peaceful Meadows, whatever the game progress.", (AcceptableValueBase)null, new object[1] { val })); Allowed = ((BaseUnityPlugin)this).Config.Bind<string>("General", "AllowedCreatures", "", new ConfigDescription("Extra creatures that may still spawn there, separated by commas (prefab names). The boar and deer that the Peaceful Meadows normally have are always allowed. Everything else that spawns on its own is blocked, including creatures from other mods.", (AcceptableValueBase)null, new object[1] { val })); AllMeadows = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllMeadows", false, new ConfigDescription("Off: only the Peaceful Meadows (the alternate Meadows biome) are made peaceful. On: every Meadows area is.", (AcceptableValueBase)null, new object[1] { val })); BlockRaids = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "BlockRaids", true, new ConfigDescription("Also stop raids (random events like attacks on your base) from starting while you are in the Peaceful Meadows.", (AcceptableValueBase)null, new object[1] { val })); new Harmony("com.actuallypeacefulmeadows").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"ActuallyPeacefulMeadows 1.0.0 loaded"); } internal static bool Active(Vector3 position, out AltBiome peaceful) { //IL_001d: 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_002f: Invalid comparison between Unknown and I4 peaceful = null; if (!Enabled.Value || WorldGenerator.instance == null) { return false; } BiomeSector biomeSector = WorldGenerator.instance.GetBiomeSector(position, false); if (biomeSector == null || (int)biomeSector.Biome != 1) { return false; } foreach (AltBiome altBiome in biomeSector.AltBiomes) { if (altBiome.m_name == "Peaceful Meadows") { peaceful = altBiome; return true; } } return AllMeadows.Value; } internal static bool Active(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) AltBiome peaceful; return Active(position, out peaceful); } private static string Clean(string name) { name = (name ?? "").Trim(); if (!name.EndsWith("(Clone)")) { return name; } return name.Substring(0, name.Length - "(Clone)".Length).Trim(); } internal static bool IsBlocked(GameObject prefab, AltBiome peaceful) { if ((Object)(object)prefab == (Object)null || (Object)(object)prefab.GetComponent<Character>() == (Object)null) { return false; } if (peaceful != null) { foreach (SpawnData item in peaceful.m_spawn) { if ((Object)(object)item.m_prefab == (Object)(object)prefab) { return false; } } } if (_allowedFor != Allowed.Value) { _allowedFor = Allowed.Value; AllowedNames.Clear(); string[] array = (_allowedFor ?? "").Split(new char[1] { ',' }); foreach (string text in array) { if (text.Trim().Length > 0) { AllowedNames.Add(text.Trim().ToLowerInvariant()); } } } return !AllowedNames.Contains(Clean(((Object)prefab).name).ToLowerInvariant()); } internal static bool IsBlockedAt(GameObject prefab, Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (Active(position, out var peaceful)) { return IsBlocked(prefab, peaceful); } return false; } } [HarmonyPatch(typeof(SpawnSystem), "Spawn")] internal static class SpawnSystem_Spawn_Patch { private static bool Prefix(SpawnData critter, Vector3 spawnPoint) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (critter != null) { return !Plugin.IsBlockedAt(critter.m_prefab, spawnPoint); } return true; } } [HarmonyPatch(typeof(CreatureSpawner), "Spawn")] internal static class CreatureSpawner_Spawn_Patch { private static bool Prefix(CreatureSpawner __instance) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) return !Plugin.IsBlockedAt(__instance.m_creaturePrefab, ((Component)__instance).transform.position); } } [HarmonyPatch(typeof(SpawnArea), "SpawnOne")] internal static class SpawnArea_SpawnOne_Patch { private static bool Prefix(SpawnArea __instance) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) foreach (SpawnData prefab in __instance.m_prefabs) { if (Plugin.IsBlockedAt(prefab.m_prefab, ((Component)__instance).transform.position)) { return false; } } return true; } } [HarmonyPatch(typeof(RandEventSystem), "SetRandomEvent")] internal static class RandEventSystem_SetRandomEvent_Patch { private static bool Prefix(RandomEvent ev, Vector3 pos) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (ev != null && Plugin.BlockRaids.Value) { return !Plugin.Active(pos); } return true; } } }