using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using DeathAnnounce.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DeathAnnounce")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DeathAnnounce")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("978a7ebf-8d6a-484f-aa5c-30fcc0cff37b")]
[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 DeathAnnounce
{
[BepInPlugin("DeathAnnounce", "WolfenGamesMods", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("DeathAnnounce");
private static Plugin PluginInstance;
internal static ManualLogSource Log;
public static Plugin GetInstance()
{
return PluginInstance;
}
private void Awake()
{
if ((Object)(object)PluginInstance == (Object)null)
{
PluginInstance = this;
}
Log = Logger.CreateLogSource("DeathAnnounce");
Log.LogInfo((object)"WolfenGamesMods <DeathAnnounce> loaded");
harmony.PatchAll(typeof(Plugin));
harmony.PatchAll(typeof(PlayerControllerBPatch));
}
}
}
namespace DeathAnnounce.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch
{
[HarmonyPatch("KillPlayer")]
[HarmonyPostfix]
private static void AnnounceDeath(PlayerControllerB __instance)
{
if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerDead)
{
string text = __instance.playerUsername + " has died to <color=#00ff00ff>" + ((object)(CauseOfDeath)(ref __instance.causeOfDeath)).ToString() + "</color>!";
text = "<color=#ff0000ff>" + text + "</color>";
HUDManager.Instance.AddTextToChatOnServer(text, -1);
}
}
}
}