Decompiled source of MoMod v1.1.0

BepInEx/plugins/MoMod.dll

Decompiled 5 months 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 GameNetcodeStuff;
using HarmonyLib;
using MoMod.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("MoMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoMod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("746b7efb-d823-42c7-b609-80b4bdea379f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoMod
{
	[BepInPlugin("Ceribia.MoMod", "Mo Mod", "1.0.0.0")]
	public class MoModBase : BaseUnityPlugin
	{
		private const string modGUID = "Ceribia.MoMod";

		private const string modName = "Mo Mod";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("Ceribia.MoMod");

		private static MoModBase Instance;

		internal ManualLogSource mls;

		internal static AudioClip moSFX;

		internal static AudioClip moeMoeMoeSFX;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Ceribia.MoMod");
			mls.LogInfo((object)"Mo Mo");
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			string text = location.TrimEnd("MoMod.dll".ToCharArray());
			string text2 = text + "moassets";
			AssetBundle val = AssetBundle.LoadFromFile(text2);
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load audio assets!");
				return;
			}
			moSFX = val.LoadAsset<AudioClip>("basicmo.mp3");
			moeMoeMoeSFX = val.LoadAsset<AudioClip>("moemoemoe.mp3");
			harmony.PatchAll(typeof(MoModBase));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
		}
	}
}
namespace MoMod.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("PlayFootstepSound")]
		[HarmonyPostfix]
		private static void PlayMoSound(ref AudioSource ___movementAudio)
		{
			if (Random.Range(0, 100) == 0)
			{
				AudioClip val = MoModBase.moSFX;
				if (Random.Range(0, 10) == 0)
				{
					val = MoModBase.moeMoeMoeSFX;
				}
				___movementAudio.pitch = Random.Range(0.93f, 1.07f);
				float num = Random.Range(0.93f, 1.07f);
				___movementAudio.PlayOneShot(val, num);
				WalkieTalkie.TransmitOneShotAudio(___movementAudio, val, num);
			}
		}
	}
}