Decompiled source of FartMod v1.0.0

FartMod.dll

Decompiled a year ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using FartMod.Patches;
using GameNetcodeStuff;
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("FartMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FartMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5db6c55b-9190-4977-8b0c-63d618fd3a17")]
[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 FartMod
{
	[BepInPlugin("Poseidon.FartMod", "Fart Mod", "1.0.0")]
	public class FartModBase : BaseUnityPlugin
	{
		private const string modGUID = "Poseidon.FartMod";

		private const string modName = "Fart Mod";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Poseidon.FartMod");

		private static FartModBase Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Poseidon.FartMod");
			mls.LogInfo((object)"TheCake Fart Mod Loaded");
			harmony.PatchAll(typeof(FartModBase));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(WhoopieCushionItemPatch));
		}
	}
}
namespace FartMod.Patches
{
	[HarmonyPatch(typeof(WhoopieCushionItem), "Fart")]
	public class WhoopieCushionItemPatch
	{
		public static AudioSource whoopieCushionAudio;

		public static AudioClip[] fartAudios;

		public static int timesPlayingInOneSpot;

		private Vector3 fartPosition;

		[HarmonyPatch("__initializeVariables")]
		[HarmonyPrefix]
		public static void initializePatch(ref AudioClip[] ___fartAudios)
		{
			fartAudios = ___fartAudios;
		}

		[HarmonyPatch("Fart")]
		[HarmonyPrefix]
		public static void FartPatch(ref AudioClip[] ___fartAudios, ref int ___timesPlayingInOneSpot, ref Vector3 ___lastPositionAtFart)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			timesPlayingInOneSpot = ___timesPlayingInOneSpot;
			Vector3 val = ___lastPositionAtFart;
			Debug.Log((object)("Whoopie Fart: " + ((object)(Vector3)(ref val)).ToString()));
		}

		public static void Fart(AudioSource playerLocation, bool isInShipRoom, Vector3 lastPositionAtFart)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (fartAudios != null)
			{
				Vector3 val = lastPositionAtFart;
				Debug.Log((object)("Player Fart: " + ((object)(Vector3)(ref val)).ToString()));
				RoundManager.Instance.PlayAudibleNoise(lastPositionAtFart, 8f, 0.8f, timesPlayingInOneSpot, isInShipRoom && StartOfRound.Instance.hangarDoorsClosed, 101158);
				RoundManager.PlayRandomClip(playerLocation, fartAudios, true, 1f, -1);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void infiniteSprintPatch(ref bool ___isCrouching, ref float ___jumpForce, ref bool ___isJumping)
		{
			if (!___isCrouching)
			{
			}
		}

		[HarmonyPatch("Crouch")]
		[HarmonyPrefix]
		private static void CrouchPatch(ref float ___sprintMeter, ref AudioSource ___movementAudio, ref bool ___isCrouching, ref bool ___isInHangarShipRoom, ref Vector3 ___serverPlayerPosition, ref Vector3 ___oldPlayerPosition)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Vector3 lastPositionAtFart = ___oldPlayerPosition;
			if (!___isCrouching)
			{
				WhoopieCushionItemPatch.Fart(___movementAudio, ___isInHangarShipRoom, lastPositionAtFart);
			}
		}

		[HarmonyPatch("Jump_performed")]
		[HarmonyPrefix]
		private static void jumpingPatch(ref bool ___isCrouching, ref float ___jumpForce)
		{
			Debug.Log((object)"Jump");
			if (___isCrouching)
			{
				___isCrouching = false;
				___jumpForce = 100f;
			}
		}
	}
}