using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon.Movement;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("DamageMeter")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0+8ea384b46b13e275341692fd1b3f2aa7215e2bd4")]
[assembly: AssemblyProduct("DamageMeter")]
[assembly: AssemblyTitle("DamageMeter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.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;
}
}
}
[BepInPlugin("sparroh.damagemeter", "DamageMeter", "1.1.0")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class DPSMeter : BaseUnityPlugin
{
public const string PluginGUID = "sparroh.damagemeter";
public const string PluginName = "DamageMeter";
public const string PluginVersion = "1.1.0";
private Harmony harmony;
public static Queue<(float time, float damage)> damageQueue = new Queue<(float, float)>();
private bool uiVisible = true;
private ConfigEntry<float> dpsWindowSeconds;
private GameObject hudContainer;
private TextMeshProUGUI totalDamageText;
private TextMeshProUGUI fiveSecDamageText;
private TextMeshProUGUI totalKillsText;
private TextMeshProUGUI totalCoresText;
public static float totalDamage = 0f;
public static int totalKills = 0;
public static int totalCoresKilled = 0;
public static float missionStartTime = 0f;
private void Awake()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
dpsWindowSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DPSWindowSeconds", 5f, "Time window (in seconds) for calculating DPS. Higher values smooth out spikes.");
Harmony val = new Harmony("sparroh.damagemeter");
val.PatchAll(typeof(DPSPatches));
val.PatchAll(typeof(MissionPatches));
((BaseUnityPlugin)this).Logger.LogInfo((object)"DamageMeter loaded successfully.");
}
private void Start()
{
missionStartTime = Time.time;
}
private void CreateHUD()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Expected O, but got Unknown
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Expected O, but got Unknown
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d3: Expected O, but got Unknown
//IL_030e: Unknown result type (might be due to invalid IL or missing references)
//IL_034c: Unknown result type (might be due to invalid IL or missing references)
//IL_0357: Unknown result type (might be due to invalid IL or missing references)
//IL_036b: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)hudContainer != (Object)null) && !((Object)(object)Player.LocalPlayer.PlayerLook == (Object)null) && !((Object)(object)Player.LocalPlayer.PlayerLook.Reticle == (Object)null))
{
RectTransform reticle = Player.LocalPlayer.PlayerLook.Reticle;
hudContainer = new GameObject("DamageMeterHUD");
hudContainer.transform.SetParent((Transform)(object)reticle, false);
RectTransform obj = hudContainer.AddComponent<RectTransform>();
obj.anchorMin = new Vector2(0.2f, 0.9f);
obj.anchorMax = new Vector2(0.2f, 0.9f);
obj.anchoredPosition = new Vector2(0f, 0f);
obj.sizeDelta = new Vector2(300f, 100f);
GameObject val = new GameObject("TotalDamageText");
val.transform.SetParent(hudContainer.transform, false);
totalDamageText = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)totalDamageText).fontSize = 18f;
((Graphic)totalDamageText).color = Color.white;
((TMP_Text)totalDamageText).enableWordWrapping = false;
((TMP_Text)totalDamageText).alignment = (TextAlignmentOptions)513;
((TMP_Text)totalDamageText).verticalAlignment = (VerticalAlignmentOptions)512;
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.anchoredPosition = new Vector2(0f, 0f);
GameObject val2 = new GameObject("FiveSecDamageText");
val2.transform.SetParent(hudContainer.transform, false);
fiveSecDamageText = val2.AddComponent<TextMeshProUGUI>();
((TMP_Text)fiveSecDamageText).fontSize = 18f;
((Graphic)fiveSecDamageText).color = Color.white;
((TMP_Text)fiveSecDamageText).enableWordWrapping = false;
((TMP_Text)fiveSecDamageText).alignment = (TextAlignmentOptions)513;
((TMP_Text)fiveSecDamageText).verticalAlignment = (VerticalAlignmentOptions)512;
RectTransform component2 = val2.GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.anchoredPosition = new Vector2(0f, -25f);
GameObject val3 = new GameObject("TotalKillsText");
val3.transform.SetParent(hudContainer.transform, false);
totalKillsText = val3.AddComponent<TextMeshProUGUI>();
((TMP_Text)totalKillsText).fontSize = 18f;
((Graphic)totalKillsText).color = Color.white;
((TMP_Text)totalKillsText).enableWordWrapping = false;
((TMP_Text)totalKillsText).alignment = (TextAlignmentOptions)513;
((TMP_Text)totalKillsText).verticalAlignment = (VerticalAlignmentOptions)512;
RectTransform component3 = val3.GetComponent<RectTransform>();
component3.anchorMin = Vector2.zero;
component3.anchorMax = Vector2.one;
component3.anchoredPosition = new Vector2(0f, -50f);
GameObject val4 = new GameObject("TotalCoresText");
val4.transform.SetParent(hudContainer.transform, false);
totalCoresText = val4.AddComponent<TextMeshProUGUI>();
((TMP_Text)totalCoresText).fontSize = 18f;
((Graphic)totalCoresText).color = Color.white;
((TMP_Text)totalCoresText).enableWordWrapping = false;
((TMP_Text)totalCoresText).alignment = (TextAlignmentOptions)513;
((TMP_Text)totalCoresText).verticalAlignment = (VerticalAlignmentOptions)512;
RectTransform component4 = val4.GetComponent<RectTransform>();
component4.anchorMin = Vector2.zero;
component4.anchorMax = Vector2.one;
component4.anchoredPosition = new Vector2(0f, -75f);
}
}
private void Update()
{
if (Keyboard.current != null && ((ButtonControl)Keyboard.current.f5Key).wasPressedThisFrame)
{
uiVisible = !uiVisible;
if ((Object)(object)hudContainer != (Object)null)
{
hudContainer.SetActive(uiVisible);
}
}
if ((Object)(object)Player.LocalPlayer == (Object)null)
{
return;
}
if ((Object)(object)hudContainer == (Object)null)
{
CreateHUD();
return;
}
float time = Time.time;
float value = dpsWindowSeconds.Value;
while (damageQueue.Count > 0 && damageQueue.Peek().time < time - value)
{
damageQueue.Dequeue();
}
float num = 0f;
foreach (var item in damageQueue)
{
num += item.damage;
}
float num2 = ((damageQueue.Count > 0) ? (num / value) : 0f);
float num3 = Time.time - missionStartTime;
float num4 = ((num3 > 0f) ? (totalDamage / num3) : 0f);
float num5 = ((num3 > 0f) ? ((float)totalKills / num3) : 0f);
float num6 = ((num3 > 0f) ? ((float)totalCoresKilled / num3) : 0f);
((TMP_Text)totalDamageText).text = $"Total Damage: <color=red>{totalDamage:F0}</color> (<color=red>{num4:F1}</color>/s)";
((TMP_Text)fiveSecDamageText).text = $"Last 5sec Damage: <color=red>{num:F0}</color> (<color=red>{num2:F1}</color>/s)";
((TMP_Text)totalKillsText).text = $"Targets Killed: <color=red>{totalKills}</color> (<color=red>{num5:F1}</color>/s)";
((TMP_Text)totalCoresText).text = $"Cores Killed: <color=red>{totalCoresKilled}</color> (<color=red>{num6:F1}</color>/s)";
}
private void OnDestroy()
{
if ((Object)(object)hudContainer != (Object)null)
{
Object.Destroy((Object)(object)hudContainer);
}
}
}
internal class DPSPatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayerData), "OnLocalPlayerDamageTarget")]
private static void PostDamage(in DamageCallbackData data)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
if (!(data.damageData.damage > 0f))
{
return;
}
DPSMeter.totalDamage += data.damageData.damage;
TargetType type = ((IFollowable)data.target).Type;
if ((type & 1) != 0 || (type & 2) != 0)
{
DPSMeter.damageQueue.Enqueue((Time.time, data.damageData.damage));
}
if (((DamageCallbackData)(ref data)).KilledTarget)
{
DPSMeter.totalKills++;
if (typeof(EnemyCore).IsAssignableFrom(((object)data.target).GetType()))
{
DPSMeter.totalCoresKilled++;
}
}
}
}
internal class MissionPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(MissionManager), "SpawnHUD")]
private static void MissionStart()
{
DPSMeter.totalDamage = 0f;
DPSMeter.totalKills = 0;
DPSMeter.totalCoresKilled = 0;
DPSMeter.damageQueue.Clear();
DPSMeter.missionStartTime = Time.time;
}
}
[CompilerGenerated]
[ExcludeFromCodeCoverage]
internal static class GitVersionInformation
{
public const string AssemblySemFileVer = "0.0.1.0";
public const string AssemblySemVer = "0.0.1.0";
public const string BranchName = "master";
public const string BuildMetaData = "";
public const string CommitDate = "2025-10-17";
public const string CommitsSinceVersionSource = "1";
public const string EscapedBranchName = "master";
public const string FullBuildMetaData = "Branch.master.Sha.8ea384b46b13e275341692fd1b3f2aa7215e2bd4";
public const string FullSemVer = "0.0.1-1";
public const string InformationalVersion = "0.0.1-1+Branch.master.Sha.8ea384b46b13e275341692fd1b3f2aa7215e2bd4";
public const string Major = "0";
public const string MajorMinorPatch = "0.0.1";
public const string Minor = "0";
public const string Patch = "1";
public const string PreReleaseLabel = "";
public const string PreReleaseLabelWithDash = "";
public const string PreReleaseNumber = "1";
public const string PreReleaseTag = "1";
public const string PreReleaseTagWithDash = "-1";
public const string SemVer = "0.0.1-1";
public const string Sha = "8ea384b46b13e275341692fd1b3f2aa7215e2bd4";
public const string ShortSha = "8ea384b";
public const string UncommittedChanges = "12";
public const string VersionSourceSha = "";
public const string WeightedPreReleaseNumber = "55001";
}
namespace DamageMeter
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "DamageMeter";
public const string PLUGIN_NAME = "DamageMeter";
public const string PLUGIN_VERSION = "0.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}