Decompiled source of PipedContent v1.0.3

PipedContent.dll

Decompiled 5 months ago
using System.Collections.Generic;
using System.Diagnostics;
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 MetalPipe.Patches;
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("MetalPipeMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MetalPipeMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("82b45e7a-0fd1-46b7-a3fe-268573a816d8")]
[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 MetalPipe
{
	[BepInPlugin("Wolfifurr.PipedContent", "PipedContent By Wolfifurr", "1.0.0")]
	[BepInProcess("Content Warning.exe")]
	public class MetalPipe : BaseUnityPlugin
	{
		private const string modGUID = "Wolfifurr.PipedContent";

		private const string modName = "PipedContent By Wolfifurr";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Wolfifurr.PipedContent");

		private static MetalPipe Instance;

		internal static ManualLogSource mls;

		internal static List<AudioClip> SFX;

		internal static AssetBundle Bundle;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Wolfifurr.PipedContent");
			mls.LogInfo((object)"Test mod has awaken");
			SFX = new List<AudioClip>();
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("PipedContent.dll".ToCharArray());
			mls.LogMessage((object)location);
			Bundle = AssetBundle.LoadFromFile(location + "pipe");
			if ((Object)(object)Bundle != (Object)null)
			{
				mls.LogMessage((object)"Asset bundle success");
				SFX = Bundle.LoadAllAssets<AudioClip>().ToList();
			}
			else
			{
				mls.LogError((object)"Failed to load asset bundle");
				mls.LogMessage((object)((Object)SFX[0]).name);
			}
			harmony.PatchAll(typeof(MetalPipe));
			harmony.PatchAll(typeof(PhysicsSoundPatches));
		}
	}
}
namespace MetalPipe.Patches
{
	[HarmonyPatch(typeof(PhysicsSound))]
	internal class PhysicsSoundPatches
	{
		[HarmonyPatch(typeof(PhysicsSound), "OnCollisionEnter")]
		[HarmonyPrefix]
		private static void OverrideAudioPatch(ref SFX_Instance[] ___impactSounds)
		{
			List<SFX_Instance> sounds = ___impactSounds.ToList();
			SFX_Instance tempSfx = ___impactSounds[0];
			MetalPipe.SFX.ForEach(delegate(AudioClip sound)
			{
				SFX_Instance val = Object.Instantiate<SFX_Instance>(tempSfx);
				((Object)val).name = ((Object)sound).name;
				val.clips = (AudioClip[])(object)new AudioClip[1] { sound };
				sounds.Add(val);
			});
			___impactSounds = sounds.ToArray();
		}
	}
}