Decompiled source of RipAndTearShotgun v1.0.0

Rip and Tear Shotgun.dll

Decompiled 7 months ago
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
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("Rip and Tear Shotgun")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Rip and Tear Shotgun")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("71b6b5cb-dd25-449e-9c4f-c122efb2eeac")]
[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 Rip_and_Tear_Shotgun;

[BepInPlugin("nihl.RipAndTearShotgun", "Rip & Tear Shotgun", "1.0.0.0")]
public class ShotgunBase : BaseUnityPlugin
{
	private const string modGUID = "nihl.RipAndTearShotgun";

	private const string modName = "Rip & Tear Shotgun";

	private const string modVersion = "1.0.0.0";

	private readonly Harmony harmony = new Harmony("nihl.RipAndTearShotgun");

	private static ShotgunBase instance;

	internal ManualLogSource MLS;

	public static AssetBundle MainAssets;

	public static AudioClip doomMusic;

	private void Awake()
	{
		if ((Object)(object)instance == (Object)null)
		{
			instance = this;
		}
		MLS = Logger.CreateLogSource("nihl.RipAndTearShotgun");
		if ((Object)(object)MainAssets == (Object)null)
		{
			MainAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "doomMusic"));
		}
		doomMusic = MainAssets.LoadAsset<AudioClip>("Assets/doomMusic.mp3");
		if ((Object)(object)doomMusic != (Object)null)
		{
			MLS.LogInfo((object)"Audio Loaded!");
		}
		MLS.LogInfo((object)"Ready to Rip & Tear!");
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "nihl.RipAndTearShotgun");
	}
}
[HarmonyPatch(typeof(ShotgunItem))]
internal class ShotgunPatch
{
	[HarmonyPatch("EquipItem")]
	[HarmonyPostfix]
	public static void EquipAudioPatch(ShotgunItem __instance)
	{
		bool flag = false;
		AudioSource val = ((Component)__instance).gameObject.AddComponent<AudioSource>();
		val.spatialBlend = 1f;
		val.clip = ShotgunBase.doomMusic;
		val.loop = true;
		if (!flag)
		{
			val.Play();
			flag = true;
		}
		else
		{
			val.UnPause();
		}
	}

	[HarmonyPatch("StopUsingGun")]
	[HarmonyPostfix]
	public static void StopUsingGunAudioPatch(ShotgunItem __instance)
	{
		foreach (AudioSource item in from a in ((Component)__instance).gameObject.GetComponents<AudioSource>()
			where (Object)(object)a.clip == (Object)(object)ShotgunBase.doomMusic
			select a)
		{
			item.Pause();
		}
	}
}