Decompiled source of SellMyScrap v1.13.1

com.github.zehsteam.SellMyScrap.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CSync.Lib;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Microsoft.CodeAnalysis;
using ShipInventory;
using ShipInventory.Extensions;
using ShipInventory.Items;
using ShipInventory.Objects;
using Steamworks;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;
using com.github.zehsteam.SellMyScrap.Commands;
using com.github.zehsteam.SellMyScrap.Data;
using com.github.zehsteam.SellMyScrap.Dependencies;
using com.github.zehsteam.SellMyScrap.Dependencies.ShipInventoryProxy;
using com.github.zehsteam.SellMyScrap.Dependencies.ShipInventoryProxy.Patches;
using com.github.zehsteam.SellMyScrap.Dependencies.Vanilla;
using com.github.zehsteam.SellMyScrap.Extensions;
using com.github.zehsteam.SellMyScrap.Helpers;
using com.github.zehsteam.SellMyScrap.Helpers.ScrapMatchAlgorithms;
using com.github.zehsteam.SellMyScrap.MonoBehaviours;
using com.github.zehsteam.SellMyScrap.NetcodePatcher;
using com.github.zehsteam.SellMyScrap.Objects;
using com.github.zehsteam.SellMyScrap.Patches;
using com.github.zehsteam.SellMyScrap.ScrapEaters;
using com.github.zehsteam.TakeyPlush;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("ShipInventoryUpdated")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Zehs")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © 2025 Zehs")]
[assembly: AssemblyDescription("[v40/v72+] Adds a few terminal commands to sell your scrap from the ship. Highly Configurable. Compatible with the ShipInventoryUpdated mod. SellFromTerminal +")]
[assembly: AssemblyFileVersion("1.13.1.0")]
[assembly: AssemblyInformationalVersion("1.13.1+8103f7fb9a5df5009003127952f5dda8a523125e")]
[assembly: AssemblyProduct("SellMyScrap")]
[assembly: AssemblyTitle("com.github.zehsteam.SellMyScrap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.13.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
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 com.github.zehsteam.SellMyScrap
{
	internal static class Assets
	{
		public static GameObject NetworkHandlerPrefab { get; private set; }

		public static GameObject OctolarScrapEaterPrefab { get; private set; }

		public static GameObject TakeyScrapEaterPrefab { get; private set; }

		public static GameObject MaxwellScrapEaterPrefab { get; private set; }

		public static GameObject YippeeScrapEaterPrefab { get; private set; }

		public static GameObject CookieFumoScrapEaterPrefab { get; private set; }

		public static GameObject PsychoScrapEaterPrefab { get; private set; }

		public static GameObject ZombiesScrapEaterPrefab { get; private set; }

		public static GameObject WolfyScrapEaterPrefab { get; private set; }

		public static AudioClip BrainRotIntroSpeechSFX { get; private set; }

		public static void Load()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = "sellmyscrap_assets";
			string text2 = Path.Combine(directoryName, text);
			if (!File.Exists(text2))
			{
				Logger.LogFatal("Failed to load assets. AssetBundle file could not be found at path \"" + text2 + "\". Make sure the \"" + text + "\" file is in the same folder as the mod's DLL file.");
			}
			else
			{
				AssetBundle val = AssetBundle.LoadFromFile(text2);
				if ((Object)(object)val == (Object)null)
				{
					Logger.LogFatal("Failed to load assets. AssetBundle is null.");
				}
				else
				{
					HandleAssetBundleLoaded(val);
				}
			}
		}

		private static void HandleAssetBundleLoaded(AssetBundle assetBundle)
		{
			NetworkHandlerPrefab = LoadAsset<GameObject>("NetworkHandler", assetBundle);
			NetworkHandlerPrefab.AddComponent<PluginNetworkBehaviour>();
			OctolarScrapEaterPrefab = LoadAsset<GameObject>("OctolarScrapEater", assetBundle);
			TakeyScrapEaterPrefab = LoadAsset<GameObject>("TakeyScrapEater", assetBundle);
			MaxwellScrapEaterPrefab = LoadAsset<GameObject>("MaxwellScrapEater", assetBundle);
			YippeeScrapEaterPrefab = LoadAsset<GameObject>("YippeeScrapEater", assetBundle);
			CookieFumoScrapEaterPrefab = LoadAsset<GameObject>("CookieFumoScrapEater", assetBundle);
			PsychoScrapEaterPrefab = LoadAsset<GameObject>("PsychoScrapEater", assetBundle);
			ZombiesScrapEaterPrefab = LoadAsset<GameObject>("ZombiesScrapEater", assetBundle);
			WolfyScrapEaterPrefab = LoadAsset<GameObject>("WolfyScrapEater", assetBundle);
			BrainRotIntroSpeechSFX = LoadAsset<AudioClip>("BrainRotIntroSpeechSFX", assetBundle);
		}

		private static T LoadAsset<T>(string name, AssetBundle assetBundle) where T : Object
		{
			if (string.IsNullOrWhiteSpace(name))
			{
				Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" from AssetBundle. Name is null or whitespace.");
				return default(T);
			}
			if ((Object)(object)assetBundle == (Object)null)
			{
				Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. AssetBundle is null.");
				return default(T);
			}
			T val = assetBundle.LoadAsset<T>(name);
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError("Failed to load asset of type \"" + typeof(T).Name + "\" with name \"" + name + "\" from AssetBundle. No asset found with that type and name.");
				return default(T);
			}
			return val;
		}

		private static bool TryLoadAsset<T>(string name, AssetBundle assetBundle, out T asset) where T : Object
		{
			asset = LoadAsset<T>(name, assetBundle);
			return (Object)(object)asset != (Object)null;
		}
	}
	internal static class ConfigManager
	{
		public static ConfigFile ConfigFile { get; private set; }

		public static ConfigEntry<bool> ExtendedLogging { get; private set; }

		public static SyncedConfigEntry<bool> SellGifts { get; private set; }

		public static SyncedConfigEntry<bool> SellShotguns { get; private set; }

		public static SyncedConfigEntry<bool> SellAmmo { get; private set; }

		public static SyncedConfigEntry<bool> SellKnives { get; private set; }

		public static SyncedConfigEntry<bool> SellPickles { get; private set; }

		public static SyncedConfigEntry<bool> SellScrapWorthZero { get; private set; }

		public static SyncedConfigEntry<bool> OnlySellScrapOnFloor { get; private set; }

		public static SyncedConfigEntry<string> PrioritySellList { get; private set; }

		public static SyncedConfigEntry<string> DontSellList { get; private set; }

		public static SyncedConfigEntry<string> SellList { get; private set; }

		public static string[] PrioritySellListArray
		{
			get
			{
				return com.github.zehsteam.SellMyScrap.Extensions.CollectionExtensions.StringToCollection<string>(PrioritySellList.Value).ToArray();
			}
			set
			{
				PrioritySellList.Value = com.github.zehsteam.SellMyScrap.Extensions.CollectionExtensions.CollectionToString(value);
			}
		}

		public static string[] DontSellListArray
		{
			get
			{
				return com.github.zehsteam.SellMyScrap.Extensions.CollectionExtensions.StringToCollection<string>(DontSellList.Value).ToArray();
			}
			set
			{
				DontSellList.Value = com.github.zehsteam.SellMyScrap.Extensions.CollectionExtensions.CollectionToString(value);
			}
		}

		public static string[] SellListArray
		{
			get
			{
				return com.github.zehsteam.SellMyScrap.Extensions.CollectionExtensions.StringToCollection<string>(SellList.Value).ToArray();
			}
			set
			{
				SellList.Value = com.github.zehsteam.SellMyScrap.Extensions.CollectionExtensions.CollectionToString(value);
			}
		}

		public static ConfigEntry<bool> OverrideWelcomeMessage { get; private set; }

		public static ConfigEntry<bool> OverrideHelpMessage { get; private set; }

		public static ConfigEntry<bool> ShowFoundItems { get; private set; }

		public static ConfigEntry<bool> SortFoundItemsPrice { get; private set; }

		public static ConfigEntry<bool> AlignFoundItemsPrice { get; private set; }

		public static ConfigEntry<bool> SpeakInShip { get; private set; }

		public static ConfigEntry<float> RareVoiceLineChance { get; private set; }

		public static ConfigEntry<bool> ShowQuotaWarning { get; private set; }

		public static ConfigEntry<int> ScrapEaterChance { get; private set; }

		public static ConfigEntry<int> OctolarSpawnWeight { get; private set; }

		public static ConfigEntry<int> TakeySpawnWeight { get; private set; }

		public static ConfigEntry<int> MaxwellSpawnWeight { get; private set; }

		public static ConfigEntry<int> YippeeSpawnWeight { get; private set; }

		public static ConfigEntry<int> CookieFumoSpawnWeight { get; private set; }

		public static ConfigEntry<int> PsychoSpawnWeight { get; private set; }

		public static ConfigEntry<int> ZombiesSpawnWeight { get; private set; }

		public static ConfigEntry<int> WolfySpawnWeight { get; private set; }

		public static void Initialize(ConfigFile configFile)
		{
			ConfigFile = configFile;
			BindConfigs();
		}

		private static void BindConfigs()
		{
			ConfigHelper.SkipAutoGen();
			ExtendedLogging = ConfigHelper.Bind("General", "ExtendedLogging", defaultValue: false, requiresRestart: false, "Enable extended logging.");
			SellGifts = ConfigHelper.BindSynced("Sell", "SellGifts", defaultValue: false, "Do you want to sell Gifts?");
			SellShotguns = ConfigHelper.BindSynced("Sell", "SellShotguns", defaultValue: false, "Do you want to sell Shotguns?");
			SellAmmo = ConfigHelper.BindSynced("Sell", "SellAmmo", defaultValue: false, "Do you want to sell Ammo?");
			SellKnives = ConfigHelper.BindSynced("Sell", "SellKnives", defaultValue: false, "Do you want to sell Kitchen knives?");
			SellPickles = ConfigHelper.BindSynced("Sell", "SellPickles", defaultValue: true, "Do you want to sell Jar of pickles?");
			SellScrapWorthZero = ConfigHelper.BindSynced("Advanced Sell", "SellScrapWorthZero", defaultValue: false, "Do you want to sell scrap worth zero?");
			OnlySellScrapOnFloor = ConfigHelper.BindSynced("Advanced Sell", "OnlySellScrapOnFloor", defaultValue: false, "Do you want to sell scrap that is only on the floor?");
			PrioritySellList = ConfigHelper.BindSynced("Advanced Sell", "PrioritySellList", "Tragedy, Comedy, Whoopie cushion, Easter egg, Clock, Soccer ball", GetPrioritySellListDescription());
			DontSellList = ConfigHelper.BindSynced("Advanced Sell", "DontSellList", "", GetDontSellListDescription());
			SellList = ConfigHelper.BindSynced("Advanced Sell", "SellList", "Whoopie cushion, Easter egg, Tragedy, Comedy", GetSellListDescription());
			OverrideWelcomeMessage = ConfigHelper.Bind("Terminal", "OverrideWelcomeMessage", defaultValue: true, requiresRestart: false, "Overrides the terminal welcome message to add additional info.");
			OverrideHelpMessage = ConfigHelper.Bind("Terminal", "OverrideHelpMessage", defaultValue: true, requiresRestart: false, "Overrides the terminal help message to add additional info.");
			ShowFoundItems = ConfigHelper.Bind("Terminal", "ShowFoundItems", defaultValue: true, requiresRestart: false, "Show found items on the confirmation screen.");
			SortFoundItemsPrice = ConfigHelper.Bind("Terminal", "SortFoundItemsPrice", defaultValue: true, requiresRestart: false, "Sorts found items from most to least expensive.");
			AlignFoundItemsPrice = ConfigHelper.Bind("Terminal", "AlignFoundItemsPrice", defaultValue: true, requiresRestart: false, "Align all prices of found items.");
			SpeakInShip = ConfigHelper.Bind("Misc", "SpeakInShip", defaultValue: true, requiresRestart: false, "The Company will speak inside your ship after selling from the terminal.");
			RareVoiceLineChance = ConfigHelper.Bind("Misc", "RareVoiceLineChance", 5f, requiresRestart: false, "The percent chance the Company will say a rare microphone voice line after selling.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f));
			ShowQuotaWarning = ConfigHelper.Bind("Misc", "ShowQuotaWarning", defaultValue: true, requiresRestart: false, "If enabled, will show a warning when you try to pull the ship's lever when the quota hasn't been fulfilled at the Company building with 0 days left.");
			ScrapEaterChance = ConfigHelper.Bind("Scrap Eater", "ScrapEaterChance", 0, requiresRestart: false, "The percent chance a scrap eater will spawn?!", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
			OctolarSpawnWeight = ConfigHelper.Bind("Scrap Eater", "OctolarSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Octolar will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
			TakeySpawnWeight = ConfigHelper.Bind("Scrap Eater", "TakeySpawnWeight", 1, requiresRestart: false, "The spawn chance weight Takey will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
			MaxwellSpawnWeight = ConfigHelper.Bind("Scrap Eater", "MaxwellSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Maxwell will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
			YippeeSpawnWeight = ConfigHelper.Bind("Scrap Eater", "YippeeSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Yippee will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
			CookieFumoSpawnWeight = ConfigHelper.Bind("Scrap Eater", "CookieFumoSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Cookie Fumo will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
			PsychoSpawnWeight = ConfigHelper.Bind("Scrap Eater", "PsychoSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Psycho will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
			ZombiesSpawnWeight = ConfigHelper.Bind("Scrap Eater", "ZombiesSpawnWeight", 1, requiresRestart: false, "The spawn chance weight Zombies will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
			WolfySpawnWeight = ConfigHelper.Bind("Scrap Eater", "WolfySpawnWeight", 1, requiresRestart: false, "The spawn chance weight Wolfy will spawn?! (scrap eater)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100));
		}

		private static string GetPrioritySellListDescription()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("Array of item names to prioritize when selling.");
			stringBuilder.AppendLine("Each entry should be separated by a comma.");
			stringBuilder.AppendLine("Item names are not case-sensitive but, spaces do matter.");
			return stringBuilder.ToString();
		}

		private static string GetDontSellListDescription()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("Array of item names to not sell.");
			stringBuilder.AppendLine("Each entry should be separated by a comma.");
			stringBuilder.AppendLine("Item names are not case-sensitive but, spaces do matter.");
			return stringBuilder.ToString();
		}

		private static string GetSellListDescription()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("Array of item names to sell when using the `sell list` command.");
			stringBuilder.AppendLine("Each entry should be separated by a comma.");
			stringBuilder.AppendLine("Item names are not case-sensitive but, spaces do matter.");
			return stringBuilder.ToString();
		}
	}
	internal static class Logger
	{
		public static ManualLogSource ManualLogSource { get; private set; }

		public static void Initialize(ManualLogSource manualLogSource)
		{
			ManualLogSource = manualLogSource;
		}

		public static void LogDebug(object data)
		{
			Log((LogLevel)32, data);
		}

		public static void LogInfo(object data, bool extended = false)
		{
			Log((LogLevel)16, data, extended);
		}

		public static void LogWarning(object data, bool extended = false)
		{
			Log((LogLevel)4, data, extended);
		}

		public static void LogError(object data, bool extended = false)
		{
			Log((LogLevel)2, data, extended);
		}

		public static void LogFatal(object data, bool extended = false)
		{
			Log((LogLevel)1, data, extended);
		}

		public static void Log(LogLevel logLevel, object data, bool extended = false)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (!extended || IsExtendedLoggingEnabled())
			{
				ManualLogSource manualLogSource = ManualLogSource;
				if (manualLogSource != null)
				{
					manualLogSource.Log(logLevel, data);
				}
			}
		}

		public static bool IsExtendedLoggingEnabled()
		{
			if (ConfigManager.ExtendedLogging == null)
			{
				return false;
			}
			return ConfigManager.ExtendedLogging.Value;
		}
	}
	[BepInPlugin("com.github.zehsteam.SellMyScrap", "SellMyScrap", "1.13.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("com.github.zehsteam.SellMyScrap");

		internal static Plugin Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			Logger.Initialize(Logger.CreateLogSource("com.github.zehsteam.SellMyScrap"));
			Logger.LogInfo("SellMyScrap has awoken!");
			_harmony.PatchAll(typeof(GameNetworkManagerPatch));
			_harmony.PatchAll(typeof(StartOfRoundPatch));
			_harmony.PatchAll(typeof(TimeOfDayPatch));
			_harmony.PatchAll(typeof(HUDManagerPatch));
			_harmony.PatchAll(typeof(TerminalPatch));
			_harmony.PatchAll(typeof(DepositItemsDeskPatch));
			_harmony.PatchAll(typeof(StartMatchLeverPatch));
			_harmony.PatchAll(typeof(InteractTriggerPatch));
			if (ShipInventoryProxy.Enabled)
			{
				ShipInventoryProxy.PatchAll(_harmony);
			}
			Assets.Load();
			ConfigManager.Initialize(((BaseUnityPlugin)this).Config);
			ScrapEaterManager.Initialize();
			NetcodePatcherAwake();
		}

		private void NetcodePatcherAwake()
		{
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				Type[] types = executingAssembly.GetTypes();
				Type[] array = types;
				foreach (Type type in array)
				{
					MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
					MethodInfo[] array2 = methods;
					foreach (MethodInfo methodInfo in array2)
					{
						try
						{
							object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
							if (customAttributes.Length != 0)
							{
								try
								{
									methodInfo.Invoke(null, null);
								}
								catch (TargetInvocationException ex)
								{
									((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to invoke method " + methodInfo.Name + ": " + ex.Message));
								}
							}
						}
						catch (Exception ex2)
						{
							((BaseUnityPlugin)this).Logger.LogWarning((object)("Error processing method " + methodInfo.Name + " in type " + type.Name + ": " + ex2.Message));
						}
					}
				}
			}
			catch (Exception ex3)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("An error occurred in NetcodePatcherAwake: " + ex3.Message));
			}
		}

		public static void HandleLocalDisconnect()
		{
			CommandManager.OnLocalDisconnect();
			SellManager.CancelSellRequest();
		}

		public static void HandleTerminalQuit()
		{
			CommandManager.OnTerminalQuit();
			SellManager.CancelSellRequest();
		}
	}
	internal static class SellManager
	{
		[CompilerGenerated]
		private sealed class <PerformSellOnServer>d__17 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private int <scrapEaterIndex>5__2;

			private int <scrapEaterVariantIndex>5__3;

			private List<GrabbableObject> <grabbableObjects>5__4;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0220: Unknown result type (might be due to invalid IL or missing references)
				//IL_022a: Expected O, but got Unknown
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_0110: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (ScrapToSell == null || SellRequest == null)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					goto IL_004f;
				case 1:
					<>1__state = -1;
					goto IL_004f;
				case 2:
					<>1__state = -1;
					goto IL_0073;
				case 3:
					<>1__state = -1;
					if (ShipInventoryProxy.SpawnItemsStatus == SpawnItemsStatus.Success)
					{
						<grabbableObjects>5__4.AddRange(ShipInventoryProxy.GetSpawnedGrabbableObjects());
						ShipInventoryProxy.ClearSpawnedGrabbableObjectsCache();
					}
					else
					{
						if (ShipInventoryProxy.SpawnItemsStatus == SpawnItemsStatus.Failed)
						{
							HUDManager.Instance.DisplayTip("SellMyScrap", "Failed to spawn items from ShipInventory!", true, false, "LC_Tip1");
							return false;
						}
						if (ShipInventoryProxy.SpawnItemsStatus == SpawnItemsStatus.Busy)
						{
							HUDManager.Instance.DisplayTip("SellMyScrap", "Failed to spawn items from ShipInventory! Chute is busy.", true, false, "LC_Tip1");
							return false;
						}
					}
					goto IL_0189;
				case 4:
					{
						<>1__state = -1;
						DepositItemsDeskHelper.SellItems_Server();
						ScrapToSell = null;
						return false;
					}
					IL_0189:
					if (!StartOfRound.Instance.shipIsLeaving)
					{
						if (<scrapEaterIndex>5__2 == -1)
						{
							ScrapEaterManager.StartRandomScrapEaterOnServer(<grabbableObjects>5__4, <scrapEaterVariantIndex>5__3);
							return false;
						}
						if (<scrapEaterIndex>5__2 > -1 && ScrapEaterManager.HasScrapEater(<scrapEaterIndex>5__2))
						{
							ScrapEaterManager.StartScrapEaterOnServer(<scrapEaterIndex>5__2, <grabbableObjects>5__4, <scrapEaterVariantIndex>5__3);
							return false;
						}
						if (ScrapEaterManager.CanUseScrapEater())
						{
							ScrapEaterManager.StartRandomScrapEaterOnServer(<grabbableObjects>5__4, <scrapEaterVariantIndex>5__3);
							return false;
						}
					}
					DepositItemsDeskHelper.PlaceItemsOnCounter(<grabbableObjects>5__4);
					PluginNetworkBehaviour.Instance.PlaceItemsOnCounterClientRpc(NetworkUtils.GetNetworkObjectReferences(<grabbableObjects>5__4));
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 4;
					return true;
					IL_004f:
					if (SellRequest.ConfirmationStatus != ConfirmationStatus.Confirmed)
					{
						<>2__current = null;
						<>1__state = 2;
						return true;
					}
					goto IL_0073;
					IL_0073:
					if ((Object)(object)DepositItemsDeskHelper.Instance == (Object)null)
					{
						Logger.LogError("Could not find depositItemsDesk. Are you landed at The Company building?");
						return false;
					}
					<scrapEaterIndex>5__2 = SellRequest.ScrapEaterIndex;
					<scrapEaterVariantIndex>5__3 = SellRequest.ScrapEaterVariantIndex;
					<grabbableObjects>5__4 = ScrapToSell.GrabbableObjects;
					if (ShipInventoryProxy.Enabled && ScrapToSell.ShipInventoryItems.Length != 0)
					{
						ShipInventoryProxy.SpawnItemsOnServer(ScrapToSell.ShipInventoryItems);
						<>2__current = (object)new WaitUntil((Func<bool>)(() => !ShipInventoryProxy.IsSpawning));
						<>1__state = 3;
						return true;
					}
					goto IL_0189;
				}
			}

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

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

		public static ScrapToSell ScrapToSell { get; private set; }

		public static SellRequest SellRequest { get; private set; }

		public static ScrapToSell GetScrapToSell(SellCommandRequest sellRequest)
		{
			ScrapToSell = ScrapHelper.GetScrapToSell(sellRequest);
			return ScrapToSell;
		}

		public static ScrapToSell GetScrapToSell(string[] sellList, bool onlyUseShipInventory = false)
		{
			ScrapToSell = ScrapHelper.GetScrapToSell(sellList);
			return ScrapToSell;
		}

		public static ScrapToSell SetScrapToSell(List<ItemData> items)
		{
			ScrapToSell = new ScrapToSell(items);
			return ScrapToSell;
		}

		public static void CreateSellRequest(SellType sellType, int value, int requestedValue, ConfirmationStatus confirmationType, int scrapEaterIndex = -2, int scrapEaterVariantIndex = -1)
		{
			SellRequest = new SellRequest(sellType, value, requestedValue, confirmationType, scrapEaterIndex, scrapEaterVariantIndex);
			string text = $"Created sell request. {ScrapToSell.ItemCount} items for ${value}.";
			if (scrapEaterIndex >= 0)
			{
				text += $" (ScrapEaterIndex: {scrapEaterIndex}, ScrapEaterVariantIndex: {scrapEaterVariantIndex})";
			}
			Logger.LogInfo(text);
		}

		public static void ConfirmSellRequest()
		{
			if (ScrapToSell != null && SellRequest != null)
			{
				SellRequest.ConfirmationStatus = ConfirmationStatus.Confirmed;
				Logger.LogInfo($"Attempting to sell {ScrapToSell.ItemCount} items for ${ScrapToSell.TotalScrapValue}.");
				if (NetworkUtils.IsServer)
				{
					ConfirmSellRequestOnServer();
				}
				else
				{
					ConfirmSellRequestOnClient();
				}
				SellRequest = null;
			}
		}

		private static void ConfirmSellRequestOnServer()
		{
			((MonoBehaviour)StartOfRound.Instance).StartCoroutine(PerformSellOnServer());
		}

		private static void ConfirmSellRequestOnClient()
		{
			//IL_0021: 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)
			PluginNetworkBehaviour.Instance.PerformSellServerRpc(ScrapToSell, SellRequest.SellType, SellRequest.ScrapEaterIndex);
		}

		public static void CancelSellRequest()
		{
			SellRequest = null;
			ScrapToSell = null;
		}

		public static void PerformSellOnServerFromClient(ScrapToSell scrapToSell, SellType sellType, int scrapEaterIndex = -2, int scrapEaterVariantIndex = -1)
		{
			ScrapToSell = scrapToSell;
			CreateSellRequest(sellType, ScrapToSell.TotalScrapValue, ScrapToSell.TotalScrapValue, ConfirmationStatus.AwaitingConfirmation, scrapEaterIndex, scrapEaterVariantIndex);
			ConfirmSellRequest();
		}

		[IteratorStateMachine(typeof(<PerformSellOnServer>d__17))]
		public static IEnumerator PerformSellOnServer()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PerformSellOnServer>d__17(0);
		}
	}
	internal static class Utils
	{
		public static string GetPluginPersistentDataPath()
		{
			return Path.Combine(Application.persistentDataPath, "SellMyScrap");
		}

		public static ConfigFile CreateConfigFile(BaseUnityPlugin plugin, string path, string name = null, bool saveOnInit = false)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			BepInPlugin metadata = MetadataHelper.GetMetadata((object)plugin);
			if (name == null)
			{
				name = metadata.GUID;
			}
			name += ".cfg";
			return new ConfigFile(Path.Combine(path, name), saveOnInit, metadata);
		}

		public static ConfigFile CreateLocalConfigFile(BaseUnityPlugin plugin, string name = null, bool saveOnInit = false)
		{
			return CreateConfigFile(plugin, Paths.ConfigPath, name, saveOnInit);
		}

		public static ConfigFile CreateGlobalConfigFile(BaseUnityPlugin plugin, string name = null, bool saveOnInit = false)
		{
			string pluginPersistentDataPath = GetPluginPersistentDataPath();
			if (name == null)
			{
				name = "global";
			}
			return CreateConfigFile(plugin, pluginPersistentDataPath, name, saveOnInit);
		}

		public static bool RandomPercent(float percent)
		{
			if (percent <= 0f)
			{
				return false;
			}
			if (percent >= 100f)
			{
				return true;
			}
			return Random.value * 100f <= percent;
		}

		public static bool ArrayContains(string[] array, string value, bool matchCase = false)
		{
			StringComparison comparisonType = ((!matchCase) ? StringComparison.OrdinalIgnoreCase : StringComparison.CurrentCulture);
			foreach (string text in array)
			{
				if (text.Equals(value, comparisonType))
				{
					return true;
				}
			}
			return false;
		}

		public static int GetOvertimeBonus(int value)
		{
			int profitQuota = TimeOfDay.Instance.profitQuota;
			int num = TimeOfDay.Instance.quotaFulfilled + value;
			if (num <= profitQuota)
			{
				return 0;
			}
			int num2 = num - profitQuota;
			int num3 = num2 / 5 + 15 * TimeOfDayPatch.GetDaysUntilDeadline();
			return Mathf.Max(num3, 0);
		}

		public static void CreateExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, int damage = 80, float minDamageRange = 0f, float maxDamageRange = 6.4f, int enemyHitForce = 6, CauseOfDeath causeOfDeath = 3, PlayerControllerB attacker = null)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_00cd: 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_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			Transform val = null;
			if ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer.transform != (Object)null)
			{
				val = RoundManager.Instance.mapPropsContainer.transform;
			}
			if (spawnExplosionEffect)
			{
				Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, explosionPosition, Quaternion.Euler(-90f, 0f, 0f), val).SetActive(true);
			}
			float num = Vector3.Distance(((Component)PlayerUtils.GetLocalPlayerScript()).transform.position, explosionPosition);
			if (num < 14f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			}
			else if (num < 25f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
			Collider[] array = Physics.OverlapSphere(explosionPosition, maxDamageRange, 2621448, (QueryTriggerInteraction)2);
			PlayerControllerB val2 = null;
			Rigidbody val3 = default(Rigidbody);
			for (int i = 0; i < array.Length; i++)
			{
				float num2 = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position);
				if (num2 > 4f && Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1))
				{
					continue;
				}
				Vector3 hitDirection;
				if (((Component)array[i]).gameObject.layer == 3)
				{
					val2 = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>();
					if ((Object)(object)val2 != (Object)null && ((NetworkBehaviour)val2).IsOwner)
					{
						float num3 = 1f - Mathf.Clamp01((num2 - minDamageRange) / (maxDamageRange - minDamageRange));
						hitDirection = ((Component)val2).transform.position - explosionPosition;
						Vector3 normalized = ((Vector3)(ref hitDirection)).normalized;
						if (((Component)val2).TryGetComponent<Rigidbody>(ref val3))
						{
							val3.AddForce(normalized * 500f);
						}
						Vector3 val4 = Vector3.Normalize((((Component)val2).transform.position + Vector3.up * 0.75f - explosionPosition) * 100f) * 30f;
						val2.DamagePlayer((int)((float)damage * num3), true, true, causeOfDeath, 0, false, val4);
					}
				}
				else if (((Component)array[i]).gameObject.layer == 21)
				{
					Landmine componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<Landmine>();
					if ((Object)(object)componentInChildren != (Object)null && !componentInChildren.hasExploded && num2 < 6f)
					{
						Logger.LogInfo("Setting off other mine", extended: true);
						((MonoBehaviour)componentInChildren).StartCoroutine(componentInChildren.TriggerOtherMineDelayed(componentInChildren));
					}
				}
				else if (((Component)array[i]).gameObject.layer == 19)
				{
					EnemyAICollisionDetect componentInChildren2 = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
					if ((Object)(object)componentInChildren2 != (Object)null && ((NetworkBehaviour)componentInChildren2.mainScript).IsOwner && num2 < 4.5f)
					{
						EnemyAI mainScript = componentInChildren2.mainScript;
						hitDirection = default(Vector3);
						EnemyAIHelper.HitEnemyOnLocalClient(mainScript, enemyHitForce, hitDirection, attacker);
						EnemyAIHelper.HitFromExplosion(componentInChildren2.mainScript, num2);
					}
				}
			}
			int num4 = ~LayerMask.GetMask(new string[1] { "Room" });
			num4 = ~LayerMask.GetMask(new string[1] { "Colliders" });
			array = Physics.OverlapSphere(explosionPosition, 10f, num4);
			Rigidbody val5 = default(Rigidbody);
			for (int j = 0; j < array.Length; j++)
			{
				if (((Component)array[j]).TryGetComponent<Rigidbody>(ref val5))
				{
					val5.AddExplosionForce(70f, explosionPosition, 10f);
				}
			}
		}

		public static int GetRandomIndexFromWeightList(IEnumerable<int> weights)
		{
			if (weights == null)
			{
				throw new ArgumentNullException("weights");
			}
			int num = 0;
			int num2 = 0;
			foreach (int weight in weights)
			{
				if (weight < 0)
				{
					throw new ArgumentException("Weights must be non-negative.");
				}
				num += weight;
			}
			if (num == 0)
			{
				throw new ArgumentException("At least one weight must be greater than zero.");
			}
			int num3 = Random.Range(0, num);
			int num4 = 0;
			num2 = 0;
			foreach (int weight2 in weights)
			{
				num4 += weight2;
				if (num3 < num4)
				{
					return num2;
				}
				num2++;
			}
			return num2 - 1;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.github.zehsteam.SellMyScrap";

		public const string PLUGIN_NAME = "SellMyScrap";

		public const string PLUGIN_VERSION = "1.13.1";
	}
}
namespace com.github.zehsteam.SellMyScrap.ScrapEaters
{
	public class ScrapEater
	{
		public GameObject SpawnPrefab;

