Decompiled source of QolElements v2.1.0

QolElements.dll

Decompiled 5 months 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 System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Railgunner.Reload;
using EntityStates.Toolbot;
using EntityStates.VagrantNovaItem;
using HG;
using HG.Reflection;
using IL.RoR2;
using IL.RoR2.UI;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates.Railgunner.Reload;
using On.EntityStates.Toolbot;
using On.EntityStates.VagrantNovaItem;
using On.RoR2;
using On.RoR2.UI;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Networking;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
internal static class log
{
	private static ManualLogSource logger;

	internal static void start(ManualLogSource logSource)
	{
		logger = logSource;
	}

	internal static void start(string name)
	{
		logger = Logger.CreateLogSource(name);
	}

	internal static void info(object data)
	{
		logger.LogInfo(data);
	}

	internal static void message(object data)
	{
		logger.LogMessage(data);
	}

	internal static void warning(object data)
	{
		logger.LogWarning(data);
	}

	internal static void error(object data)
	{
		logger.LogError(data);
	}

	internal static void fatal(object data)
	{
		logger.LogFatal(data);
	}
}
public class TextHud
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static hook_Awake <>9__21_0;

		public static hook_OnDisable <>9__21_1;

		internal void <StartTextHud>b__21_0(orig_Awake orig, HUD self)
		{
			orig.Invoke(self);
			hud = self;
			TextHud.onAwake?.Invoke();
		}

		internal void <StartTextHud>b__21_1(orig_OnDisable orig, HUD self)
		{
			orig.Invoke(self);
			hud = null;
			TextHud.onOnDisable?.Invoke();
		}
	}

	public static HUD hud;

	private GameObject objhud;

	private string hudName;

	private HGTextMeshProUGUI textMesh;

	public bool resetOnTargetChanged = true;

	public Vector2 rectSize = new Vector2(200f, 200f);

	internal ConfigEntry<bool> toggleEntry;

	private ConfigEntry<int> fontsizeEntry;

	private ConfigEntry<Vector2> positionEntry;

	public bool enabled
	{
		get
		{
			if (toggleEntry == null)
			{
				return true;
			}
			return toggleEntry.Value;
		}
	}

	public int fontSize
	{
		get
		{
			if (fontsizeEntry == null)
			{
				return -1;
			}
			return fontsizeEntry.Value;
		}
	}

	public Vector2 position
	{
		get
		{
			//IL_001e: 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)
			if (positionEntry == null)
			{
				return new Vector2(1876.5f, 73f);
			}
			return positionEntry.Value;
		}
	}

	public static event Action onAwake;

	public static event Action onOnDisable;

	public static void StartTextHud()
	{
		//IL_0014: 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: Expected O, but got Unknown
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Expected O, but got Unknown
		object obj = <>c.<>9__21_0;
		if (obj == null)
		{
			hook_Awake val = delegate(orig_Awake orig, HUD self)
			{
				orig.Invoke(self);
				hud = self;
				TextHud.onAwake?.Invoke();
			};
			<>c.<>9__21_0 = val;
			obj = (object)val;
		}
		HUD.Awake += (hook_Awake)obj;
		object obj2 = <>c.<>9__21_1;
		if (obj2 == null)
		{
			hook_OnDisable val2 = delegate(orig_OnDisable orig, HUD self)
			{
				orig.Invoke(self);
				hud = null;
				TextHud.onOnDisable?.Invoke();
			};
			<>c.<>9__21_1 = val2;
			obj2 = (object)val2;
		}
		HUD.OnDisable += (hook_OnDisable)obj2;
	}

	public TextHud(ConfigFile configFile, string name)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		hudName = name;
		DoHooks(configFile);
	}

	public TextHud(ConfigFile configFile, string name, Vector2 defaultPosition)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		hudName = name;
		positionEntry = configFile.Bind<Vector2>(name, "Position", defaultPosition, "Position of " + name + ", starting from bottom left corner");
		DoHooks(configFile);
	}

	public TextHud(ConfigFile configFile, string name, Vector2 defaultPosition, bool defaultToggle)
		: this(configFile, name, defaultPosition)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		toggleEntry = configFile.Bind<bool>(name, "Toggle", defaultToggle, "Toggles " + name);
	}

	public TextHud(ConfigFile configFile, string name, Vector2 defaultPosition, int defaultFontSize)
		: this(configFile, name, defaultPosition)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		fontsizeEntry = configFile.Bind<int>(name, "Font size", defaultFontSize, "Font size of " + name);
	}

	public TextHud(ConfigFile configFile, string name, Vector2 defaultPosition, bool defaultToggle, int defaultFontSize)
		: this(configFile, name, defaultPosition)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		toggleEntry = configFile.Bind<bool>(name, "Toggle", defaultToggle, "Toggles " + name);
		fontsizeEntry = configFile.Bind<int>(name, "Font size", defaultFontSize, "Font size of " + name);
	}

	public void UpdateText(StringBuilder text)
	{
		if (enabled)
		{
			if ((Object)(object)objhud == (Object)null)
			{
				InitHud();
			}
			((TMP_Text)textMesh).SetText(text);
		}
	}

	public void UpdateText(string text)
	{
		if (enabled)
		{
			if ((Object)(object)objhud == (Object)null)
			{
				InitHud();
			}
			((TMP_Text)textMesh).SetText(text, true);
		}
	}

	public void Destroy()
	{
		Object.Destroy((Object)(object)objhud);
	}

	private void InitHud()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0049: 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_0060: 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_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		objhud = new GameObject(hudName);
		if (Object.op_Implicit((Object)(object)hud))
		{
			objhud.transform.SetParent(hud.mainContainer.transform, false);
		}
		RectTransform obj = objhud.AddComponent<RectTransform>();
		obj.anchorMin = Vector2.zero;
		obj.anchorMax = Vector2.zero;
		obj.sizeDelta = rectSize;
		obj.anchoredPosition = position;
		textMesh = objhud.AddComponent<HGTextMeshProUGUI>();
		((TMP_Text)textMesh).outlineColor = Color32.op_Implicit(Color.black);
		((TMP_Text)textMesh).fontSizeMin = 6f;
		if (fontSize >= 0)
		{
			((TMP_Text)textMesh).fontSize = fontSize;
		}
		log.info("Created " + hudName);
	}

	private void DoHooks(ConfigFile configFile)
	{
		onAwake += delegate
		{
			if (Object.op_Implicit((Object)(object)objhud))
			{
				objhud.transform.SetParent(hud.mainContainer.transform, false);
			}
		};
		HUD.onHudTargetChangedGlobal += delegate
		{
			if (resetOnTargetChanged && Object.op_Implicit((Object)(object)objhud))
			{
				UpdateText("");
			}
		};
		configFile.ConfigReloaded += delegate
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)objhud))
			{
				if (!enabled)
				{
					Object.Destroy((Object)(object)objhud);
				}
				else
				{
					objhud.GetComponent<RectTransform>().anchoredPosition = position;
					if (fontSize >= 0)
					{
						((TMP_Text)textMesh).fontSize = fontSize;
					}
				}
			}
		};
	}
}
namespace QolElements;

