Decompiled source of Death Messages v0.0.2

plugins/Nyan.LC.DeathMessages.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Nyan.LC.DeathMessages")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("This is a description")]
[assembly: AssemblyFileVersion("0.0.2.0")]
[assembly: AssemblyInformationalVersion("0.0.2+cd928ea4d2517f38e38897cb11c63d7e0817c4ba")]
[assembly: AssemblyProduct("Nyan.LC.DeathMessages")]
[assembly: AssemblyTitle("Nyan.LC.DeathMessages")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LCDeathMessages
{
	public static class DeathMessages
	{
		private static List<string> Unknown { get; } = new List<string>(10) { "$$ was slain.", "$$'s soul left their body.", "$$ was murdered.", "$$ passed.", "$$ heart stopped.", "$$ went offline.", "$$'s life support was unplugged.", "$$ turned blue.", "$$'s incompetence was put on display.", "$$ expired." };


		private static List<string> Bludgeoning { get; } = new List<string>(8) { "$$ experienced skull crushing defeat.", "$$'s bones were shattered.", "$$ was whacked in the head.", "$$ was bludgeoned out of their misery.", "$$ was on the wrong end of an object.", "$$ found themselves before a hard place.", "$$'s neck was pulverised.", "$$ suffered a fatal blow." };


		private static List<string> Gravity { get; } = new List<string>(9) { "$$ didn't bounce.", "$$ tripped.", "$$ discovered gravity.", "$$ thought they could fly.", "$$ left a small crater.", "$$ left an average crater.", "$$ left a massive crater.", "$$ forgot to walk on solid ground.", "$$ splattered." };


		private static List<string> Blast { get; } = new List<string>(8) { "$$ went boom!", "$$ went everywhere.", "$$ went out with a bang.", "$$ was blown to smithereens.", "$$ detonated.", "$$ became a cloud of dust.", "$$ was ripped piece by piece in an explosion.", "$$ was reduced to atoms." };


		private static List<string> Strangulation { get; } = new List<string>(6) { "$$'s neck was tied up with a nice bow.", "$$ was choked out.", "$$ was throttled.", "$$ had their breath taken away.", "$$ lost their breathing privileges.", "$$'s neck was held in high regard." };


		private static List<string> Suffocation { get; } = new List<string>(9) { "$$ couldn't breathe.", "$$ ran out of air.", "$$'s lungs were empty.", "$$ took their last breath.", "$$ suffocated in the dark", "$$'s last breath was wasted.", "$$ asphyxiated.", "$$ experienced hypoxia.", "$$'s breath left them." };


		private static List<string> Mauling => new List<string>(10)
		{
			"$$ was slain.",
			"$$ was eviscerated.",
			"$$ was murdered.",
			"$$'s face was torn off.",
			"$$'s entrails were ripped out.",
			"$$ got massacred.",
			"$$ was torn in half.",
			"$$'s body was mangled.",
			"$$'s vital organs were ruptured.",
			"$$ was removed from " + ((Object)Plugin.RoundData.currentLevel).name + "."
		};

		private static List<string> Gunshots { get; } = new List<string>(9) { "$$ was given some extra holes.", "$$ became partly see-through.", "$$ had lead forcefully implanted.", "$$ was target practice.", "$$ didn't hear the gunshots.", "$$ wasn't Neo.", "$$ found out that bullets hurt.", "$$ was shot down.", "$$ walked into a training range." };


		private static List<string> Crushing { get; } = new List<string>(6) { "$$ found crushing defeat.", "$$ couldn't handle the pressure.", "$$'s life was crushed.", "$$ found too much weight upon them.", "$$ suffered under pressure.", "$$ discovered that gravity doesn't just make them fall." };


		private static List<string> Drowning { get; } = new List<string>(7) { "$$ is shark food.", "$$ is sleeping with the fish.", "$$ drowned.", "$$ tried to drink a lake.", "$$ discovered Atlantis.", "$$ drank water the wrong way.", "$$ didn't have gills." };


		private static List<string> Abandoned { get; } = new List<string>(6) { "$$ was left behind.", "$$ was forgotten.", "$$ wasn't important.", "$$ decided to stay home.", "$$ lost track of time.", "$$ forgot the last part of the mission." };


		private static List<string> Electrocution { get; } = new List<string>(8) { "$$ couldn't figure out watt happened.", "$$ couldn't contain the watts.", "$$ was turned into a battery.", "$$ became a lightning rod.", "$$'s positive life force became negative.", "$$ was zapped.", "$$ touched the wrong wire.", "$$ is no longer live." };


		public static string Get(CauseOfDeath cause, string username)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected I4, but got Unknown
			Random random = new Random();
			return ((int)cause switch
			{
				0 => Unknown[random.Next(0, Unknown.Count)], 
				1 => Bludgeoning[random.Next(0, Bludgeoning.Count)], 
				2 => Gravity[random.Next(0, Gravity.Count)], 
				3 => Blast[random.Next(0, Blast.Count)], 
				4 => Strangulation[random.Next(0, Strangulation.Count)], 
				5 => Suffocation[random.Next(0, Suffocation.Count)], 
				6 => Mauling[random.Next(0, Mauling.Count)], 
				7 => Gunshots[random.Next(0, Gunshots.Count)], 
				8 => Crushing[random.Next(0, Crushing.Count)], 
				9 => Drowning[random.Next(0, Drowning.Count)], 
				10 => Abandoned[random.Next(0, Abandoned.Count)], 
				11 => Electrocution[random.Next(0, Electrocution.Count)], 
				_ => string.Empty, 
			}).Replace("$$", username);
		}
	}
	[BepInPlugin("Nyan.LC.DeathMessages", "Nyan.LC.DeathMessages", "0.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin? Instance;

		private readonly Harmony _harmony = new Harmony("Nyan.LC.DeathMessages");

		public static StartOfRound RoundData => StartOfRound.Instance;

		public static ManualLogSource? Log
		{
			[return: NotNull]
			get;
			private set; }

		private void Awake()
		{
			if (Instance == null)
			{
				Instance = this;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Started Death Messages Plugin Successfully.");
			_harmony.PatchAll(typeof(Plugin));
			Log = ((BaseUnityPlugin)this).Logger;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
		[HarmonyPostfix]
		private static void SendDeathMessage(PlayerControllerB __instance)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.isPlayerDead)
			{
				string text = DeathMessages.Get(__instance.causeOfDeath, __instance.playerUsername);
				string text2 = "<color=#E11919>" + text + "</color>";
				HUDManager.Instance.AddTextToChatOnServer(text2, -1);
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Nyan.LC.DeathMessages";

		public const string PLUGIN_NAME = "Nyan.LC.DeathMessages";

		public const string PLUGIN_VERSION = "0.0.2";
	}
}