using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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.Logging;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("xyz.parsl.damage_stats")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Displays damage numbers")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+5fd788c2b22bfeae063b1ab4e4311cb47c719e01")]
[assembly: AssemblyProduct("xyz.parsl.damage_stats")]
[assembly: AssemblyTitle("xyz.parsl.damage_stats")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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 DamageStats
{
public class DamageUIController : MonoBehaviour
{
private class DamageInstance
{
public decimal damage;
public decimal dhealth;
public string hitter;
public bool killing_blow;
public uint multiplier = 1u;
public DamageInstance(float damage, float dhealth, string hitter, bool killing_blow)
{
this.damage = new decimal(damage);
this.damage = decimal.Round(this.damage, 3);
this.dhealth = new decimal(dhealth);
this.dhealth = decimal.Round(this.dhealth, 3);
this.hitter = hitter;
this.killing_blow = killing_blow;
}
public override string ToString()
{
string text = " (<color=lime>" + hitter + "</color>)";
string text2 = (killing_blow ? " [<color=red>killed</color>]" : "");
string text3 = ((multiplier != 1) ? $" (<b>x{multiplier}</b> = {damage * (decimal)multiplier} | {dhealth * (decimal)multiplier})" : "");
return $"dmg: <b>{damage}</b> | dHealth: <b>{dhealth}</b>{text3}{text}{text2}";
}
}
private static GUIStyle style;
private uint lines;
private float scale;
private List<DamageInstance> DamageInstances;
public void Init(uint lines, float scale)
{
this.lines = lines;
DamageInstances = new List<DamageInstance>();
this.scale = scale;
style.fontSize = (int)((float)style.fontSize * scale);
}
public void NewDamageInstance(float damage, float dhealth, string hitter, bool killing_blow)
{
decimal d = new decimal(damage);
d = decimal.Round(d, 3);
decimal d2 = new decimal(dhealth);
d2 = decimal.Round(d2, 3);
if (DamageInstances.Count > 0)
{
DamageInstance damageInstance = DamageInstances.Last();
if (damageInstance.damage == d && damageInstance.dhealth == d2 && damageInstance.hitter == hitter && !damageInstance.killing_blow)
{
if (killing_blow)
{
damageInstance.killing_blow = true;
}
damageInstance.multiplier++;
return;
}
}
if (DamageInstances.Count == lines)
{
DamageInstances.RemoveAt(0);
}
DamageInstance item = new DamageInstance(damage, dhealth, hitter, killing_blow);
DamageInstances.Add(item);
}
public void ResetText()
{
DamageInstances.Clear();
}
private void OnGUI()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: 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_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
GUI.Box(new Rect(10f * scale, 10f * scale, 600f * scale, (float)(30 * lines + 40) * scale), "");
GUI.Label(new Rect(20f * scale, 15f * scale, 80f * scale, 40f * scale), "dmg", style);
GUI.Label(new Rect(90f * scale, 15f * scale, 80f * scale, 40f * scale), "dHealth", style);
int num = 0;
foreach (DamageInstance damageInstance in DamageInstances)
{
string text = string.Format("(<b>x{0}</b> = {1} | {2})", damageInstance.multiplier, (damageInstance.damage * (decimal)damageInstance.multiplier).ToString("0.000"), (damageInstance.dhealth * (decimal)damageInstance.multiplier).ToString("0.000"));
string text2 = "(<color=lime>" + damageInstance.hitter + "</color>)" + (damageInstance.killing_blow ? " [<color=red>killed</color>]" : "");
string text3 = ((damageInstance.multiplier <= 1) ? text2 : (text + " " + text2));
GUI.Label(new Rect(20f * scale, (float)(45 + 30 * num) * scale, 70f * scale, 40f * scale), damageInstance.damage.ToString("0.000"), style);
GUI.Label(new Rect(90f * scale, (float)(45 + 30 * num) * scale, 70f * scale, 40f * scale), damageInstance.dhealth.ToString("0.000"), style);
GUI.Label(new Rect(160f * scale, (float)(45 + 30 * num) * scale, 400f * scale, 40f * scale), text3, style);
num++;
}
}
private void OnDestroy()
{
Plugin.log.LogError((object)"uk being a bitch and deleting my shit");
Debugger.Launch();
}
static DamageUIController()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
GUIStyle val = new GUIStyle
{
fontSize = 22,
richText = true
};
val.normal.textColor = Color.white;
style = val;
}
}
[BepInPlugin("xyz.parsl.damage_stats", "xyz.parsl.damage_stats", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource log;
private static Harmony harmony;
private static ConfigEntry<uint> numlabels_cfg;
private static ConfigEntry<float> uiscale_cfg;
public static DamageUIController UIController;
private void Awake()
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
log = ((BaseUnityPlugin)this).Logger;
numlabels_cfg = ((BaseUnityPlugin)this).Config.Bind<uint>("General", "num_lines", 8u, "Number of lines of damage history to display");
uiscale_cfg = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ui_scale", 0.75f, "Value by which to scale ui. Recommend 1 for 1440p, 0.75 for 1080p");
harmony = new Harmony("xyz.parsl.damage_stats");
harmony.PatchAll();
log.LogInfo((object)"Patches loaded");
GameObject val = new GameObject("DamageStats");
UIController = val.AddComponent<DamageUIController>();
((Object)val).hideFlags = (HideFlags)61;
UIController.Init(numlabels_cfg.Value, uiscale_cfg.Value);
}
}
[HarmonyPatch(typeof(EnemyIdentifier))]
internal class EnemyIdentifierPatch
{
[HarmonyPatch("DeliverDamage")]
private static void Prefix(EnemyIdentifier __instance, out float __state)
{
__state = __instance.health;
}
[HarmonyPatch("DeliverDamage")]
private static void Postfix(EnemyIdentifier __instance, float __state, float multiplier, float critMultiplier, GameObject sourceWeapon)
{
bool killing_blow = false;
if (!(__state <= 0f))
{
__instance.ForceGetHealth();
float num;
if (__instance.health <= 0f)
{
num = 0f;
killing_blow = true;
}
else
{
num = __instance.health;
}
float num2 = __state - num;
Plugin.log.LogInfo((object)$"{multiplier} damage delivered! ({__instance.hitter}) dHealth = {num2} before = {__state} after = {num} critMultiplier = {critMultiplier}");
Plugin.UIController.NewDamageInstance(multiplier, num2, __instance.hitter, killing_blow);
}
}
}
[HarmonyPatch(typeof(SceneHelper))]
internal class SceneChangePatch
{
[HarmonyPatch("LoadScene")]
private static void Prefix()
{
Plugin.UIController.ResetText();
}
}
[HarmonyPatch(typeof(SceneHelper))]
internal class SceneRestartPatch
{
[HarmonyPatch("RestartScene")]
private static void Prefix()
{
Plugin.UIController.ResetText();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "xyz.parsl.damage_stats";
public const string PLUGIN_NAME = "xyz.parsl.damage_stats";
public const string PLUGIN_VERSION = "1.1.0";
}
}