Decompiled source of FartDeath v1.1.1

FartModBase.dll

Decompiled 10 months ago
using System.CodeDom.Compiler;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FartModBase")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FartModBase")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("842f3ddc-4604-4176-b3eb-11656f468b05")]
[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 FartModBase
{
	[BepInPlugin("com.fartmodbase", "FartModBase", "0.0.1.0")]
	public class FartModBase : BaseUnityPlugin
	{
		private const string modGUID = "com.fartmodbase";

		private const string modName = "FartModBase";

		private const string modVersion = "0.0.1.0";

		private readonly Harmony harmony = new Harmony("com.fartmodbase");

		public static FartModBase Instance;

		public ManualLogSource mls;

		public AudioClip fartsound;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("com.fartmodbase");
			mls.LogInfo((object)"FartModBase loaded!");
			harmony.PatchAll();
			fartsound = GetAudioClip();
		}

		public static AudioClip GetAudioClip()
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Invalid comparison between Unknown and I4
			AudioClip val = null;
			DirectoryInfo directoryInfo = new DirectoryInfo(Assembly.GetExecutingAssembly().Location);
			string fullName = directoryInfo.FullName;
			fullName = Path.GetDirectoryName(fullName);
			Instance.mls.LogError((object)("Directory:    " + fullName));
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(fullName + "\\fart.wav", (AudioType)20);
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
				Instance.mls.LogInfo((object)"Waiting for request to be done");
			}
			if (audioClip.error != null)
			{
				Instance.mls.LogError((object)"Error happened while importing sound.");
				Instance.mls.LogError((object)audioClip.error);
			}
			val = DownloadHandlerAudioClip.GetContent(audioClip);
			if (Object.op_Implicit((Object)(object)val) && (int)val.loadState == 2)
			{
				Instance.mls.LogInfo((object)"Sound loaded");
			}
			if ((Object)(object)val == (Object)null)
			{
				Instance.mls.LogError((object)"fartsound is null");
			}
			return val;
		}
	}
}
namespace FartModBase.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

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

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

		internal static byte[] fart
		{
			get
			{
				object @object = ResourceManager.GetObject("fart", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace FartModBase.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void _awake()
		{
			FartModBase.Instance.mls.LogInfo((object)"PlayerControllerB awake");
		}

		[HarmonyPatch("KillPlayerClientRpc")]
		[HarmonyPostfix]
		private static void _killPlayer()
		{
			FartModBase.Instance.mls.LogInfo((object)"Player killed");
			AudioClip fartsound = FartModBase.Instance.fartsound;
			if ((Object)(object)fartsound == (Object)null)
			{
				FartModBase.Instance.mls.LogError((object)"Fartsound is nukk\nTrying to import it again...");
				fartsound = FartModBase.GetAudioClip();
				if ((Object)(object)fartsound == (Object)null)
				{
					FartModBase.Instance.mls.LogError((object)"Fartsound is still null\nAborting");
					return;
				}
			}
			Task task = PlaySound(FartModBase.Instance.fartsound);
		}

		private static async Task<Task> PlaySound(AudioClip clip)
		{
			if ((Object)(object)clip == (Object)null)
			{
				return Task.CompletedTask;
			}
			GameObject audioobject = new GameObject("FartSound");
			AudioSource audioSource = audioobject.AddComponent<AudioSource>();
			audioSource.clip = clip;
			audioSource.volume = 1f;
			audioSource.pitch = 1f;
			audioSource.loop = false;
			audioSource.Play();
			await Task.Delay(6000);
			Object.Destroy((Object)(object)audioobject);
			return Task.CompletedTask;
		}
	}
}