internal static class CountSpawns
{
	internal static TextHud monsterHud;

	internal static void DoSetup()
	{
		if (monsterHud.enabled)
		{
			TeamComponent.onJoinTeamGlobal += JoinedTeam;
			TeamComponent.onLeaveTeamGlobal += LeftTeam;
			log.info("Monster Counter loaded");
		}
		monsterHud.toggleEntry.SettingChanged += ToggleEntry_SettingChanged;
	}

	private static void ToggleEntry_SettingChanged(object sender, EventArgs e)
	{
		if (monsterHud.enabled)
		{
			TeamComponent.onJoinTeamGlobal += JoinedTeam;
			TeamComponent.onLeaveTeamGlobal += LeftTeam;
			Debug.Log((object)"Enabled Monster Counter");
		}
		else
		{
			TeamComponent.onJoinTeamGlobal -= JoinedTeam;
			TeamComponent.onLeaveTeamGlobal -= LeftTeam;
			Debug.Log((object)"Disabled Monster Counter");
		}
	}

	private static void JoinedTeam(TeamComponent self, TeamIndex teamIndex)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		if ((int)teamIndex == 2)
		{
			MakeMonsterText(TeamComponent.GetTeamMembers(teamIndex).Count, TeamCatalog.GetTeamDef(teamIndex).softCharacterLimit);
		}
	}

	private static void LeftTeam(TeamComponent self, TeamIndex teamIndex)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		if ((int)teamIndex == 2)
		{
			MakeMonsterText(TeamComponent.GetTeamMembers(teamIndex).Count, TeamCatalog.GetTeamDef(teamIndex).softCharacterLimit);
		}
	}

	private static void MakeMonsterText(int count, int limit)
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		Color green = default(Color);
		if (count < limit)
		{
			float num = (float)count / (float)limit;
			((Color)(ref green))..ctor(1f, 1f - num / 3f, 1f - num);
		}
		else
		{
			green = Color.green;
		}
		monsterHud.UpdateText(Util.GenerateColoredString(count.ToString(), Color32.op_Implicit(green)));
	}
}
internal static class Equipment
{
	private static float timer = 1f / 6f;

	public static EquipMode currentMode = EquipMode.Normal;

	private static float lastEquipTimeStamp;

	internal static TextHud modeText;

	internal static void DoSetup()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		EquipmentSlot.FixedUpdate += new Manipulator(IL_EquipmentSlot_FixedUpdate);
		EquipmentIcon.SetDisplayData += new Manipulator(IL_EquipmentIcon_SetDisplayData);
	}

	internal static void UpdateEquipMode()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		KeyboardShortcut value = QLConfig.equipmentKey.Value;
		if (!Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey))
		{
			return;
		}
		switch (currentMode)
		{
		case EquipMode.Normal:
			currentMode = EquipMode.Hold;
			lastEquipTimeStamp = Time.realtimeSinceStartup;
			break;
		case EquipMode.Hold:
			if (Time.realtimeSinceStartup - lastEquipTimeStamp < 2f)
			{
				currentMode = EquipMode.Toggle;
			}
			else
			{
				currentMode = EquipMode.Normal;
			}
			break;
		case EquipMode.Toggle:
			currentMode = EquipMode.Normal;
			break;
		}
	}

	private static void IL_EquipmentIcon_SetDisplayData(ILContext il)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		ILCursor val = new ILCursor(il);
		val.GotoNext((MoveType)2, new Func<Instruction, bool>[1]
		{
			(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<DisplayData>(a, "get_hasEquipment")
		});
		val.EmitDelegate<Action>((Action)delegate
		{
			if (currentMode == EquipMode.Normal)
			{
				modeText.UpdateText(string.Empty);
			}
			else
			{
				StringBuilder stringBuilder = StringBuilderPool.RentStringBuilder();
				stringBuilder.AppendFormat("<size=18>{0}</size>", currentMode.ToString());
				modeText.UpdateText(stringBuilder);
				StringBuilderPool.ReturnStringBuilder(stringBuilder);
			}
		});
	}

	private static void IL_EquipmentSlot_FixedUpdate(ILContext il)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_00ad: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
		ILCursor val = new ILCursor(il);
		int num2 = default(int);
		if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4]
		{
			(Instruction a) => ILPatternMatchingExt.MatchLdarg(a, 0),
			(Instruction a) => ILPatternMatchingExt.MatchCall<EquipmentSlot>(a, "get_characterBody"),
			(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(a, "get_isEquipmentActivationAllowed"),
			(Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref num2)
		}))
		{
			val.Index -= 1;
			val.Emit(OpCodes.Dup);
			val.Index += 1;
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<bool, EquipmentSlot, bool>>((Func<bool, EquipmentSlot, bool>)delegate(bool isAllowed, EquipmentSlot self)
			{
				if (currentMode == EquipMode.Normal || !isAllowed || (Object)(object)((Component)self).gameObject != (Object)(object)LocalUserManager.GetFirstLocalUser().cachedBodyObject)
				{
					return false;
				}
				float num;
				if (currentMode == EquipMode.Hold)
				{
					num = 1f / QLConfig.equipmentHoldFreq.Value;
					if (!self.inputBank.activateEquipment.down)
					{
						timer = num;
						return false;
					}
				}
				else
				{
					num = 1f / QLConfig.equipmentToggleFreq.Value;
				}
				timer += Time.fixedDeltaTime;
				if (timer >= num)
				{
					timer -= num;
					return true;
				}
				return false;
			});
			val.Emit(OpCodes.Or);
		}
		else
		{
			log.error("Failed EquipmentMode IL Hook: EquipmentSlot_FixedUpdate");
		}
	}
}
public enum EquipMode
{
	Normal,
	Hold,
	Toggle
}
internal class FallDamage : MonoBehaviour
{
	private static BarStyle fallBarStyle;

	private static bool hooked;

	private HUD hud;

	private HealthBar healthBar;

	private UIElementAllocator<Image> barAllocator;

	private BarInfo fallinfo;

	private bool fraility;

