Decompiled source of YouWereSlainBy v1.0.1

Mods/YouWereSlainBy.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using HarmonyLib;
using Il2CppSLZ.Marrow;
using LabFusion.Player;
using LabFusion.Utilities;
using MelonLoader;
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(DeathMessageMod), "Death Messages", "1.0.0", "KogChoy", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: AssemblyTitle("YouWereSlainBy")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("YouWereSlainBy")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0d50731d-66ef-435a-9d8c-0b8aaa3a2688")]
[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")]
public class DeathMessageMod : MelonMod
{
	[HarmonyPatch(typeof(LocalRagdoll), "Knockout", new Type[]
	{
		typeof(float),
		typeof(bool)
	})]
	private static class KnockoutPatch
	{
		private static void Prefix()
		{
			if (Enabled && !_knockoutMessageShown && !LocalRagdoll.KnockedOut)
			{
				_knockoutMessageShown = true;
				OnPlayerKnockout();
				MelonCoroutines.Start(ClearKnockoutMessageDebounce());
			}
		}
	}

	public static bool Enabled = true;

	private static bool _knockoutMessageShown;

	private const float KnockoutMessageDebounce = 0.1f;

	public static readonly List<string> DeathMessages = new List<string>
	{
		"You were killed by {0}", "{0} annihilated you", "{0} humbled you", "{0} did a funny", "\"git gud\" - {0}", "You were slain by {0}", "You just got {0}'d", "Nice one {0}! sorry did i say that out loud?", "Whats a {0}?", "Random kid -> {0}",
		"Kill {0}, you know you want to.", "KogChoy sends his regards. but {0} did it.", "Thanks {0}, real funny", "{0} DID IT {0} DID IT {0} DID IT", " This is the part where {0} kills you!", "Zombine. Get it? - {0}", "What? It was obvious. - {0}"
	};

	public static readonly List<string> KnockoutMessages = new List<string> { "You better scramble like an egg before you get folded like an omelette. - {0}", "{0} sent you to sleep", "You got folded by {0}", "{0} put you on a timeout", "Night night. Courtesy of {0}" };

	private Harmony _harmony;

	public override void OnInitializeMelon()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Expected O, but got Unknown
		Page val = Page.Root.CreatePage("Death Messages", Color.red, 0, true);
		val.CreateBool("Enabled", Color.white, Enabled, (Action<bool>)delegate(bool value)
		{
			Enabled = value;
		});
		Hooking.OnPlayerDeath += OnPlayerDeath;
		_harmony = new Harmony("KogChoy.DeathMessages");
		_harmony.PatchAll();
		MelonLogger.Msg("[Death Messages] Loaded.");
	}

	private static void OnPlayerDeath(RigManager rig)
	{
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Expected O, but got Unknown
		if (!Enabled || (Object)(object)Player.RigManager == (Object)null || (Object)(object)rig != (Object)(object)Player.RigManager)
		{
			return;
		}
		try
		{
			PlayerID val = default(PlayerID);
			if (FusionPlayer.TryGetLastAttacker(ref val) && val != null && val.IsValid && !val.IsMe)
			{
				string text = val.Metadata.Nickname.GetValueOrEmpty();
				if (string.IsNullOrEmpty(text))
				{
					text = val.Metadata.Username.GetValueOrEmpty();
				}
				if (string.IsNullOrEmpty(text))
				{
					text = "Unknown";
				}
				if (DeathMessages.Count != 0)
				{
					int index = Random.Range(0, DeathMessages.Count);
					string text2 = string.Format(DeathMessages[index], text);
					Notifier.Send(new Notification
					{
						ShowTitleOnPopup = true,
						Title = NotificationText.op_Implicit("You Died"),
						Message = NotificationText.op_Implicit(text2),
						PopupLength = 4f,
						Type = (NotificationType)0
					});
					MelonLogger.Msg("[Death Messages] " + text2);
				}
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[Death Messages] Failed to display death message: " + ex);
		}
	}

	private static void OnPlayerKnockout()
	{
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Expected O, but got Unknown
		try
		{
			PlayerID val = default(PlayerID);
			if (FusionPlayer.TryGetLastAttacker(ref val) && val != null && val.IsValid && !val.IsMe)
			{
				string text = val.Metadata.Nickname.GetValueOrEmpty();
				if (string.IsNullOrEmpty(text))
				{
					text = val.Metadata.Username.GetValueOrEmpty();
				}
				if (string.IsNullOrEmpty(text))
				{
					text = "Unknown";
				}
				if (KnockoutMessages.Count != 0)
				{
					int index = Random.Range(0, KnockoutMessages.Count);
					string text2 = string.Format(KnockoutMessages[index], text);
					Notifier.Send(new Notification
					{
						ShowTitleOnPopup = true,
						Title = NotificationText.op_Implicit("Knocked Out"),
						Message = NotificationText.op_Implicit(text2),
						PopupLength = 4f,
						Type = (NotificationType)0
					});
					MelonLogger.Msg("[Death Messages] " + text2);
				}
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[Death Messages] Failed to display knockout message: " + ex);
		}
	}

	private static IEnumerator ClearKnockoutMessageDebounce()
	{
		yield return (object)new WaitForSecondsRealtime(0.1f);
		_knockoutMessageShown = false;
	}

	public override void OnDeinitializeMelon()
	{
		Hooking.OnPlayerDeath -= OnPlayerDeath;
		if (_harmony != null)
		{
			_harmony.UnpatchSelf();
			_harmony = null;
		}
		_knockoutMessageShown = false;
	}
}