Decompiled source of Omni Extraction Toolkit v1.0.2

plugins/OmniExtractionToolkit.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("binaryn3xus")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("R.E.P.O. Omni-Extraction Toolkit Mod")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+af2132f677f6fbf34114b270094d80a725446793")]
[assembly: AssemblyProduct("Omni-Extraction Toolkit")]
[assembly: AssemblyTitle("OmniExtractionToolkit")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace OmniExtractionToolkit
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.binaryn3xus.repo.omniextraction", "Omni-Extraction Toolkit", "1.0.2")]
	public class OmniExtractionToolkitPlugin : BaseUnityPlugin
	{
		public static ConfigEntry<KeyCode> ScanKey;

		public static ConfigEntry<float> ScanRadius;

		public static ConfigEntry<float> ScanCooldown;

		public static ConfigEntry<float> HUDX;

		public static ConfigEntry<float> HUDY;

		public static ConfigEntry<bool> ShowHeldItem;

		public static ConfigEntry<bool> ShareUpgrades;

		public static ConfigEntry<bool> ShareHealth;

		public static ConfigEntry<bool> ShareEnergy;

		public static ConfigEntry<bool> ShareSprint;

		public static ConfigEntry<bool> ShareGrabStrength;

		public static ConfigEntry<bool> ShareGrabRange;

		public static ConfigEntry<bool> ShareExtraJump;

		public static ConfigEntry<bool> ShareTumble;

		public static ConfigEntry<bool> ShareTumbleClimb;

		public static ConfigEntry<bool> ShareTumbleWings;

		public static ConfigEntry<bool> ShareCrouchRest;

		public static ConfigEntry<bool> ShareThrowStrength;

		public static ConfigEntry<bool> InfiniteBattery;

		public static ConfigEntry<bool> InfiniteStamina;

		public static ConfigEntry<float> DamageMultiplier;

		public static ManualLogSource ModLogger;

		private void Awake()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			ModLogger = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"================================================");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"      OMNI-EXTRACTION TOOLKIT LOADED!       ");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"================================================");
			InitConfig();
			Harmony val = new Harmony("com.binaryn3xus.repo.omniextraction");
			val.PatchAll();
		}

		private void InitConfig()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Expected O, but got Unknown
			ScanKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Scanner", "ScanKey", (KeyCode)102, "Key to trigger a manual scan");
			ScanRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Scanner", "ScanRadius", 30f, new ConfigDescription("Radius", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>()));
			ScanCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Scanner", "ScanCooldown", 5f, new ConfigDescription("Cooldown", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 30f), Array.Empty<object>()));
			HUDX = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "Horizontal Position", 100f, new ConfigDescription("X% (0=Left, 100=Right)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			HUDY = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "Vertical Position", 0f, new ConfigDescription("Y% (0=Bottom, 100=Top)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			ShowHeldItem = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Show Held Item Value", true, "Show the name and value of the item you are currently holding (Valuables only).");
			ShareUpgrades = ((BaseUnityPlugin)this).Config.Bind<bool>("Shared Upgrades", "Master Toggle", true, (ConfigDescription)null);
			ShareHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("Shared Upgrades", "Share Health", true, (ConfigDescription)null);
			ShareEnergy = ((BaseUnityPlugin)this).Config.Bind<bool>("Shared Upgrades", "Share Energy", true, (ConfigDescription)null);
			ShareSprint = ((BaseUnityPlugin)this).Config.Bind<bool>("Shared Upgrades", "Share Sprint Speed", true, (ConfigDescription)null);
			ShareGrabStrength = ((BaseUnityPlugin)this).Config.Bind<bool>("Shared Upgrades", "Share Grab Strength", true, (ConfigDescription)null);
			ShareGrabRange = ((BaseUnityPlugin)this).Config.Bind<bool>("Shared Upgrades", "Share Grab Range", true, (ConfigDescription)null);
			ShareExtraJump = ((BaseUnityPlugin)this).Config.Bind<bool>("Shared Upgrades", "Share Extra Jump", true, (ConfigDescription)null);
			ShareTumble = ((BaseUnityPlugin)this).Config.Bind<bool>("Shared Upgrades", "Share Tumble Launch", true, (ConfigDescription)null);
			ShareTumbleClimb = ((BaseUnityPlugin)this).Config.Bind<bool>("Shared Upgrades", "Share Tumble Climb", true, (ConfigDescription)null);
			ShareTumbleWings = ((BaseUnityPlugin)this).Config.Bind<bool>("Shared Upgrades", "Share Tumble Wings", true, (ConfigDescription)null);
			ShareCrouchRest = ((BaseUnityPlugin)this).Config.Bind<bool>("Shared Upgrades", "Share Crouch Rest", true, (ConfigDescription)null);
			ShareThrowStrength = ((BaseUnityPlugin)this).Config.Bind<bool>("Shared Upgrades", "Share Throw Strength", true, (ConfigDescription)null);
			InfiniteBattery = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "Infinite Battery & Ammo", false, (ConfigDescription)null);
			InfiniteStamina = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "Infinite Stamina", false, (ConfigDescription)null);
			DamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Cheats", "Loot Damage Multiplier", 1f, new ConfigDescription("Scale impact damage. Negative = increase value!", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-5f, 10f), Array.Empty<object>()));
		}

		public static string GetBindingPath(KeyCode keyCode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Invalid comparison between Unknown and I4
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Invalid comparison between Unknown and I4
			if ((int)keyCode >= 48 && (int)keyCode <= 57)
			{
				return "<Keyboard>/" + ((object)(KeyCode)(ref keyCode)).ToString().Replace("Alpha", "");
			}
			if ((int)keyCode == 323)
			{
				return "<Mouse>/leftButton";
			}
			if ((int)keyCode == 324)
			{
				return "<Mouse>/rightButton";
			}
			if ((int)keyCode == 325)
			{
				return "<Mouse>/middleButton";
			}
			string text = ((object)(KeyCode)(ref keyCode)).ToString();
			if (text.Length > 0)
			{
				text = char.ToLower(text[0]) + text.Substring(1);
			}
			return "<Keyboard>/" + text;
		}
	}
	public static class ModInput
	{
		public const InputKey ScanInputKey = 327;
	}
}
namespace OmniExtractionToolkit.Features
{
	public static class CheatPatches
	{
		[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "BreakRPC")]
		public static class LootDamage_Patch
		{
			private static void Prefix(PhysGrabObjectImpactDetector __instance, ref float valueLost, bool _loseValue)
			{
				ValuableObject value = Traverse.Create((object)__instance).Field<ValuableObject>("valuableObject").Value;
				if (!_loseValue || !((Object)(object)value != (Object)null))
				{
					return;
				}
				float value2 = OmniExtractionToolkitPlugin.DamageMultiplier.Value;
				Traverse val = Traverse.Create((object)value);
				float value3 = val.Field<float>("dollarValueCurrent").Value;
				float value4 = val.Field<float>("dollarValueOriginal").Value;
				if (value2 < 0f)
				{
					float num = ((value4 > 0f) ? (value3 / value4) : 1f);
					valueLost *= num * value2;
				}
				else
				{
					valueLost *= value2;
				}
				float num2 = value3 - valueLost;
				if (num2 > 1E+09f)
				{
					valueLost = value3 - 1E+09f;
				}
				if ((Object)(object)RoundDirector.instance != (Object)null)
				{
					Traverse val2 = Traverse.Create((object)RoundDirector.instance);
					long num3 = val2.Field<int>("haulGoalMax").Value;
					long num4 = num3 - (int)valueLost;
					if (num4 > 2100000000)
					{
						num4 = 2100000000L;
					}
					if (num4 < 0)
					{
						num4 = 0L;
					}
					val2.Field("haulGoalMax").SetValue((object)(int)num4);
				}
			}
		}

