Decompiled source of WeatherUtils v1.0.3

WeatherUtils.dll

Decompiled 2 days ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("TestLCMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestLCMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d7aa81e1-2877-48fd-9e2e-174e5ad5a2d1")]
[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 TestLCMod
{
	[HarmonyPatch(typeof(StartOfRound))]
	public class RoundStartPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void RoundStartPostfix()
		{
			Debug.Log((object)"ROUND START DETECTED");
		}
	}
}
namespace WeatherUtils
{
	[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
	public class ScrapWeatherMultiplierPatch
	{
		[HarmonyPrefix]
		private static void Prefix(RoundManager __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			LevelWeatherType currentWeather = __instance.currentLevel.currentWeather;
			if (Plugin.WeatherConfigs.TryGetValue(currentWeather, out var value))
			{
				float value2 = value.Amount.Value;
				float value3 = value.Value.Value;
				__instance.scrapAmountMultiplier *= value2;
				__instance.scrapValueMultiplier *= value3;
				Debug.Log((object)$"[WeatherUtils] Applied {currentWeather} multipliers -> Amount: {value2}x, Value: {value3}x");
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public class RoundStartPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void RoundStartPostfix()
		{
			Debug.Log((object)"[WeatherUtils] ROUND START DETECTED");
		}
	}
	[BepInPlugin("com.donobus.WeatherUtils", "WeatherUtils", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public struct WeatherMultiplierConfig
		{
			public ConfigEntry<float> Amount;

			public ConfigEntry<float> Value;
		}

		private Harmony harmony;

		public static Dictionary<LevelWeatherType, WeatherMultiplierConfig> WeatherConfigs = new Dictionary<LevelWeatherType, WeatherMultiplierConfig>();

		private void Awake()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"=== WeatherUtils Loaded ===");
			BindWeatherConfig((LevelWeatherType)(-1), "Clear", 1f, 1f);
			BindWeatherConfig((LevelWeatherType)1, "Rainy", 1f, 1f);
			BindWeatherConfig((LevelWeatherType)2, "Stormy", 1f, 1f);
			BindWeatherConfig((LevelWeatherType)3, "Foggy", 1f, 1f);
			BindWeatherConfig((LevelWeatherType)4, "Flooded", 1f, 1f);
			BindWeatherConfig((LevelWeatherType)5, "Eclipsed", 1f, 1f);
			harmony = new Harmony("com.donobus.WeatherUtils");
			harmony.PatchAll();
		}

		private void BindWeatherConfig(LevelWeatherType weather, string displayName, float defaultAmount, float defaultValue)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			WeatherMultiplierConfig value = new WeatherMultiplierConfig
			{
				Amount = ((BaseUnityPlugin)this).Config.Bind<float>(displayName ?? "", "Scrap Amount Multiplier", defaultAmount, "Multiplier for total scrap spawned during " + displayName + " weather."),
				Value = ((BaseUnityPlugin)this).Config.Bind<float>(displayName ?? "", "Scrap Value Multiplier", defaultValue, "Multiplier for scrap value during " + displayName + " weather.")
			};
			WeatherConfigs.Add(weather, value);
		}
	}
}