		public Func<int> GetSpawnWeight;

		public ScrapEater(GameObject spawnPrefab, Func<int> getSpawnWeight)
		{
			SpawnPrefab = spawnPrefab;
			GetSpawnWeight = getSpawnWeight;
		}
	}
	public static class ScrapEaterManager
	{
		public static List<ScrapEater> ScrapEaters { get; private set; } = new List<ScrapEater>();


		internal static void Initialize()
		{
			ScrapEaters = new List<ScrapEater>(8)
			{
				new ScrapEater(Assets.OctolarScrapEaterPrefab, () => ConfigManager.OctolarSpawnWeight.Value),
				new ScrapEater(Assets.TakeyScrapEaterPrefab, () => ConfigManager.TakeySpawnWeight.Value),
				new ScrapEater(Assets.MaxwellScrapEaterPrefab, () => ConfigManager.MaxwellSpawnWeight.Value),
				new ScrapEater(Assets.YippeeScrapEaterPrefab, () => ConfigManager.YippeeSpawnWeight.Value),
				new ScrapEater(Assets.CookieFumoScrapEaterPrefab, () => ConfigManager.CookieFumoSpawnWeight.Value),
				new ScrapEater(Assets.PsychoScrapEaterPrefab, () => ConfigManager.PsychoSpawnWeight.Value),
				new ScrapEater(Assets.ZombiesScrapEaterPrefab, () => ConfigManager.ZombiesSpawnWeight.Value),
				new ScrapEater(Assets.WolfyScrapEaterPrefab, () => ConfigManager.WolfySpawnWeight.Value)
			};
		}

