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.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("megabonkDpsMeter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("DPS Meter toggle for Megabonk")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("megabonkDpsMeter")]
[assembly: AssemblyTitle("megabonkDpsMeter")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace megabonkDpsMeter
{
[BepInPlugin("tahaaydn_megabonkDpsMeter", "megabonkDpsMeter", "1.0.0")]
[BepInProcess("Megabonk.exe")]
public class Plugin : BasePlugin
{
public const string MODNAME = "megabonkDpsMeter";
public const string AUTHOR = "tahaaydn";
public const string GUID = "tahaaydn_megabonkDpsMeter";
public const string VERSION = "1.0.0";
internal static ConfigEntry<KeyCode> toggleKey;
internal static ManualLogSource log;
internal static bool disableMeter;
public Plugin()
{
log = ((BasePlugin)this).Log;
}
public override void Load()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
toggleKey = ((BasePlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)282, "Key to toggle the Stats Window");
ManualLogSource val = log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(14, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Loading ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("megabonkDpsMeter");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" v");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" by ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("tahaaydn");
}
val.LogInfo(val2);
((BasePlugin)this).AddComponent<InputDetector>();
Harmony val3 = new Harmony("tahaaydn_megabonkDpsMeter");
val3.PatchAll();
ManualLogSource val4 = log;
val2 = new BepInExInfoLogInterpolatedStringHandler(8, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("megabonkDpsMeter");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" loaded.");
}
val4.LogInfo(val2);
}
}
public class InputDetector : MonoBehaviour
{
private GameObject statsParent;
private GameObject damageWindow;
private GameObject statsWindow;
private GameObject questsWindow;
private void Update()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(Plugin.toggleKey.Value) && !Plugin.disableMeter)
{
ToggleStatsWindow();
}
}
private void ToggleStatsWindow()
{
if ((Object)(object)statsParent == (Object)null)
{
statsParent = GameObject.Find("GameUI/GameUI/DeathScreen/StatsWindows");
if ((Object)(object)statsParent != (Object)null)
{
damageWindow = ((Component)statsParent.transform.Find("W_Damage")).gameObject;
statsWindow = ((Component)statsParent.transform.Find("W_Stats")).gameObject;
questsWindow = ((Component)statsParent.transform.Find("W_Quests")).gameObject;
}
}
if (!((Object)(object)statsParent != (Object)null))
{
return;
}
bool flag = !statsParent.activeSelf;
statsParent.SetActive(flag);
statsWindow.SetActive(!flag);
questsWindow.SetActive(!flag);
if (flag)
{
GameOverDamageSourcesUi componentInChildren = statsParent.GetComponentInChildren<GameOverDamageSourcesUi>();
if (componentInChildren != null)
{
componentInChildren.Start();
}
}
}
}
[HarmonyPatch(typeof(GameOverDamageSourcesUi), "Start")]
public static class Patch_GameOverDamageSourcesUi_Start
{
private static void Prefix(GameOverDamageSourcesUi __instance)
{
GameObject val = GameObject.Find("GameUI/GameUI/DeathScreen/StatsWindows/W_Damage/WindowLayers/Content/ScrollRect/ContentEntries");
if (!((Object)(object)val == (Object)null))
{
Transform transform = val.transform;
for (int num = transform.childCount - 1; num >= 3; num--)
{
Object.Destroy((Object)(object)((Component)transform.GetChild(num)).gameObject);
}
}
}
}
[HarmonyPatch(typeof(GameManager), "StartPlaying")]
public static class Patch_GameManager_StartPlaying
{
private static void Postfix(GameManager __instance)
{
Plugin.disableMeter = false;
}
}
[HarmonyPatch(typeof(GameManager), "OnDied")]
public static class Patch_GameManager_OnDied
{
private static void Postfix(GameManager __instance)
{
Plugin.disableMeter = true;
}
}
}