Decompiled source of Assess v1.0.0

Assess.dll

Decompiled 16 hours ago
using System;
using System.Collections.Generic;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("headclef")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+330a77ac214664f2bc6f85d5d2204ec158e4c154")]
[assembly: AssemblyProduct("Assess")]
[assembly: AssemblyTitle("Assess")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
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 Assess
{
	[BepInPlugin("headclef.Assess", "Assess", "1.0.0")]
	public class Assess : BaseUnityPlugin
	{
		private const string PluginGuid = "headclef.Assess";

		private const string PluginName = "Assess";

		private const string PluginVersion = "1.0.0";

		internal static ConfigEntry<bool> ShowDamageNumbers;

		internal static ConfigEntry<float> DamageNumberDuration;

		internal static ConfigEntry<int> DamageNumberSize;

		internal static ConfigEntry<bool> ShowBarOnHover;

		internal static ConfigEntry<bool> ShowBarAlways;

		internal static ConfigEntry<bool> ShowHealthNumbers;

		internal static ConfigEntry<float> MaxDistance;

		internal static ConfigEntry<bool> RequireLineOfSight;

		internal static Assess Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_004f: Expected O, but got Unknown
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			BindConfiguration();
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
			((Component)this).gameObject.AddComponent<AssessHud>();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		private void OnDestroy()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void BindConfiguration()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			ShowDamageNumbers = ((BaseUnityPlugin)this).Config.Bind<bool>("Damage Numbers", "Enable", true, "Show a floating number every time an enemy takes damage — from your weapons, a tumble, a fall, a death pit, anything. This is the point of the mod: it makes the damage you deal legible, so upgrades like Improve's Tumble Launch or Increase Tumble Damage's multiplier stop being an act of faith.");
			DamageNumberDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Damage Numbers", "Duration", 1.2f, new ConfigDescription("How long a damage number stays on screen, in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 5f), Array.Empty<object>()));
			DamageNumberSize = ((BaseUnityPlugin)this).Config.Bind<int>("Damage Numbers", "Font Size", 22, new ConfigDescription("Font size of the damage numbers.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(8, 72), Array.Empty<object>()));
			ShowBarOnHover = ((BaseUnityPlugin)this).Config.Bind<bool>("Health Bar", "Show On Hover", true, "Show an enemy's health bar while you are looking at it. Deliberate and quiet — you get the reading when you ask for it.");
			ShowBarAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("Health Bar", "Show Above Every Enemy", false, "Show a health bar above EVERY enemy in range, all the time, with no need to look at them. Off by default on purpose: R.E.P.O. leans on not knowing exactly what is around you, and permanent bars over everything spend that tension. Turn it on if you would rather have the information.");
			ShowHealthNumbers = ((BaseUnityPlugin)this).Config.Bind<bool>("Health Bar", "Show Numbers On Bar", true, "Print the actual numbers (current / max) on the health bar, not just its length.");
			MaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Max Distance", 30f, new ConfigDescription("Only show health bars for enemies within this many metres. Damage numbers ignore this — if you hurt something, you are looking at it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 100f), Array.Empty<object>()));
			RequireLineOfSight = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Require Line Of Sight", true, "Only show health bars for enemies you can actually see. With this off you read them through walls, which is a real advantage — it is your call, but it is not the experience the game was built around.");
		}
	}
	internal sealed class AssessHud : MonoBehaviour
	{
		private sealed class Popup
		{
			public Vector3 World;

			public int Amount;

			public bool Killed;

			public float Born;
		}

		private static readonly List<Popup> _popups = new List<Popup>();

		private static readonly Color KillColor = new Color(1f, 0.35f, 0.25f);

		private static readonly Color HitColor = new Color(1f, 0.86f, 0.3f);

		private GUIStyle? _damageStyle;

		private GUIStyle? _barTextStyle;

		private Texture2D? _white;

		internal static void ClearPopups()
		{
			_popups.Clear();
		}

		internal static void AddPopup(EnemyHealth health, int amount, bool killed)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if (Assess.ShowDamageNumbers.Value && amount > 0 && !((Object)(object)health == (Object)null))
			{
				Vector3 val = HeadOf(health);
				if (!(val == Vector3.zero))
				{
					_popups.Add(new Popup
					{
						World = val,
						Amount = amount,
						Killed = killed,
						Born = Time.unscaledTime
					});
				}
			}
		}

		private static Vector3 AnchorOf(EnemyHealth health)
		{
			//IL_0010: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			Enemy enemy = health.enemy;
			if ((Object)(object)enemy == (Object)null)
			{
				return Vector3.zero;
			}
			if ((Object)(object)enemy.CenterTransform != (Object)null)
			{
				return enemy.CenterTransform.position;
			}
			return ((Component)health).transform.position;
		}

		private static Vector3 HeadOf(EnemyHealth health)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = AnchorOf(health);
			if (val == Vector3.zero)
			{
				return val;
			}
			float num = 1f;
			List<MeshRenderer> renderers = health.renderers;
			if (renderers != null)
			{
				bool flag = false;
				Bounds val2 = default(Bounds);
				foreach (MeshRenderer item in renderers)
				{
					if ((Object)(object)item == (Object)null || !((Renderer)item).enabled)
					{
						continue;
					}
					Bounds bounds = ((Renderer)item).bounds;
					Vector3 center = ((Bounds)(ref bounds)).center;
					Vector2 val3 = new Vector2(center.x - val.x, center.z - val.z);
					if (!(((Vector2)(ref val3)).sqrMagnitude > 25f))
					{
						if (!flag)
						{
							val2 = ((Renderer)item).bounds;
							flag = true;
						}
						else
						{
							((Bounds)(ref val2)).Encapsulate(((Renderer)item).bounds);
						}
					}
				}
				if (flag)
				{
					num = Mathf.Clamp(((Bounds)(ref val2)).max.y - val.y, 0.3f, 4f);
				}
			}
			return new Vector3(val.x, val.y + num + 0.25f, val.z);
		}

		private void Update()
		{
			if (_popups.Count == 0)
			{
				return;
			}
			float value = Assess.DamageNumberDuration.Value;
			float unscaledTime = Time.unscaledTime;
			for (int num = _popups.Count - 1; num >= 0; num--)
			{
				if (unscaledTime - _popups[num].Born > value)
				{
					_popups.RemoveAt(num);
				}
			}
		}

		private void OnGUI()
		{
			if (SemiFunc.RunIsLevel())
			{
				Camera val = (((Object)(object)CameraUtils.Instance != (Object)null) ? CameraUtils.Instance.MainCamera : Camera.main);
				if (!((Object)(object)val == (Object)null))
				{
					EnsureStyles();
					DrawBars(val);
					DrawPopups(val);
				}
			}
		}

		private static Vector2 WorldToScreen(Camera cam, Vector3 world, out bool behind)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = cam.WorldToScreenPoint(world);
			behind = val.z <= 0f;
			RenderTextureMain instance = RenderTextureMain.instance;
			if ((Object)(object)instance != (Object)null && instance.textureWidth > 0f && instance.textureHeight > 0f)
			{
				val.x *= (float)Screen.width / instance.textureWidth;
				val.y *= (float)Screen.height / instance.textureHeight;
			}
			return new Vector2(val.x, (float)Screen.height - val.y);
		}

		private void DrawBars(Camera cam)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			bool value = Assess.ShowBarOnHover.Value;
			bool value2 = Assess.ShowBarAlways.Value;
			if (!value && !value2)
			{
				return;
			}
			EnemyDirector instance = EnemyDirector.instance;
			if ((Object)(object)instance == (Object)null || instance.enemiesSpawned == null)
			{
				return;
			}
			Vector3 position = ((Component)cam).transform.position;
			float value3 = Assess.MaxDistance.Value;
			EnemyHealth val = null;
			float num = float.MaxValue;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor((float)Screen.width * 0.5f, (float)Screen.height * 0.5f);
			foreach (EnemyParent item in instance.enemiesSpawned)
			{
				Enemy val3 = (((Object)(object)item != (Object)null) ? item.Enemy : null);
				if ((Object)(object)val3 == (Object)null || !val3.HasHealth)
				{
					continue;
				}
				EnemyHealth health = val3.Health;
				if ((Object)(object)health == (Object)null)
				{
					continue;
				}
				int num2 = EnemyTracker.Current(health);
				if (num2 <= 0)
				{
					continue;
				}
				Vector3 val4 = AnchorOf(health);
				if (val4 == Vector3.zero)
				{
					continue;
				}
				float num3 = Vector3.Distance(position, val4);
				if (num3 > value3)
				{
					continue;
				}
				bool behind;
				Vector2 val5 = WorldToScreen(cam, val4, out behind);
				if (behind || (Assess.RequireLineOfSight.Value && !CanSee(position, val4)))
				{
					continue;
				}
				if (value2)
				{
					DrawBar(cam, health, num2);
					continue;
				}
				float num4 = Vector2.Distance(val5, val2);
				if (num4 < num && num4 < (float)Screen.height * 0.18f)
				{
					num = num4;
					val = health;
				}
			}
			if (!value2 && (Object)(object)val != (Object)null)
			{
				DrawBar(cam, val, EnemyTracker.Current(val));
			}
		}

		private static bool CanSee(Vector3 eye, Vector3 target)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = target - eye;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude < 0.5f)
			{
				return true;
			}
			return !Physics.Raycast(eye, ((Vector3)(ref val)).normalized, magnitude - 0.5f, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1);
		}

		private void DrawBar(Camera cam, EnemyHealth health, int current)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			int num = EnemyTracker.Max(health);
			if (num <= 0)
			{
				return;
			}
			Vector3 val = HeadOf(health);
			if (val == Vector3.zero)
			{
				return;
			}
			bool behind;
			Vector2 val2 = WorldToScreen(cam, val, out behind);
			if (!behind)
			{
				float num2 = Mathf.Clamp01((float)current / (float)num);
				float num3 = val2.x - 42f;
				float num4 = val2.y - 7f - (Assess.ShowHealthNumbers.Value ? 18f : 4f);
				DrawRect(new Rect(num3 - 1f, num4 - 1f, 86f, 9f), new Color(0f, 0f, 0f, 0.65f));
				DrawRect(new Rect(num3, num4, 84f, 7f), new Color(0.15f, 0.15f, 0.15f, 0.85f));
				DrawRect(new Rect(num3, num4, 84f * num2, 7f), Color.Lerp(new Color(0.9f, 0.15f, 0.1f), new Color(0.35f, 0.85f, 0.3f), num2));
				if (Assess.ShowHealthNumbers.Value && _barTextStyle != null)
				{
					GUI.Label(new Rect(num3, num4 - 16f, 84f, 16f), $"{current} / {num}", _barTextStyle);
				}
			}
		}

		private void DrawPopups(Camera cam)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			if (_popups.Count == 0 || _damageStyle == null)
			{
				return;
			}
			float value = Assess.DamageNumberDuration.Value;
			float unscaledTime = Time.unscaledTime;
			foreach (Popup popup in _popups)
			{
				float num = (unscaledTime - popup.Born) / Mathf.Max(value, 0.01f);
				if (!(num >= 1f))
				{
					bool behind;
					Vector2 val = WorldToScreen(cam, popup.World + Vector3.up * (num * 0.9f), out behind);
					if (!behind)
					{
						float a = ((num < 0.5f) ? 1f : (1f - (num - 0.5f) * 2f));
						Color color = (popup.Killed ? KillColor : HitColor);
						color.a = a;
						Color color2 = GUI.color;
						GUI.color = color;
						string text = (popup.Killed ? $"{popup.Amount} ☠" : popup.Amount.ToString());
						GUI.Label(new Rect(val.x - 60f, val.y - 12f, 120f, 24f), text, _damageStyle);
						GUI.color = color2;
					}
				}
			}
		}

		private void EnsureStyles()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00b8: Expected O, but got Unknown
			if ((Object)(object)_white == (Object)null)
			{
				_white = new Texture2D(1, 1);
				_white.SetPixel(0, 0, Color.white);
				_white.Apply();
				((Object)_white).hideFlags = (HideFlags)61;
			}
			if (_damageStyle == null)
			{
				_damageStyle = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontStyle = (FontStyle)1
				};
			}
			_damageStyle.fontSize = Assess.DamageNumberSize.Value;
			if (_barTextStyle == null)
			{
				_barTextStyle = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontStyle = (FontStyle)1,
					fontSize = 11
				};
			}
		}

		private void DrawRect(Rect r, Color c)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_white == (Object)null))
			{
				Color color = GUI.color;
				GUI.color = c;
				GUI.DrawTexture(r, (Texture)(object)_white);
				GUI.color = color;
			}
		}
	}
	internal static class EnemyTracker
	{
		private static readonly Dictionary<EnemyHealth, int> _tracked = new Dictionary<EnemyHealth, int>();

		internal static void Clear()
		{
			_tracked.Clear();
		}

		internal static void Reset(EnemyHealth eh)
		{
			if (!((Object)(object)eh == (Object)null))
			{
				_tracked[eh] = eh.health;
			}
		}

		internal static void ApplyDamage(EnemyHealth eh, int rawDamage, float damageResistance)
		{
			if (!((Object)(object)eh == (Object)null))
			{
				int num = Mathf.RoundToInt((float)rawDamage * (1f - Mathf.Min(damageResistance, 1f)));
				_tracked[eh] = Mathf.Max(0, Remaining(eh) - num);
			}
		}

		internal static void SetTruth(EnemyHealth eh, int value)
		{
			if (!((Object)(object)eh == (Object)null))
			{
				_tracked[eh] = Mathf.Max(0, value);
			}
		}

		internal static void SetDead(EnemyHealth eh)
		{
			if (!((Object)(object)eh == (Object)null))
			{
				_tracked[eh] = 0;
			}
		}

		internal static int Remaining(EnemyHealth eh)
		{
			if ((Object)(object)eh == (Object)null)
			{
				return 0;
			}
			if (_tracked.TryGetValue(eh, out var value))
			{
				return value;
			}
			_tracked[eh] = eh.health;
			return eh.health;
		}

		internal static int Current(EnemyHealth eh)
		{
			if ((Object)(object)eh == (Object)null)
			{
				return 0;
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return Remaining(eh);
			}
			return eh.healthCurrent;
		}

		internal static int Max(EnemyHealth eh)
		{
			if (!((Object)(object)eh == (Object)null))
			{
				return eh.health;
			}
			return 0;
		}
	}
}
namespace Assess.Patches
{
	[HarmonyPatch]
	internal static class EnemyHealthPatch
	{
		[HarmonyPatch(typeof(EnemyHealth), "OnSpawn")]
		[HarmonyPostfix]
		private static void OnSpawn_Postfix(EnemyHealth __instance)
		{
			try
			{
				EnemyTracker.Reset(__instance);
			}
			catch (Exception ex)
			{
				Assess.Logger.LogWarning((object)("OnSpawn hook skipped: " + ex.Message));
			}
		}

