Decompiled source of ScrapValueDetector67 v6.7.67

BepInEx/plugins/ScrapValueDetector67/Ratijas.ScrapValueDetector67.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 DunGen;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalConfig;
using LethalConfig.ConfigItems;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("DunGen")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Ratijas.ScrapValueDetector67")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("6.7.67.0")]
[assembly: AssemblyInformationalVersion("6.7.67+ba587a6af15c731d3d32386ab01503c2a301e3a0")]
[assembly: AssemblyProduct("ScrapValueDetector67")]
[assembly: AssemblyTitle("Ratijas.ScrapValueDetector67")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("6.7.67.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class ExtensionMarkerAttribute : Attribute
	{
		private readonly string <Name>k__BackingField;

		public string Name => <Name>k__BackingField;

		public ExtensionMarkerAttribute(string name)
		{
			<Name>k__BackingField = name;
		}
	}
}
namespace ScrapValueDetector67
{
	internal static class BoxTableFormatter
	{
		private class BoxTableFormatterInternal
		{
			[CompilerGenerated]
			private int <tableWidth>P;

			public const int HORIZONTAL_PADDING = 4;

			public int ContentWidth => <tableWidth>P - 4;

			public BoxTableFormatterInternal(int tableWidth)
			{
				<tableWidth>P = tableWidth;
				base..ctor();
			}

			public string FormatTableHeader()
			{
				return FormatSimpleRepeat('╒', '═', '╕');
			}

			public string FormatTableHeader(string text)
			{
				return FormatTableRowCentered('│', text, '│');
			}

			public string FormatTableSeparator()
			{
				return FormatSimpleRepeat('╞', '═', '╡');
			}

			public string FormatTableFooter()
			{
				return FormatSimpleRepeat('╘', '═', '╛');
			}

			public string FormatTableRow(string text)
			{
				return FormatTableRowLeftAligned('│', text, '│');
			}

			private string FormatSimpleRepeat(char start, char middle, char end)
			{
				StringBuilder stringBuilder = new StringBuilder(<tableWidth>P);
				stringBuilder.Append(start);
				int num = <tableWidth>P - 2;
				for (int i = 0; i < num; i++)
				{
					stringBuilder.Append(middle);
				}
				stringBuilder.Append(end);
				return stringBuilder.ToString();
			}

			private string FormatTableRowCentered(char start, string middle, char end)
			{
				StringBuilder stringBuilder = new StringBuilder(<tableWidth>P);
				stringBuilder.Append(start);
				stringBuilder.Append(' ');
				int num = (ContentWidth - middle.Length) / 2;
				if (num < 0)
				{
					stringBuilder.Append(middle);
				}
				else
				{
					for (int i = 0; i < num; i++)
					{
						stringBuilder.Append(' ');
					}
					stringBuilder.Append(middle);
					for (int j = num + middle.Length; j < ContentWidth; j++)
					{
						stringBuilder.Append(' ');
					}
				}
				stringBuilder.Append(' ');
				stringBuilder.Append(end);
				return stringBuilder.ToString();
			}

			private string FormatTableRowLeftAligned(char start, string middle, char end)
			{
				StringBuilder stringBuilder = new StringBuilder(<tableWidth>P);
				stringBuilder.Append(start);
				stringBuilder.Append(' ');
				stringBuilder.Append(middle);
				for (int i = middle.Length; i < ContentWidth; i++)
				{
					stringBuilder.Append(' ');
				}
				stringBuilder.Append(' ');
				stringBuilder.Append(end);
				return stringBuilder.ToString();
			}
		}

		[CompilerGenerated]
		private sealed class <FormatBoxTable>d__0 : IEnumerable<string>, IEnumerable, IEnumerator<string>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private string <>2__current;

			private int <>l__initialThreadId;

			private string header;

			public string <>3__header;

			private string[] rows;

			public string[] <>3__rows;

			private int minWidth;

			public int <>3__minWidth;

			private int maxWidth;

			public int <>3__maxWidth;

			private BoxTableFormatterInternal <formatter>5__2;

			private int <contentWidth>5__3;

			private string[] <>7__wrap3;

			private int <>7__wrap4;

			private string[] <>7__wrap5;

			private int <>7__wrap6;

			private string[] <>7__wrap7;

			private int <>7__wrap8;

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

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

			[DebuggerHidden]
			public <FormatBoxTable>d__0(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<formatter>5__2 = null;
				<>7__wrap3 = null;
				<>7__wrap5 = null;
				<>7__wrap7 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					int num = Math.Max(header.Length, (rows.Length != 0) ? rows.Max((string row) => row.Length) : 0);
					int tableWidth = Math.Clamp(num + 4, minWidth, maxWidth);
					<formatter>5__2 = new BoxTableFormatterInternal(tableWidth);
					<contentWidth>5__3 = <formatter>5__2.ContentWidth;
					<>2__current = <formatter>5__2.FormatTableHeader();
					<>1__state = 1;
					return true;
				}
				case 1:
					<>1__state = -1;
					<>2__current = <formatter>5__2.FormatTableHeader(header);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>2__current = <formatter>5__2.FormatTableSeparator();
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					<>7__wrap3 = rows;
					<>7__wrap4 = 0;
					goto IL_0206;
				case 4:
					<>1__state = -1;
					<>7__wrap8++;
					goto IL_01b9;
				case 5:
					{
						<>1__state = -1;
						return false;
					}
					IL_0206:
					if (<>7__wrap4 < <>7__wrap3.Length)
					{
						string str = <>7__wrap3[<>7__wrap4];
						<>7__wrap5 = str.SplitLines();
						<>7__wrap6 = 0;
						goto IL_01de;
					}
					<>7__wrap3 = null;
					<>2__current = <formatter>5__2.FormatTableFooter();
					<>1__state = 5;
					return true;
					IL_01de:
					if (<>7__wrap6 < <>7__wrap5.Length)
					{
						string str2 = <>7__wrap5[<>7__wrap6];
						<>7__wrap7 = str2.WrapLines(<contentWidth>5__3);
						<>7__wrap8 = 0;
						goto IL_01b9;
					}
					<>7__wrap5 = null;
					<>7__wrap4++;
					goto IL_0206;
					IL_01b9:
					if (<>7__wrap8 < <>7__wrap7.Length)
					{
						string text = <>7__wrap7[<>7__wrap8];
						<>2__current = <formatter>5__2.FormatTableRow(text);
						<>1__state = 4;
						return true;
					}
					<>7__wrap7 = null;
					<>7__wrap6++;
					goto IL_01de;
				}
			}

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

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

			[DebuggerHidden]
			IEnumerator<string> IEnumerable<string>.GetEnumerator()
			{
				<FormatBoxTable>d__0 <FormatBoxTable>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<FormatBoxTable>d__ = this;
				}
				else
				{
					<FormatBoxTable>d__ = new <FormatBoxTable>d__0(0);
				}
				<FormatBoxTable>d__.header = <>3__header;
				<FormatBoxTable>d__.rows = <>3__rows;
				<FormatBoxTable>d__.minWidth = <>3__minWidth;
				<FormatBoxTable>d__.maxWidth = <>3__maxWidth;
				return <FormatBoxTable>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<string>)this).GetEnumerator();
			}
		}

		[IteratorStateMachine(typeof(<FormatBoxTable>d__0))]
		public static IEnumerable<string> FormatBoxTable(string header, string[] rows, int minWidth, int maxWidth)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FormatBoxTable>d__0(-2)
			{
				<>3__header = header,
				<>3__rows = rows,
				<>3__minWidth = minWidth,
				<>3__maxWidth = maxWidth
			};
		}
	}
	internal class Config
	{
		public int[] TargetValues { get; private set; } = Array.Empty<int>();


		public Config(ConfigFile configFile)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			Config config = this;
			string text = "General";
			ConfigEntry<string> entry = configFile.Bind<string>(text, "TargetValue", "67, 69", new ConfigDescription("Notify when scrap of this value spawns", (AcceptableValueBase)null, Array.Empty<object>()));
			LethalConfigCompatibility.AddTextInputFieldConfigItemSafe(entry, requiresRestart: false);
			entry.SettingChanged += delegate
			{
				apply();
			};
			apply();
			void apply()
			{
				config.TargetValues = config.ParseIntList(entry.Value);
				Plugin.Log.LogDebug((object)("TargetValues: " + string.Join(", ", config.TargetValues)));
			}
		}

		private int[] ParseIntList(string str)
		{
			List<int> list = new List<int>();
			string[] array = str.Split(",");
			foreach (string s in array)
			{
				if (int.TryParse(s, out var result))
				{
					list.Add(result);
				}
			}
			return list.ToArray();
		}
	}
	public class ScrapValueDetectorInputActions : LcInputActions
	{
		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction DetectKey { get; set; }
	}
	internal static class LethalConfigCompatibility
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		public static void AddTextInputFieldConfigItemSafe(ConfigEntry<string> entry, bool requiresRestart = true)
		{
			if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"))
			{
				AddTextInputFieldConfigItemUnsafe(entry, requiresRestart);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void AddTextInputFieldConfigItemUnsafe(ConfigEntry<string> entry, bool requiresRestart)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(entry, requiresRestart));
		}
	}
	internal static class LethalDunGenUtils
	{
		public class TilesAndBounds
		{
			[CompilerGenerated]
			private (Tile, Bounds)[] <list>P;

			public TilesAndBounds((Tile, Bounds)[] list)
			{
				<list>P = list;
				base..ctor();
			}

			public Tile? FindTileContaining(GrabbableObject item)
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				(Tile, Bounds)[] array = <list>P;
				for (int i = 0; i < array.Length; i++)
				{
					var (result, val) = array[i];
					if (((Bounds)(ref val)).Contains(((Component)item).transform.position))
					{
						return result;
					}
				}
				return null;
			}
		}

		public static GameObject? FindDungeonRoot(this RoundManager self)
		{
			List<(Tile, Bounds)> list = new List<(Tile, Bounds)>();
			GameObject val = null;
			if ((Object)(object)self.dungeonGenerator != (Object)null)
			{
				val = self.dungeonGenerator.Root;
			}
			if ((Object)(object)val == (Object)null)
			{
				val = GameObject.Find("/Systems/LevelGeneration/LevelGenerationRoot");
			}
			return val;
		}

		public static TilesAndBounds FindTilesAndBounds(GameObject dungeonRoot)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)dungeonRoot == (Object)null)
			{
				return new TilesAndBounds(Array.Empty<(Tile, Bounds)>());
			}
			List<(Tile, Bounds)> list = new List<(Tile, Bounds)>();
			Tile[] componentsInChildren = dungeonRoot.GetComponentsInChildren<Tile>();
			foreach (Tile val in componentsInChildren)
			{
				list.Add((val, val.OverrideAutomaticTileBounds ? UnityUtil.TransformBounds(((Component)val).transform, val.TileBoundsOverride) : val.Bounds));
			}
			return new TilesAndBounds(list.ToArray());
		}

		public static TilesAndBounds FindTilesAndBounds()
		{
			GameObject val = RoundManager.Instance.FindDungeonRoot();
			if ((Object)(object)val == (Object)null)
			{
				return new TilesAndBounds(Array.Empty<(Tile, Bounds)>());
			}
			return FindTilesAndBounds(val);
		}
	}
	internal static class NotificationManager
	{
		[CompilerGenerated]
		private sealed class <DelayedHUDReporterCoroutine>d__5 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public SpawnedScrapItem[] items;

			private SpawnedScrapItem[] <>7__wrap1;

			private int <>7__wrap2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>7__wrap1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = _waitForSeconds1;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>7__wrap1 = items;
					<>7__wrap2 = 0;
					break;
				case 2:
					<>1__state = -1;
					<>7__wrap2++;
					break;
				}
				if (<>7__wrap2 < <>7__wrap1.Length)
				{
					SpawnedScrapItem spawnedScrapItem = <>7__wrap1[<>7__wrap2];
					HUDManager.Instance.DisplayTip("OMFG! Lucky scrap spawned!", $"{spawnedScrapItem.Name} worth ${spawnedScrapItem.Value}\n" + "Located in " + spawnedScrapItem.TileName, false, false, "LC_Tip1");
					<>2__current = _waitForSeconds5;
					<>1__state = 2;
					return true;
				}
				<>7__wrap1 = null;
				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 static readonly WaitForSeconds _waitForSeconds5 = new WaitForSeconds(5f);

		private static readonly WaitForSeconds _waitForSeconds1 = new WaitForSeconds(1f);

		public static void ReportAllProbabilities()
		{
			List<Item> list = new List<Item>();
			List<int> list2 = new List<int>();
			List<string> list3 = new List<string>();
			foreach (SpawnableItemWithRarity item in RoundManager.Instance.currentLevel.spawnableScrap)
			{
				list.Add(item.spawnableItem);
				list2.Add(item.rarity);
			}
			int num = list2.Sum();
			float num2 = 0f;
			for (int i = 0; i < list.Count; i++)
			{
				float num3 = (float)list2[i] / (float)num;
				int minValue = list[i].minValue;
				int maxValue = list[i].maxValue;
				int num4 = maxValue - minValue + 1;
				int[] targetValues = Plugin.Config.TargetValues;
				foreach (int num5 in targetValues)
				{
					if (num5 >= minValue && num5 <= maxValue)
					{
						float num6 = num3 / (float)num4;
						num2 += num6;
						list3.Add($"{i}, {minValue}, {maxValue}, {num6:N4}, {list[i].itemName}");
					}
				}
			}
			list3.Add($"Total: {num2}");
			foreach (string item2 in BoxTableFormatter.FormatBoxTable("Probabilities", list3.ToArray(), 40, 80))
			{
				Plugin.Log.LogInfo((object)item2);
			}
		}

		public static void Report(SpawnedScrapItem[] items)
		{
			ReportConsole(items);
			ReportHUD(items);
		}

		private static void ReportHUD(SpawnedScrapItem[] items)
		{
			((MonoBehaviour)HUDManager.Instance).StartCoroutine(DelayedHUDReporterCoroutine(items));
		}

		[IteratorStateMachine(typeof(<DelayedHUDReporterCoroutine>d__5))]
		private static IEnumerator DelayedHUDReporterCoroutine(SpawnedScrapItem[] items)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DelayedHUDReporterCoroutine>d__5(0)
			{
				items = items
			};
		}

		private static void ReportConsole(SpawnedScrapItem[] items)
		{
			string header = "< Scrap Value Detector >";
			List<string> list = new List<string>(items.Length * 3);
			for (int i = 0; i < items.Length; i++)
			{
				SpawnedScrapItem spawnedScrapItem = items[i];
				if (i != 0)
				{
					list.Add("");
				}
				list.Add($"Detected {spawnedScrapItem.Name} Worth ${spawnedScrapItem.Value}");
				list.Add("Located in " + spawnedScrapItem.TileName);
			}
			if (items.Length == 0)
			{
				list.Add("No valuable items detected");
			}
			foreach (string item in BoxTableFormatter.FormatBoxTable(header, list.ToArray(), 40, 80))
			{
				Plugin.Log.LogInfo((object)item);
			}
		}
	}
	internal readonly struct SpawnedScrapItem
	{
		[CompilerGenerated]
		private readonly GrabbableObject <GrabbableObject>P;

		public Item Item => <GrabbableObject>P.itemProperties;

		public string Name => Item.itemName;

		public int Value => <GrabbableObject>P.scrapValue;

		public string TileName { get; }

		public SpawnedScrapItem(GrabbableObject GrabbableObject, string TileName)
		{
			<GrabbableObject>P = GrabbableObject;
			this.TileName = TileName;
		}
	}
	[HarmonyPatch(typeof(GiftBoxItem))]
	internal static class GiftBoxPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("OpenGiftBoxClientRpc")]
		private static void SpawnScrapInLevelPrefixPatch(GiftBoxItem __instance, NetworkObjectReference netObjectRef, int presentValue, Vector3 startFallingPos, out __RpcExecStage __state)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected I4, but got Unknown
			__state = (__RpcExecStage)(int)((NetworkBehaviour)__instance).__rpc_exec_stage;
		}

		[HarmonyPostfix]
		[HarmonyPatch("OpenGiftBoxClientRpc")]
		private static void SpawnScrapInLevelPostfixPatch(GiftBoxItem __instance, NetworkObjectReference netObjectRef, int presentValue, Vector3 startFallingPos, __RpcExecStage __state)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if ((int)__state == 1)
			{
				((MonoBehaviour)__instance).StartCoroutine(__instance.DetectValuableScrap(netObjectRef));
			}
		}
	}
	internal static class GiftBoxExtensions
	{
		[SpecialName]
		public sealed class <G>$F8345873646F110A4436DEE177F2D532
		{
			[SpecialName]
			public static class <M>$A0B2C7B1B8F7FAE12BE9B0666051C2AC
			{
			}

			[ExtensionMarker("<M>$A0B2C7B1B8F7FAE12BE9B0666051C2AC")]
			public IEnumerator DetectValuableScrap(NetworkObjectReference netObjectRef)
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <DetectValuableScrap>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public NetworkObjectReference netObjectRef;

			private NetworkObject <netObject>5__2;

			private float <startTime>5__3;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<netObject>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<netObject>5__2 = null;
					<startTime>5__3 = Time.realtimeSinceStartup;
					goto IL_0051;
				case 1:
					<>1__state = -1;
					goto IL_0051;
				case 2:
					{
						<>1__state = -1;
						GrabbableObject val = default(GrabbableObject);
						if (!((Component)<netObject>5__2).TryGetComponent<GrabbableObject>(ref val))
						{
							return false;
						}
						LethalDunGenUtils.TilesAndBounds tilesAndBounds = LethalDunGenUtils.FindTilesAndBounds();
						if (!Plugin.Config.TargetValues.Contains(val.scrapValue))
						{
							return false;
						}
						Tile self = tilesAndBounds.FindTileContaining(val);
						string tileName = self.PrettyName();
						SpawnedScrapItem spawnedScrapItem = new SpawnedScrapItem(val, tileName);
						NotificationManager.Report(new SpawnedScrapItem[1] { spawnedScrapItem });
						return false;
					}
					IL_0051:
					if (Time.realtimeSinceStartup - <startTime>5__3 < 8f && !((NetworkObjectReference)(ref netObjectRef)).TryGet(ref <netObject>5__2, (NetworkManager)null))
					{
						<>2__current = _waitForSeconds0_03;
						<>1__state = 1;
						return true;
					}
					if ((Object)(object)<netObject>5__2 == (Object)null)
					{
						return false;
					}
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 2;
					return true;
				}
			}

			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 static readonly WaitForSeconds _waitForSeconds0_03 = new WaitForSeconds(0.03f);

		[IteratorStateMachine(typeof(<DetectValuableScrap>d__2))]
		public static IEnumerator DetectValuableScrap(this GiftBoxItem self, NetworkObjectReference netObjectRef)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DetectValuableScrap>d__2(0)
			{
				netObjectRef = netObjectRef
			};
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal static class HUDManagerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("OnEnable")]
		private static void OnEnablePrefix(HUDManager __instance)
		{
			Plugin.InputActionsInstance.DetectKey.performed += __instance.DetectValuableScrap_performed;
		}

		[HarmonyPrefix]
		[HarmonyPatch("OnDisable")]
		private static void OnDisablePrefix(HUDManager __instance)
		{
			Plugin.InputActionsInstance.DetectKey.performed -= __instance.DetectValuableScrap_performed;
		}

		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		private static void UpdatePostfix(HUDManager __instance)
		{
			if (HUDManagerExtensions.replacePingingScanWithValuableScrapTimer > 0f)
			{
				HUDManagerExtensions.replacePingingScanWithValuableScrapTimer -= Time.deltaTime;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("AssignNewNodes")]
		private static bool AssignNewNodesPrefix(HUDManager __instance, PlayerControllerB playerScript)
		{
			foreach (ScanNodeProperties item in __instance.nodesOnScreen)
			{
				item.ClearDistanceHint();
			}
			if (HUDManagerExtensions.replacePingingScanWithValuableScrapTimer <= 0f)
			{
				return true;
			}
			__instance.AssignNewValuableNodes_NoCast(playerScript);
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("PingScan_performed")]
		private static void PingScan_performedPrefix(CallbackContext context)
		{
			HUDManagerExtensions.replacePingingScanWithValuableScrapTimer = 0f;
		}
	}
	internal static class HUDManagerExtensions
	{
		[SpecialName]
		public sealed class <G>$0ABFCA468B010F10941E8D3AFD4DF38A
		{
			[SpecialName]
			public static class <M>$DBC100433FB32BFD83416BE321C142C4
			{
			}

			[ExtensionMarker("<M>$DBC100433FB32BFD83416BE321C142C4")]
			public void AssignNewValuableNodes_NoCast(PlayerControllerB playerScript)
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$DBC100433FB32BFD83416BE321C142C4")]
			public void AttemptScanValuableNode(ScanNodeProperties node, PlayerControllerB playerScript)
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$DBC100433FB32BFD83416BE321C142C4")]
			public bool MeetsScanValuableNodeRequirements(ScanNodeProperties node, PlayerControllerB playerScript)
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$DBC100433FB32BFD83416BE321C142C4")]
			public void DetectValuableScrap_performed(CallbackContext context)
			{
				throw new NotSupportedException();
			}
		}

		public static float detectorPingingScan;

		public static float replacePingingScanWithValuableScrapTimer;

		public static void AssignNewValuableNodes_NoCast(this HUDManager self, PlayerControllerB playerScript)
		{
			ScanNodeProperties[] array = Object.FindObjectsOfType<ScanNodeProperties>();
			self.nodesOnScreen.Clear();
			self.scannedScrapNum = 0;
			ScanNodeProperties[] array2 = array;
			foreach (ScanNodeProperties node in array2)
			{
				self.AttemptScanValuableNode(node, playerScript);
				if (self.nodesOnScreen.Count >= self.scanElements.Length)
				{
					break;
				}
			}
		}

		public static void AttemptScanValuableNode(this HUDManager self, ScanNodeProperties node, PlayerControllerB playerScript)
		{
			if (self.MeetsScanValuableNodeRequirements(node, playerScript))
			{
				if (node.nodeType == 2)
				{
					self.scannedScrapNum++;
				}
				if (!self.nodesOnScreen.Contains(node))
				{
					self.nodesOnScreen.Add(node);
				}
				if (self.playerPingingScan >= 0f)
				{
					self.AssignNodeToUIElement(node);
				}
				node.AddDistanceHint(playerScript);
			}
		}

		public static bool MeetsScanValuableNodeRequirements(this HUDManager self, ScanNodeProperties node, PlayerControllerB playerScript)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0084: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)node == (Object)null)
			{
				return false;
			}
			if (node.nodeType != 2)
			{
				return false;
			}
			if (!Plugin.Config.TargetValues.Contains(node.scrapValue))
			{
				return false;
			}
			GrabbableObject componentInParent = ((Component)node).GetComponentInParent<GrabbableObject>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				return false;
			}
			if ((Object)(object)componentInParent.playerHeldBy == (Object)(object)playerScript)
			{
				return false;
			}
			Camera gameplayCamera = playerScript.gameplayCamera;
			Vector3 val = gameplayCamera.WorldToViewportPoint(((Component)componentInParent).transform.position);
			if (val.x < 0f || val.x > 1f || val.y < 0f || val.y > 1f || val.z < 0f)
			{
				return false;
			}
			return true;
		}

		public static void DetectValuableScrap_performed(this HUDManager self, CallbackContext context)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			HUDManager instance = HUDManager.Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				instance.PingScan_performed(context);
				replacePingingScanWithValuableScrapTimer = 5f;
			}
		}
	}
	internal static class ScanNodePropertiesExtensions
	{
		[SpecialName]
		public sealed class <G>$9B07504E30D3AC2D0B45AEE537383467
		{
			[SpecialName]
			public static class <M>$32EA96B722A95F78847ED5BAF3703422
			{
			}

			[ExtensionMarker("<M>$32EA96B722A95F78847ED5BAF3703422")]
			public void AddDistanceHint(PlayerControllerB playerScript)
			{
				throw new NotSupportedException();
			}

			[ExtensionMarker("<M>$32EA96B722A95F78847ED5BAF3703422")]
			public void ClearDistanceHint()
			{
				throw new NotSupportedException();
			}
		}

		public static void AddDistanceHint(this ScanNodeProperties self, PlayerControllerB playerScript)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			self.ClearDistanceHint();
			GrabbableObject componentInParent = ((Component)self).GetComponentInParent<GrabbableObject>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				float num = Vector3.Distance(((Component)playerScript).transform.position, ((Component)componentInParent).transform.position);
				float num2 = Mathf.Round(num * 10f) / 10f;
				self.subText += $"\n(distance: {num2:F1})";
			}
		}

		public static void ClearDistanceHint(this ScanNodeProperties self)
		{
			int num = self.subText.IndexOf("\n(distance: ");
			if (num != -1)
			{
				self.subText = self.subText.Substring(0, num);
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal static class RoundManagerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("SyncScrapValuesClientRpc")]
		private static void SpawnScrapInLevelPrefixPatch(RoundManager __instance, NetworkObjectReference[] spawnedScrap, int[] allScrapValue, out __RpcExecStage __state)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected I4, but got Unknown
			__state = (__RpcExecStage)(int)((NetworkBehaviour)__instance).__rpc_exec_stage;
		}

		[HarmonyPostfix]
		[HarmonyPatch("SyncScrapValuesClientRpc")]
		private static void SpawnScrapInLevelPostfixPatch(RoundManager __instance, NetworkObjectReference[] spawnedScrap, int[] allScrapValue, __RpcExecStage __state)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			if ((int)__state != 1)
			{
				return;
			}
			List<SpawnedScrapItem> list = new List<SpawnedScrapItem>();
			LethalDunGenUtils.TilesAndBounds tilesAndBounds = LethalDunGenUtils.FindTilesAndBounds();
			NetworkObject val = default(NetworkObject);
			GrabbableObject val2 = default(GrabbableObject);
			for (int i = 0; i < spawnedScrap.Length; i++)
			{
				if (((NetworkObjectReference)(ref spawnedScrap[i])).TryGet(ref val, (NetworkManager)null) && ((Component)val).TryGetComponent<GrabbableObject>(ref val2) && Plugin.Config.TargetValues.Contains(val2.scrapValue))
				{
					Tile self = tilesAndBounds.FindTileContaining(val2);
					string tileName = self.PrettyName();
					SpawnedScrapItem item = new SpawnedScrapItem(val2, tileName);
					list.Add(item);
				}
			}
			NotificationManager.Report(list.ToArray());
		}
	}
	[BepInPlugin("Ratijas.ScrapValueDetector67", "ScrapValueDetector67", "6.7.67")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static ScrapValueDetectorInputActions InputActionsInstance;

		private static Harmony Harmony;

		internal static Config Config { get; private set; }

		private void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			InputActionsInstance = new ScrapValueDetectorInputActions();
			Config = new Config(((BaseUnityPlugin)this).Config);
			Harmony = new Harmony("ScrapValueDetector67");
			Harmony.PatchAll();
		}
	}
	internal static class StringExtensions
	{
		public static string PadMiddle(this string str, int totalWidth)
		{
			return str.PadLeft(totalWidth / 2).PadRight(totalWidth);
		}

		public static string Repeat(this char chatToRepeat, int repeat)
		{
			return new string(chatToRepeat, repeat);
		}

		public static string Repeat(this string stringToRepeat, int repeat)
		{
			StringBuilder stringBuilder = new StringBuilder(repeat * stringToRepeat.Length);
			for (int i = 0; i < repeat; i++)
			{
				stringBuilder.Append(stringToRepeat);
			}
			return stringBuilder.ToString();
		}

		public static string[] SplitLines(this string str)
		{
			return str.Split('\n');
		}

		public static string[] WrapLines(this string str, int maxWidth)
		{
			List<string> list = new List<string>((int)Math.Ceiling((float)str.Length / (float)maxWidth));
			ReadOnlySpan<char> span = str.AsSpan();
			while (span.Length > maxWidth)
			{
				int num = span.Slice(0, maxWidth).LastIndexOf(' ');
				int num2 = ((num == -1) ? maxWidth : Math.Min(num, maxWidth));
				ReadOnlySpan<char> span2 = span.Slice(0, num2);
				int num3 = num2;
				span = span.Slice(num3, span.Length - num3);
				list.Add(span2.Trim().ToString());
			}
			list.Add(span.Trim().ToString());
			return list.ToArray();
		}
	}
	internal static class TileExtensions
	{
		[SpecialName]
		public sealed class <G>$6D6CC2FFC067E3E657D2E9EF47862B9D
		{
			[SpecialName]
			public static class <M>$87131BAECBC5787F7F5BCFCB40AA4315
			{
			}

			[ExtensionMarker("<M>$87131BAECBC5787F7F5BCFCB40AA4315")]
			public string PrettyName()
			{
				throw new NotSupportedException();
			}
		}

		public static string PrettyName(this Tile? self)
		{
			string text = "unknown";
			if ((Object)(object)self != (Object)null)
			{
				text = ((Object)self).name;
				if (text.EndsWith("(Clone)"))
				{
					ReadOnlySpan<char> readOnlySpan = text.AsSpan();
					int length = "(Clone)".Length;
					text = readOnlySpan.Slice(0, readOnlySpan.Length - length).Trim().ToString();
				}
			}
			return text;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Ratijas.ScrapValueDetector67";

		public const string PLUGIN_NAME = "ScrapValueDetector67";

		public const string PLUGIN_VERSION = "6.7.67";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}