Decompiled source of CollapseDisplay v1.3.3

plugins/CollapseDisplay/CollapseDisplay.dll

Decompiled a month ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CollapseDisplay;
using CollapseDisplay.Config;
using CollapseDisplay.Networking;
using CollapseDisplay.Properties;
using CollapseDisplay.Utilities.Extensions;
using IL.RoR2.UI;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
using MonoMod.Cil;
using MonoMod.Utils;
using On.RoR2.UI;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using Unity;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CollapseDisplay")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyConfiguration("Release")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyInformationalVersion("1.0.0+b0153eda84ce47070d08d3269e4d2c5bc4d0bf3d")]
[assembly: AssemblyTitle("CollapseDisplay")]
[assembly: AssemblyProduct("CollapseDisplay")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CollapseDisplay
{
	public class AcceptableValueMin<T> : AcceptableValueBase where T : IComparable
	{
		public T MinValue { get; }

		public AcceptableValueMin(T minValue)
			: base(typeof(T))
		{
			if (minValue == null)
			{
				throw new ArgumentNullException("minValue");
			}
			MinValue = minValue;
		}

		public override object Clamp(object value)
		{
			if (MinValue.CompareTo(value) > 0)
			{
				return MinValue;
			}
			return value;
		}

		public override bool IsValid(object value)
		{
			return MinValue.CompareTo(value) <= 0;
		}

		public override string ToDescriptionString()
		{
			return $"# Acceptable value range: Greater than or equal to {MinValue}";
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Gorakh.CollapseDisplay", "CollapseDisplay", "1.3.3")]
	public class CollapseDisplayPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "Gorakh.CollapseDisplay";

		public const string PluginAuthor = "Gorakh";

		public const string PluginName = "CollapseDisplay";

		public const string PluginVersion = "1.3.3";

		private static Sprite _healthBarHighlight;

		internal static CollapseDisplayPlugin Instance { get; private set; }

		public static DelayedDamageDisplayOptions CollapseDisplayOptions { get; private set; }

		public static DelayedDamageDisplayOptions WarpedEchoDisplayOptions { get; private set; }

		private void Awake()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			Stopwatch stopwatch = Stopwatch.StartNew();
			Log.Init(((BaseUnityPlugin)this).Logger);
			Instance = SingletonHelper.Assign<CollapseDisplayPlugin>(Instance, this);
			Texture2D val = new Texture2D(1, 1);
			if (ImageConversion.LoadImage(val, Resources.HealthBarHighlight_Opaque))
			{
				_healthBarHighlight = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)1, new Vector4(4f, 3f, 3f, 4f));
				((Object)_healthBarHighlight).name = "HealthBarHighlightOpaque";
			}
			else
			{
				Log.Error("Failed to load health bar overlay texture", "X:\\Git\\RoR2\\CollapseDisplay\\CollapseDisplay\\CollapseDisplayPlugin.cs", "Awake", 42);
				_healthBarHighlight = null;
			}
			Sprite highlightSprite = (Object.op_Implicit((Object)(object)_healthBarHighlight) ? _healthBarHighlight : Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/texUIHighlightExecute.png").WaitForCompletion());
			CollapseDisplayOptions = new DelayedDamageDisplayOptions(highlightSprite, ((BaseUnityPlugin)this).Config, "Collapse", new Color(84f / 85f, 0.14509805f, 22f / 85f, 1f), 1f);
			WarpedEchoDisplayOptions = new DelayedDamageDisplayOptions(highlightSprite, ((BaseUnityPlugin)this).Config, "Warped Echo", new Color(54f / 85f, 0.5921569f, 47f / 85f, 1f), 1f);
			if (RiskOfOptionsCompat.Enabled)
			{
				RiskOfOptionsCompat.Initialize();
			}
			HealthBarTypeRegistration.Initialize();
			HealthBarHooks.Initialize();
			DelayedDamageProviderHooks.Initialize();
			stopwatch.Stop();
			Log.Info_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalSeconds:F2} seconds");
		}

		private void OnDestroy()
		{
			HealthBarTypeRegistration.Cleanup();
			HealthBarHooks.Cleanup();
			DelayedDamageProviderHooks.Cleanup();
			Instance = SingletonHelper.Unassign<CollapseDisplayPlugin>(Instance, this);
		}
	}
	public struct DelayedDamageInfo : IEquatable<DelayedDamageInfo>
	{
		public static readonly DelayedDamageInfo None = new DelayedDamageInfo(-1f, FixedTimeStamp.negativeInfinity);

		public float Damage;

		public Net_RunFixedTimeStampWrapper Wrap_DamageTimestamp;

		public FixedTimeStamp DamageTimestamp
		{
			readonly get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				return Wrap_DamageTimestamp;
			}
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				Wrap_DamageTimestamp = value;
			}
		}

		public DelayedDamageInfo()
		{
			Damage = 0f;
			Wrap_DamageTimestamp = default(Net_RunFixedTimeStampWrapper);
		}

		public DelayedDamageInfo(float damage, FixedTimeStamp damageTimestamp)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			Damage = damage;
			Wrap_DamageTimestamp = damageTimestamp;
		}

		public readonly bool Equals(DelayedDamageInfo other)
		{
			if (Damage == other.Damage)
			{
				return Wrap_DamageTimestamp.Equals(other.Wrap_DamageTimestamp);
			}
			return false;
		}
	}
	[DisallowMultipleComponent]
	public class DelayedDamageProvider : NetworkBehaviour
	{
		[SyncVar]
		private DelayedDamageInfo _collapseDamage;

		[SyncVar]
		private DelayedDamageInfo _warpedEchoDamage;

		private CharacterBody _body;

		private HealthComponent _healthComponent;

		public DelayedDamageInfo CollapseDamage => _collapseDamage;

		public DelayedDamageInfo WarpedEchoDamage => _warpedEchoDamage;

		public DelayedDamageInfo Network_collapseDamage
		{
			get
			{
				return _collapseDamage;
			}
			[param: In]
			set
			{
				((NetworkBehaviour)this).SetSyncVar<DelayedDamageInfo>(value, ref _collapseDamage, 1u);
			}
		}

		public DelayedDamageInfo Network_warpedEchoDamage
		{
			get
			{
				return _warpedEchoDamage;
			}
			[param: In]
			set
			{
				((NetworkBehaviour)this).SetSyncVar<DelayedDamageInfo>(value, ref _warpedEchoDamage, 2u);
			}
		}

		private void Awake()
		{
			_body = ((Component)this).GetComponent<CharacterBody>();
			_healthComponent = ((Component)this).GetComponent<HealthComponent>();
		}

		private void FixedUpdate()
		{
			if (NetworkServer.active)
			{
				fixedUpdateServer();
			}
		}

		[Server]
		private void fixedUpdateServer()
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Invalid comparison between Unknown and I4
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_00eb: 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_00fa: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Debug.LogWarning((object)"[Server] function 'System.Void CollapseDisplay.DelayedDamageProvider::fixedUpdateServer()' called on client");
				return;
			}
			DelayedDamageInfo none = DelayedDamageInfo.None;
			DelayedDamageInfo none2 = DelayedDamageInfo.None;
			if (Object.op_Implicit((Object)(object)_body))
			{
				if (Object.op_Implicit((Object)(object)_healthComponent) && _healthComponent.alive)
				{
					DotController val = DotController.FindDotController(((Component)this).gameObject);
					if (Object.op_Implicit((Object)(object)val) && val.HasDotActive((DotIndex)8))
					{
						float num = float.PositiveInfinity;
						none.Damage = 0f;
						foreach (DotStack dotStack in val.dotStackList)
						{
							if ((int)dotStack.dotIndex == 8)
							{
								num = Mathf.Min(num, dotStack.timer);
								float damage = dotStack.damage;
								DamageInfo damageInfo = new DamageInfo
								{
									attacker = dotStack.attackerObject,
									damageType = (dotStack.damageType | DamageTypeCombo.op_Implicit((DamageType)67108864)),
									damage = damage
								};
								modifyIncomingDamage(ref damage, damageInfo);
								if (damage > 0f)
								{
									none.Damage += damage;
								}
							}
						}
						if (float.IsFinite(num) && num > 0f)
						{
							none.DamageTimestamp = FixedTimeStamp.now + num;
						}
					}
				}
				if (_body.incomingDamageList.Count > 0)
				{
					float num2 = float.PositiveInfinity;
					none2.Damage = 0f;
					foreach (DelayedDamageInfo incomingDamage in _body.incomingDamageList)
					{
						num2 = Mathf.Min(num2, incomingDamage.timeUntilDamage);
						DamageInfo halfDamage = incomingDamage.halfDamage;
						float damage2 = halfDamage.damage;
						modifyIncomingDamage(ref damage2, halfDamage);
						if (damage2 > 0f)
						{
							none2.Damage += damage2;
						}
					}
					if (float.IsFinite(num2) && num2 > 0f)
					{
						none2.DamageTimestamp = FixedTimeStamp.now + num2;
					}
				}
			}
			Network_collapseDamage = none;
			Network_warpedEchoDamage = none2;
		}

		private void modifyIncomingDamage(ref float damage, DamageInfo damageInfo)
		{
			//IL_0008: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			bool flag = damageInfo.crit;
			bool num = DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)2)) != 0;
			CharacterMaster val = null;
			CharacterBody val2 = null;
			TeamIndex val3 = (TeamIndex)(-1);
			Vector3 val4 = Vector3.zero;
			float combinedHealth = _healthComponent.combinedHealth;
			if (Object.op_Implicit((Object)(object)damageInfo.attacker))
			{
				val2 = damageInfo.attacker.GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)val2))
				{
					val3 = val2.teamComponent.teamIndex;
					val4 = val2.corePosition - damageInfo.position;
				}
			}
			if (val3 == _body.teamComponent.teamIndex)
			{
				TeamDef teamDef = TeamCatalog.GetTeamDef(val3);
				if (teamDef != null)
				{
					damage *= teamDef.friendlyFireScaling;
				}
			}
			if (Object.op_Implicit((Object)(object)val2))
			{
				if (val2.canPerformBackstab && DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)67108864)) == 0L && (((ProcChainMask)(ref damageInfo.procChainMask)).HasProc((ProcType)17) || BackstabManager.IsBackstab(-val4, _body)))
				{
					flag = true;
				}
				val = val2.master;
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.inventory))
				{
					if (combinedHealth >= _healthComponent.fullCombinedHealth * 0.9f)
					{
						int itemCount = val.inventory.GetItemCount(Items.Crowbar);
						if (itemCount > 0)
						{
							damage *= 1f + 0.75f * (float)itemCount;
						}
					}
					int itemCount2 = val.inventory.GetItemCount(Items.NearbyDamageBonus);
					if (itemCount2 > 0 && ((Vector3)(ref val4)).sqrMagnitude <= 169f)
					{
						damage *= 1f + (float)itemCount2 * 0.2f;
					}
					int itemCount3 = val.inventory.GetItemCount(Items.FragileDamageBonus);
					if (itemCount3 > 0)
					{
						damage *= 1f + (float)itemCount3 * 0.2f;
					}
					if (val2.HasBuff(Buffs.LowerHealthHigherDamageBuff))
					{
						int itemCount4 = val.inventory.GetItemCount(Items.LowerHealthHigherDamage);
						damage *= 1f + (float)itemCount4 * 0.2f;
					}
					if (damageInfo.procCoefficient > 0f && _body.HasBuff(Buffs.MercExpose) && val2.bodyIndex == BodyCatalog.FindBodyIndex("MercBody"))
					{
						float num2 = val2.damage * 3.5f;
						damage += num2;
					}
					if (_body.isBoss)
					{
						int itemCount5 = val.inventory.GetItemCount(Items.BossDamageBonus);
						if (itemCount5 > 0)
						{
							damage *= 1f + 0.2f * (float)itemCount5;
						}
					}
				}
				if (flag)
				{
					damage *= val2.critMultiplier;
				}
			}
			if (DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)16)) != 0L)
			{
				damage *= 1.5f;
			}
			if (_body.HasBuff(Buffs.DeathMark))
			{
				damage *= 1.5f;
			}
			if (!num)
			{
				float armor = _body.armor;
				armor += _healthComponent.adaptiveArmorValue;
				if ((_body.bodyFlags & 0x40) != 0 && DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)131072)) != 0L)
				{
					armor += 300f;
				}
				float num3 = ((armor >= 0f) ? (1f - armor / (armor + 100f)) : (2f - 100f / (100f - armor)));
				damage = Mathf.Max(1f, damage * num3);
				if (Object.op_Implicit((Object)(object)_body.inventory))
				{
					int itemCount6 = _body.inventory.GetItemCount(Items.ArmorPlate);
					if (itemCount6 > 0)
					{
						damage = Mathf.Max(1f, damage - 5f * (float)itemCount6);
					}
				}
			}
			if (_body.hasOneShotProtection)
			{
				float num4 = (_healthComponent.fullCombinedHealth + _healthComponent.barrier) * (1f - _body.oneShotProtectionFraction);
				float num5 = Mathf.Max(0f, num4 - _healthComponent.serverDamageTakenThisUpdate);
				damage = Mathf.Min(damage, num5);
			}
			if (DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)524288)) != 0L)
			{
				float num6 = Mathf.Lerp(3f, 1f, _healthComponent.combinedHealthFraction);
				damage *= num6;
			}
			if (_body.HasBuff(Buffs.LunarShell) && damage > _healthComponent.fullHealth * 0.1f)
			{
				damage = _healthComponent.fullHealth * 0.1f;
			}
			if (Object.op_Implicit((Object)(object)_body.inventory))
			{
				int itemCount7 = _body.inventory.GetItemCount(Items.MinHealthPercentage);
				if (itemCount7 > 0)
				{
					float num7 = _healthComponent.fullCombinedHealth * ((float)itemCount7 / 100f);
					damage = Mathf.Max(0f, Mathf.Min(damage, _healthComponent.combinedHealth - num7));
				}
			}
			if (!damageInfo.delayedDamageSecondHalf && _body.HasBuff(Buffs.DelayedDamageBuff))
			{
				damage *= 0.5f;
			}
		}

		private void UNetVersion()
		{
		}

		public override bool OnSerialize(NetworkWriter writer, bool forceAll)
		{
			if (forceAll)
			{
				GeneratedNetworkCode._WriteDelayedDamageInfo_None(writer, _collapseDamage);
				GeneratedNetworkCode._WriteDelayedDamageInfo_None(writer, _warpedEchoDamage);
				return true;
			}
			bool flag = false;
			if ((((NetworkBehaviour)this).syncVarDirtyBits & (true ? 1u : 0u)) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				GeneratedNetworkCode._WriteDelayedDamageInfo_None(writer, _collapseDamage);
			}
			if ((((NetworkBehaviour)this).syncVarDirtyBits & 2u) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				GeneratedNetworkCode._WriteDelayedDamageInfo_None(writer, _warpedEchoDamage);
			}
			if (!flag)
			{
				writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
			}
			return flag;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
			if (initialState)
			{
				_collapseDamage = GeneratedNetworkCode._ReadDelayedDamageInfo_None(reader);
				_warpedEchoDamage = GeneratedNetworkCode._ReadDelayedDamageInfo_None(reader);
				return;
			}
			int num = (int)reader.ReadPackedUInt32();
			if (((uint)num & (true ? 1u : 0u)) != 0)
			{
				_collapseDamage = GeneratedNetworkCode._ReadDelayedDamageInfo_None(reader);
			}
			if (((uint)num & 2u) != 0)
			{
				_warpedEchoDamage = GeneratedNetworkCode._ReadDelayedDamageInfo_None(reader);
			}
		}
	}
	internal static class DelayedDamageProviderHooks
	{
		private static readonly List<DelayedDamageProvider> _delayedDamageProviderPrefabComponents = new List<DelayedDamageProvider>();

		public static void Initialize()
		{
			destroyAllPrefabComponents();
			((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)delegate
			{
				if (_delayedDamageProviderPrefabComponents.Capacity < BodyCatalog.bodyCount)
				{
					_delayedDamageProviderPrefabComponents.Capacity = BodyCatalog.bodyCount;
				}
				foreach (GameObject allBodyPrefab in BodyCatalog.allBodyPrefabs)
				{
					if (Object.op_Implicit((Object)(object)allBodyPrefab.GetComponent<HealthComponent>()))
					{
						DelayedDamageProvider item = allBodyPrefab.AddComponent<DelayedDamageProvider>();
						_delayedDamageProviderPrefabComponents.Add(item);
					}
				}
			});
		}

		public static void Cleanup()
		{
			destroyAllPrefabComponents();
		}

		private static void destroyAllPrefabComponents()
		{
			foreach (DelayedDamageProvider delayedDamageProviderPrefabComponent in _delayedDamageProviderPrefabComponents)
			{
				Object.Destroy((Object)(object)delayedDamageProviderPrefabComponent);
			}
			_delayedDamageProviderPrefabComponents.Clear();
		}
	}
	internal static class HealthBarHooks
	{
		private readonly struct AdditionalBarInfos
		{
			public static readonly FieldInfo[] BarInfoFields = (from f in typeof(AdditionalBarInfos).GetFields(BindingFlags.Instance | BindingFlags.Public)
				where f.FieldType == typeof(BarInfo)
				select f).ToArray();

			public readonly BarInfo CollapseDamageBarInfo;

			public readonly BarInfo WarpedEchoDamageBarInfo;

			public readonly int EnabledBarCount;

			public AdditionalBarInfos(BarInfo collapseDamageBarInfo, BarInfo warpedEchoDamageBarInfo)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0004: 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_001c: Unknown result type (might be due to invalid IL or missing references)
				int num = 0;
				CollapseDamageBarInfo = collapseDamageBarInfo;
				if (CollapseDamageBarInfo.enabled)
				{
					num++;
				}
				WarpedEchoDamageBarInfo = warpedEchoDamageBarInfo;
				if (WarpedEchoDamageBarInfo.enabled)
				{
					num++;
				}
				EnabledBarCount = num;
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__HealthBar_ApplyBars;

			public static Func<HealthBar, AdditionalBarInfos> <1>__collectBarInfos;

			public static <>F{00000018}<int, AdditionalBarInfos, int> <2>__addDamageDisplayBarsToCount;
		}

		public static void Initialize()
		{
			//IL_0010: 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: Expected O, but got Unknown
			object obj = <>O.<0>__HealthBar_ApplyBars;
			if (obj == null)
			{
				Manipulator val = HealthBar_ApplyBars;
				<>O.<0>__HealthBar_ApplyBars = val;
				obj = (object)val;
			}
			HealthBar.ApplyBars += (Manipulator)obj;
		}

		public static void Cleanup()
		{
			//IL_0010: 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: Expected O, but got Unknown
			object obj = <>O.<0>__HealthBar_ApplyBars;
			if (obj == null)
			{
				Manipulator val = HealthBar_ApplyBars;
				<>O.<0>__HealthBar_ApplyBars = val;
				obj = (object)val;
			}
			HealthBar.ApplyBars -= (Manipulator)obj;
		}

		private static void HealthBar_ApplyBars(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			MethodReference handleBarMethod = null;
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref handleBarMethod) && nameStartsWith(handleBarMethod, "<ApplyBars>g__HandleBar|")
			}))
			{
				int localsVarIndex = -1;
				if (val.TryGotoPrev(new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdloca(x, ref localsVarIndex)
				}))
				{
					VariableDefinition val2 = il.Method.Body.Variables[localsVarIndex];
					val.Index = 0;
					VariableDefinition val3 = il.AddVariable<AdditionalBarInfos>();
					val.Emit(OpCodes.Ldarg_0);
					val.EmitDelegate<Func<HealthBar, AdditionalBarInfos>>((Func<HealthBar, AdditionalBarInfos>)collectBarInfos);
					val.Emit(OpCodes.Stloc, val3);
					if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
					{
						(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<BarInfoCollection>(x, "GetActiveCount")
					}))
					{
						val.Emit(OpCodes.Ldloca, val3);
						val.EmitDelegate<<>F{00000018}<int, AdditionalBarInfos, int>>((<>F{00000018}<int, AdditionalBarInfos, int>)addDamageDisplayBarsToCount);
						if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[1]
						{
							(Instruction x) => ILPatternMatchingExt.MatchRet(x)
						}))
						{
							Log.Error("Failed to find patch location", "X:\\Git\\RoR2\\CollapseDisplay\\CollapseDisplay\\HealthBarHooks.cs", "HealthBar_ApplyBars", 118);
							return;
						}
						FieldInfo[] barInfoFields = AdditionalBarInfos.BarInfoFields;
						foreach (FieldInfo fieldInfo in barInfoFields)
						{
							val.Emit(OpCodes.Ldarg_0);
							val.Emit(OpCodes.Ldloca, val3);
							val.Emit(OpCodes.Ldflda, fieldInfo);
							val.Emit(OpCodes.Ldloca, val2);
							val.Emit(OpCodes.Call, handleBarMethod);
						}
					}
					else
					{
						Log.Error("Failed to find bar count patch location", "X:\\Git\\RoR2\\CollapseDisplay\\CollapseDisplay\\HealthBarHooks.cs", "HealthBar_ApplyBars", 111);
					}
				}
				else
				{
					Log.Error("Failed to find locals variable", "X:\\Git\\RoR2\\CollapseDisplay\\CollapseDisplay\\HealthBarHooks.cs", "HealthBar_ApplyBars", 78);
				}
			}
			else
			{
				Log.Error("Failed to find HandleBar method", "X:\\Git\\RoR2\\CollapseDisplay\\CollapseDisplay\\HealthBarHooks.cs", "HealthBar_ApplyBars", 84);
			}
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			static int addDamageDisplayBarsToCount(int activeCount, in AdditionalBarInfos damageDisplayBarInfos)
			{
				return activeCount + damageDisplayBarInfos.EnabledBarCount;
			}
			static bool nameStartsWith(MethodReference methodReference, string value)
			{
				if (methodReference == null || ((MemberReference)methodReference).Name == null)
				{
					return false;
				}
				return ((MemberReference)methodReference).Name.StartsWith(value);
			}
		}

		private static AdditionalBarInfos collectBarInfos(HealthBar healthBar)
		{
			//IL_0020: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			HealthBarType barType = HealthBarType.Unknown;
			HealthBarTypeProvider healthBarTypeProvider = default(HealthBarTypeProvider);
			if (((Component)healthBar).TryGetComponent<HealthBarTypeProvider>(ref healthBarTypeProvider))
			{
				barType = healthBarTypeProvider.Type;
			}
			DelayedDamageBarStyle damageBarStyle = CollapseDisplayPlugin.CollapseDisplayOptions.GetDamageBarStyle(barType);
			BarStyle barStyle = damageBarStyle.BarStyle;
			BarInfo val = default(BarInfo);
			val.enabled = false;
			val.color = barStyle.baseColor;
			val.sprite = barStyle.sprite;
			val.imageType = barStyle.imageType;
			val.sizeDelta = barStyle.sizeDelta;
			val.normalizedXMin = 0f;
			val.normalizedXMax = 0f;
			BarInfo barInfo2 = val;
			DelayedDamageBarStyle damageBarStyle2 = CollapseDisplayPlugin.WarpedEchoDisplayOptions.GetDamageBarStyle(barType);
			BarStyle barStyle2 = damageBarStyle2.BarStyle;
			val = default(BarInfo);
			val.enabled = false;
			val.color = barStyle2.baseColor;
			val.sprite = barStyle2.sprite;
			val.imageType = barStyle2.imageType;
			val.sizeDelta = barStyle2.sizeDelta;
			val.normalizedXMin = 0f;
			val.normalizedXMax = 0f;
			BarInfo barInfo3 = val;
			HealthComponent healthComponent = healthBar.source;
			DelayedDamageProvider delayedDamageProvider = default(DelayedDamageProvider);
			float totalBarDamageAmount;
			if (Object.op_Implicit((Object)(object)healthComponent) && ((Component)healthComponent).TryGetComponent<DelayedDamageProvider>(ref delayedDamageProvider))
			{
				totalBarDamageAmount = 0f;
				if (damageBarStyle2.EnabledConfig.Value)
				{
					tryAddDelayedDamageBar(delayedDamageProvider.WarpedEchoDamage, ref barInfo3);
				}
				if (damageBarStyle.EnabledConfig.Value)
				{
					tryAddDelayedDamageBar(delayedDamageProvider.CollapseDamage, ref barInfo2);
				}
			}
			return new AdditionalBarInfos(barInfo2, barInfo3);
			void addBar(ref BarInfo barInfo, float damageAmount)
			{
				//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_0052: Unknown result type (might be due to invalid IL or missing references)
				barInfo.enabled = true;
				HealthBarValues healthBarValues = healthComponent.GetHealthBarValues();
				float combinedHealth = healthComponent.combinedHealth;
				float fullCombinedHealth = healthComponent.fullCombinedHealth;
				float num = Mathf.Max(0f, combinedHealth - totalBarDamageAmount);
				float num2 = Mathf.Max(0f, num - damageAmount);
				float num3 = 1f - healthBarValues.curseFraction;
				float num4 = num2 / fullCombinedHealth * num3;
				barInfo.normalizedXMin = Mathf.Clamp01(num4);
				float num5 = num / fullCombinedHealth * num3;
				barInfo.normalizedXMax = Mathf.Clamp01(num5);
				totalBarDamageAmount += Mathf.Max(0f, num - num2);
			}
			void tryAddDelayedDamageBar(DelayedDamageInfo delayedDamageInfo, ref BarInfo barInfo)
			{
				//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)
				FixedTimeStamp damageTimestamp = delayedDamageInfo.DamageTimestamp;
				if (((FixedTimeStamp)(ref damageTimestamp)).timeUntil > 0f)
				{
					float num6 = delayedDamageInfo.Damage - healthComponent.barrier;
					if (num6 > 0f)
					{
						addBar(ref barInfo, num6);
					}
				}
			}
		}
	}
	public enum HealthBarType
	{
		Unknown,
		Hud,
		Combat,
		AllyList,
		Count
	}
	public class HealthBarTypeProvider : MonoBehaviour
	{
		public HealthBarType Type;
	}
	internal static class HealthBarTypeRegistration
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__HealthBar_Awake;
		}

		private static readonly HealthBarStyle _combatHealthBarStyle = Addressables.LoadAssetAsync<HealthBarStyle>((object)"RoR2/Base/Common/CombatHealthBar.asset").WaitForCompletion();

		private static readonly List<HealthBarTypeProvider> _addedPrefabProviders = new List<HealthBarTypeProvider>();

		public static void Initialize()
		{
			//IL_0010: 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: Expected O, but got Unknown
			object obj = <>O.<0>__HealthBar_Awake;
			if (obj == null)
			{
				hook_Awake val = HealthBar_Awake;
				<>O.<0>__HealthBar_Awake = val;
				obj = (object)val;
			}
			HealthBar.Awake += (hook_Awake)obj;
			registerHealthBarPrefab("RoR2/Base/UI/HUDSimple.prefab", HealthBarType.Hud);
			registerHealthBarPrefab("RoR2/Base/UI/CombatHealthbar.prefab", HealthBarType.Combat);
			registerHealthBarPrefab("RoR2/Base/UI/AllyCard.prefab", HealthBarType.AllyList);
			static void registerHealthBarPrefab(string assetPath, HealthBarType type)
			{
				//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)
				GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)assetPath).WaitForCompletion();
				if (!Object.op_Implicit((Object)(object)val2))
				{
					Log.Error("Invalid asset path '" + assetPath + "'", "X:\\Git\\RoR2\\CollapseDisplay\\CollapseDisplay\\HealthBarTypeRegistration.cs", "Initialize", 23);
				}
				else
				{
					int num = 0;
					HealthBar[] componentsInChildren = val2.GetComponentsInChildren<HealthBar>(true);
					foreach (HealthBar val3 in componentsInChildren)
					{
						if (!Object.op_Implicit((Object)(object)((Component)val3).GetComponent<HealthBarTypeProvider>()))
						{
							HealthBarTypeProvider healthBarTypeProvider = ((Component)val3).gameObject.AddComponent<HealthBarTypeProvider>();
							healthBarTypeProvider.Type = type;
							_addedPrefabProviders.Add(healthBarTypeProvider);
							num++;
						}
					}
					if (num == 0)
					{
						Log.Warning("No health bars found on asset '" + assetPath + "'", "X:\\Git\\RoR2\\CollapseDisplay\\CollapseDisplay\\HealthBarTypeRegistration.cs", "Initialize", 43);
					}
				}
			}
		}

		public static void Cleanup()
		{
			//IL_0010: 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: Expected O, but got Unknown
			object obj = <>O.<0>__HealthBar_Awake;
			if (obj == null)
			{
				hook_Awake val = HealthBar_Awake;
				<>O.<0>__HealthBar_Awake = val;
				obj = (object)val;
			}
			HealthBar.Awake -= (hook_Awake)obj;
			foreach (HealthBarTypeProvider addedPrefabProvider in _addedPrefabProviders)
			{
				Object.Destroy((Object)(object)addedPrefabProvider);
			}
			_addedPrefabProviders.Clear();
		}

		private static void HealthBar_Awake(orig_Awake orig, HealthBar self)
		{
			if (!Object.op_Implicit((Object)(object)((Component)self).GetComponent<HealthBarTypeProvider>()))
			{
				HealthBarType healthBarType = HealthBarType.Unknown;
				if ((Object)(object)self.style == (Object)(object)_combatHealthBarStyle)
				{
					healthBarType = HealthBarType.Combat;
				}
				Log.Info($"Health bar {self} is not registered, assuming bar type of {healthBarType}", "X:\\Git\\RoR2\\CollapseDisplay\\CollapseDisplay\\HealthBarTypeRegistration.cs", "HealthBar_Awake", 80);
				((Component)self).gameObject.AddComponent<HealthBarTypeProvider>().Type = healthBarType;
			}
			orig.Invoke(self);
		}
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		private static string getLogPrefix(string callerPath, string callerMemberName, int callerLineNumber)
		{
			int num = callerPath.LastIndexOf("CollapseDisplay\\");
			if (num >= 0)
			{
				callerPath = callerPath.Substring(num + "CollapseDisplay\\".Length);
			}
			return $"{callerPath}:{callerLineNumber} ({callerMemberName}) ";
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Error_NoCallerPrefix(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Fatal_NoCallerPrefix(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Info_NoCallerPrefix(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogMessage((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Message_NoCallerPrefix(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogWarning((object)(getLogPrefix(callerPath, callerMemberName, callerLineNumber) + data));
		}

		internal static void Warning_NoCallerPrefix(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	internal static class RiskOfOptionsCompat
	{
		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void Initialize()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			addDisplayOptions(CollapseDisplayPlugin.CollapseDisplayOptions);
			addDisplayOptions(CollapseDisplayPlugin.WarpedEchoDisplayOptions);
			ModSettingsManager.SetModDescription("Options for Collapse Display", "Gorakh.CollapseDisplay", "Collapse Display");
			FileInfo fileInfo = null;
			DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(((BaseUnityPlugin)CollapseDisplayPlugin.Instance).Info.Location));
			do
			{
				FileInfo[] files = directoryInfo.GetFiles("icon.png", SearchOption.TopDirectoryOnly);
				if (files != null && files.Length != 0)
				{
					fileInfo = files[0];
					break;
				}
				directoryInfo = directoryInfo.Parent;
			}
			while (directoryInfo != null && !string.Equals(directoryInfo.Name, "plugins", StringComparison.OrdinalIgnoreCase));
			if (fileInfo != null)
			{
				Texture2D val = new Texture2D(256, 256);
				if (ImageConversion.LoadImage(val, File.ReadAllBytes(fileInfo.FullName)))
				{
					Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
					((Object)obj).name = "CollapseDisplayIcon";
					ModSettingsManager.SetModIcon(obj, "Gorakh.CollapseDisplay", "Collapse Display");
				}
			}
			static void addDamageBarStyle(DelayedDamageBarStyle damageBarStyle)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Expected O, but got Unknown
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(damageBarStyle.EnabledConfig), "Gorakh.CollapseDisplay", "Collapse Display");
			}
			static void addDisplayOptions(DelayedDamageDisplayOptions displayOptions)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Expected O, but got Unknown
				//IL_0020: 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_0030: Expected O, but got Unknown
				//IL_0035: Expected O, but got Unknown
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Expected O, but got Unknown
				ModSettingsManager.AddOption((BaseOption)new ColorOption(displayOptions.IndicatorColor), "Gorakh.CollapseDisplay", "Collapse Display");
				ConfigEntry<float> indicatorScale = displayOptions.IndicatorScale;
				FloatFieldConfig val2 = new FloatFieldConfig();
				((NumericFieldConfig<float>)val2).Min = 0f;
				ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(indicatorScale, val2), "Gorakh.CollapseDisplay", "Collapse Display");
				addDamageBarStyle(displayOptions.HUDHealthBarStyle);
				addDamageBarStyle(displayOptions.AllyListHealthBarStyle);
				addDamageBarStyle(displayOptions.CombatHealthBarStyle);
			}
		}
	}
}
namespace CollapseDisplay.Utilities.Extensions
{
	public static class PatchExtensions
	{
		public static void EmitSkipMethodCall(this ILCursor c, MethodDefinition method = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			c.EmitSkipMethodCall(OpCodes.Br, method);
		}

