Decompiled source of TooManyPuddles v0.1.0

TooManyPuddles/TooManyPuddles.dll

Decompiled 8 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("TooManyPuddles")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TooManyPuddles")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ba7d716b-f857-430a-863c-2b8995205a16")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TooManyPuddles
{
	internal class ConfigHandler
	{
		private ConfigEntry<bool> spawnPuddlesNonRainyCfg;

		private ConfigEntry<int> minPuddleSpawnCfg;

		private ConfigEntry<int> maxPuddleSpawnCfg;

		private ConfigEntry<int> puddleSpawnCapCfg;

		internal bool spawnPuddlesNonRainy
		{
			get
			{
				return spawnPuddlesNonRainyCfg.Value;
			}
			set
			{
				spawnPuddlesNonRainyCfg.Value = value;
			}
		}

		internal int puddleSpawnCap
		{
			get
			{
				if (puddleSpawnCapCfg.Value < 0)
				{
					return (int)((ConfigEntryBase)puddleSpawnCapCfg).DefaultValue;
				}
				return puddleSpawnCapCfg.Value;
			}
			set
			{
				puddleSpawnCapCfg.Value = value;
			}
		}

		internal int minPuddleSpawn
		{
			get
			{
				if (minPuddleSpawnCfg.Value < 0)
				{
					return (int)((ConfigEntryBase)minPuddleSpawnCfg).DefaultValue;
				}
				return minPuddleSpawnCfg.Value;
			}
			set
			{
				minPuddleSpawnCfg.Value = value;
			}
		}

		internal int maxPuddleSpawn
		{
			get
			{
				if (maxPuddleSpawnCfg.Value < 0)
				{
					return (int)((ConfigEntryBase)maxPuddleSpawnCfg).DefaultValue;
				}
				return maxPuddleSpawnCfg.Value;
			}
			set
			{
				maxPuddleSpawnCfg.Value = value;
			}
		}

		public ConfigHandler(ConfigFile Config)
		{
			spawnPuddlesNonRainyCfg = Config.Bind<bool>("Puddle Spawn Settings", "Spawn Puddles on Non-Rainy Days", false, "If set to true, extra puddles will still spawn even if it is not rainy, vanilla puddles will be unaffected");
			minPuddleSpawnCfg = Config.Bind<int>("Puddle Spawn Settings", "Min Puddle Spawn", 0, "Minimum amount of extra puddles to spawn");
			maxPuddleSpawnCfg = Config.Bind<int>("Puddle Spawn Settings", "Max Puddle Spawn", 750, "Maximum amount of extra puddles to spawn");
			puddleSpawnCapCfg = Config.Bind<int>("Puddle Spawn Settings", "Puddle Spawn Cap", 1, "Prevents more than this many extra puddles from spawning to prevent lag, all vanila puddles will be unaffected");
		}
	}
	[BepInPlugin("Aliki.TooManyPuddles", "Too Many Puddles", "0.1.0.0")]
	public class TooManyPuddlesModBase : BaseUnityPlugin
	{
		private const string modGUID = "Aliki.TooManyPuddles";

		private const string modName = "Too Many Puddles";

		private const string modVersion = "0.1.0.0";

		private readonly Harmony harmonyOBJ = new Harmony("Aliki.TooManyPuddles");

		internal static TooManyPuddlesModBase Instance;

		internal ManualLogSource mlsOBJ;

		internal ConfigHandler configOBJ;

		internal RoundManager currentRound;

		internal StartOfRound startOfCurrentRound;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mlsOBJ = Logger.CreateLogSource("Aliki.TooManyPuddles");
			mlsOBJ.LogInfo((object)"Adding an Appalling Number of Puddles (._. )");
			configOBJ = new ConfigHandler(((BaseUnityPlugin)this).Config);
			harmonyOBJ.PatchAll();
		}
	}
}
namespace TooManyPuddles.Patches
{
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void RoundManagerInstance(ref RoundManager __instance)
		{
			TooManyPuddlesModBase.Instance.currentRound = __instance;
		}

		[HarmonyPatch("SpawnOutsideHazards")]
		[HarmonyPostfix]
		private static void SpawnQuicksand(ref GameObject ___quicksandPrefab, ref GameObject[] ___outsideAINodes, ref GameObject ___mapPropsContainer, ref SelectableLevel ___currentLevel)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			if ((int)___currentLevel.currentWeather == 1 || TooManyPuddlesModBase.Instance.configOBJ.spawnPuddlesNonRainy)
			{
				ManualLogSource mlsOBJ = TooManyPuddlesModBase.Instance.mlsOBJ;
				Random random = new Random(StartOfRound.Instance.randomMapSeed + 2);
				NavMeshHit val = default(NavMeshHit);
				int minPuddleSpawn = TooManyPuddlesModBase.Instance.configOBJ.minPuddleSpawn;
				int maxPuddleSpawn = TooManyPuddlesModBase.Instance.configOBJ.maxPuddleSpawn;
				int num = (int)(random.NextDouble() * (double)(maxPuddleSpawn - minPuddleSpawn) + (double)minPuddleSpawn);
				num = Mathf.Min(TooManyPuddlesModBase.Instance.configOBJ.puddleSpawnCap, num);
				mlsOBJ.LogMessage((object)("Number of Extra Puddles: " + num));
				for (int i = 0; i < num; i++)
				{
					Vector3 position = ___outsideAINodes[random.Next(0, ___outsideAINodes.Length)].transform.position;
					Vector3 val2 = TooManyPuddlesModBase.Instance.currentRound.GetRandomNavMeshPositionInBoxPredictable(position, 30f, val, random, -1, 1f) + Vector3.up;
					GameObject val3 = Object.Instantiate<GameObject>(___quicksandPrefab, val2, Quaternion.identity, ___mapPropsContainer.transform);
					string text = (i + 1).ToString();
					Vector3 val4 = val2;
					mlsOBJ.LogInfo((object)("Spawned puddle " + text + " at " + ((object)(Vector3)(ref val4)).ToString()));
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartOfRoundInstance(ref StartOfRound __instance)
		{
			TooManyPuddlesModBase.Instance.startOfCurrentRound = __instance;
		}
	}
}