Decompiled source of CustomDeathMessage v1.0.0

CustomDeathMessage.dll

Decompiled 10 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using TMPro;
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("CustomDeathMessage")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CustomDeathMessage")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f048cd05-0a19-4f9e-8376-bc58c4518662")]
[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 CustomDeathMessage;

[BepInPlugin("Swaggies.CustomDeathMessage", "CustomDeathMessage", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private const string _guid = "Swaggies.CustomDeathMessage";

	private const string _name = "CustomDeathMessage";

	private const string _ver = "1.0.0";

	private readonly Harmony harmony = new Harmony("Swaggies.CustomDeathMessage");

	private static Plugin Instance;

	private static ManualLogSource logga;

	public static ConfigEntry<string> message;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		logga = Logger.CreateLogSource("Swaggies.CustomDeathMessage");
		harmony.PatchAll(typeof(Plugin));
		logga.LogInfo((object)"CustomDeathMessage up and running.");
		message = ((BaseUnityPlugin)this).Config.Bind<string>("General", "DeathMessage", "[LIFE SUPPORT: OFFLINE]", "What your custom death message should be. Default value is game's default death message.");
	}

	[HarmonyPatch(typeof(PlayerControllerB), "KillPlayer")]
	[HarmonyPrefix]
	private static void DeathPatch()
	{
		GameObject val = GameObject.Find("Systems/UI/Canvas/DeathScreen/GameOverText");
		TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
		if (message.Value == "")
		{
			((TMP_Text)component).text = "[LIFE SUPPORT: OFFLINE]";
		}
		else
		{
			((TMP_Text)component).text = message.Value;
		}
	}
}