		[HarmonyPatch(typeof(RoundDirector), "Update")]
		public static class InfiniteBattery_Patch
		{
			private static void Postfix(RoundDirector __instance)
			{
				if (OmniExtractionToolkitPlugin.InfiniteBattery.Value)
				{
					Traverse.Create((object)__instance).Field("debugInfiniteBattery").SetValue((object)true);
				}
			}
		}

		[HarmonyPatch(typeof(PlayerController), "Update")]
		public static class InfiniteStamina_Patch
		{
			private static void Postfix(PlayerController __instance)
			{
				if (OmniExtractionToolkitPlugin.InfiniteStamina.Value)
				{
					__instance.DebugEnergy = true;
				}
			}
		}

		[HarmonyPatch(typeof(PunManager))]
		public static class SharedUpgrades_Patch
		{
			private static bool _syncing;

			private static bool ShouldSync => OmniExtractionToolkitPlugin.ShareUpgrades.Value && !_syncing && PhotonNetwork.IsMasterClient;

			private static void SyncToAll(string _steamID, int value, string rpcMethodName)
			{
				if ((Object)(object)PunManager.instance == (Object)null)
				{
					return;
				}
				PhotonView component = ((Component)PunManager.instance).GetComponent<PhotonView>();
				if ((Object)(object)component == (Object)null)
				{
					return;
				}
				_syncing = true;
				PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
				foreach (PlayerAvatar val in array)
				{
					string text = SemiFunc.PlayerGetSteamID(val);
					if (!string.IsNullOrEmpty(text) && text != _steamID)
					{
						MethodInfo method = typeof(PunManager).GetMethod(rpcMethodName);
						if (method != null)
						{
							method.Invoke(PunManager.instance, new object[2] { text, value });
						}
						component.RPC(rpcMethodName, (RpcTarget)1, new object[2] { text, value });
					}
				}
				_syncing = false;
			}