		internal static bool CanUseScrapEater()
		{
			int value = ConfigManager.ScrapEaterChance.Value;
			return Utils.RandomPercent(value);
		}

		internal static bool HasScrapEater(int index)
		{
			if (ScrapEaters.Count == 0)
			{
				return false;
			}
			if (index < 0 || index > ScrapEaters.Count - 1)
			{
				return false;
			}
			return true;
		}

		public static void AddScrapEater(GameObject spawnPrefab, Func<int> GetSpawnWeight)
		{
			ScrapEaters.Add(new ScrapEater(spawnPrefab, GetSpawnWeight));
		}

		internal static void StartRandomScrapEaterOnServer(List<GrabbableObject> scrap, int variantIndex = -1)
		{
			if (NetworkUtils.IsServer)
			{
				int randomScrapEaterIndex = GetRandomScrapEaterIndex();
				if (randomScrapEaterIndex != -1)
				{
					StartScrapEaterOnServer(randomScrapEaterIndex, scrap, variantIndex);
				}
			}
		}

		internal static void StartScrapEaterOnServer(int index, List<GrabbableObject> scrap, int variantIndex = -1)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkUtils.IsServer)
			{
				GameObject spawnPrefab = ScrapEaters[index].SpawnPrefab;
				GameObject val = Object.Instantiate<GameObject>(spawnPrefab, Vector3.zero, Quaternion.identity);
				NetworkObject component = val.GetComponent<NetworkObject>();
				component.Spawn(true);
				ScrapEaterBehaviour component2 = val.GetComponent<ScrapEaterBehaviour>();
				component2.SetData(scrap, variantIndex);
				Logger.LogInfo($"Spawned scrap eater #{index + 1}");
			}
		}

		private static int GetRandomScrapEaterIndex()
		{
			return Utils.GetRandomIndexFromWeightList(ScrapEaters.Select((ScrapEater x) => x.GetSpawnWeight()).ToList());
		}
	}
}
namespace com.github.zehsteam.SellMyScrap.Patches
{
	[HarmonyPatch(typeof(DepositItemsDesk))]
	internal static class DepositItemsDeskPatch
	{
		public static int ClipIndex = -1;