	internal static void DoSetup()
	{
		//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_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: 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_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: 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_00ab: Expected O, but got Unknown
		if (QLConfig.genesisFallMode.Value != 0)
		{
			LegacyResourcesAPI.Load<GameObject>("Prefabs/HUDSimple").AddComponent<FallDamage>();
			HealthBarStyle val = Addressables.LoadAssetAsync<HealthBarStyle>((object)"RoR2/Base/Common/HUDHealthBar.asset").WaitForCompletion();
			val.lowHealthOverStyle.baseColor = new Color(0.4f, 0.4f, 0.4f, 1f);
			BarStyle val2 = default(BarStyle);
			val2.sprite = val.cullBarStyle.sprite;
			val2.imageType = val.cullBarStyle.imageType;
			val2.sizeDelta = val.cullBarStyle.sizeDelta;
			fallBarStyle = val2;
			HealthBar.UpdateBarInfos += new Manipulator(HealthBar_UpdateBarInfos);
			hooked = true;
			log.info("Genesis Fall loaded");
		}
		QLConfig.genesisFallMode.SettingChanged += GenesisFallMode_SettingChanged;
	}

	private static void GenesisFallMode_SettingChanged(object sender, EventArgs e)
	{
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Expected O, but got Unknown
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Expected O, but got Unknown
		if (QLConfig.genesisFallMode.Value != 0)
		{
			GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/HUDSimple");
			if (!Object.op_Implicit((Object)(object)val.GetComponent<FallDamage>()))
			{
				val.AddComponent<FallDamage>();
			}
			if (!hooked)
			{
				HealthBar.UpdateBarInfos += new Manipulator(HealthBar_UpdateBarInfos);
				hooked = true;
			}
			Debug.Log((object)("Genesis Fall set to " + QLConfig.genesisFallMode.Value));
		}
		else
		{
			HealthBar.UpdateBarInfos -= new Manipulator(HealthBar_UpdateBarInfos);
			hooked = false;
			Debug.Log((object)"Genesis Fall disabled");
		}
	}

	private static void HealthBar_UpdateBarInfos(ILContext il)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		ILCursor val = new ILCursor(il);
		if (val.TryGotoNext(new Func<Instruction, bool>[1]
		{
			(Instruction a) => ILPatternMatchingExt.MatchLdflda<BarInfoCollection>(a, "lowHealthOverBarInfo")
		}) && val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
		{
			(Instruction a) => ILPatternMatchingExt.MatchLdfld<HealthBar>(a, "hasLowHealthItem")
		}))
		{
			val.RemoveRange(8);
		}
		else
		{
			log.error("Genesis Fall: Failed HealthBar_hasLowHealthItem IL hook");
		}
	}

	private void Awake()
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: 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_0089: 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)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Invalid comparison between Unknown and I4
		hud = ((Component)this).GetComponent<HUD>();
		healthBar = hud.healthBar;
		barAllocator = new UIElementAllocator<Image>(healthBar.barContainer, healthBar.style.barPrefab, true, false);
		fallinfo = new BarInfo
		{
			enabled = false,
			sprite = fallBarStyle.sprite,
			imageType = fallBarStyle.imageType,
			sizeDelta = fallBarStyle.sizeDelta
		};
		if (Object.op_Implicit((Object)(object)Run.instance))
		{
			fraility = (int)Run.instance.selectedDifficulty >= 5 || RunArtifactManager.instance.IsArtifactEnabled(Artifacts.weakAssKneesArtifactDef);
		}
	}

	private void FixedUpdate()
	{
		//IL_03f6: 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_0427: Unknown result type (might be due to invalid IL or missing references)
		//IL_042c: Unknown result type (might be due to invalid IL or missing references)
		//IL_043d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0447: Unknown result type (might be due to invalid IL or missing references)
		//IL_0458: Unknown result type (might be due to invalid IL or missing references)
		//IL_0462: Unknown result type (might be due to invalid IL or missing references)
		//IL_0463: Unknown result type (might be due to invalid IL or missing references)
		//IL_0495: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: 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_00ca: 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_00d3: 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_00e2: 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_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: 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)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: 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_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: 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_0284: 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_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0335: Unknown result type (might be due to invalid IL or missing references)
		//IL_033a: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		CharacterBody val = healthBar.source?.body;
		if (QLConfig.genesisFallMode.Value == FallMode.Disabled)
		{
			return;
		}
		if (QLConfig.genesisFallMode.Value == FallMode.GenesisOnly && val != null)
		{
			Inventory inventory = val.inventory;
			if (((inventory != null) ? new int?(inventory.GetItemCount(Items.NovaOnLowHealth)) : null) <= 0)
			{
				return;
			}
		}
		if (!((Object)(object)val != (Object)null) || ((Object.op_Implicit((Object)(object)val.inventory) && val.inventory.GetItemCount(Items.FallBoots) != 0) ? 1 : 0) > (false ? 1 : 0) || (val.bodyFlags & 1) != 0)
		{
			goto IL_03b6;
		}
		Ray val2 = new Ray(val.footPosition, Vector3.down);
		LayerIndex val3 = LayerIndex.world;
		int num = LayerMask.op_Implicit(((LayerIndex)(ref val3)).mask);
		val3 = LayerIndex.collideWithCharacterHullOnly;
		RaycastHit val4 = default(RaycastHit);
		if (!Physics.Raycast(val2, ref val4, 300f, num | LayerMask.op_Implicit(((LayerIndex)(ref val3)).mask), (QueryTriggerInteraction)2))
		{
			Ray val5 = new Ray(val.footPosition + new Vector3(0f, val.characterMotor.capsuleCollider.height, 0f) + new Vector3(0f, -300f, 0f), Vector3.up);
			val3 = LayerIndex.collideWithCharacterHullOnly;
			if (!Physics.Raycast(val5, ref val4, 300f, LayerMask.op_Implicit(((LayerIndex)(ref val3)).mask), (QueryTriggerInteraction)2))
			{
				goto IL_03b6;
			}
		}
		float num2 = (float)Math.Sqrt(Math.Pow(val.characterMotor.velocity.y, 2.0) - (double)(2f * Physics.gravity.y * Vector3.Distance(((RaycastHit)(ref val4)).point, val.footPosition)));
		if (num2 > 35f)
		{
			float num3 = Math.Max(num2 - val.jumpPower - 20f, 0f) / 60f;
			if (fraility)
			{
				num3 *= 2f;
			}
			float num4 = ((val.armor >= 0f) ? (1f - val.armor / (val.armor + 100f)) : (2f - 100f / (100f - val.armor)));
			num3 = (num3 * num4 * val.maxHealth / val.cursePenalty - (float)(healthBar.source.itemCounts.armorPlate * 5)) / (val.maxHealth + val.maxShield);
			HealthBarValues healthBarValues = healthBar.source.GetHealthBarValues();
			fallinfo.normalizedXMin = Math.Max(healthBarValues.healthFraction + healthBarValues.shieldFraction + healthBarValues.barrierFraction - num3, -1f);
			fallinfo.normalizedXMax = healthBarValues.healthFraction + healthBarValues.shieldFraction;
			if (fallinfo.normalizedXMin < fallinfo.normalizedXMax)
			{
				fallinfo.enabled = true;
				if (!QLConfig.genesisFallConfirmToggle.Value || (fallinfo.normalizedXMin < HealthComponent.lowHealthFraction && healthBarValues.healthFraction + healthBarValues.shieldFraction > HealthComponent.lowHealthFraction))
				{
					fallinfo.color = QLConfig.genesisFallConfirmColor.Value;
					if (!QLConfig.genesisFallConfirmBarOverflow.Value)
					{
						Math.Max(fallinfo.normalizedXMin, 0f);
					}
				}
				else
				{
					fallinfo.color = QLConfig.genesisFallColor.Value;
					fallinfo.normalizedXMin = Math.Max(fallinfo.normalizedXMin, 0f);
				}
			}
			else
			{
				fallinfo.enabled = false;
			}
		}
		else
		{
			fallinfo.enabled = false;
		}
		goto IL_03c2;
		IL_03b6:
		fallinfo.enabled = false;
		goto IL_03c2;
		IL_03c2:
		if (fallinfo.enabled)
		{
			barAllocator.AllocateElements(1);
			Image obj = barAllocator.elements[0];
			obj.type = fallinfo.imageType;
			obj.sprite = fallinfo.sprite;
			((Graphic)obj).color = fallinfo.color;
			RectTransform val6 = (RectTransform)((Component)obj).transform;
			val6.anchorMin = new Vector2(fallinfo.normalizedXMin, 0f);
			val6.anchorMax = new Vector2(fallinfo.normalizedXMax, 1f);
			val6.anchoredPosition = Vector2.zero;
			val6.sizeDelta = new Vector2(fallinfo.sizeDelta * 0.5f + 1f, fallinfo.sizeDelta + 1f);
		}
		else
		{
			barAllocator.AllocateElements(0);
		}
	}
}
public enum FallMode
{
	Disabled,
	GenesisOnly,
	Always
}
internal class GenesisTimer : MonoBehaviour
{
	internal static TextHud genesisTextHud;