			[HarmonyPostfix]
			[HarmonyPatch("UpgradePlayerHealth")]
			private static void H_P(string _steamID, int value)
			{
				if (ShouldSync && OmniExtractionToolkitPlugin.ShareHealth.Value)
				{
					SyncToAll(_steamID, value, "UpgradePlayerHealth");
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("UpgradePlayerEnergy")]
			private static void E_P(string _steamID, int value)
			{
				if (ShouldSync && OmniExtractionToolkitPlugin.ShareEnergy.Value)
				{
					SyncToAll(_steamID, value, "UpgradePlayerEnergy");
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("UpgradePlayerSprintSpeed")]
			private static void S_P(string _steamID, int value)
			{
				if (ShouldSync && OmniExtractionToolkitPlugin.ShareSprint.Value)
				{
					SyncToAll(_steamID, value, "UpgradePlayerSprintSpeed");
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("UpgradePlayerGrabStrength")]
			private static void GS_P(string _steamID, int value)
			{
				if (ShouldSync && OmniExtractionToolkitPlugin.ShareGrabStrength.Value)
				{
					SyncToAll(_steamID, value, "UpgradePlayerGrabStrength");
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("UpgradePlayerGrabRange")]
			private static void GR_P(string _steamID, int value)
			{
				if (ShouldSync && OmniExtractionToolkitPlugin.ShareGrabRange.Value)
				{
					SyncToAll(_steamID, value, "UpgradePlayerGrabRange");
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("UpgradePlayerExtraJump")]
			private static void J_P(string _steamID, int value)
			{
				if (ShouldSync && OmniExtractionToolkitPlugin.ShareExtraJump.Value)
				{
					SyncToAll(_steamID, value, "UpgradePlayerExtraJump");
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("UpgradePlayerTumbleLaunch")]
			private static void T_P(string _steamID, int value)
			{
				if (ShouldSync && OmniExtractionToolkitPlugin.ShareTumble.Value)
				{
					SyncToAll(_steamID, value, "UpgradePlayerTumbleLaunch");
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("UpgradePlayerTumbleClimb")]
			private static void TC_P(string _steamID, int value)
			{
				if (ShouldSync && OmniExtractionToolkitPlugin.ShareTumbleClimb.Value)
				{
					SyncToAll(_steamID, value, "UpgradePlayerTumbleClimb");
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("UpgradePlayerTumbleWings")]
			private static void TW_P(string _steamID, int value)
			{
				if (ShouldSync && OmniExtractionToolkitPlugin.ShareTumbleWings.Value)
				{
					SyncToAll(_steamID, value, "UpgradePlayerTumbleWings");
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("UpgradePlayerCrouchRest")]
			private static void CR_P(string _steamID, int value)
			{
				if (ShouldSync && OmniExtractionToolkitPlugin.ShareCrouchRest.Value)
				{
					SyncToAll(_steamID, value, "UpgradePlayerCrouchRest");
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("UpgradePlayerThrowStrength")]
			private static void TS_P(string _steamID, int value)
			{
				if (ShouldSync && OmniExtractionToolkitPlugin.ShareThrowStrength.Value)
				{
					SyncToAll(_steamID, value, "UpgradePlayerThrowStrength");
				}
			}
		}
	}
	public class EnhancedHUD : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <CreateUI>d__8 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public EnhancedHUD <>4__this;

			private TMP_FontAsset <font>5__1;

			private RectTransform <canvasRect>5__2;

			private GameObject <go>5__3;

			private GameObject <heldGo>5__4;

			private RectTransform <heldRt>5__5;

			private Image <bg>5__6;

			private GameObject <fill>5__7;

			private Image <img>5__8;

			private GameObject <lblGo>5__9;

			private TextMeshProUGUI <tmp>5__10;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <CreateUI>d__8(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<font>5__1 = null;
				<canvasRect>5__2 = null;
				<go>5__3 = null;
				<heldGo>5__4 = null;
				<heldRt>5__5 = null;
				<bg>5__6 = null;
				<fill>5__7 = null;
				<img>5__8 = null;
				<lblGo>5__9 = null;
				<tmp>5__10 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Expected O, but got Unknown
				//IL_0121: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: Expected O, but got Unknown
				//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0217: Unknown result type (might be due to invalid IL or missing references)
				//IL_0232: Unknown result type (might be due to invalid IL or missing references)
				//IL_0248: Unknown result type (might be due to invalid IL or missing references)
				//IL_0252: Expected O, but got Unknown
				//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_02cb: Expected O, but got Unknown
				//IL_030e: Unknown result type (might be due to invalid IL or missing references)
				//IL_032e: Unknown result type (might be due to invalid IL or missing references)
				//IL_034e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0364: Unknown result type (might be due to invalid IL or missing references)
				//IL_037a: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_03cb: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					<font>5__1 = null;
					if ((Object)(object)ItemInfoUI.instance != (Object)null)
					{
						<tmp>5__10 = ((Component)ItemInfoUI.instance).GetComponent<TextMeshProUGUI>();
						if ((Object)(object)<tmp>5__10 != (Object)null)
						{
							<font>5__1 = ((TMP_Text)<tmp>5__10).font;
						}
						<tmp>5__10 = null;
					}
					<canvasRect>5__2 = ((Component)HUDCanvas.instance).GetComponent<RectTransform>();
					<go>5__3 = new GameObject("EnhancedMapTracker");
					<go>5__3.transform.SetParent((Transform)(object)<canvasRect>5__2, false);
					<>4__this.mapText = <go>5__3.AddComponent<TextMeshProUGUI>();
					if ((Object)(object)<font>5__1 != (Object)null)
					{
						((TMP_Text)<>4__this.mapText).font = <font>5__1;
					}
					((TMP_Text)<>4__this.mapText).fontSize = 20f;
					<heldGo>5__4 = new GameObject("EnhancedHeldItem");
					<heldGo>5__4.transform.SetParent((Transform)(object)<canvasRect>5__2, false);
					<>4__this.heldItemText = <heldGo>5__4.AddComponent<TextMeshProUGUI>();
					if ((Object)(object)<font>5__1 != (Object)null)
					{
						((TMP_Text)<>4__this.heldItemText).font = <font>5__1;
					}
					((TMP_Text)<>4__this.heldItemText).fontSize = 22f;
					((TMP_Text)<>4__this.heldItemText).alignment = (TextAlignmentOptions)1026;
					<heldRt>5__5 = <heldGo>5__4.GetComponent<RectTransform>();
					RectTransform obj = <heldRt>5__5;
					RectTransform obj2 = <heldRt>5__5;
					Vector2 val = default(Vector2);
					((Vector2)(ref val))..ctor(0.5f, 0f);
					obj2.anchorMax = val;
					obj.anchorMin = val;
					<heldRt>5__5.pivot = new Vector2(0.5f, 0f);
					<heldRt>5__5.anchoredPosition = new Vector2(0f, 50f);
					<heldRt>5__5.sizeDelta = new Vector2(600f, 50f);
					<>4__this.cooldownBar = new GameObject("EnhancedCooldownBar");
					<>4__this.cooldownBar.transform.SetParent((Transform)(object)<canvasRect>5__2, false);
					<>4__this.cooldownBar.AddComponent<RectTransform>();
					<bg>5__6 = <>4__this.cooldownBar.AddComponent<Image>();
					((Graphic)<bg>5__6).color = new Color(0f, 0f, 0f, 0.7f);
					<fill>5__7 = new GameObject("Fill");
					<fill>5__7.transform.SetParent(<>4__this.cooldownBar.transform, false);
					<>4__this.cooldownFill = <fill>5__7.AddComponent<RectTransform>();
					<>4__this.cooldownFill.anchorMin = Vector2.zero;
					<>4__this.cooldownFill.anchorMax = new Vector2(0f, 1f);
					<>4__this.cooldownFill.pivot = new Vector2(0f, 0.5f);
					<>4__this.cooldownFill.anchoredPosition = Vector2.zero;
					<>4__this.cooldownFill.sizeDelta = Vector2.zero;
					<img>5__8 = <fill>5__7.AddComponent<Image>();
					((Graphic)<img>5__8).color = new Color(1f, 0.84f, 0f, 1f);
					<lblGo>5__9 = new GameObject("Label");
					<lblGo>5__9.transform.SetParent(<>4__this.cooldownBar.transform, false);
					<>4__this.cooldownLabel = <lblGo>5__9.AddComponent<TextMeshProUGUI>();
					if ((Object)(object)<font>5__1 != (Object)null)
					{
						((TMP_Text)<>4__this.cooldownLabel).font = <font>5__1;
					}
					((TMP_Text)<>4__this.cooldownLabel).fontSize = 11f;
					((TMP_Text)<>4__this.cooldownLabel).text = "RECHARGING SCANNER";
					<>4__this.UpdatePosition();
					<>4__this.cooldownBar.SetActive(false);
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private TextMeshProUGUI mapText;

		private TextMeshProUGUI heldItemText;

		private GameObject cooldownBar;

		private RectTransform cooldownFill;

		private TextMeshProUGUI cooldownLabel;

		private float lastX;

		private float lastY;

		private void Start()
		{
			((MonoBehaviour)this).StartCoroutine(CreateUI());
		}

		[IteratorStateMachine(typeof(<CreateUI>d__8))]
		private IEnumerator CreateUI()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <CreateUI>d__8(0)
			{
				<>4__this = this
			};
		}

		private void UpdatePosition()
		{
			//IL_0063: 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_006d: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)mapText == (Object)null) && !((Object)(object)cooldownBar == (Object)null))
			{
				float num = OmniExtractionToolkitPlugin.HUDX.Value / 100f;
				float num2 = OmniExtractionToolkitPlugin.HUDY.Value / 100f;
				RectTransform component = ((Component)mapText).GetComponent<RectTransform>();
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(num, num2);
				component.pivot = val;
				Vector2 val4 = (component.anchorMin = (component.anchorMax = val));
				float num3 = Mathf.Lerp(20f, -20f, num);
				float num4 = Mathf.Lerp(20f, -20f, num2);
				component.anchoredPosition = new Vector2(num3, num4);
				if (num < 0.33f)
				{
					((TMP_Text)mapText).alignment = (TextAlignmentOptions)513;
				}
				else if (num > 0.66f)
				{
					((TMP_Text)mapText).alignment = (TextAlignmentOptions)516;
				}
				else
				{
					((TMP_Text)mapText).alignment = (TextAlignmentOptions)514;
				}
				RectTransform component2 = cooldownBar.GetComponent<RectTransform>();
				((Vector2)(ref val))..ctor(num, num2);
				component2.pivot = val;
				val4 = (component2.anchorMin = (component2.anchorMax = val));
				component2.sizeDelta = new Vector2(135f, 8f);
				float num5 = ((num2 > 0.5f) ? (-110f) : 110f);
				component2.anchoredPosition = new Vector2(num3, num4 + num5);
				RectTransform component3 = ((Component)cooldownLabel).GetComponent<RectTransform>();
				((Vector2)(ref val4))..ctor(num, (float)((!(num2 > 0.5f)) ? 1 : 0));
				component3.anchorMax = val4;
				component3.anchorMin = val4;
				component3.pivot = new Vector2(num, 0f);
				component3.anchoredPosition = new Vector2(0f, (float)((num2 > 0.5f) ? (-24) : 4));
				component3.sizeDelta = new Vector2(200f, 18f);
				if (num < 0.33f)
				{
					((TMP_Text)cooldownLabel).alignment = (TextAlignmentOptions)513;
				}
				else if (num > 0.66f)
				{
					((TMP_Text)cooldownLabel).alignment = (TextAlignmentOptions)516;
				}
				else
				{
					((TMP_Text)cooldownLabel).alignment = (TextAlignmentOptions)514;
				}
				lastX = OmniExtractionToolkitPlugin.HUDX.Value;
				lastY = OmniExtractionToolkitPlugin.HUDY.Value;
			}
		}

		private void Update()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			bool flag = (Object)(object)GameDirector.instance != (Object)null && (int)GameDirector.instance.currentState == 2;
			bool flag2 = true;
			if ((Object)(object)MenuManager.instance != (Object)null)
			{
				flag2 = Traverse.Create((object)MenuManager.instance).Field<int>("currentMenuState").Value == 1;
			}
			bool flag3 = flag && flag2 && !SemiFunc.MenuLevel();
			if (lastX != OmniExtractionToolkitPlugin.HUDX.Value || lastY != OmniExtractionToolkitPlugin.HUDY.Value)
			{
				UpdatePosition();
			}
			if ((Object)(object)mapText != (Object)null)
			{
				((Component)mapText).gameObject.SetActive(flag3);
				if (flag3 && (Object)(object)RoundDirector.instance != (Object)null)
				{
					Traverse val = Traverse.Create((object)RoundDirector.instance);
					int value = val.Field("currentHaul").GetValue<int>();
					int value2 = val.Field("haulGoalMax").GetValue<int>();
					int value3 = val.Field("haulGoal").GetValue<int>();
					((TMP_Text)mapText).text = $"<color=white>Haul: <color=yellow>${value}</color> / Goal: ${value3}\nMap Total: <color=green>${value2}</color></color>";
				}
				else
				{
					((TMP_Text)mapText).text = "";
				}
			}
			if ((Object)(object)heldItemText != (Object)null)
			{
				PhysGrabObject val2 = null;
				if ((Object)(object)PhysGrabber.instance != (Object)null)
				{
					val2 = Traverse.Create((object)PhysGrabber.instance).Field<PhysGrabObject>("grabbedPhysGrabObject").Value;
				}
				bool flag4 = false;
				float num = 0f;
				string arg = "";
				if ((Object)(object)val2 != (Object)null)
				{
					ValuableObject component = ((Component)val2).GetComponent<ValuableObject>();
					bool flag5 = (Object)(object)((Component)val2).GetComponent<ItemEquippable>() != (Object)null;
					bool flag6 = SemiFunc.RunIsShop();
					if ((Object)(object)component != (Object)null && (!flag5 || flag6))
					{
						flag4 = true;
						arg = ((Object)((Component)val2).gameObject).name.Replace("(Clone)", "").Trim();
						num = Traverse.Create((object)component).Field<float>("dollarValueCurrent").Value;
					}
				}
				bool flag7 = flag3 && OmniExtractionToolkitPlugin.ShowHeldItem.Value && flag4;
				((Component)heldItemText).gameObject.SetActive(flag7);
				if (flag7)
				{
					((TMP_Text)heldItemText).text = $"{arg} <color=#00FF00>(${num:F0})</color>";
				}
				else
				{
					((TMP_Text)heldItemText).text = "";
				}
			}
			if ((Object)(object)cooldownBar != (Object)null)
			{
				float num2 = Time.time - ScannerPatches.lastScanTime;
				float value4 = OmniExtractionToolkitPlugin.ScanCooldown.Value;
				if (flag3 && num2 < value4)
				{
					cooldownBar.SetActive(true);
					cooldownFill.anchorMax = new Vector2(num2 / value4, 1f);
				}
				else
				{
					cooldownBar.SetActive(false);
				}
			}
		}
	}
	[HarmonyPatch(typeof(HUDCanvas), "Awake")]
	public static class HUDCanvas_Patch
	{
		private static void Postfix(HUDCanvas __instance)
		{
			if ((Object)(object)((Component)__instance).gameObject.GetComponent<EnhancedHUD>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<EnhancedHUD>();
			}
		}
	}
	public static class ScannerPatches
	{
		[HarmonyPatch(typeof(PlayerController), "Update")]
		public static class PlayerScan_Patch
		{
			private static void Postfix()
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if ((SemiFunc.InputDown((InputKey)327) || Input.GetKeyDown(OmniExtractionToolkitPlugin.ScanKey.Value)) && !(Time.time - lastScanTime < OmniExtractionToolkitPlugin.ScanCooldown.Value))
				{
					DoLocalScan();
					lastScanTime = Time.time;
				}
			}
		}

		[HarmonyPatch(typeof(ItemTracker), "ValuableTarget")]
		public static class TrackerRange_Patch
		{
			private static bool Prefix(ItemTracker __instance)
			{
				//IL_006a: 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_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0166: Unknown result type (might be due to invalid IL or missing references)
				//IL_0169: Unknown result type (might be due to invalid IL or missing references)
				object value = Traverse.Create((object)__instance).Field("trackerType").GetValue();
				if (value == null || value.ToString() != "Valuable")
				{
					return true;
				}
				Traverse val = Traverse.Create((object)__instance);
				Transform value2 = val.Field("nozzleTransform").GetValue<Transform>();
				if ((Object)(object)value2 == (Object)null)
				{
					return true;
				}
				Vector3 position = value2.position;
				float num = 500f;
				Collider[] array = Physics.OverlapSphere(position, num, LayerMask.op_Implicit(SemiFunc.LayerMaskGetPhysGrabObject()));
				PhysGrabObject val2 = null;
				ValuableObject value3 = null;
				ValuableDiscoverCustom value4 = null;
				float num2 = float.MaxValue;
				Collider[] array2 = array;
				foreach (Collider val3 in array2)
				{
					PhysGrabObject val4 = null;
					ValuableObject componentInParent = ((Component)val3).GetComponentInParent<ValuableObject>();
					ValuableDiscoverCustom val5 = null;
					if ((Object)(object)componentInParent != (Object)null)
					{
						if (!Traverse.Create((object)componentInParent).Field<bool>("discovered").Value)
						{
							val4 = Traverse.Create((object)componentInParent).Field<PhysGrabObject>("physGrabObject").Value;
						}
					}
					else
					{
						val5 = ((Component)val3).GetComponentInParent<ValuableDiscoverCustom>();
						if ((Object)(object)val5 != (Object)null && !Traverse.Create((object)val5).Field<bool>("discovered").Value)
						{
							val4 = Traverse.Create((object)val5).Field<PhysGrabObject>("physGrabObject").Value;
						}
					}
					if ((Object)(object)val4 != (Object)null)
					{
						float num3 = Vector3.Distance(position, val4.midPoint);
						PhysGrabObjectImpactDetector value5 = Traverse.Create((object)val4).Field<PhysGrabObjectImpactDetector>("impactDetector").Value;
						if (num3 < num2 && !val4.grabbed && (Object)(object)value5 != (Object)null && !value5.inCart)
						{
							num2 = num3;
							val2 = val4;
							value3 = componentInParent;
							value4 = val5;
						}
					}
				}
				if ((Object)(object)val2 != (Object)null)
				{
					val.Field("currentTarget").SetValue((object)((Component)val2).transform);
					val.Field("currentTargetPhysGrabObject").SetValue((object)val2);
					val.Field("currentTargetValuable").SetValue((object)value3);
					val.Field("currentTargetValuableCustom").SetValue((object)value4);
					val.Field("hasTarget").SetValue((object)true);
					PhotonView value6 = Traverse.Create((object)val2).Field<PhotonView>("photonView").Value;
					if ((Object)(object)value6 != (Object)null)
					{
						val.Method("SetTarget", new object[1] { value6.ViewID }).GetValue();
					}
				}
				else
				{
					val.Field("hasTarget").SetValue((object)false);
				}
				return false;
			}
		}

		public static float lastScanTime = -100f;

		public static void DoLocalScan()
		{
			//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_0034: 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)
			if ((Object)(object)PlayerController.instance == (Object)null)
			{
				return;
			}
			Vector3 position = ((Component)PlayerController.instance).transform.position;
			float value = OmniExtractionToolkitPlugin.ScanRadius.Value;
			int num = 0;
			int num2 = LayerMask.op_Implicit(SemiFunc.LayerMaskGetPhysGrabObject());
			Collider[] array = Physics.OverlapSphere(position, value, num2);
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				ValuableObject componentInParent = ((Component)val).GetComponentInParent<ValuableObject>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					PhysGrabObject value2 = Traverse.Create((object)componentInParent).Field<PhysGrabObject>("physGrabObject").Value;
					if ((Object)(object)value2 != (Object)null && (Object)(object)ValuableDiscover.instance != (Object)null)
					{
						ValuableDiscover.instance.New(value2, (State)0, (ValuableDiscoverCustom)null);
						num++;
					}
					continue;
				}
				ValuableDiscoverCustom componentInParent2 = ((Component)val).GetComponentInParent<ValuableDiscoverCustom>();
				if ((Object)(object)componentInParent2 != (Object)null)
				{
					PhysGrabObject value3 = Traverse.Create((object)componentInParent2).Field<PhysGrabObject>("physGrabObject").Value;
					if ((Object)(object)value3 != (Object)null && (Object)(object)ValuableDiscover.instance != (Object)null)
					{
						ValuableDiscover.instance.New(value3, (State)0, componentInParent2);
						num++;
					}
				}
			}
			if (num > 0)
			{
				SemiFunc.UIItemInfoText((ItemAttributes)null, $"Area scanned. (Found {num} items)");
			}
			else
			{
				SemiFunc.UIItemInfoText((ItemAttributes)null, "Area scanned. No new items found.");
			}
		}
	}
	public static class UIPatches
	{
		[HarmonyPatch(typeof(ItemInfoUI), "ItemInfoText")]
		public static class ItemInfoUI_Patch
		{
			private static void Prefix(ref string message, ItemAttributes _itemAttributes)
			{
				if (!((Object)(object)_itemAttributes != (Object)null))
				{
					return;
				}
				ValuableObject componentInParent = ((Component)_itemAttributes).GetComponentInParent<ValuableObject>();
				bool flag = (Object)(object)((Component)_itemAttributes).GetComponent<ItemEquippable>() != (Object)null;
				bool flag2 = SemiFunc.RunIsShop();
				if ((Object)(object)componentInParent != (Object)null && (!flag || flag2))
				{
					float value = Traverse.Create((object)componentInParent).Field<float>("dollarValueCurrent").Value;
					message += $" <color=#00FF00>(${value:F0})</color>";
				}
				else if (flag2)
				{
					int value2 = Traverse.Create((object)_itemAttributes).Field<int>("value").Value;
					if (value2 > 0)
					{
						message += $" <color=#00FF00>(${value2:F0})</color>";
					}
				}
			}
		}

		[HarmonyPatch(typeof(PhysGrabber), "RayCheck")]
		public static class PhysGrabber_RayCheck_Patch
		{
			private static void Prefix(PhysGrabber __instance)
			{
				Traverse val = Traverse.Create((object)__instance);
				val.Field("currentlyLookingAtPhysGrabObject").SetValue((object)null);
				val.Field("currentlyLookingAtItemAttributes").SetValue((object)null);
			}

			private static void Postfix(PhysGrabber __instance)
			{
				Traverse val = Traverse.Create((object)__instance);
				PhysGrabObject value = val.Field<PhysGrabObject>("currentlyLookingAtPhysGrabObject").Value;
				ItemAttributes value2 = val.Field<ItemAttributes>("currentlyLookingAtItemAttributes").Value;
				if ((Object)(object)value != (Object)null && (Object)(object)value2 == (Object)null)
				{
					ValuableObject component = ((Component)value).GetComponent<ValuableObject>();
					if ((Object)(object)component != (Object)null)
					{
						float value3 = Traverse.Create((object)component).Field<float>("dollarValueCurrent").Value;
						string arg = ((Object)((Component)value).gameObject).name.Replace("(Clone)", "").Trim();
						SemiFunc.UIItemInfoText((ItemAttributes)null, $"{arg} <color=#00FF00>(${value3:F0})</color>");
					}
				}
			}
		}
	}
	public static class VanillaFixPatches
	{
		[HarmonyPatch(typeof(ShopRadio), "Update")]
		public static class ShopRadio_Update_Patch
		{
			private static bool Prefix(ShopRadio __instance)
			{
				PhysGrabObject value = Traverse.Create((object)__instance).Field<PhysGrabObject>("physGrabObject").Value;
				if ((Object)(object)value != (Object)null && value.dead)
				{
					return false;
				}
				ParticleSystem value2 = Traverse.Create((object)__instance).Field<ParticleSystem>("smoke").Value;
				if ((Object)(object)value2 == (Object)null || (Object)(object)((Component)value2).gameObject == (Object)null)
				{
					return false;
				}
				return true;
			}
		}
	}
}