		public static bool SpeakInShip = false;

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void StartPatch(ref DepositItemsDesk __instance)
		{
			DepositItemsDeskHelper.SetInstance(__instance);
		}

		[HarmonyPatch("SellItemsOnServer")]
		[HarmonyPrefix]
		private static bool SellItemsOnServerPatch(ref DepositItemsDesk __instance)
		{
			if (__instance.itemsOnCounter.Count == 0)
			{
				return false;
			}
			if (NetworkUtils.IsServer)
			{
				SetMicrophoneSpeakData_Server(SpeakInShip);
			}
			return true;
		}

		[HarmonyPatch("MicrophoneSpeak")]
		[HarmonyPrefix]
		private static bool MicrophoneSpeakPatch(ref DepositItemsDesk __instance)
		{
			AudioClip[] microphoneAudios = __instance.microphoneAudios;
			AudioClip[] rareMicrophoneAudios = __instance.rareMicrophoneAudios;
			List<AudioClip> list = new List<AudioClip>(microphoneAudios.Length + rareMicrophoneAudios.Length);
			list.AddRange(microphoneAudios);
			list.AddRange(rareMicrophoneAudios);
			List<AudioClip> list2 = list;
			if (ClipIndex == -1)
			{
				ClipIndex = GetRandomAudioClipIndex();
			}
			AudioClip val = list2[ClipIndex];
			__instance.speakerAudio.PlayOneShot(val, 1f);
			if (SpeakInShip && ConfigManager.SpeakInShip.Value)
			{
				StartOfRound.Instance.speakerAudioSource.PlayOneShot(val, 1f);
			}
			SpeakInShip = false;
			ClipIndex = -1;
			return false;
		}

		private static int GetRandomAudioClipIndex()
		{
			if (Utils.RandomPercent(ConfigManager.RareVoiceLineChance.Value))
			{
				return Random.Range(0, DepositItemsDeskHelper.Instance.rareMicrophoneAudios.Length) + DepositItemsDeskHelper.Instance.microphoneAudios.Length;
			}
			return Random.Range(0, DepositItemsDeskHelper.Instance.microphoneAudios.Length);
		}

		public static void SetMicrophoneSpeakData_LocalClient(bool speakInShip, int clipIndex)
		{
			SpeakInShip = speakInShip;
			ClipIndex = clipIndex;
		}

		private static void SetMicrophoneSpeakData_Server(bool speakInShip)
		{
			SpeakInShip = speakInShip;
			ClipIndex = GetRandomAudioClipIndex();
			PluginNetworkBehaviour.Instance.SetMicrophoneSpeakDataClientRpc(speakInShip, ClipIndex);
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal static class GameNetworkManagerPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			AddNetworkPrefabs();
		}

		private static void AddNetworkPrefabs()
		{
			AddNetworkPrefab(Assets.NetworkHandlerPrefab);
			foreach (ScrapEater scrapEater in ScrapEaterManager.ScrapEaters)
			{
				AddNetworkPrefab(scrapEater.SpawnPrefab);
			}
		}

		private static void AddNetworkPrefab(GameObject prefab)
		{
			if ((Object)(object)prefab == (Object)null)
			{
				Logger.LogError("Failed to register network prefab. GameObject is null.");
				return;
			}
			NetworkManager.Singleton.AddNetworkPrefab(prefab);
			Logger.LogInfo("Registered \"" + ((Object)prefab).name + "\" network prefab.");
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal static class HUDManagerPatch
	{
		[CompilerGenerated]
		private sealed class <ScrollRewardsListText>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Scrollbar rewardsScrollbar;

			public float duration;

			private float <timer>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<timer>5__2 = 0f;
					rewardsScrollbar.value = 1f;
					break;
				case 2:
					<>1__state = -1;
					<timer>5__2 += Time.deltaTime;
					break;
				}
				if (<timer>5__2 < duration)
				{
					if (<timer>5__2 > duration)
					{
						<timer>5__2 = duration;
					}
					float num = 1f / duration * <timer>5__2;
					rewardsScrollbar.value = 1f - num;
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
				rewardsScrollbar.value = 0f;
				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();
			}
		}

