Decompiled source of Aurality v1.1.0

Aurality.dll

Decompiled 7 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Aurality")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Aurality")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8a9aff6e-2dac-460b-9ace-a00f3abda91e")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
namespace Aurality;

[BepInPlugin("bruce.comfy.valheim.aurality", "Aurality", "1.1.0")]
public sealed class Aurality : BaseUnityPlugin
{
	public const string PluginGuid = "bruce.comfy.valheim.aurality";

	public const string PluginName = "Aurality";

	public const string PluginVersion = "1.1.0";

	private Harmony _harmony;

	private void Awake()
	{
		PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
		_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "bruce.comfy.valheim.aurality");
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}
}
public static class ZSFXUtils
{
	public static bool IsBuzzingSfx(ZSFX sfx)
	{
		if (((Object)sfx).name == "sfx_deathsquito_attack(Clone)")
		{
			return true;
		}
		if (sfx.m_audioClips == null || sfx.m_audioClips.Length == 0)
		{
			return false;
		}
		AudioClip[] audioClips = sfx.m_audioClips;
		foreach (AudioClip val in audioClips)
		{
			if (Object.op_Implicit((Object)(object)val) && ((Object)val).name == "Insect_Wasp_WingsLoop3")
			{
				return true;
			}
		}
		return false;
	}
}
[HarmonyPatch(typeof(ZSFX))]
internal static class ZSFXPatch
{
	[HarmonyPostfix]
	[HarmonyPatch("Awake")]
	private static void ZSFXAwakePostix(ZSFX __instance)
	{
		if (PluginConfig.IsModEnabled.Value && PluginConfig.IsBuzzingDisabled.Value && ZSFXUtils.IsBuzzingSfx(__instance))
		{
			__instance.m_audioSource.mute = true;
		}
	}
}
public static class PluginConfig
{
	public static ConfigEntry<bool> IsModEnabled { get; private set; }

	public static ConfigEntry<bool> IsBuzzingDisabled { get; private set; }

	public static void BindConfig(ConfigFile config)
	{
		IsModEnabled = config.Bind<bool>("_Global", "isModEnabled", true, "Globally enable or disable this mod.");
		IsBuzzingDisabled = config.Bind<bool>("audioDisables", "buzzingDisabled", true, "Removes SFX from deathsquitoes for those sensitive to buzzing.");
	}
}