Decompiled source of DeathCounter v0.1.0

Tomatobird.DeathCounter.dll

Decompiled a day ago
using System;
using System.Diagnostics;
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 TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tomatobird.DeathCounter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+c12b9e5f06778c493d16a7d77581b179da023405")]
[assembly: AssemblyProduct("LCDeathCounter")]
[assembly: AssemblyTitle("Tomatobird.DeathCounter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.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 LCDeathCounter
{
	public class DeathCounter : MonoBehaviour
	{
		public static int deathcount;
	}
	[BepInPlugin("Tomatobird.DeathCounter", "LCDeathCounter", "0.1.0")]
	public class LCDeathCounter : BaseUnityPlugin
	{
		public static LCDeathCounter Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			Logger.LogInfo((object)"Tomatobird.DeathCounter v0.1.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("Tomatobird.DeathCounter");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Tomatobird.DeathCounter";

		public const string PLUGIN_NAME = "LCDeathCounter";

		public const string PLUGIN_VERSION = "0.1.0";
	}
}
namespace LCDeathCounter.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class PlayerControllerPatcher
	{
		[HarmonyPatch("KillPlayer")]
		[HarmonyPostfix]
		internal static void KillPlayerPatch()
		{
			DeathCounter.deathcount++;
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager))]
	internal class QuickMenuPatcher
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		internal static void QuickMenuStartPatch(QuickMenuManager __instance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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)
			GameObject val = new GameObject("DeathCounterText");
			val.transform.parent = __instance.menuContainer.transform;
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((Graphic)val2).color = new Color(1f, 0.5647f, 0f, 1f);
			((TMP_Text)val2).alignment = (TextAlignmentOptions)1026;
			((Transform)((TMP_Text)val2).rectTransform).localScale = Vector3.one;
			((TMP_Text)val2).rectTransform.anchoredPosition = new Vector2(0f, 30f);
			((TMP_Text)val2).rectTransform.anchoredPosition3D = new Vector3(0f, 0f, 0f);
			((TMP_Text)val2).rectTransform.anchorMax = new Vector2(1f, 0f);
			((TMP_Text)val2).rectTransform.anchorMin = new Vector2(0f, 0f);
			((TMP_Text)val2).rectTransform.offsetMax = new Vector2(0f, 4f);
			((TMP_Text)val2).rectTransform.offsetMin = new Vector2(0f, 4f);
			((TMP_Text)val2).rectTransform.sizeDelta = new Vector2(0f, 0f);
			((TMP_Text)val2).fontSize = 24f;
			((TMP_Text)val2).text = "Deaths: 0";
		}

		[HarmonyPatch("OpenQuickMenu")]
		[HarmonyPostfix]
		internal static void QuickMenuEnablePatch(QuickMenuManager __instance)
		{
			Transform obj = __instance.menuContainer.transform.Find("DeathCounterText");
			TextMeshProUGUI val = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
			if ((Object)(object)val != (Object)null)
			{
				((TMP_Text)val).text = $"Deaths: {DeathCounter.deathcount}";
			}
		}
	}
}