Decompiled source of MagicMissile v1.0.2

Mods/MagicMissile.dll

Decompiled 5 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppRUMBLE.Players.Subsystems;
using Il2CppRUMBLE.Poses;
using MagicMissile;
using MelonLoader;
using MelonLoader.Utils;
using RumbleSoundsOnSceneChange;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Class1), "MagicMissile", "1.0.2", "PeppaStone", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 255, 51, 238)]
[assembly: AssemblyTitle("MagicMissile")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MagicMissile")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9ec5b13a-2bed-4e9f-b549-14beec88f2c4")]
[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 MagicMissile;

public class Class1 : MelonMod
{
	[HarmonyPatch(typeof(PlayerPoseSystem), "OnPoseSetCompleted", new Type[] { typeof(PoseSet) })]
	private static class PosePatch
	{
		private static void Postfix(PoseSet set)
		{
			MoveDetected(((Object)set).name);
		}
	}

	private static int fileAmount = 0;

	private static string[] moves = new string[4];

	private bool allFilesFound = false;

	public override void OnLateInitializeMelon()
	{
		while (!allFilesFound)
		{
			string text = "\\MagicMissile\\magicmissile" + fileAmount + ".mp3";
			if (File.Exists(MelonEnvironment.UserDataDirectory + text))
			{
				fileAmount++;
				continue;
			}
			MelonLogger.Msg("Magic Missile file amount: " + fileAmount);
			allFilesFound = true;
		}
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		moves = new string[moves.Length];
	}

	public static void MoveDetected(string name)
	{
		if (!(name == "SprintPoseSet"))
		{
			for (int i = 0; i < moves.Length - 1; i++)
			{
				moves[i] = moves[i + 1];
			}
			moves[3] = name;
			if (moves[0] == "PoseSetSpawnPillar" && moves[1] == "PoseSetUppercut" && moves[2] == "PoseSetKick" && moves[3] == "PoseSetStraight")
			{
				Random random = new Random();
				string text = "\\MagicMissile\\magicmissile" + random.Next(0, fileAmount) + ".mp3";
				AdditionalSounds.PlaySound(text);
			}
		}
	}
}