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 NoWeeds v1.0.0
plugins/NoWeeds.dll
Decompiled 2 weeks agousing System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Unity.Netcode; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace NoWeeds; [BepInPlugin("community.NoWeeds", "NoWeeds", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ConfigEntry<bool> DisableCadaver; internal static ConfigEntry<int> VainMax; private void Awake() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; DisableCadaver = ((BaseUnityPlugin)this).Config.Bind<bool>("Cadaver Growths", "Disable", true, "true = Cadaver Growths (the plants that overrun indoor hallways) no longer spawn. Cadaver Blooms cannot appear either, since they hatch from those plants."); VainMax = ((BaseUnityPlugin)this).Config.Bind<int>("Vain Shrouds", "MaxSpreadIterations", -1, "Outdoor weeds that attract the Kidnapper Fox. -1 = vanilla behaviour, 0 = no Vain Shrouds (and therefore no fox), a value > 0 = caps how far they spread on each moon."); new Harmony("community.NoWeeds").PatchAll(typeof(Patches)); Log.LogInfo((object)("NoWeeds loaded: Cadaver Growths disabled = " + DisableCadaver.Value + ", Vain Shrouds max spread = " + VainMax.Value)); } internal static bool IsServer() { return (Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer; } internal static bool IsCadaverGrowth(EnemyType t) { if ((Object)(object)t == (Object)null) { return false; } if ((Object)(object)t.enemyPrefab != (Object)null && (Object)(object)t.enemyPrefab.GetComponentInChildren<CadaverGrowthAI>(true) != (Object)null) { return true; } return t.enemyName == "Cadaver Growths"; } internal static void ApplyCadaver(SelectableLevel level) { if ((Object)(object)level == (Object)null || level.Enemies == null) { return; } foreach (SpawnableEnemyWithRarity enemy in level.Enemies) { if (enemy != null && IsCadaverGrowth(enemy.enemyType) && enemy.enemyType.spawningDisabled != DisableCadaver.Value) { enemy.enemyType.spawningDisabled = DisableCadaver.Value; Log.LogInfo((object)(((!DisableCadaver.Value) ? "Cadaver Growths allowed" : "Cadaver Growths blocked") + " on " + level.PlanetName)); } } } internal static void ApplyVain(SelectableLevel level) { if ((Object)(object)level == (Object)null) { return; } int value = VainMax.Value; if (value >= 0) { if (value == 0) { level.moldSpreadIterations = 0; level.moldStartPosition = -1; } else if (level.moldSpreadIterations > value) { level.moldSpreadIterations = value; } } } internal static void ApplyVainAll(StartOfRound sor) { if (!((Object)(object)sor == (Object)null) && sor.levels != null) { SelectableLevel[] levels = sor.levels; foreach (SelectableLevel level in levels) { ApplyVain(level); } } } } internal static class Patches { [HarmonyPatch(typeof(RoundManager), "LoadNewLevel")] [HarmonyPrefix] private static void BeforeLoadNewLevel(SelectableLevel newLevel) { if (Plugin.IsServer()) { Plugin.ApplyCadaver(newLevel); Plugin.ApplyVain(newLevel); } } [HarmonyPatch(typeof(StartOfRound), "SetPlanetsMold")] [HarmonyPostfix] private static void AfterSetPlanetsMold(StartOfRound __instance) { if (Plugin.IsServer()) { Plugin.ApplyVainAll(__instance); } } [HarmonyPatch(typeof(StartOfRound), "LoadPlanetsMoldSpreadData")] [HarmonyPostfix] private static void AfterLoadMold(StartOfRound __instance) { if (Plugin.IsServer()) { Plugin.ApplyVainAll(__instance); } } }