Decompiled source of BidenSoda v1.1.3

BidenSoda.dll

Decompiled 3 months ago
using System;
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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("Spantle")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Makes Joe Biden yell SODA when you hold a red soda can scrap item.")]
[assembly: AssemblyFileVersion("1.1.3.0")]
[assembly: AssemblyInformationalVersion("1.1.3")]
[assembly: AssemblyProduct("BidenSoda")]
[assembly: AssemblyTitle("Spantle.BidenSoda")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 BidenSoda
{
	[BepInPlugin("Spantle.BidenSoda", "BidenSoda", "1.1.3")]
	public class BidenSodaPlugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("Spantle.BidenSoda");

		public static AudioClip soda;

		public static ManualLogSource logger;

		public static ConfigEntry<int> volume;

		public static ConfigEntry<bool> canBeHeardByEnemies;

		public static ConfigEntry<bool> cancellable;

		private void Awake()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			logger = ((BaseUnityPlugin)this).Logger;
			volume = ((BaseUnityPlugin)this).Config.Bind<int>("Client-side settings", "Volume", 100, new ConfigDescription("The volume percentage that the sound will play at. This only affects your side, and does not affect enemy AI.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			cancellable = ((BaseUnityPlugin)this).Config.Bind<bool>("Client-side settings", "Cancellable", true, "Whether switching to another item will stop the sound. If this is false, the sound can be spammed. This only affects your side, and does not affect enemy AI.");
			canBeHeardByEnemies = ((BaseUnityPlugin)this).Config.Bind<bool>("Server-side settings", "CanBeHeardByEnemies", true, "Whether enemy AI will be able to hear the sound. The host's value of this setting determines this for all players.");
			soda = AssetBundle.LoadFromMemory(Resource.soda).LoadAsset<AudioClip>("Assets/soda.wav");
			harmony.PatchAll(typeof(GrabbableObject_Patch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"SODAAAAAAAAAAAA!!! (Spantle.BidenSoda plugin has loaded)");
		}
	}
	[HarmonyPatch(typeof(GrabbableObject))]
	public static class GrabbableObject_Patch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(GrabbableObject), "EquipItem")]
		private static void EquipItem(GrabbableObject __instance)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)__instance).name == "RedSodaCan" || ((Object)__instance).name == "RedSodaCan(Clone)")
			{
				BidenSodaPlugin.logger.LogInfo((object)"SODA EQUIPPED");
				AudioSource component = ((Component)__instance).gameObject.GetComponent<AudioSource>();
				component.PlayOneShot(BidenSodaPlugin.soda, (float)BidenSodaPlugin.volume.Value / 200f);
				WalkieTalkie.TransmitOneShotAudio(component, BidenSodaPlugin.soda, 1f);
				if (BidenSodaPlugin.canBeHeardByEnemies.Value)
				{
					Object.FindObjectOfType<RoundManager>().PlayAudibleNoise(((Component)__instance).transform.position, 50f, 0.9f, 0, false, 0);
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GrabbableObject), "PocketItem")]
		private static void PocketItem(GrabbableObject __instance)
		{
			if (((Object)__instance).name == "RedSodaCan" || ((Object)__instance).name == "RedSodaCan(Clone)")
			{
				BidenSodaPlugin.logger.LogInfo((object)"soda pocketed :(");
				if (BidenSodaPlugin.cancellable.Value)
				{
					((Component)__instance).gameObject.GetComponent<AudioSource>().Stop();
				}
			}
		}
	}
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resource
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					resourceMan = new ResourceManager("BidenSoda.Resource", typeof(Resource).Assembly);
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] soda => (byte[])ResourceManager.GetObject("soda", resourceCulture);

		internal Resource()
		{
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Spantle.BidenSoda";

		public const string PLUGIN_NAME = "BidenSoda";

		public const string PLUGIN_VERSION = "1.1.3";
	}
}