using System;
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+79c24ee21fc61070207243043aeed88cea50e9c7")]
[assembly: AssemblyProduct("BossKillTimer")]
[assembly: AssemblyTitle("BossKillTimer")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BossKillTimer
{
[BepInPlugin("com.Moffein.BossKillTimer", "Boss Kill Timer", "1.0.4")]
public class BossKillTimer : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static hook_TakeDamage <>9__2_0;
public static hook_OnCharacterDeath <>9__2_1;
internal void <Awake>b__2_0(orig_TakeDamage orig, HealthComponent self, DamageInfo di)
{
if (NetworkServer.active && self.body.isChampion && (!teleOnly || self.body.isBoss) && !Object.op_Implicit((Object)(object)((Component)self).gameObject.GetComponent<KillTimerComponent>()))
{
KillTimerComponent killTimerComponent = ((Component)self).gameObject.AddComponent<KillTimerComponent>();
killTimerComponent.bodyString = Util.GetBestBodyName(((Component)self).gameObject);
killTimerComponent.StartTimer();
}
orig.Invoke(self, di);
}
internal void <Awake>b__2_1(orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport)
{
orig.Invoke(self, damageReport);
if (NetworkServer.active && Object.op_Implicit((Object)(object)damageReport.victim) && damageReport.victimIsChampion && (!teleOnly || damageReport.victimIsBoss))
{
KillTimerComponent component = ((Component)damageReport.victim).GetComponent<KillTimerComponent>();
if (Object.op_Implicit((Object)(object)component))
{
component.EndTimer();
}
}
}
}
public static bool teleOnly;
public static float instakillThreshold;
public void Awake()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: 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;
object obj = <>c.<>9__2_0;
if (obj == null)
{
hook_TakeDamage val = delegate(orig_TakeDamage orig, HealthComponent self, DamageInfo di)
{
if (NetworkServer.active && self.body.isChampion && (!teleOnly || self.body.isBoss) && !Object.op_Implicit((Object)(object)((Component)self).gameObject.GetComponent<KillTimerComponent>()))
{
KillTimerComponent killTimerComponent = ((Component)self).gameObject.AddComponent<KillTimerComponent>();
killTimerComponent.bodyString = Util.GetBestBodyName(((Component)self).gameObject);
killTimerComponent.StartTimer();
}
orig.Invoke(self, di);
};
<>c.<>9__2_0 = val;
obj = (object)val;
}
HealthComponent.TakeDamage += (hook_TakeDamage)obj;
object obj2 = <>c.<>9__2_1;
if (obj2 == null)
{
hook_OnCharacterDeath val2 = delegate(orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport)
{
orig.Invoke(self, damageReport);
if (NetworkServer.active && Object.op_Implicit((Object)(object)damageReport.victim) && damageReport.victimIsChampion && (!teleOnly || damageReport.victimIsBoss))
{
KillTimerComponent component = ((Component)damageReport.victim).GetComponent<KillTimerComponent>();
if (Object.op_Implicit((Object)(object)component))
{
component.EndTimer();
}
}
};
<>c.<>9__2_1 = val2;
obj2 = (object)val2;
}
GlobalEventManager.OnCharacterDeath += (hook_OnCharacterDeath)obj2;
}
}
public class KillTimerComponent : MonoBehaviour
{
private float stopwatch;
public bool timerStarted = false;
public bool hasDied = false;
public string bodyString = "BOSS";
public void FixedUpdate()
{
if (timerStarted)
{
stopwatch += Time.fixedDeltaTime;
}
}
public void StartTimer()
{
if (!timerStarted)
{
timerStarted = true;
stopwatch = 0f;
}
}
private void OnDestroy()
{
EndTimer();
}
public void EndTimer()
{
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
if (!hasDied)
{
hasDied = true;
bool flag = stopwatch <= BossKillTimer.instakillThreshold;
string text = string.Empty;
if (flag)
{
text += "<style=cIsHealing>INSTANT KILL!</style> ";
}
text = text + "<style=cIsHealth>" + bodyString + "</style>";
text += " was killed in ";
text = text + "<style=cIsDamage>" + stopwatch + "</style>";
text += " seconds!";
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = text
});
}
}
}
}
namespace R2API.Utils
{
[AttributeUsage(AttributeTargets.Assembly)]
public class ManualNetworkRegistrationAttribute : Attribute
{
}
}