using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Arce.BossDamageSummary")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0")]
[assembly: AssemblyProduct("Arce.BossDamageSummary")]
[assembly: AssemblyTitle("BossDamageSummary")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
[Embedded]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
[Embedded]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace Microsoft.CodeAnalysis
{
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace BossDamageSummary
{
[BepInPlugin("Arce.BossDamageSummary", "BossDamageSummary", "0.2.0")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(Creature), "RpcLogic___ObserverHit___701300449")]
private static class HitPatch
{
private static void Postfix(Creature __instance, Player __0, int __3)
{
Instance.RecordDamage(__instance, __0, __3);
}
}
[HarmonyPatch(typeof(Creature), "RpcLogic___ObserverExplosionHit___2627372740")]
private static class ExplosionHitPatch
{
private static void Postfix(Creature __instance, Player __0, int __2)
{
Instance.RecordDamage(__instance, __0, __2);
}
}
private const float SummaryDuration = 12f;
private const float CardPadding = 10f;
private static readonly Dictionary<ulong, (string Name, long Damage)> DamageByPlayer = new Dictionary<ulong, (string, long)>();
private static readonly FieldInfo InspectHolderField = AccessTools.Field(typeof(WeaponUI), "_weaponInspectHolder");
private static readonly FieldInfo InspectedNameField = AccessTools.Field(typeof(WeaponUI), "_inspectedNameText");
private static readonly FieldInfo DescriptionField = AccessTools.Field(typeof(WeaponUI), "_descriptionText");
private Harmony _harmony;
private Coroutine? _summaryRoutine;
private GameObject? _cardOutline;
private WeaponUI? _weaponUi;
private bool _bossDefeated;
private bool _summaryVisible;
public const string Id = "Arce.BossDamageSummary";
internal static ManualLogSource Log { get; private set; } = null;
private static Plugin Instance { get; set; } = null;
public static string Name => "BossDamageSummary";
public static string Version => "0.2.0";
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
_harmony = new Harmony("Arce.BossDamageSummary");
_harmony.PatchAll();
BossManager.OnGlobalBossSpawn += BeginBossFight;
BossManager.OnGlobalBossDeath += OnBossDeath;
BossManager.OnGlobalBossDespawn += OnBossDespawn;
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
}
private void OnDestroy()
{
BossManager.OnGlobalBossSpawn -= BeginBossFight;
BossManager.OnGlobalBossDeath -= OnBossDeath;
BossManager.OnGlobalBossDespawn -= OnBossDespawn;
if (Object.op_Implicit((Object)(object)_cardOutline))
{
Object.Destroy((Object)(object)_cardOutline);
}
_harmony.UnpatchSelf();
}
private void BeginBossFight()
{
_bossDefeated = false;
DamageByPlayer.Clear();
if (_summaryRoutine != null)
{
((MonoBehaviour)this).StopCoroutine(_summaryRoutine);
_summaryRoutine = null;
}
HideSummary();
}
private void OnBossDespawn()
{
if (!_bossDefeated)
{
BeginBossFight();
}
}
private void RecordDamage(Creature creature, Player player, int damage)
{
if (!((Object)(object)creature != (Object)(object)BossManager.Boss) && Object.op_Implicit((Object)(object)player) && damage > 0)
{
ulong steamID = player.SteamID;
string item = (string.IsNullOrWhiteSpace(player.SteamName) ? $"Player {steamID}" : player.SteamName);
(string, long) value;
long num = (DamageByPlayer.TryGetValue(steamID, out value) ? value.Item2 : 0);
DamageByPlayer[steamID] = (item, num + damage);
ShowOrUpdateSummary(((Item)BossManager.Boss).GetName());
}
}
private void OnBossDeath()
{
_bossDefeated = true;
string bossName = (Object.op_Implicit((Object)(object)BossManager.Boss) ? ((Item)BossManager.Boss).GetName() : "Boss");
if (_summaryRoutine != null)
{
((MonoBehaviour)this).StopCoroutine(_summaryRoutine);
}
ShowOrUpdateSummary(bossName);
_summaryRoutine = ((MonoBehaviour)this).StartCoroutine(HideSummaryAfterDelay(bossName));
}
private IEnumerator HideSummaryAfterDelay(string bossName)
{
yield return null;
ShowOrUpdateSummary(bossName);
yield return (object)new WaitForSecondsRealtime(12f);
HideSummary();
_summaryRoutine = null;
}
private void ShowOrUpdateSummary(string bossName)
{
long num = DamageByPlayer.Values.Sum<(string, long)>(((string Name, long Damage) entry) => entry.Damage);
if (num <= 0)
{
return;
}
StringBuilder stringBuilder = new StringBuilder();
foreach (var item in DamageByPlayer.Values.OrderByDescending<(string, long), long>(((string Name, long Damage) entry) => entry.Damage))
{
stringBuilder.AppendLine($"{item.Item1}: {item.Item2:N0} ({(double)item.Item2 / (double)num:P0})");
}
string text = bossName + " — Damage";
string text2 = stringBuilder.ToString().TrimEnd();
bool summaryVisible = _summaryVisible;
PlayerUI.ShowInspectInfo((Purchasable)null, text, text2);
_summaryVisible = true;
if (summaryVisible && TryGetNativeCard(out RectTransform holder, out TextMeshProUGUI _, out TextMeshProUGUI _))
{
LeanTween.cancel(holder);
}
ResizeNativeCard();
}
private void ResizeNativeCard()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
if (TryGetNativeCard(out RectTransform holder, out TextMeshProUGUI nameText, out TextMeshProUGUI descriptionText))
{
((TMP_Text)nameText).rectTransform.sizeDelta = new Vector2(-20f, ((TMP_Text)nameText).rectTransform.sizeDelta.y);
((TMP_Text)descriptionText).ForceMeshUpdate(false, false);
((TMP_Text)descriptionText).rectTransform.sizeDelta = new Vector2(-20f, ((TMP_Text)descriptionText).preferredHeight);
holder.sizeDelta = new Vector2(holder.sizeDelta.x, ((TMP_Text)nameText).rectTransform.sizeDelta.y + ((TMP_Text)descriptionText).rectTransform.sizeDelta.y + 10f);
EnsureNativeBorder(holder);
}
}
private void EnsureNativeBorder(RectTransform holder)
{
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Expected O, but got Unknown
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)_cardOutline) && Object.op_Implicit((Object)(object)_weaponUi))
{
Image[] componentsInChildren = ((Component)((Component)_weaponUi).transform.root).GetComponentsInChildren<Image>(true);
Image val = ((IEnumerable<Image>)componentsInChildren).FirstOrDefault((Func<Image, bool>)((Image image) => ((Object)image).name == "Outline" && ((Object)((Component)image).transform.parent).name == "TutorialBox")) ?? ((IEnumerable<Image>)componentsInChildren).FirstOrDefault((Func<Image, bool>)((Image image) => ((Object)image).name == "Outline"));
if (!Object.op_Implicit((Object)(object)val))
{
Log.LogWarning((object)"Could not find a native UI outline for the damage card.");
return;
}
_cardOutline = Object.Instantiate<GameObject>(((Component)val).gameObject, (Transform)(object)holder, false);
((Object)_cardOutline).name = "BossDamageOutline";
_cardOutline.SetActive(true);
RectTransform val2 = (RectTransform)_cardOutline.transform;
val2.anchorMin = Vector2.zero;
val2.anchorMax = Vector2.one;
val2.anchoredPosition = Vector2.zero;
val2.sizeDelta = Vector2.zero;
((Transform)val2).SetAsLastSibling();
((Graphic)_cardOutline.GetComponent<Image>()).raycastTarget = false;
}
}
private bool TryGetNativeCard(out RectTransform holder, out TextMeshProUGUI nameText, out TextMeshProUGUI descriptionText)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
if (!Object.op_Implicit((Object)(object)_weaponUi))
{
_weaponUi = Object.FindAnyObjectByType<WeaponUI>();
}
holder = null;
nameText = null;
descriptionText = null;
if (!Object.op_Implicit((Object)(object)_weaponUi))
{
return false;
}
holder = (RectTransform)InspectHolderField.GetValue(_weaponUi);
nameText = (TextMeshProUGUI)InspectedNameField.GetValue(_weaponUi);
descriptionText = (TextMeshProUGUI)DescriptionField.GetValue(_weaponUi);
if (Object.op_Implicit((Object)(object)holder) && Object.op_Implicit((Object)(object)nameText))
{
return Object.op_Implicit((Object)(object)descriptionText);
}
return false;
}
private void HideSummary()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
if (_summaryVisible)
{
PlayerUI.HideInspectInfo((Purchasable)null);
if (TryGetNativeCard(out RectTransform _, out TextMeshProUGUI nameText, out TextMeshProUGUI _))
{
((TMP_Text)nameText).rectTransform.sizeDelta = new Vector2(0f, ((TMP_Text)nameText).rectTransform.sizeDelta.y);
}
_summaryVisible = false;
}
}
}
}
namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ConstantExpectedAttribute : Attribute
{
public object? Min { get; set; }
public object? Max { get; set; }
}
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ExperimentalAttribute : Attribute
{
public string DiagnosticId { get; }
public string? UrlFormat { get; set; }
public ExperimentalAttribute(string diagnosticId)
{
DiagnosticId = diagnosticId;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullAttribute : Attribute
{
public string[] Members { get; }
public MemberNotNullAttribute(string member)
{
Members = new string[1] { member };
}
public MemberNotNullAttribute(params string[] members)
{
Members = members;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullWhenAttribute : Attribute
{
public bool ReturnValue { get; }
public string[] Members { get; }
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
Members = new string[1] { member };
}
public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
{
ReturnValue = returnValue;
Members = members;
}
}
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SetsRequiredMembersAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class StringSyntaxAttribute : Attribute
{
public const string CompositeFormat = "CompositeFormat";
public const string DateOnlyFormat = "DateOnlyFormat";
public const string DateTimeFormat = "DateTimeFormat";
public const string EnumFormat = "EnumFormat";
public const string GuidFormat = "GuidFormat";
public const string Json = "Json";
public const string NumericFormat = "NumericFormat";
public const string Regex = "Regex";
public const string TimeOnlyFormat = "TimeOnlyFormat";
public const string TimeSpanFormat = "TimeSpanFormat";
public const string Uri = "Uri";
public const string Xml = "Xml";
public string Syntax { get; }
public object?[] Arguments { get; }
public StringSyntaxAttribute(string syntax)
{
Syntax = syntax;
Arguments = new object[0];
}
public StringSyntaxAttribute(string syntax, params object?[] arguments)
{
Syntax = syntax;
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class UnscopedRefAttribute : Attribute
{
}
}
namespace System.Runtime.Versioning
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresPreviewFeaturesAttribute : Attribute
{
public string? Message { get; }
public string? Url { get; set; }
public RequiresPreviewFeaturesAttribute()
{
}
public RequiresPreviewFeaturesAttribute(string? message)
{
Message = message;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CallerArgumentExpressionAttribute : Attribute
{
public string ParameterName { get; }
public CallerArgumentExpressionAttribute(string parameterName)
{
ParameterName = parameterName;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CollectionBuilderAttribute : Attribute
{
public Type BuilderType { get; }
public string MethodName { get; }
public CollectionBuilderAttribute(Type builderType, string methodName)
{
BuilderType = builderType;
MethodName = methodName;
}
}
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
public const string RefStructs = "RefStructs";
public const string RequiredMembers = "RequiredMembers";
public string FeatureName { get; }
public bool IsOptional { get; set; }
public CompilerFeatureRequiredAttribute(string featureName)
{
FeatureName = featureName;
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
{
public string[] Arguments { get; }
public InterpolatedStringHandlerArgumentAttribute(string argument)
{
Arguments = new string[1] { argument };
}
public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
{
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerAttribute : Attribute
{
}
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal static class IsExternalInit
{
}
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ModuleInitializerAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class OverloadResolutionPriorityAttribute : Attribute
{
public int Priority { get; }
public OverloadResolutionPriorityAttribute(int priority)
{
Priority = priority;
}
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
[ExcludeFromCodeCoverage]
internal sealed class ParamCollectionAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiredMemberAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresLocationAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SkipLocalsInitAttribute : Attribute
{
}
}