Decompiled source of ConfettiDeath v1.0.0

ConfettiDeath.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using ConfettiDeath;
using HBMF.AudioImporter;
using HBMF.ModMenu;
using HBMF.Utilities;
using HarmonyLib;
using Il2Cpp;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using MelonLoader.Preferences;
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(Mod), "ConfettiDeath", "1.0.0", "korbykob", null)]
[assembly: MelonGame("GexagonVR", "Hard Bullet")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ConfettiDeath")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ConfettiDeath")]
[assembly: AssemblyTitle("ConfettiDeath")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ConfettiDeath;

[HarmonyPatch]
public class Mod : MelonMod
{
	private static AudioClip clip;

	private static Il2CppAssetBundle assets;

	private static readonly List<HealthContainer> ignore = new List<HealthContainer>();

	private static MelonPreferences_Entry<bool> enabled;

	public override void OnInitializeMelon()
	{
		assets = Il2CppAssetBundleManager.LoadFromMemory(Il2CppStructArray<byte>.op_Implicit(Utils.GetResource(Assembly.GetExecutingAssembly(), "ConfettiDeath.confettideath.assets")));
		clip = Audio.Import(Utils.GetResource(Assembly.GetExecutingAssembly(), "ConfettiDeath.Death.wav"));
		enabled = MelonPreferences.CreateCategory("ConfettiDeath").CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		Menu.CreateCategory("CONFETTI DEATH").CreateBool("ENABLE", enabled.Value, (Action<bool>)delegate(bool value)
		{
			enabled.Value = value;
		});
	}

	[HarmonyPatch(typeof(HealthContainer), "OnDamageTakenReact", new Type[]
	{
		typeof(Damage),
		typeof(DamageSender)
	})]
	[HarmonyPostfix]
	public static void Death(HealthContainer __instance)
	{
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Expected O, but got Unknown
		if (!ignore.Contains(__instance) && __instance._currentHealthCount <= 0f)
		{
			ignore.Add(__instance);
			if (enabled.Value)
			{
				AudioSource val = Object.Instantiate<GameObject>(assets.LoadAsset<GameObject>("Confetti.prefab"), ((Component)__instance).transform.parent.parent.parent.Find("[BODY]/PhysicalBones/spine_02").position, Quaternion.identity).AddComponent<AudioSource>();
				val.clip = clip;
				val.Play(new PlaySettings
				{
					Volume = 3f
				});
			}
		}
	}

	[HarmonyPatch(typeof(HealthContainer), "OnEnable")]
	[HarmonyPostfix]
	public static void Restore(HealthContainer __instance)
	{
		if (ignore.Contains(__instance))
		{
			ignore.Remove(__instance);
		}
	}
}