	private EntityStateMachine stateMachine;

	private NetworkedBodyAttachment bodyAttachment;

	private float alpha = 255f;

	internal static void DoSetup()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		if (genesisTextHud.enabled)
		{
			LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/BodyAttachments/VagrantNovaItemBodyAttachment").AddComponent<GenesisTimer>();
			DetonateState.OnEnter += new hook_OnEnter(DetonateState_OnEnter);
			log.info("Genesis Timer loaded");
		}
		genesisTextHud.toggleEntry.SettingChanged += ToggleEntry_SettingChanged;
	}

	private static void ToggleEntry_SettingChanged(object sender, EventArgs e)
	{
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Expected O, but got Unknown
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		if (genesisTextHud.enabled)
		{
			GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/BodyAttachments/VagrantNovaItemBodyAttachment");
			if (!Object.op_Implicit((Object)(object)val.GetComponent<GenesisTimer>()))
			{
				val.AddComponent<GenesisTimer>();
			}
			DetonateState.OnEnter += new hook_OnEnter(DetonateState_OnEnter);
			Debug.Log((object)"Enabled Genesis Timer");
		}
		else
		{
			DetonateState.OnEnter -= new hook_OnEnter(DetonateState_OnEnter);
			Debug.Log((object)"Disabled Genesis Timer");
		}
	}

	private static void DetonateState_OnEnter(orig_OnEnter orig, DetonateState self)
	{
		orig.Invoke(self);
		int itemStack = ((BaseVagrantNovaItemState)self).GetItemStack();
		if (itemStack > 1)
		{
			self.duration /= (float)itemStack;
		}
	}

	private void OnEnable()
	{
		stateMachine = ((Component)this).GetComponent<EntityStateMachine>();
		if (!Object.op_Implicit((Object)(object)stateMachine))
		{
			log.warning("Genesis: null stateMachine");
		}
		bodyAttachment = ((Component)this).GetComponent<NetworkedBodyAttachment>();
		if (!Object.op_Implicit((Object)(object)bodyAttachment))
		{
			log.error("Genesis: Failed to get body attachment");
		}
	}

	private void FixedUpdate()
	{
		if (!genesisTextHud.enabled)
		{
			return;
		}
		HUD hud = TextHud.hud;
		CharacterMaster obj = ((hud != null) ? hud.targetMaster : null);
		CharacterBody attachedBody = bodyAttachment.attachedBody;
		if ((Object)(object)obj != (Object)(object)((attachedBody != null) ? attachedBody.master : null))
		{
			return;
		}
		EntityState state = stateMachine.state;
		if (state == null)
		{
			log.warning("Genesis: null State");
		}
		float num = 0f - state.fixedAge;
		BaseVagrantNovaItemState val = (BaseVagrantNovaItemState)(object)((state is BaseVagrantNovaItemState) ? state : null);
		num = ((state is RechargeState) ? (num + Recharge(val)) : ((state is ChargeState) ? (num + Charge(val)) : ((!(state is DetonateState)) ? 0f : (num + Detonate((DetonateState)(object)((val is DetonateState) ? val : null))))));
		StringBuilder stringBuilder = StringBuilderPool.RentStringBuilder();
		if (num <= 0f)
		{
			if (alpha > 0f)
			{
				alpha -= 0.75f;
				stringBuilder.AppendFormat("<color=#999999{0:X2}>Ready</color>", (byte)alpha);
			}
			else
			{
				stringBuilder.Append("");
			}
		}
		else
		{
			alpha = 255f;
			stringBuilder.AppendFormat("<color=#ffe5{0:X2}ff>{1}</color>", (byte)Mathf.Clamp(15f * (num - 1.5f), 0f, 255f), (num < 2.8f) ? num.ToString("0.0") : num.ToString("0"));
		}
		genesisTextHud.UpdateText(stringBuilder);
		StringBuilderPool.ReturnStringBuilder(stringBuilder);
	}

	private float Recharge(BaseVagrantNovaItemState state)
	{
		return RechargeState.baseDuration / (float)(state.GetItemStack() + 1) + Charge(state);
	}

	private float Charge(BaseVagrantNovaItemState state)
	{
		return ChargeState.baseDuration / (Object.op_Implicit((Object)(object)((BaseBodyAttachmentState)state).attachedBody) ? ((BaseBodyAttachmentState)state).attachedBody.attackSpeed : 1f);
	}

	private float Detonate(DetonateState state)
	{
		return state.duration + Recharge((BaseVagrantNovaItemState)(object)state);
	}

	private void OnDisable()
	{
		genesisTextHud.UpdateText("");
	}
}
internal static class LunarShop
{
	internal static void DoSetup()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		QLConfig.seerToggle.SettingChanged += SeerToggle_SettingChanged;
		if (QLConfig.seerToggle.Value)
		{
			BazaarController.SetUpSeerStations += new hook_SetUpSeerStations(BazaarController_SetUpSeerStations);
			log.info("Dream Seer loaded");
		}
		QLConfig.lunarShopToggle.SettingChanged += LunarShopToggle_SettingChanged;
		if (QLConfig.lunarShopToggle.Value)
		{
			PurchaseInteraction.CanBeAffordedByInteractor += new hook_CanBeAffordedByInteractor(PurchaseInteraction_CanBeAffordedByInteractor);
		}
	}

	private static void SeerToggle_SettingChanged(object sender, EventArgs e)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		if (QLConfig.seerToggle.Value)
		{
			BazaarController.SetUpSeerStations += new hook_SetUpSeerStations(BazaarController_SetUpSeerStations);
			Debug.Log((object)"Enabled Dream Seer");
		}
		else
		{
			BazaarController.SetUpSeerStations -= new hook_SetUpSeerStations(BazaarController_SetUpSeerStations);
			Debug.Log((object)"Dream Seer fully disabled");
		}
	}

	private static void BazaarController_SetUpSeerStations(orig_SetUpSeerStations orig, BazaarController self)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Invalid comparison between Unknown and I4
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Invalid comparison between Unknown and I4
		for (int i = 0; i < self.seerSceneOverrides.Length; i++)
		{
			if ((int)self.seerSceneOverrides[i].sceneDef.sceneDefIndex == 14)
			{
				self.seerSceneOverrides[i].overrideChance = QLConfig.seerGoldChance.Value;
			}
			else if ((int)self.seerSceneOverrides[i].sceneDef.sceneDefIndex == 46)
			{
				self.seerSceneOverrides[i].overrideChance = QLConfig.seerVoidChance.Value;
			}
		}
		orig.Invoke(self);
	}

	private static void LunarShopToggle_SettingChanged(object sender, EventArgs e)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		if (QLConfig.lunarShopToggle.Value)
		{
			PurchaseInteraction.CanBeAffordedByInteractor += new hook_CanBeAffordedByInteractor(PurchaseInteraction_CanBeAffordedByInteractor);
			Debug.Log((object)"Enabled Lunar shop disabler");
		}
		else
		{
			PurchaseInteraction.CanBeAffordedByInteractor += new hook_CanBeAffordedByInteractor(PurchaseInteraction_CanBeAffordedByInteractor);
			Debug.Log((object)"Lunar shop disabler fully disabled");
		}
	}

	private static bool PurchaseInteraction_CanBeAffordedByInteractor(orig_CanBeAffordedByInteractor orig, PurchaseInteraction self, Interactor activator)
	{
		if ((NetworkServer.active && ((Object)self).name.StartsWith("LunarShop")) || ((Object)self).name.StartsWith("LunarRecycler"))
		{
			return false;
		}
		return orig.Invoke(self, activator);
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("dolso.qolelements", "QolElements", "2.1.0")]
public class Main : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static hook_Start <>9__0_0;

		public static hook_FixedUpdate <>9__0_1;

		internal void <Awake>b__0_0(orig_Start orig, Stage self)
		{
			if (QLConfig.podToggle.Value)
			{
				self.usePod = false;
			}
			orig.Invoke(self);
		}

		internal void <Awake>b__0_1(orig_FixedUpdate orig, Reloading self)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			orig.Invoke(self);
			if (QLConfig.autoReloadToggle.Value && ((EntityState)self).fixedAge >= self.adjustedBoostWindowDelay + QLConfig.autoReloadPortion.Value * self.adjustedBoostWindowDuration)
			{
				((EntityState)self).outer.SetNextState((EntityState)new BoostConfirm());
			}
		}
	}

	private void Awake()
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Expected O, but got Unknown
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Expected O, but got Unknown
		log.start(((BaseUnityPlugin)this).Logger);
		QLConfig.DoConfig();
		TextHud.StartTextHud();
		CountSpawns.DoSetup();
		GenesisTimer.DoSetup();
		FallDamage.DoSetup();
		object obj = <>c.<>9__0_0;
		if (obj == null)
		{
			hook_Start val = delegate(orig_Start orig, Stage self)
			{
				if (QLConfig.podToggle.Value)
				{
					self.usePod = false;
				}
				orig.Invoke(self);
			};
			<>c.<>9__0_0 = val;
			obj = (object)val;
		}
		Stage.Start += (hook_Start)obj;
		object obj2 = <>c.<>9__0_1;
		if (obj2 == null)
		{
			hook_FixedUpdate val2 = delegate(orig_FixedUpdate orig, Reloading self)
			{
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Expected O, but got Unknown
				orig.Invoke(self);
				if (QLConfig.autoReloadToggle.Value && ((EntityState)self).fixedAge >= self.adjustedBoostWindowDelay + QLConfig.autoReloadPortion.Value * self.adjustedBoostWindowDuration)
				{
					((EntityState)self).outer.SetNextState((EntityState)new BoostConfirm());
				}
			};
			<>c.<>9__0_1 = val2;
			obj2 = (object)val2;
		}
		Reloading.FixedUpdate += (hook_FixedUpdate)obj2;
		Mountain.DoSetup();
		MultRetool.DoSetup();
		Equipment.DoSetup();
		LunarShop.DoSetup();
		OOBIndicator.DoSetup();
	}

	private void Update()
	{
		Equipment.UpdateEquipMode();
		if (PingHud.pingHud.enabled && Object.op_Implicit((Object)(object)TextHud.hud))
		{
			PingHud.UpdatePingHud();
		}
	}
}
internal static class Mountain
{
	internal static void DoSetup()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Expected O, but got Unknown
		if (QLConfig.mountainRewardToggle.Value)
		{
			BossGroup.onBossGroupDefeatedServer += BossGroup_onBossGroupDefeatedServer;
		}
		if (QLConfig.mountainInteractToggle.Value)
		{
			ShrineBossBehavior.AddShrineStack += new Manipulator(AddShrineStack_IL);
		}
		if (QLConfig.mountainRewardToggle.Value || QLConfig.mountainInteractToggle.Value)
		{
			log.info("Mountain Counter loaded");
		}
		QLConfig.mountainRewardToggle.SettingChanged += MountainRewardToggle_SettingChanged;
		QLConfig.mountainInteractToggle.SettingChanged += MountainInteractToggle_SettingChanged;
	}

	private static void MountainRewardToggle_SettingChanged(object sender, EventArgs e)
	{
		if (QLConfig.mountainRewardToggle.Value)
		{
			BossGroup.onBossGroupDefeatedServer += BossGroup_onBossGroupDefeatedServer;
			Debug.Log((object)"Enabled Mountain on boss reward message");
		}
		else
		{
			BossGroup.onBossGroupDefeatedServer -= BossGroup_onBossGroupDefeatedServer;
			Debug.Log((object)"Disabled Mountain on boss reward message");
		}
	}

	private static void MountainInteractToggle_SettingChanged(object sender, EventArgs e)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		if (QLConfig.mountainInteractToggle.Value)
		{
			ShrineBossBehavior.AddShrineStack += new Manipulator(AddShrineStack_IL);
			Debug.Log((object)"Enabled Mountain on shrine interact message");
		}
		else
		{
			ShrineBossBehavior.AddShrineStack -= new Manipulator(AddShrineStack_IL);
			Debug.Log((object)"Disabled Mountain on shrine interact message");
		}
	}

	private static void BossGroup_onBossGroupDefeatedServer(BossGroup self)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Expected O, but got Unknown
		int participatingPlayerCount = Run.instance.participatingPlayerCount;
		int num = 1 + self.bonusRewardCount;
		int num2 = participatingPlayerCount * num;
		if (participatingPlayerCount > 1 && num > 1 && self.scaleRewardsByPlayerCount)
		{
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = $"{num2} items over {participatingPlayerCount} players is <b>{num}</b> items each"
			});
		}
	}

	private static void AddShrineStack_IL(ILContext il)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		ILCursor val = new ILCursor(il);
		val.GotoNext(new Func<Instruction, bool>[1]
		{
			(Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, typeof(Chat), "SendBroadcastChat")
		});
		val.EmitDelegate<Func<SubjectFormatChatMessage, SimpleChatMessage>>((Func<SubjectFormatChatMessage, SimpleChatMessage>)delegate(SubjectFormatChatMessage subject)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			string text = "";
			if (Object.op_Implicit((Object)(object)TeleporterInteraction.instance))
			{
				text = $" {TeleporterInteraction.instance.shrineBonusStacks}";
			}
			return new SimpleChatMessage
			{
				baseToken = string.Format(Language.GetString(((SubjectChatMessage)subject).baseToken.Replace("_2P", "")), ((SubjectChatMessage)subject).GetSubjectName()) + text
			};
		});
	}
}
internal class OOBIndicator : MonoBehaviour
{
	private static Sprite sprite;