		[HarmonyPatch(typeof(EnemyHealth), "HurtRPC")]
		[HarmonyPostfix]
		private static void HurtRPC_Postfix(EnemyHealth __instance, int _damage, PhotonMessageInfo _info)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (SemiFunc.MasterOnlyRPC(_info))
				{
					int num = EnemyTracker.Remaining(__instance);
					EnemyTracker.ApplyDamage(__instance, _damage, __instance.damageResistance);
					int amount = num - EnemyTracker.Remaining(__instance);
					AssessHud.AddPopup(__instance, amount, killed: false);
				}
			}
			catch (Exception ex)
			{
				Assess.Logger.LogWarning((object)("HurtRPC hook skipped: " + ex.Message));
			}
		}

		[HarmonyPatch(typeof(EnemyHealth), "DeathRPC")]
		[HarmonyPostfix]
		private static void DeathRPC_Postfix(EnemyHealth __instance, PhotonMessageInfo _info)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (SemiFunc.MasterOnlyRPC(_info))
				{
					int num = EnemyTracker.Remaining(__instance);
					EnemyTracker.SetDead(__instance);
					if (num > 0)
					{
						AssessHud.AddPopup(__instance, num, killed: true);
					}
				}
			}
			catch (Exception ex)
			{
				Assess.Logger.LogWarning((object)("DeathRPC hook skipped: " + ex.Message));
			}
		}
	}
	[HarmonyPatch]
	internal static class EnemyTickPatch
	{
		[HarmonyPatch(typeof(EnemyTick), "UpdateSyncedHealthRPC")]
		[HarmonyPostfix]
		private static void UpdateSyncedHealthRPC_Postfix(EnemyTick __instance, int _currentSyncedHealth)
		{
			try
			{
				EnemyHealth val = (((Object)(object)__instance.enemy != (Object)null) ? __instance.enemy.Health : null);
				if (!((Object)(object)val == (Object)null))
				{
					EnemyTracker.SetTruth(val, _currentSyncedHealth);
				}
			}
			catch (Exception ex)
			{
				Assess.Logger.LogWarning((object)("Tick sync hook skipped: " + ex.Message));
			}
		}
	}
	[HarmonyPatch]
	internal static class SceneSwitchPatch
	{
		[HarmonyPatch(typeof(SemiFunc), "OnSceneSwitch")]
		[HarmonyPrefix]
		private static void OnSceneSwitch_Prefix()
		{
			try
			{
				EnemyTracker.Clear();
				AssessHud.ClearPopups();
			}
			catch (Exception ex)
			{
				Assess.Logger.LogWarning((object)("Scene switch hook skipped: " + ex.Message));
			}
		}
	}
}