		[HarmonyPatch("DisplayCreditsEarning")]
		[HarmonyPrefix]
		[HarmonyPriority(800)]
		private static bool DisplayCreditsEarningPatch(ref HUDManager __instance, int creditsEarned, GrabbableObject[] objectsSold, int newGroupCredits, ref Coroutine ___scrollRewardTextCoroutine)
		{
			Logger.LogInfo($"Earned ${creditsEarned}; sold {objectsSold.Length} items; new credits amount: ${newGroupCredits}");
			string text = ScrapHelper.GetScrapMessage(objectsSold.ToList());
			int num = text.Split('\n').Length;
			int num2 = ((num < 8) ? (8 - num) : 0);
			for (int i = 0; i < num2; i++)
			{
				text += "\n\t";
			}
			((TMP_Text)__instance.moneyRewardsListText).text = text;
			((TMP_Text)__instance.moneyRewardsTotalText).text = $"TOTAL: ${creditsEarned}";
			__instance.moneyRewardsAnimator.SetTrigger("showRewards");
			__instance.rewardsScrollbar.value = 1f;
			if (num >= 9)
			{
				if (___scrollRewardTextCoroutine != null)
				{
					((MonoBehaviour)__instance).StopCoroutine(___scrollRewardTextCoroutine);
				}
				___scrollRewardTextCoroutine = ((MonoBehaviour)__instance).StartCoroutine(ScrollRewardsListText(__instance.rewardsScrollbar));
			}
			return false;
		}