	private static GameObject indicator;

	private static SpriteRenderer spriter;

	private HUD hud;

	private const float maxDistance = 20f;

	private float a = 1f;

	internal static void DoSetup()
	{
		//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)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		if (QLConfig.OOBIToggle.Value)
		{
			Texture2D val = Addressables.LoadAssetAsync<Texture2D>((object)"RoR2/Base/UI/texCrosshairCircleRemap.png").WaitForCompletion();
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height);
			sprite = Sprite.Create(val, val2, new Vector2(0.5f, 0.5f));
			LegacyResourcesAPI.Load<GameObject>("Prefabs/HUDSimple").AddComponent<OOBIndicator>();
			log.info("OOBIndicator loaded");
		}
		QLConfig.OOBIToggle.SettingChanged += OOBIToggle_SettingChanged;
	}

	private static void OOBIToggle_SettingChanged(object sender, EventArgs e)
	{
		//IL_0021: 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_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		if (QLConfig.OOBIToggle.Value)
		{
			if ((Object)(object)sprite == (Object)null)
			{
				Texture2D val = Addressables.LoadAssetAsync<Texture2D>((object)"RoR2/Base/UI/texCrosshairCircleRemap.png").WaitForCompletion();
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height);
				sprite = Sprite.Create(val, val2, new Vector2(0.5f, 0.5f));
			}
			GameObject val3 = LegacyResourcesAPI.Load<GameObject>("Prefabs/HUDSimple");
			if (!Object.op_Implicit((Object)(object)val3.GetComponent<OOBIndicator>()))
			{
				val3.AddComponent<OOBIndicator>();
			}
			Debug.Log((object)"Enabled OoB Indicator");
		}
		else
		{
			Debug.Log((object)"Disabled OoB Indicator");
		}
	}

	private void MakeIndicator()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		indicator = new GameObject("OOBISprite");
		indicator.layer = LayerIndex.uiWorldSpace.intVal;
		spriter = indicator.AddComponent<SpriteRenderer>();
		spriter.sprite = sprite;
		SpriteRenderer obj = spriter;
		obj.size *= 0.01f;
	}

	private void Awake()
	{
		hud = ((Component)this).GetComponent<HUD>();
	}

	private void FixedUpdate()
	{
		//IL_0081: 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)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: 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_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: 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_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_00ea: 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_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: 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_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: 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)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: 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)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		if (QLConfig.OOBIToggle.Value && Util.HasEffectiveAuthority(hud.targetBodyObject) && hud.healthBar.source.alive)
		{
			if (!Object.op_Implicit((Object)(object)indicator))
			{
				MakeIndicator();
			}
			CharacterBody body = hud.healthBar.source.body;
			CharacterMotor characterMotor = body.characterMotor;
			Vector3 normalized;
			if (Object.op_Implicit((Object)(object)characterMotor))
			{
				normalized = ((Vector3)(ref characterMotor.velocity)).normalized;
			}
			else
			{
				Vector3 velocity = body.rigidbody.velocity;
				normalized = ((Vector3)(ref velocity)).normalized;
			}
			Vector3 corePosition = body.corePosition;
			corePosition.y -= 1f;
			Vector3 corePosition2 = body.corePosition;
			corePosition2.y += 1f;
			bool flag = false;
			Vector3 val = corePosition;
			Vector3 val2 = corePosition2;
			Vector3 val3 = normalized;
			LayerIndex val4 = LayerIndex.collideWithCharacterHullOnly;
			int num = LayerMask.op_Implicit(((LayerIndex)(ref val4)).mask);
			val4 = LayerIndex.pickups;
			RaycastHit val5 = default(RaycastHit);
			if (Physics.CapsuleCast(val, val2, 0.6f, val3, ref val5, 20f, num | LayerMask.op_Implicit(((LayerIndex)(ref val4)).mask), (QueryTriggerInteraction)2))
			{
				flag = Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val5)).collider).GetComponent<MapZone>());
			}
			Vector3 val6 = corePosition + normalized * 20f;
			Vector3 val7 = corePosition2 + normalized * 20f;
			Vector3 val8 = -normalized;
			val4 = LayerIndex.collideWithCharacterHullOnly;
			RaycastHit val9 = default(RaycastHit);
			if (Physics.CapsuleCast(val6, val7, 0.5f, val8, ref val9, 20f, LayerMask.op_Implicit(((LayerIndex)(ref val4)).mask), (QueryTriggerInteraction)2) && Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val9)).collider).GetComponent<MapZone>()) && (!flag || ((RaycastHit)(ref val5)).distance > 20f - ((RaycastHit)(ref val9)).distance))
			{
				flag = true;
				val5 = val9;
			}
			if (flag)
			{
				indicator.SetActive(true);
				indicator.transform.position = ((RaycastHit)(ref val5)).point;
				Transform transform = indicator.transform;
				Quaternion val10 = Quaternion.FromToRotation(indicator.transform.forward, ((RaycastHit)(ref val5)).normal);
				transform.Rotate(((Quaternion)(ref val10)).eulerAngles);
				spriter.color = new Color(0.5f, 0.5f, 1f, a);
				a = 1f;
			}
			else if (a > 0f)
			{
				spriter.color = new Color(0.5f, 0.5f, 0.5f, a);
				a -= 0.015f;
			}
			else
			{
				indicator.SetActive(false);
			}
		}
	}
}
internal static class PingHud
{
	public static TextHud pingHud;