		public static void EmitSkipMethodCall(this ILCursor c, OpCode branchOpCode, MethodDefinition method = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			c.EmitSkipMethodCall(branchOpCode, null, method);
		}

		public static void EmitSkipMethodCall(this ILCursor c, OpCode branchOpCode, Action<ILCursor> emitSkippedReturnValue, MethodDefinition method = null)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			if (c == null)
			{
				throw new ArgumentNullException("c");
			}
			if ((int)((OpCode)(ref branchOpCode)).FlowControl != 0 && (int)((OpCode)(ref branchOpCode)).FlowControl != 3)
			{
				throw new ArgumentException($"Invalid branch OpCode: {branchOpCode}");
			}
			if (method == null)
			{
				MethodReference val = default(MethodReference);
				if (!ILPatternMatchingExt.MatchCallOrCallvirt(c.Next, ref val))
				{
					Log.Error($"Failed to find method call to skip: {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "X:\\Git\\RoR2\\CollapseDisplay\\CollapseDisplay\\Utilities\\Extensions\\PatchExtensions.cs", "EmitSkipMethodCall", 33);
					return;
				}
				method = Extensions.SafeResolve(val);
				if (method == null)
				{
					Log.Error($"Failed to resolve method '{((MemberReference)val).FullName}': {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "X:\\Git\\RoR2\\CollapseDisplay\\CollapseDisplay\\Utilities\\Extensions\\PatchExtensions.cs", "EmitSkipMethodCall", 41);
					return;
				}
			}
			int num = ((MethodReference)method).Parameters.Count + ((!method.IsStatic) ? 1 : 0);
			bool flag = Extensions.Is((MemberReference)(object)((MethodReference)method).ReturnType, (MemberInfo)typeof(void));
			ILLabel val2 = c.DefineLabel();
			c.Emit(branchOpCode, (object)val2);
			int index = c.Index;
			c.Index = index + 1;
			if (num > 0 || !flag)
			{
				ILLabel val3 = c.DefineLabel();
				c.Emit(OpCodes.Br, (object)val3);
				c.MarkLabel(val2);
				for (int i = 0; i < num; i++)
				{
					c.Emit(OpCodes.Pop);
				}
				if (emitSkippedReturnValue != null)
				{
					emitSkippedReturnValue(c);
				}
				else if (!flag)
				{
					Log.Warning($"Skipped method ({((MemberReference)method).FullName}) is not void, emitting default value: {((MemberReference)c.Context.Method).FullName} at instruction {c.Next} ({c.Index})", "X:\\Git\\RoR2\\CollapseDisplay\\CollapseDisplay\\Utilities\\Extensions\\PatchExtensions.cs", "EmitSkipMethodCall", 73);
					if (((MethodReference)method).ReturnType.IsValueType)
					{
						VariableDefinition val4 = c.Context.AddVariable(((MethodReference)method).ReturnType);
						c.Emit(OpCodes.Ldloca, val4);
						c.Emit(OpCodes.Initobj, ((MethodReference)method).ReturnType);
						c.Emit(OpCodes.Ldloc, val4);
					}
					else
					{
						c.Emit(OpCodes.Ldnull);
					}
				}
				c.MarkLabel(val3);
			}
			else
			{
				c.MarkLabel(val2);
			}
		}

		public static bool TryFindParameter(this MethodReference method, Type type, string name, out ParameterDefinition parameter)
		{
			//IL_0006: 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)
			Enumerator<ParameterDefinition> enumerator = method.Parameters.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ParameterDefinition current = enumerator.Current;
					if ((string.IsNullOrEmpty(name) || ((ParameterReference)current).Name == name) && (type == null || Extensions.Is((MemberReference)(object)((ParameterReference)current).ParameterType, (MemberInfo)type)))
					{
						parameter = current;
						return true;
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			parameter = null;
			return false;
		}

		public static bool TryFindParameter(this MethodReference method, string name, out ParameterDefinition parameter)
		{
			return method.TryFindParameter(null, name, out parameter);
		}

		public static bool TryFindParameter(this MethodReference method, Type type, out ParameterDefinition parameter)
		{
			return method.TryFindParameter(type, null, out parameter);
		}

		public static bool TryFindParameter<T>(this MethodReference method, string name, out ParameterDefinition parameter)
		{
			return method.TryFindParameter(typeof(T), name, out parameter);
		}

		public static bool TryFindParameter<T>(this MethodReference method, out ParameterDefinition parameter)
		{
			return method.TryFindParameter(typeof(T), null, out parameter);
		}

		public static VariableDefinition AddVariable(this ILContext context, TypeReference variableType)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			VariableDefinition val = new VariableDefinition(variableType);
			context.Method.Body.Variables.Add(val);
			return val;
		}

		public static VariableDefinition AddVariable(this ILContext context, Type variableType)
		{
			return context.AddVariable(context.Import(variableType));
		}

		public static VariableDefinition AddVariable<T>(this ILContext context)
		{
			return context.AddVariable(context.Import(typeof(T)));
		}

		public static void EmitStoreStack(this ILCursor cursor, params VariableDefinition[] variables)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			if (cursor == null)
			{
				throw new ArgumentNullException("cursor");
			}
			if (variables == null)
			{
				throw new ArgumentNullException("variables");
			}
			if (variables.Length != 0)
			{
				for (int num = variables.Length - 1; num >= 1; num--)
				{
					cursor.Emit(OpCodes.Stloc, variables[num]);
				}
				cursor.Emit(OpCodes.Dup);
				cursor.Emit(OpCodes.Stloc, variables[0]);
				for (int i = 1; i < variables.Length; i++)
				{
					cursor.Emit(OpCodes.Ldloc, variables[i]);
				}
			}
		}
	}
}
namespace CollapseDisplay.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					resourceMan = new ResourceManager("CollapseDisplay.Properties.Resources", typeof(Resources).Assembly);
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] HealthBarHighlight_Opaque => (byte[])ResourceManager.GetObject("HealthBarHighlight_Opaque", resourceCulture);

		internal Resources()
		{
		}
	}
}
namespace CollapseDisplay.Networking
{
	public struct Net_RunFixedTimeStampWrapper : IEquatable<Net_RunFixedTimeStampWrapper>
	{
		public float t;

