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.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;
[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("TestAccount666.DamageMetrics")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DamageMetrics")]
[assembly: AssemblyTitle("TestAccount666.DamageMetrics")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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.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]
[Microsoft.CodeAnalysis.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]
[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 DamageMetrics
{
[BepInPlugin("Matsuura.TestAccount666.DamageMetrics", "DamageMetrics", "1.0.0")]
public class HealthMetricsBase : BaseUnityPlugin
{
private const string MOD_GUID = "Matsuura.TestAccount666.DamageMetrics";
private const string MOD_NAME = "DamageMetrics";
private const string MOD_VERSION = "1.0.0";
private static HealthMetricsBase? _instance;
private static ManualLogSource? _logSource;
private readonly Harmony _harmony = new Harmony("Matsuura.TestAccount666.DamageMetrics");
internal void Awake()
{
if (_instance == null)
{
_instance = this;
}
if (_logSource == null)
{
_logSource = Logger.CreateLogSource("Matsuura.TestAccount666.DamageMetrics");
}
_harmony.PatchAll();
_logSource.LogInfo((object)"DamageMetrics Awake");
}
internal static void Log(string message)
{
ManualLogSource? logSource = _logSource;
if (logSource != null)
{
logSource.LogInfo((object)message);
}
}
internal static void LogD(string message)
{
ManualLogSource? logSource = _logSource;
if (logSource != null)
{
logSource.LogDebug((object)message);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "TestAccount666.DamageMetrics";
public const string PLUGIN_NAME = "DamageMetrics";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace DamageMetrics.Patches
{
[HarmonyPatch(typeof(HUDManager))]
internal class HealthHUDPatches
{
private static TextMeshProUGUI _healthText = null;
private const string DEFAULT_VALUE_HEALTH_TEXT = "-0";
private static int _oldValueHealthValueForUpdater;
public static int healthValueForUpdater = 100;
private static readonly Color _HealthyColor = Color32.op_Implicit(new Color32((byte)0, byte.MaxValue, (byte)0, byte.MaxValue));
private static readonly Color _CriticalHealthColor = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)0, (byte)0, byte.MaxValue));
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void Start(ref HUDManager __instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0040: 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)
GameObject val = new GameObject("HealthHUDDisplay");
val.AddComponent<RectTransform>();
TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
RectTransform rectTransform = ((TMP_Text)val2).rectTransform;
((Transform)rectTransform).SetParent(((Component)__instance.PTTIcon).transform, false);
rectTransform.anchoredPosition = new Vector2(8f, -57f);
((TMP_Text)val2).font = ((TMP_Text)__instance.controlTipLines[0]).font;
((TMP_Text)val2).fontSize = 16f;
((TMP_Text)val2).text = "100";
((Graphic)val2).color = _HealthyColor;
((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
((Behaviour)val2).enabled = true;
_healthText = val2;
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void Update()
{
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_healthText == (Object)null) && healthValueForUpdater != _oldValueHealthValueForUpdater)
{
_oldValueHealthValueForUpdater = healthValueForUpdater;
int num = 100 - healthValueForUpdater;
((TMP_Text)_healthText).text = ((num > 0) ? (-num).ToString().PadLeft((num < 10) ? 2 : 3, ' ') : "-0");
TextMeshProUGUI healthText = _healthText;
((TMP_Text)healthText).text = ((TMP_Text)healthText).text + " ";
double percentage = (double)healthValueForUpdater / 100.0;
((Graphic)_healthText).color = ColorInterpolation(_CriticalHealthColor, _HealthyColor, percentage);
}
}
public static int LinearInterpolation(int start, int end, double percentage)
{
return start + (int)Math.Round(percentage * (double)(end - start));
}
public static Color ColorInterpolation(Color start, Color end, double percentage)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: 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_0068: Unknown result type (might be due to invalid IL or missing references)
return new Color(HexToFloat(LinearInterpolation(FloatToHex(start.r), FloatToHex(end.r), percentage)), HexToFloat(LinearInterpolation(FloatToHex(start.g), FloatToHex(end.g), percentage)), HexToFloat(LinearInterpolation(FloatToHex(start.b), FloatToHex(end.b), percentage)), 1f);
}
public static float HexToFloat(int hex)
{
return (float)hex / 255f;
}
public static int FloatToHex(float f)
{
return (int)f * 255;
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerPatches
{
[HarmonyPrefix]
[HarmonyPatch("LateUpdate")]
private static void LateUpdate_Prefix(PlayerControllerB __instance)
{
if (__instance == null || (((NetworkBehaviour)__instance).IsOwner && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) || 1 == 0)
{
HealthHUDPatches.healthValueForUpdater = ((__instance.health >= 0) ? __instance.health : 0);
}
}
}
}