Decompiled source of SoundAPIWeatherBinding v1.0.2

BepInEx/plugins/SoundAPIWeatherBinding/SoundAPIWeatherBinding.dll

Decompiled a month 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.Logging;
using HarmonyLib;
using UnityEngine;
using WeatherRegistry;
using WeatherTweaks.Definitions;
using loaforcsSoundAPI;
using loaforcsSoundAPI.SoundPacks.Data.Conditions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SoundAPIWeatherBinding")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SoundAPIWeatherBinding")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ca66baa5-bd5a-475e-9f3c-95df9bc6940e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[SoundAPICondition("LethalCompany:weather:iscombinedweather", false, null)]
public class WeatherIsCombinedCondition : Condition
{
	public string Value { get; internal set; }

	public override bool Evaluate(IContext context)
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Invalid comparison between Unknown and I4
		if (!Object.op_Implicit((Object)(object)StartOfRound.Instance))
		{
			return false;
		}
		if (!Object.op_Implicit((Object)(object)StartOfRound.Instance.currentLevel))
		{
			return false;
		}
		Weather currentLevelWeather = WeatherManager.GetCurrentLevelWeather();
		WeatherTweaksWeather val = (WeatherTweaksWeather)(object)((currentLevelWeather is WeatherTweaksWeather) ? currentLevelWeather : null);
		if (val != null)
		{
			CustomWeatherType customType = val.CustomType;
			if ((int)customType == 1)
			{
				return true;
			}
			return false;
		}
		return false;
	}
}
namespace SoundAPIWeatherBinding;

[BepInPlugin("ZetaArcade.SoundAPIWeatherBinding", "SoundAPIWeatherBinding", "1.0.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class SoundAPIWeatherBindingBase : BaseUnityPlugin
{
	public static SoundAPIWeatherBindingBase Instance;

	private ManualLogSource mls;

	private const string modGUID = "ZetaArcade.SoundAPIWeatherBinding";

	private const string modName = "SoundAPIWeatherBinding";

	private const string modVersion = "1.0.2";

	private readonly Harmony harmony = new Harmony("ZetaArcade.SoundAPIWeatherBinding");

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		mls = Logger.CreateLogSource("ZetaArcade.SoundAPIWeatherBinding");
		SoundAPI.RegisterAll(Assembly.GetExecutingAssembly());
		((BaseUnityPlugin)this).Logger.LogInfo((object)"SoundAPI Weather Binding is registering!");
	}

	public static void Log(string message)
	{
		Instance.PassLog(message, isError: false);
	}

	public static void LogError(string message)
	{
		Instance.PassLog(message, isError: true);
	}

	private void PassLog(string message, bool isError)
	{
		if (isError)
		{
			mls.LogError((object)message);
		}
		else
		{
			mls.LogInfo((object)message);
		}
	}
}
[SoundAPICondition("LethalCompany:weather:name", false, null)]
public class WeatherNameCondition : Condition
{
	public string Value { get; internal set; }

	public override bool Evaluate(IContext context)
	{
		if (!Object.op_Implicit((Object)(object)StartOfRound.Instance))
		{
			return false;
		}
		if (!Object.op_Implicit((Object)(object)StartOfRound.Instance.currentLevel))
		{
			return false;
		}
		string b = ((object)(LevelWeatherType)(ref StartOfRound.Instance.currentLevel.currentWeather)).ToString();
		return string.Equals(Value, b, StringComparison.InvariantCultureIgnoreCase);
	}
}
[SoundAPICondition("LethalCompany:weather:isweatherpresent", false, null)]
public class WeatherIsPresentCondition : Condition
{
	public string Value { get; internal set; }

	public override bool Evaluate(IContext context)
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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 (!Object.op_Implicit((Object)(object)StartOfRound.Instance))
		{
			return false;
		}
		if (!Object.op_Implicit((Object)(object)StartOfRound.Instance.currentLevel))
		{
			return false;
		}
		Weather currentLevelWeather = WeatherManager.GetCurrentLevelWeather();
		LevelWeatherType weatherType = ((WeatherResolvable)new WeatherNameResolvable(Value)).WeatherType;
		WeatherTweaksWeather val = (WeatherTweaksWeather)(object)((currentLevelWeather is WeatherTweaksWeather) ? currentLevelWeather : null);
		if (val != null)
		{
			for (int i = 0; i < val.WeatherTypes.Count; i++)
			{
				if (val.WeatherTypes[i].WeatherType == weatherType)
				{
					return true;
				}
			}
			return false;
		}
		if (currentLevelWeather.VanillaWeatherType == weatherType)
		{
			return true;
		}
		return false;
	}
}