Decompiled source of BossKillTimer v2.0.1

BossKillTimer.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using On.RoR2;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[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("BossKillTimer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f8cde8594e1b96dbb79201879ccf9be4aff6b2f7")]
[assembly: AssemblyProduct("BossKillTimer")]
[assembly: AssemblyTitle("BossKillTimer")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BossKillTimer
{
	[BepInPlugin("com.Moffein.BossKillTimer", "Boss Kill Timer", "2.0.1")]
	public class BossKillTimer : BaseUnityPlugin
	{
		public static bool teleOnly = false;

		public static float instakillThreshold = 0f;

		private static Dictionary<CharacterBody, float> dict = new Dictionary<CharacterBody, float>();

		public void Awake()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			teleOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Teleporter Bosses Only", false, "Only show kill times when bosses with red healthbars die.").Value;
			instakillThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Instakill Threshold", 1f, "Display an instakill message when the kill time is <= to this value.").Value;
			Stage.onStageStartGlobal += Stage_onStageStartGlobal;
			HealthComponent.TakeDamage += new hook_TakeDamage(HealthComponent_TakeDamage);
			GlobalEventManager.OnCharacterDeath += new hook_OnCharacterDeath(GlobalEventManager_OnCharacterDeath);
		}

		private void GlobalEventManager_OnCharacterDeath(orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport)
		{
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			orig.Invoke(self, damageReport);
			if (NetworkServer.active && Object.op_Implicit((Object)(object)damageReport.victimBody) && dict.TryGetValue(damageReport.victimBody, out var value))
			{
				float num = Time.time - value;
				bool flag = num <= instakillThreshold;
				string text = string.Empty;
				if (flag)
				{
					text += "<style=cIsHealing>INSTANT KILL!</style> ";
				}
				text = text + "<style=cIsHealth>" + Util.GetBestBodyName(((Component)damageReport.victimBody).gameObject) + "</style>";
				text += " was killed in ";
				text = text + "<style=cIsDamage>" + num + "</style>";
				text += " seconds!";
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = text
				});
				dict.Remove(damageReport.victimBody);
			}
		}

		private void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			if (NetworkServer.active && Object.op_Implicit((Object)(object)self.body) && self.body.isChampion && Object.op_Implicit((Object)(object)self.body.teamComponent) && (int)self.body.teamComponent.teamIndex != 1 && !dict.ContainsKey(self.body))
			{
				dict.Add(self.body, Time.time);
			}
			orig.Invoke(self, damageInfo);
		}

		private void Stage_onStageStartGlobal(Stage obj)
		{
			dict.Clear();
		}
	}
}
namespace R2API.Utils
{
	[AttributeUsage(AttributeTargets.Assembly)]
	public class ManualNetworkRegistrationAttribute : Attribute
	{
	}
}