	private static Queue<int> pingQueue = new Queue<int>();

	private static int pingSum = 0;

	private static float lastPingTimeStamp = 0f;

	internal static void UpdatePingHud()
	{
		if (Time.realtimeSinceStartup - lastPingTimeStamp < 0.015f)
		{
			return;
		}
		lastPingTimeStamp = Time.realtimeSinceStartup;
		int ping = GetPing();
		if (ping <= 0)
		{
			if (pingQueue.Count > 0)
			{
				pingHud.UpdateText(string.Empty);
				pingSum = 0;
				pingQueue.Clear();
			}
		}
		else
		{
			pingSum += ping;
			pingQueue.Enqueue(ping);
			while (pingQueue.Count > 60)
			{
				pingSum -= pingQueue.Dequeue();
			}
			pingHud.UpdateText((pingSum / pingQueue.Count).ToString());
		}
	}

	private static int GetPing()
	{
		if (NetworkClient.active && Object.op_Implicit((Object)(object)NetworkManagerSystem.singleton))
		{
			NetworkConnection connection = ((NetworkManager)NetworkManagerSystem.singleton).client.connection;
			if (connection != null)
			{
				return (int)RttManager.GetConnectionRTTInMilliseconds(connection);
			}
		}
		return -1;
	}
}
internal static class QLConfig
{
	public static ConfigFile configFile;