		public Net_RunFixedTimeStampWrapper()
		{
			t = 0f;
		}

		public readonly bool Equals(Net_RunFixedTimeStampWrapper other)
		{
			return t == other.t;
		}

		public static implicit operator FixedTimeStamp(Net_RunFixedTimeStampWrapper wrapper)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return new FixedTimeStamp(wrapper.t);
		}

		public static implicit operator Net_RunFixedTimeStampWrapper(FixedTimeStamp timeStamp)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Net_RunFixedTimeStampWrapper result = new Net_RunFixedTimeStampWrapper();
			result.t = timeStamp.t;
			return result;
		}
	}
}
namespace CollapseDisplay.Config
{
	public class DelayedDamageBarStyle
	{
		public readonly ConfigEntry<bool> EnabledConfig;

		public readonly HealthBarType BarType;

		private readonly DelayedDamageDisplayOptions _displayOptions;

		private readonly float _baseSizeDelta;

		private BarStyle _barStyle;

		public BarStyle BarStyle => _barStyle;

		public DelayedDamageBarStyle(ConfigFile file, string sectionName, HealthBarType type, BarStyle baseStyle, DelayedDamageDisplayOptions displayOptions)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_0088: 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)
			BarType = type;
			string text = type switch
			{
				HealthBarType.Hud => "Player HUD", 
				HealthBarType.AllyList => "Ally List", 
				HealthBarType.Combat => "Enemy", 
				_ => throw new NotImplementedException($"Bar type {type} is not implemented"), 
			};
			EnabledConfig = file.Bind<bool>(sectionName, "Show on " + text, true, new ConfigDescription("If this damage indicator should display on " + text + " healthbars", (AcceptableValueBase)null, Array.Empty<object>()));
			_barStyle = baseStyle;
			_baseSizeDelta = _barStyle.sizeDelta;
			_displayOptions = displayOptions;
			_displayOptions.IndicatorColor.SettingChanged += IndicatorColor_SettingChanged;
			updateBarColor();
			_displayOptions.IndicatorScale.SettingChanged += IndicatorScale_SettingChanged;
			updateBarSizeDelta();
		}

		private void IndicatorColor_SettingChanged(object sender, EventArgs e)
		{
			updateBarColor();
		}

		private void updateBarColor()
		{
			//IL_0011: 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)
			_barStyle.baseColor = _displayOptions.IndicatorColor.Value;
		}

		private void IndicatorScale_SettingChanged(object sender, EventArgs e)
		{
			updateBarSizeDelta();
		}

		private void updateBarSizeDelta()
		{
			_barStyle.sizeDelta = Mathf.Max(0f, _baseSizeDelta * _displayOptions.IndicatorScale.Value);
		}
	}
	public class DelayedDamageDisplayOptions
	{
		public readonly ConfigEntry<Color> IndicatorColor;

		public readonly ConfigEntry<float> IndicatorScale;

		public readonly DelayedDamageBarStyle HUDHealthBarStyle;

		public readonly DelayedDamageBarStyle AllyListHealthBarStyle;

		public readonly DelayedDamageBarStyle CombatHealthBarStyle;

		public DelayedDamageBarStyle FallbackHealthBarStyle => CombatHealthBarStyle ?? AllyListHealthBarStyle ?? HUDHealthBarStyle;

		public DelayedDamageDisplayOptions(Sprite highlightSprite, ConfigFile file, string sectionName, Color defaultColor, float defaultIndicatorScale)
		{
			//IL_000e: 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_0025: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			IndicatorColor = file.Bind<Color>(sectionName, "Indicator Color", defaultColor, new ConfigDescription("The color of this damage indicator", (AcceptableValueBase)null, Array.Empty<object>()));
			IndicatorScale = file.Bind<float>(sectionName, "Indicator Scale", defaultIndicatorScale, new ConfigDescription("The scale of this damage indicator", (AcceptableValueBase)null, Array.Empty<object>()));
			HUDHealthBarStyle = new DelayedDamageBarStyle(file, sectionName, HealthBarType.Hud, new BarStyle
			{
				enabled = true,
				imageType = (Type)1,
				sizeDelta = 5f,
				sprite = highlightSprite
			}, this);
			AllyListHealthBarStyle = new DelayedDamageBarStyle(file, sectionName, HealthBarType.AllyList, new BarStyle
			{
				enabled = true,
				imageType = (Type)1,
				sizeDelta = 1f,
				sprite = highlightSprite
			}, this);
			CombatHealthBarStyle = new DelayedDamageBarStyle(file, sectionName, HealthBarType.Combat, new BarStyle
			{
				enabled = true,
				imageType = (Type)1,
				sizeDelta = 1f,
				sprite = highlightSprite
			}, this);
		}

		public DelayedDamageBarStyle GetDamageBarStyle(HealthBarType barType)
		{
			return barType switch
			{
				HealthBarType.Hud => HUDHealthBarStyle, 
				HealthBarType.Combat => CombatHealthBarStyle, 
				HealthBarType.AllyList => AllyListHealthBarStyle, 
				HealthBarType.Unknown => FallbackHealthBarStyle, 
				_ => throw new NotImplementedException($"{barType} is not implemented"), 
			};
		}
	}
}
namespace Unity
{
	[StructLayout(LayoutKind.Auto, CharSet = CharSet.Auto)]
	public class GeneratedNetworkCode
	{
		public static void _WriteNet_RunFixedTimeStampWrapper_None(NetworkWriter writer, Net_RunFixedTimeStampWrapper value)
		{
			writer.Write(value.t);
		}

		public static void _WriteDelayedDamageInfo_None(NetworkWriter writer, DelayedDamageInfo value)
		{
			writer.Write(value.Damage);
			_WriteNet_RunFixedTimeStampWrapper_None(writer, value.Wrap_DamageTimestamp);
		}

		public static Net_RunFixedTimeStampWrapper _ReadNet_RunFixedTimeStampWrapper_None(NetworkReader reader)
		{
			Net_RunFixedTimeStampWrapper result = default(Net_RunFixedTimeStampWrapper);
			result.t = reader.ReadSingle();
			return result;
		}

		public static DelayedDamageInfo _ReadDelayedDamageInfo_None(NetworkReader reader)
		{
			DelayedDamageInfo result = default(DelayedDamageInfo);
			result.Damage = reader.ReadSingle();
			result.Wrap_DamageTimestamp = _ReadNet_RunFixedTimeStampWrapper_None(reader);
			return result;
		}
	}
}