Decompiled source of MuteEquipment Reupload v1.2.0

MuteEquipment.dll

Decompiled 16 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MuteEquipment")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0")]
[assembly: AssemblyProduct("MuteEquipment")]
[assembly: AssemblyTitle("MuteEquipment")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MuteEquipment
{
	[BepInPlugin("com.PicklePower01.MuteEquipment", "MuteEquipment", "1.2.0")]
	public class MuteEquipmentPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.PicklePower01.MuteEquipment";

		public const string PluginName = "MuteEquipment";

		public const string PluginVersion = "1.2.0";

		private ConfigEntry<bool> muteBlastShower;

		private ConfigEntry<bool> muteJadeElephant;

		private ConfigEntry<bool> muteDeusExMachina;

		private void Awake()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			muteBlastShower = ((BaseUnityPlugin)this).Config.Bind<bool>("Equipment To Mute", "Blast Shower(Backpack)", true, "Whether or not you want the blast shower equipment muted. WARNING: This removes both the audio and visual effects for this equipment!");
			muteJadeElephant = ((BaseUnityPlugin)this).Config.Bind<bool>("Equipment To Mute", "Jade Elephant (Armor buff)", true, "Whether or not you want the Jade Elephant equipment muted.");
			muteDeusExMachina = ((BaseUnityPlugin)this).Config.Bind<bool>("Equipment To Mute", "Deus Ex Machina (Parry)", true, "Whether or not you want the Deus Ex Machina equipment muted. WARNING: This removes both the audio and visual effects for this equipment!");
			Util.PlaySound_string_GameObject += new hook_PlaySound_string_GameObject(PlaySound);
			EquipmentSlot.FireCleanse += new hook_FireCleanse(FireCleanse);
			EffectManager.SpawnEffect_GameObject_EffectData_bool += new hook_SpawnEffect_GameObject_EffectData_bool(SpawnEffect);
		}

		private void OnDestroy()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			Util.PlaySound_string_GameObject -= new hook_PlaySound_string_GameObject(PlaySound);
			EquipmentSlot.FireCleanse -= new hook_FireCleanse(FireCleanse);
			EffectManager.SpawnEffect_GameObject_EffectData_bool -= new hook_SpawnEffect_GameObject_EffectData_bool(SpawnEffect);
		}

		private uint PlaySound(orig_PlaySound_string_GameObject orig, string soundName, GameObject gameObject)
		{
			if (soundName == "Play_UI_equipment_activate")
			{
				return 0u;
			}
			if (muteJadeElephant.Value && soundName == "Play_item_use_gainArmor")
			{
				return 0u;
			}
			return orig.Invoke(soundName, gameObject);
		}

		private bool FireCleanse(orig_FireCleanse orig, EquipmentSlot self)
		{
			if (!muteBlastShower.Value)
			{
				return orig.Invoke(self);
			}
			CleanseSystem.CleanseBodyServer(self.characterBody, true, false, true, true, true, true);
			return true;
		}

		private void SpawnEffect(orig_SpawnEffect_GameObject_EffectData_bool orig, GameObject effectPrefab, EffectData effectData, bool transmit)
		{
			if (!muteDeusExMachina.Value || !IsDeusExMachinaEffect(effectPrefab))
			{
				orig.Invoke(effectPrefab, effectData, transmit);
			}
		}

		private static bool IsDeusExMachinaEffect(GameObject effectPrefab)
		{
			if (!Object.op_Implicit((Object)(object)effectPrefab))
			{
				return false;
			}
			if (!((Object)(object)effectPrefab == (Object)(object)CommonAssets.parryActivateEffect))
			{
				return (Object)(object)effectPrefab == (Object)(object)CommonAssets.parryEffect;
			}
			return true;
		}
	}
}