	private const string GENESISFALL = "Genesis Fall";

	public static ConfigEntry<Color> genesisFallColor;

	public static ConfigEntry<bool> genesisFallConfirmToggle;

	public static ConfigEntry<Color> genesisFallConfirmColor;

	public static ConfigEntry<bool> genesisFallConfirmBarOverflow;

	public static ConfigEntry<FallMode> genesisFallMode;

	private const string MISC = "Misc";

	public static ConfigEntry<bool> podToggle;

	public static ConfigEntry<bool> autoReloadToggle;

	public static ConfigEntry<float> autoReloadPortion;

	public static ConfigEntry<bool> lunarShopToggle;

	public static ConfigEntry<bool> OOBIToggle;

	private const string DREAMSEER = "Dream Seer";

	public static ConfigEntry<bool> seerToggle;

	public static ConfigEntry<float> seerGoldChance;

	public static ConfigEntry<float> seerVoidChance;

	public static ConfigEntry<bool> mountainInteractToggle;

	public static ConfigEntry<bool> mountainRewardToggle;

	public static ConfigEntry<bool> multRetoolToggle;

	private const string EQUIPMODE = "Equipment Mode";

	public static ConfigEntry<float> equipmentHoldFreq;

	public static ConfigEntry<float> equipmentToggleFreq;

	public static ConfigEntry<KeyboardShortcut> equipmentKey;

