Decompiled source of RepoDifficulty v0.1.0

RepoDifficulty.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RepoDifficulty")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RepoDifficulty")]
[assembly: AssemblyTitle("RepoDifficulty")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 RepoDifficulty
{
	[BepInPlugin("den.repo.difficulty", "REPO Difficulty", "0.1.0")]
	public sealed class Plugin : BaseUnityPlugin
	{
		private sealed class Spawn
		{
			public int Baseline;

			public int Scaled;
		}

		private sealed class Bar
		{
			public EnemyHealth Enemy;

			public int ViewId;

			public int Current;

			public int Max;

			public float Until;

			public Renderer[] Renderers;
		}

		private sealed class Hit
		{
			public int Before;

			public int Max;

			public int ViewId;

			public int Instance;

			public EnemyHealth Enemy;
		}

		private const byte HealthEvent = 186;

		private const string Protocol = "den.difficulty.hp.v1";

		private const string DifficultyKey = "den.difficulty.mode.v1";

		private static Plugin self;

		private readonly string[] names = new string[5] { "Normal", "Hard", "Expert", "Nightmare", "Hell" };

		private readonly float[] hp = new float[5] { 1f, 1.5f, 2f, 3f, 5f };

		private readonly float[] damage = new float[5] { 1f, 1.25f, 1.5f, 2f, 3f };

		private ConfigEntry<int> selected;

		private ConfigEntry<float> duration;

		private ConfigEntry<float> radius;

		private ConfigEntry<bool> barsEnabled;

		private ConfigEntry<bool> difficultyHud;

		private FieldInfo maxField;

		private FieldInfo currentField;

		private FieldInfo enemyField;

		private Harmony harmony;

		private bool ready;

		private bool blocked;

		private bool hadRoom;

		private bool damageHook;

		private string room = "";

		private int originalMaster;

		private int stageMode = -1;

		private float nextPublish;

		private float noticeUntil;

		private string notice = "";

		private readonly Dictionary<EnemyHealth, Spawn> spawned = new Dictionary<EnemyHealth, Spawn>();

		private readonly Dictionary<int, Bar> localBars = new Dictionary<int, Bar>();

		private readonly Dictionary<int, Bar> remoteBars = new Dictionary<int, Bar>();

		private bool Host
		{
			get
			{
				if (SemiFunc.IsMultiplayer())
				{
					return PhotonNetwork.IsMasterClient;
				}
				return true;
			}
		}

		private bool Stage
		{
			get
			{
				if ((Object)(object)RunManager.instance != (Object)null)
				{
					return SemiFunc.RunIsLevel();
				}
				return false;
			}
		}

		private bool Authoritative
		{
			get
			{
				if (ready && !blocked && Host)
				{
					return Stage;
				}
				return false;
			}
		}

		private int Mode
		{
			get
			{
				if (stageMode < 0)
				{
					return Mathf.Clamp(selected.Value, 0, 4);
				}
				return stageMode;
			}
		}

		private void Awake()
		{
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected O, but got Unknown
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_01ef: Expected O, but got Unknown
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Expected O, but got Unknown
			//IL_0229: Expected O, but got Unknown
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Expected O, but got Unknown
			self = this;
			selected = ((BaseUnityPlugin)this).Config.Bind<int>("Difficulty", "Mode", 0, "0 Normal, 1 Hard, 2 Expert, 3 Nightmare, 4 Hell");
			duration = ((BaseUnityPlugin)this).Config.Bind<float>("HealthBars", "SecondsAfterHit", 4f, "Show HP for this long after the last hit");
			radius = ((BaseUnityPlugin)this).Config.Bind<float>("HealthBars", "MaxDistance", 22f, "Maximum display distance");
			barsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("HealthBars", "Enabled", true, "Show enemy HP after damage");
			difficultyHud = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowDifficulty", true, "Show difficulty and F4 help");
			maxField = AccessTools.Field(typeof(EnemyHealth), "health");
			currentField = AccessTools.Field(typeof(EnemyHealth), "healthCurrent");
			enemyField = AccessTools.Field(typeof(EnemyHealth), "enemy");
			MethodInfo methodInfo = AccessTools.Method(typeof(EnemyHealth), "OnSpawn", (Type[])null, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(EnemyHealth), "Hurt", (Type[])null, (Type[])null);
			if (maxField == null || currentField == null || maxField.FieldType != typeof(int) || currentField.FieldType != typeof(int) || methodInfo == null || methodInfo2 == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Unsupported REPO enemy API; disabled.");
				return;
			}
			harmony = new Harmony("den.repo.difficulty");
			try
			{
				harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin), "SpawnBefore", (Type[])null), new HarmonyMethod(typeof(Plugin), "SpawnAfter", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(Plugin), "HurtBefore", (Type[])null), new HarmonyMethod(typeof(Plugin), "HurtAfter", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				MethodInfo[] array = (from m in typeof(PlayerHealth).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
					where m.Name == "HurtOther" && m.GetParameters().Any((ParameterInfo p) => p.Name == "damage" && p.ParameterType == typeof(int)) && m.GetParameters().Any((ParameterInfo p) => p.Name == "enemyIndex" && p.ParameterType == typeof(int))
					select m).ToArray();
				if (array.Length == 1)
				{
					harmony.Patch((MethodBase)array[0], new HarmonyMethod(typeof(Plugin), "PlayerHit", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					damageHook = true;
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"Enemy damage multiplier unavailable; HP scaling still enabled.");
				}
				SceneManager.sceneLoaded += SceneLoaded;
				PhotonNetwork.NetworkingClient.EventReceived += OnEvent;
				ready = true;
				((BaseUnityPlugin)this).Logger.LogInfo((object)("REPO Difficulty initialized; damage hook=" + damageHook));
			}
			catch (Exception ex)
			{
				harmony.UnpatchSelf();
				((BaseUnityPlugin)this).Logger.LogError((object)ex);
			}
		}

		private void OnDestroy()
		{
			if (ready)
			{
				SceneManager.sceneLoaded -= SceneLoaded;
				PhotonNetwork.NetworkingClient.EventReceived -= OnEvent;
			}
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			if ((Object)(object)self == (Object)(object)this)
			{
				self = null;
			}
		}

		private void SceneLoaded(Scene scene, LoadSceneMode mode)
		{
			spawned.Clear();
			localBars.Clear();
			remoteBars.Clear();
			stageMode = -1;
		}

		private int Read(FieldInfo f, EnemyHealth e)
		{
			if (!((Object)(object)e == (Object)null))
			{
				return (int)f.GetValue(e);
			}
			return 0;
		}

		private int ViewId(EnemyHealth e)
		{
			if ((Object)(object)e == (Object)null)
			{
				return 0;
			}
			PhotonView val = ((Component)e).GetComponent<PhotonView>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)e).GetComponentInParent<PhotonView>();
			}
			if (!((Object)(object)val == (Object)null))
			{
				return val.ViewID;
			}
			return 0;
		}

		private static void SpawnBefore(EnemyHealth __instance)
		{
			try
			{
				if ((Object)(object)self == (Object)null || !self.Authoritative || (Object)(object)__instance == (Object)null)
				{
					return;
				}
				if (self.spawned.TryGetValue(__instance, out var value))
				{
					if (self.Read(self.maxField, __instance) == value.Scaled)
					{
						self.maxField.SetValue(__instance, value.Baseline);
					}
					self.spawned.Remove(__instance);
				}
				self.localBars.Remove(((Object)__instance).GetInstanceID());
				int num = self.ViewId(__instance);
				if (num > 0)
				{
					self.Send(num, 0, 1);
				}
			}
			catch (Exception ex)
			{
				Plugin plugin = self;
				if (plugin != null)
				{
					((BaseUnityPlugin)plugin).Logger.LogWarning((object)ex);
				}
			}
		}

		private static void SpawnAfter(EnemyHealth __instance)
		{
			try
			{
				if ((Object)(object)self != (Object)null && self.Authoritative)
				{
					self.Scale(__instance, fresh: true);
				}
			}
			catch (Exception ex)
			{
				Plugin plugin = self;
				if (plugin != null)
				{
					((BaseUnityPlugin)plugin).Logger.LogWarning((object)ex);
				}
			}
		}

		private void Scale(EnemyHealth e, bool fresh)
		{
			if ((Object)(object)e == (Object)null || spawned.ContainsKey(e))
			{
				return;
			}
			if (stageMode < 0)
			{
				stageMode = Mathf.Clamp(selected.Value, 0, 4);
			}
			int num = Read(maxField, e);
			int num2 = Read(currentField, e);
			if (num > 0 && num2 > 0)
			{
				int num3 = Mathf.Clamp(Mathf.RoundToInt((float)num * hp[Mode]), 1, 1000000);
				int num4 = (fresh ? num3 : Mathf.Clamp(Mathf.RoundToInt((float)num2 / (float)num * (float)num3), 1, num3));
				if (Mode != 0)
				{
					maxField.SetValue(e, num3);
					currentField.SetValue(e, num4);
				}
				spawned[e] = new Spawn
				{
					Baseline = num,
					Scaled = num3
				};
			}
		}

		private static void HurtBefore(EnemyHealth __instance, out Hit __state)
		{
			__state = null;
			try
			{
				if (!((Object)(object)self == (Object)null) && self.Authoritative && !((Object)(object)__instance == (Object)null))
				{
					self.Scale(__instance, fresh: false);
					__state = new Hit
					{
						Before = self.Read(self.currentField, __instance),
						Max = self.Read(self.maxField, __instance),
						ViewId = self.ViewId(__instance),
						Instance = ((Object)__instance).GetInstanceID(),
						Enemy = __instance
					};
				}
			}
			catch (Exception ex)
			{
				Plugin plugin = self;
				if (plugin != null)
				{
					((BaseUnityPlugin)plugin).Logger.LogWarning((object)ex);
				}
			}
		}

		private static void HurtAfter(Hit __state)
		{
			try
			{
				if ((Object)(object)self == (Object)null || !self.Authoritative || __state == null || __state.Before <= 0 || __state.Max <= 0)
				{
					return;
				}
				int num = self.Read(self.currentField, __state.Enemy);
				if (num < __state.Before)
				{
					num = Mathf.Clamp(num, 0, __state.Max);
					if (num == 0)
					{
						self.localBars.Remove(__state.Instance);
					}
					else
					{
						self.Touch(self.localBars, __state.Instance, __state.Enemy, __state.ViewId, num, __state.Max);
					}
					if (__state.ViewId > 0)
					{
						self.Send(__state.ViewId, num, __state.Max);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin plugin = self;
				if (plugin != null)
				{
					((BaseUnityPlugin)plugin).Logger.LogWarning((object)ex);
				}
			}
		}

		private static void PlayerHit(ref int damage, int enemyIndex)
		{
			try
			{
				if (!((Object)(object)self == (Object)null) && self.Authoritative && damage > 0 && enemyIndex >= 0)
				{
					float num = self.damage[self.Mode];
					if (num > 1f)
					{
						damage = Mathf.Clamp(Mathf.RoundToInt((float)damage * num), 1, 1000000);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin plugin = self;
				if (plugin != null)
				{
					((BaseUnityPlugin)plugin).Logger.LogWarning((object)ex);
				}
			}
		}

		private void Send(int view, int current, int max)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0063: Expected O, but got Unknown
			if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient)
			{
				object[] obj = new object[5] { "den.difficulty.hp.v1", null, null, null, null };
				Scene activeScene = SceneManager.GetActiveScene();
				obj[1] = ((Scene)(ref activeScene)).name;
				obj[2] = view;
				obj[3] = current;
				obj[4] = max;
				PhotonNetwork.RaiseEvent((byte)186, (object)obj, new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)0
				}, SendOptions.SendReliable);
			}
		}

		private void OnEvent(EventData e)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if (e.Code != 186 || !ready || blocked || !PhotonNetwork.InRoom || PhotonNetwork.MasterClient == null || e.Sender != PhotonNetwork.MasterClient.ActorNumber || !Stage || !(e.CustomData is object[] array) || array.Length != 5 || !object.Equals(array[0], "den.difficulty.hp.v1"))
			{
				return;
			}
			object objA = array[1];
			Scene activeScene = SceneManager.GetActiveScene();
			if (object.Equals(objA, ((Scene)(ref activeScene)).name) && array[2] is int num && num > 0 && array[3] is int num2 && array[4] is int num3 && num3 > 0 && num3 <= 1000000 && num2 >= 0 && num2 <= num3)
			{
				if (num2 == 0)
				{
					remoteBars.Remove(num);
					return;
				}
				PhotonView val = PhotonView.Find(num);
				EnemyHealth e2 = (((Object)(object)val == (Object)null) ? null : (((Component)val).GetComponent<EnemyHealth>() ?? ((Component)val).GetComponentInChildren<EnemyHealth>() ?? ((Component)val).GetComponentInParent<EnemyHealth>()));
				Touch(remoteBars, num, e2, num, num2, num3);
			}
		}

		private void Touch(Dictionary<int, Bar> map, int id, EnemyHealth e, int view, int current, int max)
		{
			if (!map.TryGetValue(id, out var value))
			{
				value = (map[id] = new Bar());
			}
			if ((Object)(object)value.Enemy != (Object)(object)e)
			{
				value.Renderers = null;
				value.Enemy = e;
			}
			value.ViewId = view;
			value.Current = current;
			value.Max = max;
			value.Until = Time.unscaledTime + Mathf.Clamp(duration.Value, 0.5f, 30f);
		}

		private int DisplayMode()
		{
			if (!PhotonNetwork.InRoom || Host)
			{
				return Mode;
			}
			if (((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).TryGetValue((object)"den.difficulty.mode.v1", out object value) && value is int num && num >= 0 && num <= 4)
			{
				return num;
			}
			return -1;
		}

		private void Update()
		{
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Expected O, but got Unknown
			//IL_0225: Expected O, but got Unknown
			if (!ready)
			{
				return;
			}
			string text = (PhotonNetwork.InRoom ? PhotonNetwork.CurrentRoom.Name : "");
			if (text != room || hadRoom != PhotonNetwork.InRoom)
			{
				room = text;
				hadRoom = PhotonNetwork.InRoom;
				blocked = false;
				nextPublish = 0f;
				originalMaster = ((PhotonNetwork.InRoom && PhotonNetwork.MasterClient != null) ? PhotonNetwork.MasterClient.ActorNumber : 0);
				localBars.Clear();
				remoteBars.Clear();
			}
			if (PhotonNetwork.InRoom && PhotonNetwork.MasterClient != null && PhotonNetwork.MasterClient.ActorNumber != originalMaster)
			{
				blocked = true;
			}
			if (Host && !blocked && Input.GetKeyDown((KeyCode)285))
			{
				if (Stage)
				{
					notice = "Difficulty changes in lobby / shop only";
				}
				else
				{
					selected.Value = (Mathf.Clamp(selected.Value, 0, 4) + 1) % 5;
					((BaseUnityPlugin)this).Config.Save();
					stageMode = -1;
					nextPublish = 0f;
					notice = "Next stage: " + names[selected.Value];
				}
				noticeUntil = Time.unscaledTime + 4f;
			}
			if (Stage && Host && stageMode < 0)
			{
				stageMode = Mathf.Clamp(selected.Value, 0, 4);
			}
			if (Time.unscaledTime >= nextPublish)
			{
				nextPublish = Time.unscaledTime + 1f;
				if (PhotonNetwork.InRoom && Host && !blocked && (!((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).TryGetValue((object)"den.difficulty.mode.v1", out object value) || !object.Equals(value, Mode)))
				{
					Room currentRoom = PhotonNetwork.CurrentRoom;
					Hashtable val = new Hashtable();
					((Dictionary<object, object>)val).Add((object)"den.difficulty.mode.v1", (object)Mode);
					currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
				}
				int[] array = (from x in localBars
					where x.Value.Until <= Time.unscaledTime || (Object)(object)x.Value.Enemy == (Object)null
					select x.Key).ToArray();
				foreach (int key in array)
				{
					localBars.Remove(key);
				}
				array = (from x in remoteBars
					where x.Value.Until <= Time.unscaledTime
					select x.Key).ToArray();
				foreach (int key2 in array)
				{
					remoteBars.Remove(key2);
				}
			}
		}

		private Vector3 Head(Bar b)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			EnemyHealth enemy = b.Enemy;
			if (b.Renderers == null)
			{
				object? obj = enemyField?.GetValue(enemy);
				Component val = (Component)((obj is Component) ? obj : null);
				if ((Object)(object)val == (Object)null)
				{
					val = (Component)(object)enemy;
				}
				b.Renderers = (from r in val.GetComponentsInChildren<Renderer>(false)
					where (Object)(object)r != (Object)null && (r is MeshRenderer || r is SkinnedMeshRenderer)
					select r).ToArray();
			}
			Bounds bounds = default(Bounds);
			((Bounds)(ref bounds))..ctor(((Component)enemy).transform.position, Vector3.one);
			bool flag = false;
			Renderer[] renderers = b.Renderers;
			foreach (Renderer val2 in renderers)
			{
				if ((Object)(object)val2 == (Object)null || !val2.enabled || !((Component)val2).gameObject.activeInHierarchy)
				{
					continue;
				}
				Bounds bounds2 = val2.bounds;
				if (!(((Bounds)(ref bounds2)).size.y > 15f))
				{
					if (!flag)
					{
						bounds = val2.bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref bounds)).Encapsulate(val2.bounds);
					}
				}
			}
			if (!flag)
			{
				return ((Component)enemy).transform.position + Vector3.up * 1.6f;
			}
			return new Vector3(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).max.y + 0.18f, ((Bounds)(ref bounds)).center.z);
		}

		private static Rect DisplayViewport(Camera cam)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			RenderTexture targetTexture = cam.targetTexture;
			if ((Object)(object)targetTexture == (Object)null || ((Texture)targetTexture).width <= 0 || ((Texture)targetTexture).height <= 0)
			{
				return cam.pixelRect;
			}
			float num = (float)((Texture)targetTexture).width / (float)((Texture)targetTexture).height;
			float num2 = Screen.width;
			float num3 = Screen.height;
			if (num2 / num3 > num)
			{
				num2 = num3 * num;
			}
			else
			{
				num3 = num2 / num;
			}
			return new Rect(((float)Screen.width - num2) * 0.5f, ((float)Screen.height - num3) * 0.5f, num2, num3);
		}

		private void OnGUI()
		{
			//IL_0109: 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)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Expected O, but got Unknown
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			if (!ready || (Object)(object)RunManager.instance == (Object)null)
			{
				return;
			}
			if (difficultyHud.Value && (Stage || SemiFunc.RunIsShop() || SemiFunc.RunIsLobby() || SemiFunc.RunIsLobbyMenu()))
			{
				int num = DisplayMode();
				GUI.Box(new Rect((float)(Screen.width - 250), 18f, 232f, 52f), blocked ? "DIFFICULTY SUSPENDED" : ((num < 0) ? "DIFFICULTY: waiting for host" : ("DIFFICULTY: " + names[num])));
				if (Host)
				{
					GUI.Label(new Rect((float)(Screen.width - 238), 39f, 220f, 22f), Stage ? "F4: Lobby / Shop only" : "F4: Change Difficulty");
				}
			}
			if (Time.unscaledTime < noticeUntil)
			{
				GUI.Box(new Rect((float)((Screen.width - 380) / 2), 16f, 380f, 35f), notice);
			}
			if (!barsEnabled.Value || !Stage || blocked)
			{
				return;
			}
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				return;
			}
			Rect val = DisplayViewport(main);
			foreach (Bar value in (Host ? localBars : remoteBars).Values)
			{
				if (value.Until <= Time.unscaledTime || value.Current <= 0 || value.Max <= 0)
				{
					continue;
				}
				if ((Object)(object)value.Enemy == (Object)null && value.ViewId > 0)
				{
					PhotonView val2 = PhotonView.Find(value.ViewId);
					if ((Object)(object)val2 != (Object)null)
					{
						value.Enemy = ((Component)val2).GetComponent<EnemyHealth>() ?? ((Component)val2).GetComponentInChildren<EnemyHealth>() ?? ((Component)val2).GetComponentInParent<EnemyHealth>();
					}
				}
				if ((Object)(object)value.Enemy == (Object)null || !((Component)value.Enemy).gameObject.activeInHierarchy)
				{
					continue;
				}
				Vector3 val3 = Head(value);
				float num2 = Vector3.Distance(((Component)main).transform.position, val3);
				if (!(num2 > Mathf.Clamp(radius.Value, 3f, 60f)))
				{
					Vector3 val4 = main.WorldToViewportPoint(val3);
					if (!(val4.z <= 0f) && !(val4.x < 0f) && !(val4.x > 1f) && !(val4.y < 0f) && !(val4.y > 1f))
					{
						float num3 = ((Rect)(ref val)).x + val4.x * ((Rect)(ref val)).width;
						float num4 = (float)Screen.height - (((Rect)(ref val)).y + val4.y * ((Rect)(ref val)).height);
						float num5 = Mathf.Clamp(170f - num2 * 2f, 105f, 170f);
						float num6 = 12f;
						Color color = GUI.color;
						float num7 = Mathf.Clamp01((value.Until - Time.unscaledTime) / 0.45f);
						GUI.color = new Color(0.07f, 0.07f, 0.07f, 0.9f * num7);
						GUI.DrawTexture(new Rect(num3 - num5 / 2f - 1f, num4 - 1f, num5 + 2f, num6 + 2f), (Texture)(object)Texture2D.whiteTexture);
						float num8 = Mathf.Clamp01((float)value.Current / (float)value.Max);
						GUI.color = new Color(0.88f, 0.22f, 0.2f, num7);
						GUI.DrawTexture(new Rect(num3 - num5 / 2f, num4, num5 * num8, num6), (Texture)(object)Texture2D.whiteTexture);
						GUI.color = new Color(1f, 1f, 1f, num7);
						GUIStyle val5 = new GUIStyle(GUI.skin.label)
						{
							alignment = (TextAnchor)4,
							fontSize = 15
						};
						GUI.Label(new Rect(num3 - 100f, num4 - 25f, 200f, 24f), value.Current + " / " + value.Max, val5);
						GUI.color = color;
					}
				}
			}
		}
	}
}