using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace Abken.NineSols.DeathCounter; [BepInPlugin("abken.ninesols.deathcounter", "Death Counter", "1.0.0")] public sealed class DeathCounterPlugin : BaseUnityPlugin { public const string PluginGuid = "abken.ninesols.deathcounter"; public const string PluginName = "Death Counter"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry EnableDeathCounter; internal static ConfigEntry DeathCount; internal static ConfigEntry ShowDeathCounter; private Harmony _harmony; private GUIStyle _counterStyle; private void Awake() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; EnableDeathCounter = ((BaseUnityPlugin)this).Config.Bind("Death Counter", "Enable", true, "Count normal player deaths."); DeathCount = ((BaseUnityPlugin)this).Config.Bind("Death Counter", "Deaths", 0, "Current death count. You can edit or reset this from the config manager."); ShowDeathCounter = ((BaseUnityPlugin)this).Config.Bind("Death Counter", "ShowOnScreen", true, "Show the death counter on screen."); _harmony = new Harmony("abken.ninesols.deathcounter"); _harmony.PatchAll(); Log.LogInfo((object)"Death Counter 1.0.0 loaded."); } private void OnDestroy() { if (_harmony != null) { _harmony.UnpatchSelf(); } } private void OnGUI() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (EnableDeathCounter.Value && ShowDeathCounter.Value) { if (_counterStyle == null) { GUIStyle val = new GUIStyle(GUI.skin.label); val.fontSize = 22; val.fontStyle = (FontStyle)1; val.normal.textColor = Color.white; _counterStyle = val; } GUI.Label(new Rect(24f, 24f, 320f, 40f), "Deaths: " + DeathCount.Value, _counterStyle); } } } [HarmonyPatch(typeof(PlayerDeadState))] internal static class PlayerDeadStatePatch { [HarmonyPostfix] [HarmonyPatch("NormalDeadHandle")] private static void CountNormalDeath() { if (DeathCounterPlugin.EnableDeathCounter.Value) { ConfigEntry deathCount = DeathCounterPlugin.DeathCount; deathCount.Value += 1; DeathCounterPlugin.Log.LogInfo((object)("Death counter: " + DeathCounterPlugin.DeathCount.Value)); } } }