	internal static void DoConfig()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		//IL_002e: 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_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: 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)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Expected O, but got Unknown
		//IL_030c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0316: Expected O, but got Unknown
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_0352: Expected O, but got Unknown
		//IL_0370: Unknown result type (might be due to invalid IL or missing references)
		configFile = new ConfigFile(Paths.ConfigPath + "//QolElements.cfg", true);
		CountSpawns.monsterHud = new TextHud(configFile, "Monster Counter", new Vector2(103f, -57f), defaultToggle: true, 15)
		{
			resetOnTargetChanged = false
		};
		GenesisTimer.genesisTextHud = new TextHud(configFile, "Genesis Timer", new Vector2(1200f, 550f), defaultToggle: true, 16);
		PingHud.pingHud = new TextHud(configFile, "Ping Hud", new Vector2(1981f, 963f), defaultToggle: true, 13)
		{
			resetOnTargetChanged = false
		};
		genesisFallMode = configFile.Bind<FallMode>("Genesis Fall", "Mode", FallMode.GenesisOnly, "If Genesis Fall should diabled, only when you have Genesis Loop, or always active");
		genesisFallColor = configFile.Bind<Color>("Genesis Fall", "Color", new Color(1f, 1f, 0f, 1f), "Genesis Fall ColorRGBA, hexadecimal");
		genesisFallConfirmToggle = configFile.Bind<bool>("Genesis Fall", "Enough fall toggle", true, "Toggles if when fall dmg will put you below low health threshold, change fall color");
		genesisFallConfirmColor = configFile.Bind<Color>("Genesis Fall", "Enough fall color", new Color(0f, 0f, 1f, 1f), "ColorRGBA, hexadecimal");
		genesisFallConfirmBarOverflow = configFile.Bind<bool>("Genesis Fall", "Bar overflow", true, "Toggles if damage indictator should overflow past bar when damage is more than your hp. Only active when above low hp threshold");
		autoReloadToggle = configFile.Bind<bool>("Misc", "Railgun auto reload toggle", true, "Toggles auto reloading railgunner");
		autoReloadPortion = configFile.Bind<float>("Misc", "Railgun auto reload portion", 0.3f, new ConfigDescription("At which point in the boost window to auto reload", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		multRetoolToggle = configFile.Bind<bool>("Misc", "Mult Retool toggle", true, "Extend Mult's retool cooldown so that it smoothly swap spams");
		podToggle = configFile.Bind<bool>("Misc", "Drop pod disabler", false, "If stage 1 drop pod should be diabled");
		lunarShopToggle = configFile.Bind<bool>("Misc", "Lunar shop disabler", false, "Disable being able to buy lunar items in bazaar");
		OOBIToggle = configFile.Bind<bool>("Misc", "Out of Bounds Indicator toggle", false, "Shows if you are about to run into a teleport wall");
		seerToggle = configFile.Bind<bool>("Dream Seer", "Toggle", true, "Toggles Dream Seer overide chance");
		seerGoldChance = configFile.Bind<float>("Dream Seer", "Gilded Coast", 0.05f, "Chance of Gilded Coast option appearing insead of a normal stage. Vanilla chance is 0.05");
		seerVoidChance = configFile.Bind<float>("Dream Seer", "Deep Void", 0.05f, "Chance of Deep Void option appearing insead of a normal stage, after min stages have passed. Vanilla chance is 0.05");
		mountainInteractToggle = configFile.Bind<bool>("Mountain Counter", "On shrine interact toggle", true, "Toggles if when hitting mountain shrine, add mountain count after chat message");
		mountainRewardToggle = configFile.Bind<bool>("Mountain Counter", "On boss reward toggle", true, "Toggles if when dropping boss rewards, to send chat message detailing item distribution");
		equipmentHoldFreq = configFile.Bind<float>("Equipment Mode", "Hold Frequency", 15f, new ConfigDescription("The frequency of automatic equipment usage while in Hold mode", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>()));
		equipmentToggleFreq = configFile.Bind<float>("Equipment Mode", "Toggle Frequency", 10f, new ConfigDescription("The frequency of automatic equipment usage while in Toggle mode", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>()));
		equipmentKey = configFile.Bind<KeyboardShortcut>("Equipment Mode", "Key", new KeyboardShortcut((KeyCode)286, Array.Empty<KeyCode>()), "The key for switching equipment mode");
		Equipment.modeText = new TextHud(configFile, "Equipment Mode");
		DoOptions();
	}

	private static void DoOptions()
	{
		//IL_0017: 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)
		if (RiskofOptions.enabled)
		{
			log.info("Risk of Options detected");
			RiskofOptions.SetSprite(Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/UI/sawblade.psd").WaitForCompletion());
			RiskofOptions.AddOption(CountSpawns.monsterHud.toggleEntry, "Misc", "Monster Counter toggle");
			RiskofOptions.AddOption(GenesisTimer.genesisTextHud.toggleEntry, "Genesis Fall", "Genesis Timer toggle");
			RiskofOptions.AddOption(PingHud.pingHud.toggleEntry, "Misc", "Ping Hud toggle");
			RiskofOptions.AddOption<FallMode>(genesisFallMode);
			RiskofOptions.AddOption(genesisFallColor);
			RiskofOptions.AddOption(genesisFallConfirmToggle);
			RiskofOptions.AddOption(genesisFallConfirmColor);
			RiskofOptions.AddOption(genesisFallConfirmBarOverflow);
			RiskofOptions.AddOption(autoReloadToggle);
			RiskofOptions.AddSlider(autoReloadPortion, 0f, 1f, "{0:0.00}");
			RiskofOptions.AddOption(multRetoolToggle);
			RiskofOptions.AddOption(podToggle);
			RiskofOptions.AddOption(lunarShopToggle);
			RiskofOptions.AddOption(OOBIToggle);
			RiskofOptions.AddOption(seerToggle);
			RiskofOptions.AddSlider(seerGoldChance, 0f, 1f, "{0:0.00}");
			RiskofOptions.AddSlider(seerVoidChance, 0f, 1f, "{0:0.00}");
			RiskofOptions.AddOption(mountainInteractToggle);
			RiskofOptions.AddOption(mountainRewardToggle);
			RiskofOptions.AddSlider(equipmentHoldFreq, 1f, 60f, "{0:0} hz");
			RiskofOptions.AddSlider(equipmentToggleFreq, 1f, 60f, "{0:0} hz");
			RiskofOptions.AddOption(equipmentKey);
		}
	}

	[ConCommand(/*Could not decode attribute arguments.*/)]
	private static void qolReloadConfig(ConCommandArgs args)
	{
		configFile.Reload();
	}
}
internal static class MultRetool
{
	private const float retoolSpeed = 0.46f;

	private const float newBaseCooldown = 0.53f;

	internal static void DoSetup()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		QLConfig.multRetoolToggle.SettingChanged += MultRetoolToggle_SettingChanged;
		if (QLConfig.multRetoolToggle.Value)
		{
			ToolbotStanceSwap.OnEnter += new hook_OnEnter(ToolbotStanceSwap_OnEnter);
		}
	}

	private static void MultRetoolToggle_SettingChanged(object sender, EventArgs e)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		if (QLConfig.multRetoolToggle.Value)
		{
			ToolbotStanceSwap.OnEnter += new hook_OnEnter(ToolbotStanceSwap_OnEnter);
			Debug.Log((object)"Enabled Retool swap");
		}
		else
		{
			ToolbotStanceSwap.OnEnter -= new hook_OnEnter(ToolbotStanceSwap_OnEnter);
			Debug.Log((object)"Disabled Retool swap");
		}
	}

	private static void ToolbotStanceSwap_OnEnter(orig_OnEnter orig, ToolbotStanceSwap self)
	{
		if (((EntityState)self).isAuthority)
		{
			self.baseDuration = 0.46f;
			GenericSkill specialBonusStockSkill = ((EntityState)self).characterBody.skillLocator.specialBonusStockSkill;
			specialBonusStockSkill.skillDef.baseRechargeInterval = ((((EntityState)self).characterBody.attackSpeed < 1.07f) ? 0.53f : 0.5f);
			specialBonusStockSkill.RecalculateFinalRechargeInterval();
		}
		orig.Invoke(self);
	}
}
internal static class RiskofOptions
{
	private static bool? _enabled;

	internal static bool enabled
	{
		get
		{
			if (!_enabled.HasValue)
			{
				_enabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
			}
			return _enabled.Value;
		}
	}

	internal static void SetSprite(Sprite sprite)
	{
		ModSettingsManager.SetModIcon(sprite);
	}

	internal static void AddOption(ConfigEntry<bool> entry)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry));
	}

	internal static void AddOption(ConfigEntry<bool> entry, string category, string name)
	{
		//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_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
		{
			category = category,
			name = name
		}));
	}

	internal static void AddOption<T>(ConfigEntry<T> entry) where T : Enum
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)entry));
	}

	internal static void AddOption(ConfigEntry<Color> entry)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new ColorOption(entry));
	}

	internal static void AddOption(ConfigEntry<KeyboardShortcut> entry)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry));
	}

	internal static void AddSlider(ConfigEntry<float> entry, float min, float max, string format)
	{
		//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_000d: 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_0020: Expected O, but got Unknown
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig
		{
			min = min,
			max = max,
			formatString = format
		}));
	}
}