		[IteratorStateMachine(typeof(<ScrollRewardsListText>d__1))]
		private static IEnumerator ScrollRewardsListText(Scrollbar rewardsScrollbar, float duration = 3f)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ScrollRewardsListText>d__1(0)
			{
				rewardsScrollbar = rewardsScrollbar,
				duration = duration
			};
		}
	}
	[HarmonyPatch(typeof(InteractTrigger))]
	internal static class InteractTriggerPatch
	{
		[HarmonyPatch("StopInteraction")]
		[HarmonyPostfix]
		private static void StopInteractionPatch(ref InteractTrigger __instance)
		{
			if ((Object)(object)StartMatchLeverPatch.InteractTrigger == (Object)(object)__instance)
			{
				StartMatchLeverPatch.DisplayedSellWarning = false;
			}
		}
	}
	[HarmonyPatch(typeof(StartMatchLever))]
	internal static class StartMatchLeverPatch
	{
		public static InteractTrigger InteractTrigger;

		public static bool DisplayedSellWarning;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(ref StartMatchLever __instance)
		{
			InteractTrigger = ((Component)__instance).GetComponent<InteractTrigger>();
			DisplayedSellWarning = false;
		}

		[HarmonyPatch("BeginHoldingInteractOnLever")]
		[HarmonyPostfix]
		private static void BeginHoldingInteractOnLeverPatch(ref StartMatchLever __instance)
		{
			if (TimeOfDay.Instance.daysUntilDeadline > 0 || !ConfigManager.ShowQuotaWarning.Value)
			{
				if (__instance.triggerScript.timeToHold == 4.01f)
				{
					__instance.triggerScript.timeToHold = 0.7f;
				}
			}
			else if (!((Object)(object)DepositItemsDeskHelper.Instance == (Object)null) && StartOfRound.Instance.shipHasLanded)
			{
				if (TimeOfDay.Instance.quotaFulfilled >= TimeOfDay.Instance.profitQuota)
				{
					__instance.triggerScript.timeToHold = 0.7f;
				}
				else if (!DisplayedSellWarning)
				{
					DisplayedSellWarning = true;
					__instance.triggerScript.timeToHold = 4.01f;
					HUDManager.Instance.DisplayTip("HALT!", "You did not sell enough scrap to fulfill the profit quota.", true, false, "LC_Tip1");
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal static class StartOfRoundPatch
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch()
		{
			SpawnNetworkHandler();
		}

		private static void SpawnNetworkHandler()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkUtils.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(Assets.NetworkHandlerPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			RemoveMapPropsContainerForTesting();
		}

		private static void RemoveMapPropsContainerForTesting()
		{
			GameObject val = GameObject.Find("Environment/MapPropsContainerForTesting");
			if (!((Object)(object)val == (Object)null))
			{
				val.SetActive(false);
			}
		}

		[HarmonyPatch("OnClientConnect")]
		[HarmonyPrefix]
		private static void OnClientConnectPatch(ref ulong clientId)
		{
			if (NetworkUtils.IsServer)
			{
				SyncedConfigEntryBase.SendConfigsToClient(clientId);
			}
		}

		[HarmonyPatch("OnLocalDisconnect")]
		[HarmonyPrefix]
		private static void OnLocalDisconnectPatch()
		{
			Plugin.HandleLocalDisconnect();
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal static class TerminalPatch
	{
		private static bool _hasOverrideTerminalNodes;

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void StartPatchPrefix(ref Terminal __instance)
		{
			TerminalHelper.SetInstance(__instance);
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void StartPatchPostfix(ref TerminalNodesList ___terminalNodes)
		{
			OverrideTerminalNodes(___terminalNodes);
		}

		private static void OverrideTerminalNodes(TerminalNodesList terminalNodes)
		{
			if (!_hasOverrideTerminalNodes)
			{
				_hasOverrideTerminalNodes = true;
				if (ConfigManager.OverrideWelcomeMessage.Value)
				{
					OverrideWelcomeTerminalNode(terminalNodes);
				}
				if (ConfigManager.OverrideHelpMessage.Value)
				{
					OverrideHelpTerminalNode(terminalNodes);
				}
			}
		}

		private static void OverrideWelcomeTerminalNode(TerminalNodesList terminalNodes)
		{
			int index = 1;
			string displayText = terminalNodes.specialNodes[index].displayText;
			string text = "Type \"Help\" for a list of commands.";
			string displayText2 = displayText.Replace(text, text + "\n\n[SellMyScrap]\nType \"Sell\" for a list of commands.");
			terminalNodes.specialNodes[index].displayText = displayText2;
		}

		private static void OverrideHelpTerminalNode(TerminalNodesList terminalNodes)
		{
			int index = 13;
			string displayText = terminalNodes.specialNodes[index].displayText;
			string text = ">OTHER\nTo see the list of other commands";
			string displayText2 = displayText.Replace(text, text + ".\n\n>SELL\nTo see the list of SellMyScrap commands.");
			terminalNodes.specialNodes[index].displayText = displayText2;
		}

		[HarmonyPatch("QuitTerminal")]
		[HarmonyPostfix]
		private static void QuitTerminalPatch()
		{
			Plugin.HandleTerminalQuit();
		}

		[HarmonyPatch("ParsePlayerSentence")]
		[HarmonyPrefix]
		[HarmonyPriority(800)]
		private static bool ParsePlayerSentencePatch(ref Terminal __instance, ref TerminalNode __result)
		{
			string[] array = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded).Split(' ', StringSplitOptions.RemoveEmptyEntries);
			if (CommandManager.TryExecuteCommand(array, out var terminalNode))
			{
				if ((Object)(object)terminalNode == (Object)null)
				{
					__result = TerminalHelper.CreateTerminalNode("TerminalNode is null!\n\n");
					return false;
				}
				__result = terminalNode;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	internal static class TimeOfDayPatch
	{
		private static int _daysUntilDeadline = 3;

		private static int _preDaysUntilDeadline = 3;

		private static int _postDaysUntilDeadline = 3;

		[HarmonyPatch("SetBuyingRateForDay")]
		[HarmonyPrefix]
		private static void SetBuyingRateForDayPatchPrefix()
		{
			_preDaysUntilDeadline = TimeOfDay.Instance.daysUntilDeadline;
		}

		[HarmonyPatch("SetBuyingRateForDay")]
		[HarmonyPostfix]
		private static void SetBuyingRateForDayPatchPostfix()
		{
			_postDaysUntilDeadline = TimeOfDay.Instance.daysUntilDeadline;
			SetDaysUntilDeadline();
		}

		private static void SetDaysUntilDeadline()
		{
			if (_postDaysUntilDeadline == 0)
			{
				if (_preDaysUntilDeadline == 0)
				{
					_daysUntilDeadline = 0;
				}
				else
				{
					_daysUntilDeadline = -1;
				}
			}
			else
			{
				_daysUntilDeadline = _postDaysUntilDeadline;
			}
		}

		public static int GetDaysUntilDeadline()
		{
			return _daysUntilDeadline;
		}
	}
}
namespace com.github.zehsteam.SellMyScrap.Data
{
	public enum SellType
	{
		None,
		Amount,
		Quota,
		All,
		Item,
		List
	}
	public enum ConfirmationStatus
	{
		None,
		AwaitingConfirmation,
		Confirmed
	}
	public class SellRequest
	{
		public SellType SellType;

		public int ScrapValue;

		public int RequestedScrapValue;

		public ConfirmationStatus ConfirmationStatus;

		public int ScrapEaterIndex;

		public int ScrapEaterVariantIndex;

		public int RealScrapValue => ScrapHelper.GetRealValue(ScrapValue);

		public SellRequest(SellType sellType, int scrapValue, int requestedScrapValue, ConfirmationStatus confirmationStatus, int scrapEaterIndex = -2, int scrapEaterVariantIndex = -1)
		{
			SellType = sellType;
			ScrapValue = scrapValue;
			RequestedScrapValue = requestedScrapValue;
			ConfirmationStatus = confirmationStatus;
			ScrapEaterIndex = scrapEaterIndex;
			ScrapEaterVariantIndex = scrapEaterVariantIndex;
		}
	}
}
namespace com.github.zehsteam.SellMyScrap.Objects
{
	public enum ItemLocation
	{
		Ship,
		Vehicle,
		ShipInventory
	}
	public class ItemData
	{
		public GrabbableObject GrabbableObject { get; set; }

		public ShipInventoryItemData ShipInventoryItemData { get; set; }

		public ItemLocation ItemLocation { get; set; }

		public string ItemName => GetItemName();

		public int ScrapValue => GetScrapValue();

		public ItemData(GrabbableObject grabbableObject, ItemLocation itemLocation)
		{
			GrabbableObject = grabbableObject;
			ItemLocation = itemLocation;
		}

		public ItemData(ShipInventoryItemData shipInventoryItemData, ItemLocation itemLocation)
		{
			ShipInventoryItemData = shipInventoryItemData;
			ItemLocation = itemLocation;
		}

		private string GetItemName()
		{
			if ((Object)(object)GrabbableObject != (Object)null)
			{
				return GrabbableObject.itemProperties.itemName;
			}
			if (ShipInventoryProxy.Enabled && ShipInventoryItemData != null)
			{
				return ShipInventoryItemData.GetItemName();
			}
			return string.Empty;
		}

		private int GetScrapValue()
		{
			if ((Object)(object)GrabbableObject != (Object)null)
			{
				return GrabbableObject.scrapValue;
			}
			if (ShipInventoryProxy.Enabled && ShipInventoryItemData != null)
			{
				return ShipInventoryItemData.ScrapValue;
			}
			return 0;
		}
	}
	[Serializable]
	public class ScrapToSell : INetworkSerializable
	{
		public NetworkObjectReference[] ShipNetworkObjectReferences = Array.Empty<NetworkObjectReference>();

		public NetworkObjectReference[] VehicleNetworkObjectReferences = Array.Empty<NetworkObjectReference>();

		public ShipInventoryItemData[] ShipInventoryItems = Array.Empty<ShipInventoryItemData>();

		private List<ItemData> _itemDataList = new List<ItemData>();

		private bool _setItemDataList;

		private List<GrabbableObject> _shipGrabbableObjects = new List<GrabbableObject>();

		private bool _setShipGrabbableObjects;

		private List<GrabbableObject> _vehicleGrabbableObjects = new List<GrabbableObject>();

		private bool _setVehicleGrabbableObjects;

		public List<ItemData> ItemDataList
		{
			get
			{
				if (!_setItemDataList)
				{
					SetItemDataList();
				}
				return _itemDataList;
			}
			set
			{
				_itemDataList = value;
				_setItemDataList = true;
			}
		}

		public List<GrabbableObject> GrabbableObjects
		{
			get
			{
				List<GrabbableObject> shipGrabbableObjects = ShipGrabbableObjects;
				List<GrabbableObject> vehicleGrabbableObjects = VehicleGrabbableObjects;
				List<GrabbableObject> list = new List<GrabbableObject>(shipGrabbableObjects.Count + vehicleGrabbableObjects.Count);
				list.AddRange(shipGrabbableObjects);
				list.AddRange(vehicleGrabbableObjects);
				return list;
			}
		}

		public List<GrabbableObject> ShipGrabbableObjects
		{
			get
			{
				if (!_setShipGrabbableObjects)
				{
					SetShipGrabbableObjects();
				}
				return _shipGrabbableObjects;
			}
			set
			{
				_shipGrabbableObjects = value;
				_setShipGrabbableObjects = true;
			}
		}

		public List<GrabbableObject> VehicleGrabbableObjects
		{
			get
			{
				if (!_setVehicleGrabbableObjects)
				{
					SetVehicleGrabbableObjects();
				}
				return _vehicleGrabbableObjects;
			}
			set
			{
				_vehicleGrabbableObjects = value;
				_setVehicleGrabbableObjects = true;
			}
		}

		public int ItemCount => GetItemCount();

		public int TotalScrapValue => GetTotalScrapValue();

		public int RealTotalScrapValue => ScrapHelper.GetRealValue(TotalScrapValue);

		public ScrapToSell()
		{
		}

		public ScrapToSell(List<ItemData> items)
		{
			ItemDataList = items;
			ShipGrabbableObjects = (from x in items
				where (Object)(object)x.GrabbableObject != (Object)null && x.ItemLocation == ItemLocation.Ship
				select x.GrabbableObject).ToList();
			VehicleGrabbableObjects = (from x in items
				where (Object)(object)x.GrabbableObject != (Object)null && x.ItemLocation == ItemLocation.Vehicle
				select x.GrabbableObject).ToList();
			ShipInventoryItems = (from x in items
				where x.ShipInventoryItemData != null
				select x.ShipInventoryItemData).ToArray();
			SetShipNetworkObjectReferences();
			SetVehicleNetworkObjectReferences();
		}

		private void SetShipNetworkObjectReferences()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			List<NetworkObjectReference> list = new List<NetworkObjectReference>();
			NetworkObject val = default(NetworkObject);
			foreach (GrabbableObject shipGrabbableObject in ShipGrabbableObjects)
			{
				if (((Component)shipGrabbableObject).TryGetComponent<NetworkObject>(ref val))
				{
					list.Add(NetworkObjectReference.op_Implicit(val));
				}
			}
			ShipNetworkObjectReferences = list.ToArray();
		}

		private void SetVehicleNetworkObjectReferences()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			List<NetworkObjectReference> list = new List<NetworkObjectReference>();
			NetworkObject val = default(NetworkObject);
			foreach (GrabbableObject vehicleGrabbableObject in VehicleGrabbableObjects)
			{
				if (((Component)vehicleGrabbableObject).TryGetComponent<NetworkObject>(ref val))
				{
					list.Add(NetworkObjectReference.op_Implicit(val));
				}
			}
			VehicleNetworkObjectReferences = list.ToArray();
		}

		private void SetItemDataList()
		{
			ItemDataList = ScrapHelper.GetItemDataList(ShipGrabbableObjects, VehicleGrabbableObjects, ShipInventoryItems);
		}

		private void SetShipGrabbableObjects()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			ShipGrabbableObjects = new List<GrabbableObject>();
			NetworkObjectReference[] shipNetworkObjectReferences = ShipNetworkObjectReferences;
			NetworkObject val2 = default(NetworkObject);
			GrabbableObject item = default(GrabbableObject);
			for (int i = 0; i < shipNetworkObjectReferences.Length; i++)
			{
				NetworkObjectReference val = shipNetworkObjectReferences[i];
				if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null) && ((Component)val2).TryGetComponent<GrabbableObject>(ref item))
				{
					ShipGrabbableObjects.Add(item);
				}
			}
		}

		private void SetVehicleGrabbableObjects()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			VehicleGrabbableObjects = new List<GrabbableObject>();
			NetworkObjectReference[] vehicleNetworkObjectReferences = VehicleNetworkObjectReferences;
			NetworkObject val2 = default(NetworkObject);
			GrabbableObject item = default(GrabbableObject);
			for (int i = 0; i < vehicleNetworkObjectReferences.Length; i++)
			{
				NetworkObjectReference val = vehicleNetworkObjectReferences[i];
				if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null) && ((Component)val2).TryGetComponent<GrabbableObject>(ref item))
				{
					VehicleGrabbableObjects.Add(item);
				}
			}
		}

		private int GetItemCount()
		{
			return GrabbableObjects.Count + ShipInventoryItems.Length;
		}

		private int GetTotalScrapValue()
		{
			return GrabbableObjects.Sum((GrabbableObject x) => x.scrapValue) + ShipInventoryItems.Sum((ShipInventoryItemData x) => x.ScrapValue);
		}

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			((BufferSerializer<NetworkObjectReference>*)(&serializer))->SerializeValue<NetworkObjectReference>(ref ShipNetworkObjectReferences, default(ForNetworkSerializable));
			((BufferSerializer<NetworkObjectReference>*)(&serializer))->SerializeValue<NetworkObjectReference>(ref VehicleNetworkObjectReferences, default(ForNetworkSerializable));
			((BufferSerializer<ShipInventoryItemData>*)(&serializer))->SerializeValue<ShipInventoryItemData>(ref ShipInventoryItems, default(ForNetworkSerializable));
		}
	}
	public class SellCommandRequest
	{
		[CompilerGenerated]
		private int <value>P;

		public int Value => <value>P;

		public bool OnlyAllowedScrap { get; set; }

		public bool WithOvertimeBonus { get; set; }

		public bool OnlyUseShipInventory { get; set; }

		public BaseScrapMatchAlgorithm ScrapMatchAlgorithm { get; set; }

		public int TargetValue
		{
			get
			{
				if (!WithOvertimeBonus)
				{
					return GetSellValue(Value);
				}
				return GetSellValueWithOvertime();
			}
		}

		public SellCommandRequest(int value)
		{
			<value>P = value;
			OnlyAllowedScrap = true;
			ScrapMatchAlgorithm = BaseScrapMatchAlgorithm.Default;
			base..ctor();
		}

		public ScrapToSell GetScrapToSell(List<ItemData> items)
		{
			if (Value == int.MaxValue)
			{
				return new ScrapToSell(items);
			}
			return new ScrapToSell(ScrapMatchAlgorithm.FindMatch(items, TargetValue, ConfigManager.PrioritySellListArray));
		}

		private int GetSellValue(int value)
		{
			if (value == int.MaxValue)
			{
				return value;
			}
			return Mathf.CeilToInt((float)value / StartOfRound.Instance.companyBuyingRate);
		}

		private int GetSellValueWithOvertime()
		{
			int profitQuota = TimeOfDay.Instance.profitQuota;
			int quotaFulfilled = TimeOfDay.Instance.quotaFulfilled;
			int num = quotaFulfilled + Value - profitQuota;
			if (num <= 0)
			{
				return GetSellValue(Value);
			}
			int value = Value;
			int num2 = Mathf.Max(profitQuota - quotaFulfilled, 0);
			value -= (TimeOfDayPatch.GetDaysUntilDeadline() + 1) * 15;
			int value2 = Mathf.CeilToInt((float)(5 * value + num2 + 75) / 6f);
			return GetSellValue(value2);
		}
	}
	public class SyncedConfigEntry<T> : SyncedConfigEntryBase
	{
		private ConfigEntry<T> _configEntry;

		private T _serverValue;

		public T Value
		{
			get
			{
				return GetValue();
			}
			set
			{
				SetValue(value);
			}
		}

		public T DefaultValue => (T)((ConfigEntryBase)_configEntry).DefaultValue;

		public override string Section => ((ConfigEntryBase)_configEntry).Definition.Section;

		public override string Key => ((ConfigEntryBase)_configEntry).Definition.Key;

		public event Action<T> SettingChanged;

		public SyncedConfigEntry(string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues = null, ConfigFile configFile = null)
		{
			SyncedConfigEntryBase.AddInstance(this);
			_configEntry = ConfigHelper.Bind(section, key, defaultValue, requiresRestart: false, description, acceptableValues, null, configFile);
			_configEntry.SettingChanged += SettingChangedInternal;
		}

		public T GetValue()
		{
			if (NetworkUtils.IsConnected && !NetworkUtils.IsServer)
			{
				return _serverValue;
			}
			return _configEntry.Value;
		}

		public void SetValue(T value)
		{
			if (!NetworkUtils.IsConnected || NetworkUtils.IsServer)
			{
				_configEntry.Value = value;
			}
		}

		public void ResetToDefault()
		{
			if (!NetworkUtils.IsConnected || NetworkUtils.IsServer)
			{
				_configEntry.Value = DefaultValue;
			}
		}

		private void SettingChangedInternal(object sender, EventArgs e)
		{
			if (NetworkUtils.IsConnected && NetworkUtils.IsServer)
			{
				this.SettingChanged?.Invoke(Value);
				SendConfigToClients();
			}
		}

		private void SendConfigToClients()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkUtils.IsConnected && NetworkUtils.IsServer)
			{
				PluginNetworkBehaviour.Instance?.SetSyncedConfigValueClientRpc(Section, Key, Value.ToString());
			}
		}

		public override void SendConfigToClient(ulong clientId)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkUtils.IsConnected && NetworkUtils.IsServer)
			{
				ClientRpcParams val = default(ClientRpcParams);
				val.Send = new ClientRpcSendParams
				{
					TargetClientIds = new <>z__ReadOnlySingleElementList<ulong>(clientId)
				};
				ClientRpcParams clientRpcParams = val;
				PluginNetworkBehaviour.Instance?.SetSyncedConfigValueClientRpc(Section, Key, Value.ToString(), clientRpcParams);
			}
		}

		public override void SetValueFromServer(string value)
		{
			if (NetworkUtils.IsConnected && !NetworkUtils.IsServer)
			{
				if (!value.TryConvertTo<T>(out var result))
				{
					throw new InvalidOperationException($"Failed to parse value: \"{value}\" for type {typeof(T)}");
				}
				_serverValue = result;
				Logger.LogInfo("Set synced config entry value from server. (Section: \"" + Section + "\", Key: \"" + Key + "\", Value: \"" + value + "\")", extended: true);
				this.SettingChanged?.Invoke(result);
			}
		}
	}
	public abstract class SyncedConfigEntryBase
	{
		private static readonly object _instancesLock = new object();

		public static List<SyncedConfigEntryBase> Instances { get; private set; } = new List<SyncedConfigEntryBase>();


		public abstract string Section { get; }

		public abstract string Key { get; }

		public static void AddInstance(SyncedConfigEntryBase instance)
		{
			lock (_instancesLock)
			{
				Instances.Add(instance);
			}
		}

		public static void RemoveInstance(SyncedConfigEntryBase instance)
		{
			lock (_instancesLock)
			{
				Instances.Remove(instance);
			}
		}

		public abstract void SendConfigToClient(ulong clientId);

		public abstract void SetValueFromServer(string value);

		public static void SendConfigsToClient(ulong clientId)
		{
			if (!NetworkUtils.IsConnected || !NetworkUtils.IsServer || NetworkUtils.IsLocalClientId(clientId))
			{
				return;
			}
			foreach (SyncedConfigEntryBase instance in Instances)
			{
				instance.SendConfigToClient(clientId);
			}
		}

		public static void SetValueFromServer(string section, string key, string value)
		{
			if (NetworkUtils.IsConnected && !NetworkUtils.IsServer)
			{
				SyncedConfigEntryBase syncedConfigEntryBase = Instances.Find((SyncedConfigEntryBase x) => x.Section == section && x.Key == key);
				if (syncedConfigEntryBase == null)
				{
					Logger.LogWarning("No matching synced config entry found for section: \"" + section + "\", key: \"" + key + "\"");
				}
				else
				{
					syncedConfigEntryBase.SetValueFromServer(value);
				}
			}
		}
	}
}
namespace com.github.zehsteam.SellMyScrap.MonoBehaviours
{
	public class CookieFumoScrapEaterBehaviour : ScrapEaterExtraBehaviour
	{
		[CompilerGenerated]
		private sealed class <StartAnimation>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public CookieFumoScrapEaterBehaviour <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Expected O, but got Unknown
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0104: Unknown result type (might be due to invalid IL or missing references)
				//IL_0147: Unknown result type (might be due to invalid IL or missing references)
				//IL_0151: Expected O, but got Unknown
				//IL_0173: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Expected O, but got Unknown
				//IL_019a: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a4: Expected O, but got Unknown
				//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01dd: Expected O, but got Unknown
				//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0209: Expected O, but got Unknown
				//IL_0231: Unknown result type (might be due to invalid IL or missing references)
				//IL_023b: Expected O, but got Unknown
				//IL_0259: Unknown result type (might be due to invalid IL or missing references)
				//IL_0263: Expected O, but got Unknown
				//IL_0284: Unknown result type (might be due to invalid IL or missing references)
				//IL_028a: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d1: Expected O, but got Unknown
				//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				CookieFumoScrapEaterBehaviour cookieFumoScrapEaterBehaviour = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.fallSFX);
					<>2__current = ((MonoBehaviour)cookieFumoScrapEaterBehaviour).StartCoroutine(cookieFumoScrapEaterBehaviour.MoveToPosition(cookieFumoScrapEaterBehaviour.spawnPosition, cookieFumoScrapEaterBehaviour.startPosition, 2f));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					cookieFumoScrapEaterBehaviour.StopAudioSource(cookieFumoScrapEaterBehaviour.soundEffectsAudio);
					cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.landSFX, cookieFumoScrapEaterBehaviour.landIndex);
					cookieFumoScrapEaterBehaviour.ShakeCamera();
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					cookieFumoScrapEaterBehaviour.PlayAudioSource(cookieFumoScrapEaterBehaviour.movementAudio);
					<>2__current = ((MonoBehaviour)cookieFumoScrapEaterBehaviour).StartCoroutine(cookieFumoScrapEaterBehaviour.MoveToPosition(cookieFumoScrapEaterBehaviour.startPosition, cookieFumoScrapEaterBehaviour.endPosition, cookieFumoScrapEaterBehaviour.movementDuration));
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					cookieFumoScrapEaterBehaviour.StopAudioSource(cookieFumoScrapEaterBehaviour.movementAudio);
					<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.pauseDuration / 2f);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.beforeEatSFX));
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.pauseDuration / 2f);
					<>1__state = 6;
					return true;
				case 6:
					<>1__state = -1;
					cookieFumoScrapEaterBehaviour.MoveTargetScrapToTargetTransform(cookieFumoScrapEaterBehaviour.mouthTransform, cookieFumoScrapEaterBehaviour.suckDuration - 0.1f);
					<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.suckDuration);
					<>1__state = 7;
					return true;
				case 7:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.eatSFX));
					<>1__state = 8;
					return true;
				case 8:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.voiceLineSFX, cookieFumoScrapEaterBehaviour._voiceLineIndex));
					<>1__state = 9;
					return true;
				case 9:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(cookieFumoScrapEaterBehaviour.pauseDuration / 2f);
					<>1__state = 10;
					return true;
				case 10:
					<>1__state = -1;
					cookieFumoScrapEaterBehaviour.PlayAudioSource(cookieFumoScrapEaterBehaviour.movementAudio);
					<>2__current = ((MonoBehaviour)cookieFumoScrapEaterBehaviour).StartCoroutine(cookieFumoScrapEaterBehaviour.MoveToPosition(cookieFumoScrapEaterBehaviour.endPosition, cookieFumoScrapEaterBehaviour.startPosition, cookieFumoScrapEaterBehaviour.movementDuration));
					<>1__state = 11;
					return true;
				case 11:
					<>1__state = -1;
					cookieFumoScrapEaterBehaviour.StopAudioSource(cookieFumoScrapEaterBehaviour.movementAudio);
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 12;
					return true;
				case 12:
					<>1__state = -1;
					cookieFumoScrapEaterBehaviour.PlayOneShotSFX(cookieFumoScrapEaterBehaviour.takeOffSFX);
					<>2__current = ((MonoBehaviour)cookieFumoScrapEaterBehaviour).StartCoroutine(cookieFumoScrapEaterBehaviour.MoveToPosition(cookieFumoScrapEaterBehaviour.startPosition, cookieFumoScrapEaterBehaviour.spawnPosition, 2f));
					<>1__state = 13;
					return true;
				case 13:
					<>1__state = -1;
					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();
			}
		}

		[Space(20f)]
		[Header("Cookie Fumo")]
		[Space(5f)]
		public AudioClip fallSFX;

		public AudioClip beforeEatSFX;

		public AudioClip[] voiceLineSFX = Array.Empty<AudioClip>();

		private int _voiceLineIndex;

		protected override void Start()
		{
			if (NetworkUtils.IsServer)
			{
				_voiceLineIndex = Random.Range(0, voiceLineSFX.Length);
				SetDataClientRpc(_voiceLineIndex);
			}
			base.Start();
		}

		[ClientRpc]
		private void SetDataClientRpc(int voiceLineIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3160276146u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, voiceLineIndex);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3160276146u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					_voiceLineIndex = voiceLineIndex;
				}
			}
		}

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

		protected override void __initializeVariables()
		{
			base.__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_CookieFumoScrapEaterBehaviour()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3160276146u, new RpcReceiveHandler(__rpc_handler_3160276146));
		}

		private static void __rpc_handler_3160276146(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int dataClientRpc = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref dataClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((CookieFumoScrapEaterBehaviour)(object)target).SetDataClientRpc(dataClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "CookieFumoScrapEaterBehaviour";
		}
	}
	internal class CoroutineRunner : MonoBehaviour
	{
		public static CoroutineRunner Instance { get; private set; }

		public static void Spawn()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Instance != (Object)null))
			{
				new GameObject("SellMyScrap CoroutineRunner", new Type[1] { typeof(CoroutineRunner) });
			}
		}

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Instance = this;
			((Object)this).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)this);
		}

		public static Coroutine Start(IEnumerator routine)
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Spawn();
			}
			CoroutineRunner instance = Instance;
			return ((instance != null) ? ((MonoBehaviour)instance).StartCoroutine(routine) : null) ?? null;
		}

		public static void Stop(IEnumerator routine)
		{
			if (!((Object)(object)Instance == (Object)null))
			{
				((MonoBehaviour)Instance).StopCoroutine(routine);
			}
		}

		public static void Stop(Coroutine routine)
		{
			if (!((Object)(object)Instance == (Object)null))
			{
				((MonoBehaviour)Instance).StopCoroutine(routine);
			}
		}
	}
	public class DestroyAfterTimeBehaviour : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <DestoryAfterTime>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public DestroyAfterTimeBehaviour <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Expected O, but got Unknown
				int num = <>1__state;
				DestroyAfterTimeBehaviour destroyAfterTimeBehaviour = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(destroyAfterTimeBehaviour.duration);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					Object.Destroy((Object)(object)((Component)destroyAfterTimeBehaviour).gameObject);
					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();
			}
		}

		public float duration = 5f;

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

		[IteratorStateMachine(typeof(<DestoryAfterTime>d__2))]
		private IEnumerator DestoryAfterTime()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DestoryAfterTime>d__2(0)
			{
				<>4__this = this
			};
		}
	}
	public class MaxwellScrapEaterBehaviour : ScrapEaterExtraBehaviour
	{
		[CompilerGenerated]
		private sealed class <MoveLocalPlayerToMaxwell>d__13 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public MaxwellScrapEaterBehaviour <>4__this;

			public float duration;

			private PlayerControllerB <localPlayerScript>5__2;

			private Vector3 <startPosition>5__3;

			private Vector3 <endPosition>5__4;

			private float <timer>5__5;

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

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

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

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

			private bool MoveNext()
			{
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				MaxwellScrapEaterBehaviour maxwellScrapEaterBehaviour = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<localPlayerScript>5__2 = PlayerUtils.GetLocalPlayerScript();
					maxwellScrapEaterBehaviour._isTarget = true;
					PlayerUtils.SetLocalPlayerMovementEnabled(enabled: false);
					PlayerUtils.SetLocalPlayerAllowDeathEnabled(enabled: false);
					<startPosition>5__3 = ((Component)<localPlayerScript>5__2).transform.position;
					<endPosition>5__4 = maxwellScrapEaterBehaviour.mouthTransform.position;
					<endPosition>5__4.x += 1f;
					<endPosition>5__4.y = ((Component)maxwellScrapEaterBehaviour).transform.position.y;
					<timer>5__5 = 0f;
					break;
				case 1:
					<>1__state = -1;
					<timer>5__5 += Time.deltaTime;
					break;
				}
				if (<timer>5__5 < duration)
				{
					float num2 = 1f / duration * <timer>5__5;
					Vector3 position = <startPosition>5__3 + (<endPosition>5__4 - <startPosition>5__3) * num2;
					((Component)<localPlayerScript>5__2).transform.position = position;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				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();
			}
		}

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

			private object <>2__current;

			public MaxwellScrapEaterBehaviour <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0063: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Expected O, but got Unknown
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_0108: Unknown result type (might be due to invalid IL or missing references)
				//IL_014b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0155: Expected O, but got Unknown
				//IL_017e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0188: Expected O, but got Unknown
				//IL_0204: Unknown result type (might be due to invalid IL or missing references)
				//IL_020e: Expected O, but got Unknown
				//IL_0231: Unknown result type (might be due to invalid IL or missing references)
				//IL_023b: Expected O, but got Unknown
				//IL_025e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0268: Expected O, but got Unknown
				//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c2: Expected O, but got Unknown
				//IL_0336: Unknown result type (might be due to invalid IL or missing references)
				//IL_0340: Expected O, but got Unknown
				//IL_0367: Unknown result type (might be due to invalid IL or missing references)
				//IL_036d: 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_01e2: Expected O, but got Unknown
				//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				MaxwellScrapEaterBehaviour maxwellScrapEaterBehaviour = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					maxwellScrapEaterBehaviour.SetAnimationIdle();
					<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveToPosition(maxwellScrapEaterBehaviour.spawnPosition, maxwellScrapEaterBehaviour.startPosition, 2f));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.landSFX, maxwellScrapEaterBehaviour.landIndex);
					maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.meowSFX, maxwellScrapEaterBehaviour._meowIndex);
					maxwellScrapEaterBehaviour.ShakeCamera();
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					maxwellScrapEaterBehaviour.PlayAudioSource(maxwellScrapEaterBehaviour.movementAudio);
					<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveToPosition(maxwellScrapEaterBehaviour.startPosition, maxwellScrapEaterBehaviour.endPosition, maxwellScrapEaterBehaviour.movementDuration));
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					maxwellScrapEaterBehaviour.StopAudioSource(maxwellScrapEaterBehaviour.movementAudio);
					<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.pauseDuration / 3f);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					maxwellScrapEaterBehaviour.SetAnimationDance();
					<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.pauseDuration / 3f * 2f);
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -1;
					if (maxwellScrapEaterBehaviour._isTarget)
					{
						((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveLocalPlayerToMaxwell(maxwellScrapEaterBehaviour.suckDuration - 0.1f));
					}
					maxwellScrapEaterBehaviour.MoveTargetScrapToTargetTransform(maxwellScrapEaterBehaviour.mouthTransform, maxwellScrapEaterBehaviour.suckDuration - 0.1f);
					<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.suckDuration);
					<>1__state = 6;
					return true;
				case 6:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.eatSFX));
					<>1__state = 7;
					return true;
				case 7:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.pauseDuration / 3f * 2f);
					<>1__state = 8;
					return true;
				case 8:
					<>1__state = -1;
					maxwellScrapEaterBehaviour.SetAnimationIdle();
					<>2__current = (object)new WaitForSeconds(maxwellScrapEaterBehaviour.pauseDuration / 3f);
					<>1__state = 9;
					return true;
				case 9:
					<>1__state = -1;
					if (maxwellScrapEaterBehaviour._isTarget)
					{
						PlayerUtils.SetLocalPlayerAllowDeathEnabled(enabled: true);
					}
					if (maxwellScrapEaterBehaviour._isEvil)
					{
						<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.StartEvilMaxwell());
						<>1__state = 10;
						return true;
					}
					if (maxwellScrapEaterBehaviour._isTarget)
					{
						PlayerUtils.SetLocalPlayerMovementEnabled(enabled: true);
					}
					maxwellScrapEaterBehaviour.PlayAudioSource(maxwellScrapEaterBehaviour.movementAudio);
					<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveToPosition(maxwellScrapEaterBehaviour.endPosition, maxwellScrapEaterBehaviour.startPosition, maxwellScrapEaterBehaviour.movementDuration));
					<>1__state = 12;
					return true;
				case 10:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(3f);
					<>1__state = 11;
					return true;
				case 11:
					<>1__state = -1;
					return false;
				case 12:
					<>1__state = -1;
					maxwellScrapEaterBehaviour.StopAudioSource(maxwellScrapEaterBehaviour.movementAudio);
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 13;
					return true;
				case 13:
					<>1__state = -1;
					maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.takeOffSFX);
					<>2__current = ((MonoBehaviour)maxwellScrapEaterBehaviour).StartCoroutine(maxwellScrapEaterBehaviour.MoveToPosition(maxwellScrapEaterBehaviour.startPosition, maxwellScrapEaterBehaviour.spawnPosition, 2f));
					<>1__state = 14;
					return true;
				case 14:
					<>1__state = -1;
					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();
			}
		}

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

			private object <>2__current;

			public MaxwellScrapEaterBehaviour <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Expected O, but got Unknown
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Expected O, but got Unknown
				//IL_0135: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				MaxwellScrapEaterBehaviour maxwellScrapEaterBehaviour = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					maxwellScrapEaterBehaviour.bodyObject.SetActive(false);
					maxwellScrapEaterBehaviour.evilObject.SetActive(true);
					maxwellScrapEaterBehaviour.purrAudio.Stop();
					maxwellScrapEaterBehaviour.PlayOneShotSFX(maxwellScrapEaterBehaviour.evilNoise);
					<>2__current = (object)new WaitForSeconds(1.25f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (maxwellScrapEaterBehaviour._isTarget)
					{
						PlayerUtils.SetLocalPlayerMovementEnabled(enabled: true);
					}
					<>2__current = (object)new WaitForSeconds(0.25f);
					<>1__state = 2;
					return true;
				case 2:
				{
					<>1__state = -1;
					Vector3 position = ((Component)maxwellScrapEaterBehaviour).transform.position;
					position.y += 0.31f;
					Utils.CreateExplosion(position, spawnExplosionEffect: true, 100, 0f, 6.4f, 6, (CauseOfDeath)3);
					maxwellScrapEaterBehaviour.evilObject.transform.SetParent((Transform)null);
					maxwellScrapEaterBehaviour.evilObject.AddComponent<DestroyAfterTimeBehaviour>().duration = 15f;
					Rigidbody[] componentsInChildren = maxwellScrapEaterBehaviour.evilObject.GetComponentsInChildren<Rigidbody>();
					foreach (Rigidbody val in componentsInChildren)
					{
						val.isKinematic = false;
						val.AddExplosionForce(1000f, maxwellScrapEaterBehaviour.evilObject.transform.position, 100f);
					}
					PlayerUtils.ReviveDeadPlayersAfterTime(5f);
					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();
			}
		}

		[Space(20f)]
		[Header("Maxwell")]
		[Space(5f)]
		public GameObject bodyObject;

		public GameObject evilObject;

		public Animator danceAnimator;

		public AudioSource purrAudio;

		public AudioSource danceAudio;

		public AudioClip[] meowSFX = Array.Empty<AudioClip>();

		public AudioClip evilNoise;

		private bool _isEvil;

		private int _meowIndex;

		private bool _isTarget;

		protected override void Start()
		{
			if (NetworkUtils.IsServer)
			{
				if (PlayerUtils.HasPlayerMagoroku() || PlayerUtils.HasPlayerPsychoHypnotic())
				{
					_isEvil = Utils.RandomPercent(80f);
				}
				else
				{
					_isEvil = Utils.RandomPercent(50f);
				}
				_meowIndex = Random.Range(0, meowSFX.Length);
				SetDataClientRpc(_isEvil, _meowIndex);
			}
			base.Start();
		}

		[ClientRpc]
		private void SetDataClientRpc(bool isEvil, int meowIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_0083: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2957132727u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isEvil, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, meowIndex);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2957132727u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				_isEvil = isEvil;
				_meowIndex = meowIndex;
				if (PlayerUtils.IsLocalPlayerMagoroku() && (Utils.RandomPercent(40f) || (isEvil && Utils.RandomPercent(80f))))
				{
					_isTarget = true;
				}
			}
		}

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

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

		[IteratorStateMachine(typeof(<StartEvilMaxwell>d__14))]
		p