Decompiled source of SellMyScrap v1.12.5

com.github.zehsteam.SellMyScrap.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
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 Newtonsoft.Json;
using Newtonsoft.Json.Linq;
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.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.Patches;
using com.github.zehsteam.SellMyScrap.ScrapEaters;
using com.github.zehsteam.TakeyPlush;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.zehsteam.SellMyScrap")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds a few terminal commands to sell your scrap from the ship. Highly Configurable. Compatible with the ShipInventoryUpdated mod. SellFromTerminal +")]
[assembly: AssemblyFileVersion("1.12.5.0")]
[assembly: AssemblyInformationalVersion("1.12.5+5f12f3211f5ae430ed3fedda53270c8563a51206")]
[assembly: AssemblyProduct("SellMyScrap")]
[assembly: AssemblyTitle("com.github.zehsteam.SellMyScrap")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.12.5.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 class ConfigManager
	{
		public ConfigEntry<bool> ExtendedLogging { get; private set; }

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

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

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

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

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

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

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

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

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

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

		public string[] PrioritySellListArray
		{
			get
			{
				return Utils.StringToCollection<string>(PrioritySellList.Value).ToArray();
			}
			set
			{
				PrioritySellList.Value = Utils.CollectionToString(value);
			}
		}

		public string[] DontSellListArray
		{
			get
			{
				return Utils.StringToCollection<string>(DontSellList.Value).ToArray();
			}
			set
			{
				DontSellList.Value = Utils.CollectionToString(value);
			}
		}

		public string[] SellListArray
		{
			get
			{
				return Utils.StringToCollection<string>(SellList.Value).ToArray();
			}
			set
			{
				SellList.Value = Utils.CollectionToString(value);
			}
		}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		public ConfigManager()
		{
			BindConfigs();
			MigrateOldConfigSettings();
			ConfigHelper.ClearUnusedEntries();
		}

		private 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", 75, 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 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 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 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();
		}

		private void MigrateOldConfigSettings()
		{
			foreach (KeyValuePair<ConfigDefinition, string> orphanedConfigEntry in ConfigHelper.GetOrphanedConfigEntries())
			{
				MigrateOldConfigSetting(orphanedConfigEntry.Key.Section, orphanedConfigEntry.Key.Key, orphanedConfigEntry.Value);
			}
		}

		private void MigrateOldConfigSetting(string section, string key, string value)
		{
			StringComparison comparisonType = StringComparison.OrdinalIgnoreCase;
			if (section.Equals("Sell Settings", comparisonType))
			{
				if (key.Equals("SellGifts", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue(SellGifts, value);
					return;
				}
				if (key.Equals("SellShotguns", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue(SellShotguns, value);
					return;
				}
				if (key.Equals("SellAmmo", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue(SellAmmo, value);
					return;
				}
				if (key.Equals("SellKnives", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue(SellKnives, value);
					return;
				}
				if (key.Equals("SellPickles", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue(SellPickles, value);
					return;
				}
			}
			if (section.Equals("Advanced Sell Settings", comparisonType))
			{
				if (key.Equals("SellScrapWorthZero", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue(SellScrapWorthZero, value);
					return;
				}
				if (key.Equals("OnlySellScrapOnFloor", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue(OnlySellScrapOnFloor, value);
					return;
				}
				if (Utils.StringEquals(key, new string[2] { "PrioritySellList", "PrioritySellListJson" }, matchCase: false))
				{
					ConfigHelper.SetConfigEntryValue(PrioritySellList, value.Replace("\\", ""));
				}
				if (Utils.StringEquals(key, new string[2] { "DontSellList", "DontSellListJson" }, matchCase: false))
				{
					ConfigHelper.SetConfigEntryValue(DontSellList, value.Replace("\\", ""));
				}
				if (Utils.StringEquals(key, new string[2] { "SellList", "SellListJson" }, matchCase: false))
				{
					ConfigHelper.SetConfigEntryValue(SellList, value.Replace("\\", ""));
				}
			}
			if (section.Equals("Terminal Settings", comparisonType))
			{
				if (key.Equals("OverrideWelcomeMessage", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<bool>(OverrideWelcomeMessage, value);
					return;
				}
				if (key.Equals("OverrideHelpMessage", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<bool>(OverrideHelpMessage, value);
					return;
				}
				if (key.Equals("ShowFoundItems", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<bool>(ShowFoundItems, value);
					return;
				}
				if (key.Equals("SortFoundItemsPrice", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<bool>(SortFoundItemsPrice, value);
					return;
				}
				if (key.Equals("AlignFoundItemsPrice", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<bool>(AlignFoundItemsPrice, value);
					return;
				}
			}
			if (section.Equals("Misc Settings", comparisonType))
			{
				if (key.Equals("SpeakInShip", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<bool>(SpeakInShip, value);
					return;
				}
				if (key.Equals("RareVoiceLineChance", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<float>(RareVoiceLineChance, value);
					return;
				}
			}
			if (section.Equals("Scrap Eater Settings", comparisonType))
			{
				if (key.Equals("ScrapEaterChance", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<int>(ScrapEaterChance, value);
				}
				else if (key.Equals("OctolarSpawnWeight", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<int>(OctolarSpawnWeight, value);
				}
				else if (key.Equals("TakeySpawnWeight", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<int>(TakeySpawnWeight, value);
				}
				else if (key.Equals("MaxwellSpawnWeight", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<int>(MaxwellSpawnWeight, value);
				}
				else if (key.Equals("YippeeSpawnWeight", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<int>(YippeeSpawnWeight, value);
				}
				else if (key.Equals("CookieFumoSpawnWeight", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<int>(CookieFumoSpawnWeight, value);
				}
				else if (key.Equals("PsychoSpawnWeight", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<int>(PsychoSpawnWeight, value);
				}
				else if (key.Equals("ZombiesSpawnWeight", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<int>(ZombiesSpawnWeight, value);
				}
				else if (key.Equals("WolfySpawnWeight", comparisonType))
				{
					ConfigHelper.SetConfigEntryValue<int>(WolfySpawnWeight, value);
				}
			}
		}

		internal void TrySetCustomValues()
		{
			if (!SteamUtils.IsLocalClient(PlayerName.Insym))
			{
				TrySetCustomValuesForThorlar();
				TrySetCustomValuesForTakerst();
				if (ScrapEaterChance.Value == 0 && DontSellListArray.Length == 1 && DontSellListArray[0].Equals("gold bar", StringComparison.OrdinalIgnoreCase) && !SaveHelper.LoadValue("ResetScrapEaterChance", SaveLocation.Modpack, defaultValue: false))
				{
					ScrapEaterChance.Value = (int)((ConfigEntryBase)ScrapEaterChance).DefaultValue;
					SaveHelper.SaveValue("ResetScrapEaterChance", value: true, SaveLocation.Modpack);
				}
			}
		}

		private void TrySetCustomValuesForThorlar()
		{
			if (SteamUtils.IsLocalClient(PlayerName.Thorlar) && TakeySpawnWeight.Value > 0 && !SaveHelper.LoadValue("RemovedTakeyScrapEaterSpawnWeight", SaveLocation.Modpack, defaultValue: false))
			{
				TakeySpawnWeight.Value = 0;
				SaveHelper.SaveValue("RemovedTakeyScrapEaterSpawnWeight", value: true, SaveLocation.Modpack);
			}
		}

		private void TrySetCustomValuesForTakerst()
		{
			if (SteamUtils.IsLocalClient(PlayerName.Takerst))
			{
				if (!Utils.ArrayContains(DontSellListArray, "Smol Takey"))
				{
					List<string> list = DontSellListArray.ToList();
					list.Add("Smol Takey");
					DontSellListArray = list.ToArray();
				}
				if (!Utils.ArrayContains(DontSellListArray, "Takey Box"))
				{
					List<string> list2 = DontSellListArray.ToList();
					list2.Add("Takey Box");
					DontSellListArray = list2.ToArray();
				}
				if (!Utils.ArrayContains(DontSellListArray, "Takey Mug"))
				{
					List<string> list3 = DontSellListArray.ToList();
					list3.Add("Takey Mug");
					DontSellListArray = list3.ToArray();
				}
			}
		}
	}
	internal static class Content
	{
		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()
		{
			LoadAssetsFromAssetBundle();
		}

		private static void LoadAssetsFromAssetBundle()
		{
			AssetBundle val = LoadAssetBundle("sellmyscrap_assets");
			if (!((Object)(object)val == (Object)null))
			{
				NetworkHandlerPrefab = LoadAssetFromAssetBundle<GameObject>("NetworkHandler", val);
				NetworkHandlerPrefab.AddComponent<PluginNetworkBehaviour>();
				OctolarScrapEaterPrefab = LoadAssetFromAssetBundle<GameObject>("OctolarScrapEater", val);
				TakeyScrapEaterPrefab = LoadAssetFromAssetBundle<GameObject>("TakeyScrapEater", val);
				MaxwellScrapEaterPrefab = LoadAssetFromAssetBundle<GameObject>("MaxwellScrapEater", val);
				YippeeScrapEaterPrefab = LoadAssetFromAssetBundle<GameObject>("YippeeScrapEater", val);
				CookieFumoScrapEaterPrefab = LoadAssetFromAssetBundle<GameObject>("CookieFumoScrapEater", val);
				PsychoScrapEaterPrefab = LoadAssetFromAssetBundle<GameObject>("PsychoScrapEater", val);
				ZombiesScrapEaterPrefab = LoadAssetFromAssetBundle<GameObject>("ZombiesScrapEater", val);
				WolfyScrapEaterPrefab = LoadAssetFromAssetBundle<GameObject>("WolfyScrapEater", val);
				BrainRotIntroSpeechSFX = LoadAssetFromAssetBundle<AudioClip>("BrainRotIntroSpeechSFX", val);
				Plugin.Logger.LogInfo((object)"Successfully loaded assets from AssetBundle!");
			}
		}

		private static AssetBundle LoadAssetBundle(string fileName)
		{
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location);
				string text = Path.Combine(directoryName, fileName);
				return AssetBundle.LoadFromFile(text);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Failed to load AssetBundle \"{fileName}\". {arg}");
			}
			return null;
		}

		private static T LoadAssetFromAssetBundle<T>(string name, AssetBundle assetBundle) where T : Object
		{
			if (string.IsNullOrWhiteSpace(name))
			{
				Plugin.Logger.LogError((object)("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)
			{
				Plugin.Logger.LogError((object)("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)
			{
				Plugin.Logger.LogError((object)("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;
		}
	}
	public static class NetworkUtils
	{
		public static bool IsConnected
		{
			get
			{
				if ((Object)(object)NetworkManager.Singleton == (Object)null)
				{
					return false;
				}
				return NetworkManager.Singleton.IsConnectedClient;
			}
		}

		public static bool IsServer
		{
			get
			{
				if ((Object)(object)NetworkManager.Singleton == (Object)null)
				{
					return false;
				}
				return NetworkManager.Singleton.IsServer;
			}
		}

		public static bool IsHost
		{
			get
			{
				if ((Object)(object)NetworkManager.Singleton == (Object)null)
				{
					return false;
				}
				return NetworkManager.Singleton.IsHost;
			}
		}

		public static ulong GetLocalClientId()
		{
			return NetworkManager.Singleton.LocalClientId;
		}

		public static bool IsLocalClientId(ulong clientId)
		{
			return clientId == GetLocalClientId();
		}

		public static NetworkObjectReference[] GetNetworkObjectReferences(List<GrabbableObject> grabbableObjects)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (grabbableObjects == null || grabbableObjects.Count == 0)
			{
				return Array.Empty<NetworkObjectReference>();
			}
			List<NetworkObjectReference> list = new List<NetworkObjectReference>();
			NetworkObject val = default(NetworkObject);
			foreach (GrabbableObject grabbableObject in grabbableObjects)
			{
				if (((Component)grabbableObject).TryGetComponent<NetworkObject>(ref val))
				{
					list.Add(NetworkObjectReference.op_Implicit(val));
				}
			}
			return list.ToArray();
		}

		public static List<GrabbableObject> GetGrabbableObjects(NetworkObjectReference[] networkObjectReferences)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (networkObjectReferences == null || networkObjectReferences.Length == 0)
			{
				return new List<GrabbableObject>();
			}
			List<GrabbableObject> list = new List<GrabbableObject>();
			NetworkObject val2 = default(NetworkObject);
			GrabbableObject item = default(GrabbableObject);
			for (int i = 0; i < networkObjectReferences.Length; i++)
			{
				NetworkObjectReference val = networkObjectReferences[i];
				if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null) && ((Component)val2).TryGetComponent<GrabbableObject>(ref item))
				{
					list.Add(item);
				}
			}
			return list;
		}
	}
	internal static class PlayerUtils
	{
		[CompilerGenerated]
		private sealed class <ReviveDeadPlayersAfterTimeCO>d__15 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float time;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(time);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (AreAllPlayersDead())
					{
						StartOfRound.Instance.ReviveDeadPlayers();
					}
					return false;
				}
			}

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

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

		private static float _previousPlayerMovementSpeed;

		private static float _previousPlayerJumpForce;

		public static PlayerControllerB GetLocalPlayerScript()
		{
			if ((Object)(object)GameNetworkManager.Instance == (Object)null)
			{
				return null;
			}
			return GameNetworkManager.Instance.localPlayerController;
		}

		public static bool IsLocalPlayer(PlayerControllerB playerScript)
		{
			return (Object)(object)playerScript == (Object)(object)GetLocalPlayerScript();
		}

		public static bool IsLocalPlayer(PlayerName playerName)
		{
			return SteamUtils.IsLocalClient(playerName);
		}

		public static bool IsLocalPlayer(params PlayerName[] playerNames)
		{
			foreach (PlayerName playerName in playerNames)
			{
				if (SteamUtils.IsLocalClient(playerName))
				{
					return true;
				}
			}
			return false;
		}

		public static bool IsPlayer(PlayerControllerB playerScript, PlayerName playerName)
		{
			if ((Object)(object)playerScript == (Object)null)
			{
				return false;
			}
			return SteamUtils.IsPlayer(playerName, playerScript.playerUsername, playerScript.playerSteamId);
		}

		public static bool HasPlayer(PlayerName playerName)
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB playerScript in allPlayerScripts)
			{
				if (IsPlayer(playerScript, playerName))
				{
					return true;
				}
			}
			return false;
		}

		public static bool HasPlayer(params PlayerName[] playerNames)
		{
			foreach (PlayerName playerName in playerNames)
			{
				if (HasPlayer(playerName))
				{
					return true;
				}
			}
			return false;
		}

		public static PlayerControllerB GetPlayerScript(PlayerName playerName)
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (IsPlayer(val, playerName))
				{
					return val;
				}
			}
			return null;
		}

		public static PlayerControllerB GetPlayerScriptByClientId(ulong clientId)
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (val.actualClientId == clientId)
				{
					return val;
				}
			}
			return null;
		}

		public static bool AreAllPlayersDead()
		{
			bool result = true;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!val.isPlayerDead)
				{
					result = false;
				}
			}
			return result;
		}

		public static void SetLocalPlayerMovementEnabled(bool enabled)
		{
			PlayerControllerB localPlayerScript = GetLocalPlayerScript();
			if (enabled)
			{
				if (_previousPlayerMovementSpeed == 0f)
				{
					_previousPlayerMovementSpeed = 4.6f;
				}
				if (_previousPlayerJumpForce == 0f)
				{
					_previousPlayerJumpForce = 13f;
				}
				localPlayerScript.movementSpeed = _previousPlayerMovementSpeed;
				localPlayerScript.jumpForce = _previousPlayerJumpForce;
			}
			else
			{
				if (localPlayerScript.movementSpeed > 0f)
				{
					_previousPlayerMovementSpeed = localPlayerScript.movementSpeed;
				}
				if (localPlayerScript.jumpForce > 0f)
				{
					_previousPlayerJumpForce = localPlayerScript.jumpForce;
				}
				localPlayerScript.movementSpeed = 0f;
				localPlayerScript.jumpForce = 0f;
			}
		}

		public static void SetLocalPlayerAllowDeathEnabled(bool enabled)
		{
			if (!((Object)(object)StartOfRound.Instance == (Object)null))
			{
				FieldInfo field = typeof(StartOfRound).GetField("allowLocalPlayerDeath", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (!(field == null))
				{
					field.SetValue(StartOfRound.Instance, enabled);
				}
			}
		}

		public static void ReviveDeadPlayersAfterTime(float time)
		{
			((MonoBehaviour)StartOfRound.Instance).StartCoroutine(ReviveDeadPlayersAfterTimeCO(time));
		}

		[IteratorStateMachine(typeof(<ReviveDeadPlayersAfterTimeCO>d__15))]
		private static IEnumerator ReviveDeadPlayersAfterTimeCO(float time)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ReviveDeadPlayersAfterTimeCO>d__15(0)
			{
				time = time
			};
		}
	}
	[BepInPlugin("com.github.zehsteam.SellMyScrap", "SellMyScrap", "1.12.5")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class Plugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <PerformSellOnServer>d__34 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Plugin <>4__this;

			private int <scrapEaterIndex>5__1;

			private int <scrapEaterVariantIndex>5__2;

			private List<GrabbableObject> <grabbableObjects>5__3;

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

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

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

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

			private bool MoveNext()
			{
				//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ca: Expected O, but got Unknown
				//IL_0169: Unknown result type (might be due to invalid IL or missing references)
				//IL_0173: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (<>4__this.ScrapToSell == null || <>4__this.SellRequest == null)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					goto IL_0076;
				case 1:
					<>1__state = -1;
					goto IL_0076;
				case 2:
					<>1__state = -1;
					goto IL_00a7;
				case 3:
					<>1__state = -1;
					if (ShipInventoryProxy.SpawnItemsStatus == SpawnItemsStatus.Success)
					{
						<grabbableObjects>5__3.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_0207;
				case 4:
					{
						<>1__state = -1;
						DepositItemsDeskHelper.SellItems_Server();
						<>4__this.ScrapToSell = null;
						return false;
					}
					IL_0207:
					if (!StartOfRound.Instance.shipIsLeaving)
					{
						if (<scrapEaterIndex>5__1 == -1)
						{
							ScrapEaterManager.StartRandomScrapEaterOnServer(<grabbableObjects>5__3, <scrapEaterVariantIndex>5__2);
							return false;
						}
						if (<scrapEaterIndex>5__1 > -1 && ScrapEaterManager.HasScrapEater(<scrapEaterIndex>5__1))
						{
							ScrapEaterManager.StartScrapEaterOnServer(<scrapEaterIndex>5__1, <grabbableObjects>5__3, <scrapEaterVariantIndex>5__2);
							return false;
						}
						if (ScrapEaterManager.CanUseScrapEater())
						{
							ScrapEaterManager.StartRandomScrapEaterOnServer(<grabbableObjects>5__3, <scrapEaterVariantIndex>5__2);
							return false;
						}
					}
					DepositItemsDeskHelper.PlaceItemsOnCounter(<grabbableObjects>5__3);
					PluginNetworkBehaviour.Instance.PlaceItemsOnCounterClientRpc(NetworkUtils.GetNetworkObjectReferences(<grabbableObjects>5__3));
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 4;
					return true;
					IL_0076:
					if (<>4__this.SellRequest.ConfirmationStatus != ConfirmationStatus.Confirmed)
					{
						<>2__current = null;
						<>1__state = 2;
						return true;
					}
					goto IL_00a7;
					IL_00a7:
					if ((Object)(object)DepositItemsDeskHelper.Instance == (Object)null)
					{
						Logger.LogError((object)"Could not find depositItemsDesk. Are you landed at The Company building?");
						return false;
					}
					<scrapEaterIndex>5__1 = <>4__this.SellRequest.ScrapEaterIndex;
					<scrapEaterVariantIndex>5__2 = <>4__this.SellRequest.ScrapEaterVariantIndex;
					<grabbableObjects>5__3 = <>4__this.ScrapToSell.GrabbableObjects;
					if (ShipInventoryProxy.Enabled && <>4__this.ScrapToSell.ShipInventoryItems.Length != 0)
					{
						ShipInventoryProxy.SpawnItemsOnServer(<>4__this.ScrapToSell.ShipInventoryItems);
						<>2__current = (object)new WaitUntil((Func<bool>)(() => !ShipInventoryProxy.IsSpawning));
						<>1__state = 3;
						return true;
					}
					goto IL_0207;
				}
			}

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

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

		private readonly Harmony _harmony = new Harmony("com.github.zehsteam.SellMyScrap");

		internal static Plugin Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static ConfigManager ConfigManager { get; private set; }

		public ScrapToSell ScrapToSell { get; private set; }

		public SellRequest SellRequest { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Logger = Logger.CreateLogSource("com.github.zehsteam.SellMyScrap");
			Logger.LogInfo((object)"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);
			}
			ConfigManager = new ConfigManager();
			Content.Load();
			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)
								{
									Logger.LogWarning((object)("Failed to invoke method " + methodInfo.Name + ": " + ex.Message));
								}
							}
						}
						catch (Exception ex2)
						{
							Logger.LogWarning((object)("Error processing method " + methodInfo.Name + " in type " + type.Name + ": " + ex2.Message));
						}
					}
				}
			}
			catch (Exception ex3)
			{
				Logger.LogError((object)("An error occurred in NetcodePatcherAwake: " + ex3.Message));
			}
		}

		public void OnLocalDisconnect()
		{
			CommandManager.OnLocalDisconnect();
			CancelSellRequest();
		}

		public void OnTerminalQuit()
		{
			CommandManager.OnTerminalQuit();
			CancelSellRequest();
		}

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

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

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

		public 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((object)text);
		}

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

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

		private void ConfirmSellRequestOnClient()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			PluginNetworkBehaviour.Instance.PerformSellServerRpc(ScrapToSell, SellRequest.SellType, SellRequest.ScrapEaterIndex);
		}

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

		public 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__34))]
		public IEnumerator PerformSellOnServer()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PerformSellOnServer>d__34(0)
			{
				<>4__this = this
			};
		}

		public void LogInfoExtended(object data)
		{
			LogExtended((LogLevel)16, data);
		}

		public void LogWarningExtended(object data)
		{
			LogExtended((LogLevel)4, data);
		}

		public void LogExtended(LogLevel level, object data)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if (ConfigManager == null || ConfigManager.ExtendedLogging == null)
			{
				Logger.Log(level, data);
			}
			else if (ConfigManager.ExtendedLogging.Value)
			{
				Logger.Log(level, data);
			}
		}
	}
	internal enum PlayerName
	{
		CritHaxXoG,
		Takerst,
		Insym,
		Thorlar,
		PsychoHypnotic,
		Magoroku,
		ZombiesAteMyChannel,
		WolfsMyChocolate,
		Hiccubz,
		Lunxara,
		PANDAM0NIEM,
		Jxshkins,
		SpookyTug,
		Raqaizal,
		MaestroSpooks,
		VanoraDarkWolf,
		TetraFlash,
		XSuperBeefyx,
		Ariesgoddess168,
		LustStings,
		TIMETELL,
		IElucian,
		Irishdev13,
		Oopsmyleg,
		Reapermitsuki,
		Yinisin,
		AGlitchedNpc
	}
	internal static class SteamUtils
	{
		public static List<PlayerData> PlayersData { get; private set; }

		static SteamUtils()
		{
			PlayersData = new List<PlayerData>();
			PlayersData = new List<PlayerData>(27)
			{
				new PlayerData(PlayerName.CritHaxXoG, "CritHaxXoG", 76561198993712632uL),
				new PlayerData(PlayerName.Takerst, "Takerst", 76561197980238122uL),
				new PlayerData(PlayerName.Insym, "Insym", 76561198008109303uL),
				new PlayerData(PlayerName.Thorlar, "Thorlar", 76561197964616102uL),
				new PlayerData(PlayerName.PsychoHypnotic, "PsychoHypnotic", 76561197970440803uL),
				new PlayerData(PlayerName.Magoroku, "Magoroku", 76561197982837475uL),
				new PlayerData(PlayerName.ZombiesAteMyChannel, "ZombieAteMyChannel", 76561197990822861uL),
				new PlayerData(PlayerName.WolfsMyChocolate, new string[2] { "WolfsMyChocolate", "wolfyfook" }, new ulong[2] { 76561199112488706uL, 76561199589529626uL }),
				new PlayerData(PlayerName.Hiccubz, "Hiccubz", 76561199090697084uL),
				new PlayerData(PlayerName.Lunxara, "Lunxara", 76561198086325047uL),
				new PlayerData(PlayerName.PANDAM0NIEM, "PANDAM0NIEM", 76561199169070660uL),
				new PlayerData(PlayerName.Jxshkins, "jxshkins", 76561199004549621uL),
				new PlayerData(PlayerName.SpookyTug, "SpookyTug", 76561198053549767uL),
				new PlayerData(PlayerName.Raqaizal, "Raqaizal", 76561198047992629uL),
				new PlayerData(PlayerName.MaestroSpooks, "MaestroSpooks", 76561198150757587uL),
				new PlayerData(PlayerName.VanoraDarkWolf, "Vanora", 76561198064529684uL),
				new PlayerData(PlayerName.TetraFlash, "TetraFlash", 76561197993458924uL),
				new PlayerData(PlayerName.XSuperBeefyx, "xSuperBeefyx", 76561197964982016uL),
				new PlayerData(PlayerName.Ariesgoddess168, "NewAgeAries", 76561198174632877uL),
				new PlayerData(PlayerName.LustStings, "lustings", 76561198053068793uL),
				new PlayerData(PlayerName.TIMETELL, "TIMETELL", 76561197967817500uL),
				new PlayerData(PlayerName.IElucian, "iElucian", 76561197962979730uL),
				new PlayerData(PlayerName.Irishdev13, "TTV_Irishdev13", 76561198123000350uL),
				new PlayerData(PlayerName.Oopsmyleg, "Oopsmyleg", 76561198113371889uL),
				new PlayerData(PlayerName.Reapermitsuki, "reaper-mitsuki", 76561198281494776uL),
				new PlayerData(PlayerName.Yinisin, "Yinisin", 76561199582073183uL),
				new PlayerData(PlayerName.AGlitchedNpc, "a glitched npc", 76561198984467725uL)
			};
		}

		public static bool IsPlayer(PlayerName playerName, string username, ulong steamId)
		{
			return GetPlayerData(playerName)?.IsPlayer(username, steamId) ?? false;
		}

		public static PlayerData GetLocalClientPlayerData()
		{
			foreach (PlayerData playersDatum in PlayersData)
			{
				if (playersDatum.IsLocalClient())
				{
					return playersDatum;
				}
			}
			return null;
		}

		public static PlayerData GetPlayerData(PlayerName playerName)
		{
			foreach (PlayerData playersDatum in PlayersData)
			{
				if (playersDatum.PlayerName == playerName)
				{
					return playersDatum;
				}
			}
			return null;
		}

		public static bool IsLocalClient(PlayerName playerName)
		{
			return GetPlayerData(playerName)?.IsLocalClient() ?? false;
		}

		public static bool IsLocalClient(string username, ulong steamId)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (!SteamClient.IsValid)
			{
				return false;
			}
			if (!SteamClient.IsLoggedOn)
			{
				return false;
			}
			if (SteamClient.Name.Equals(username, StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (SteamId.op_Implicit(SteamClient.SteamId) == steamId)
			{
				return true;
			}
			return false;
		}
	}
	internal class PlayerData
	{
		public PlayerName PlayerName { get; private set; }

		public string[] Username { get; private set; }

		public ulong[] SteamId { get; private set; }

		public PlayerData(PlayerName playerName, string username, ulong steamId)
		{
			PlayerName = playerName;
			Username = new string[1] { username };
			SteamId = new ulong[1] { steamId };
		}

		public PlayerData(PlayerName playerName, string[] username, ulong[] steamId)
		{
			PlayerName = playerName;
			Username = username;
			SteamId = steamId;
		}

		public bool IsLocalClient()
		{
			for (int i = 0; i < Username.Length; i++)
			{
				if (SteamUtils.IsLocalClient(Username[i], SteamId[i]))
				{
					return true;
				}
			}
			return false;
		}

		public bool IsPlayer(string username, ulong steamId)
		{
			for (int i = 0; i < Username.Length; i++)
			{
				if (Username[i].Equals(username, StringComparison.OrdinalIgnoreCase))
				{
					return true;
				}
				if (SteamId[i] == steamId)
				{
					return true;
				}
			}
			return false;
		}
	}
	internal static class Utils
	{
		public static string GetEnumName<T>(T value) where T : Enum
		{
			return Enum.GetName(typeof(T), value) ?? string.Empty;
		}

		public static string GetPluginDirectoryPath()
		{
			return Path.GetDirectoryName(((BaseUnityPlugin)Plugin.Instance).Info.Location);
		}

		public static string GetConfigDirectoryPath()
		{
			return Paths.ConfigPath;
		}

		public static string GetGlobalConfigDirectoryPath()
		{
			return Path.Combine(Application.persistentDataPath, "SellMyScrap");
		}

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

		public static ConfigFile CreateLocalConfigFile(string name = null, bool saveOnInit = false)
		{
			if (name == null)
			{
				name = "com.github.zehsteam.SellMyScrap-" + name;
			}
			return CreateConfigFile(Paths.ConfigPath, name, saveOnInit);
		}

		public static ConfigFile CreateGlobalConfigFile(string name = null, bool saveOnInit = false)
		{
			if (name == null)
			{
				name = "global";
			}
			return CreateConfigFile(GetGlobalConfigDirectoryPath(), 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: 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)
					{
						Plugin.Instance.LogInfoExtended("Setting off other mine");
						((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(List<int> weightList)
		{
			List<(int, int)> list = new List<(int, int)>();
			for (int i = 0; i < weightList.Count; i++)
			{
				int num = weightList[i];
				if (num > 0)
				{
					list.Add((i, num));
				}
			}
			int num2 = 0;
			foreach (var item4 in list)
			{
				int item = item4.Item2;
				num2 += item;
			}
			if (num2 == 0)
			{
				return -1;
			}
			int num3 = Random.Range(0, num2);
			int num4 = 0;
			foreach (var item5 in list)
			{
				int item2 = item5.Item1;
				int item3 = item5.Item2;
				num4 += item3;
				if (num3 < num4)
				{
					return item2;
				}
			}
			throw new InvalidOperationException("Weights are not properly specified.");
		}

		public static List<List<T>> SplitList<T>(List<T> items, int numberOfLists)
		{
			List<List<T>> list = new List<List<T>>();
			int count = items.Count;
			int num = Mathf.CeilToInt((float)count / (float)numberOfLists);
			for (int i = 0; i < numberOfLists; i++)
			{
				List<T> range = items.GetRange(i * num, Mathf.Min(num, count - i * num));
				list.Add(range);
			}
			return list;
		}

		public static Coroutine StartCoroutine(IEnumerator routine)
		{
			if ((Object)(object)Plugin.Instance != (Object)null)
			{
				return ((MonoBehaviour)Plugin.Instance).StartCoroutine(routine);
			}
			if ((Object)(object)GameNetworkManager.Instance != (Object)null)
			{
				return ((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(routine);
			}
			Plugin.Logger.LogError((object)("Failed to start coroutine. " + routine));
			return null;
		}

		public static IEnumerable<T> StringToCollection<T>(string value)
		{
			if (string.IsNullOrEmpty(value))
			{
				return Enumerable.Empty<T>();
			}
			T result;
			return from x in value.Split(',', StringSplitOptions.RemoveEmptyEntries)
				where !string.IsNullOrWhiteSpace(x)
				select x.Trim() into x
				select TryConvertStringToType<T>(x, out result) ? result : default(T) into x
				where x != null
				select x;
		}

		public static string CollectionToString<T>(IEnumerable<T> value)
		{
			if (value == null || !value.Any())
			{
				return string.Empty;
			}
			return string.Join(", ", from x in value
				where x != null && !string.IsNullOrWhiteSpace(x.ToString())
				select x.ToString().Trim());
		}

		public static bool TryConvertStringToType<T>(string value, out T result)
		{
			if (string.IsNullOrWhiteSpace(value))
			{
				result = default(T);
				return false;
			}
			try
			{
				Type typeFromHandle = typeof(T);
				if (typeFromHandle.IsEnum && Enum.TryParse(typeFromHandle, value.Trim(), ignoreCase: true, out object result2))
				{
					result = (T)result2;
					return true;
				}
				if (typeFromHandle == typeof(Guid) && Guid.TryParse(value.Trim(), out var result3))
				{
					result = (T)(object)result3;
					return true;
				}
				Type conversionType = Nullable.GetUnderlyingType(typeFromHandle) ?? typeFromHandle;
				result = (T)Convert.ChangeType(value.Trim(), conversionType);
				return true;
			}
			catch
			{
				result = default(T);
				return false;
			}
		}

		public static bool StringEquals(string input, string[] values, bool matchCase = true)
		{
			StringComparison comparisonType = ((!matchCase) ? StringComparison.OrdinalIgnoreCase : StringComparison.CurrentCulture);
			return values.Any((string value) => input.Equals(value, comparisonType));
		}

		public static bool StringContains(string input, string[] values, bool matchCase = true)
		{
			StringComparison comparisonType = ((!matchCase) ? StringComparison.OrdinalIgnoreCase : StringComparison.CurrentCulture);
			return values.Any((string value) => input.Contains(value, comparisonType));
		}
	}
	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.12.5";
	}
}
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()
		{
			ConfigManager configManager = Plugin.ConfigManager;
			ScrapEaters = new List<ScrapEater>(8)
			{
				new ScrapEater(Content.OctolarScrapEaterPrefab, () => configManager.OctolarSpawnWeight.Value),
				new ScrapEater(Content.TakeyScrapEaterPrefab, () => configManager.TakeySpawnWeight.Value),
				new ScrapEater(Content.MaxwellScrapEaterPrefab, () => configManager.MaxwellSpawnWeight.Value),
				new ScrapEater(Content.YippeeScrapEaterPrefab, () => configManager.YippeeSpawnWeight.Value),
				new ScrapEater(Content.CookieFumoScrapEaterPrefab, () => configManager.CookieFumoSpawnWeight.Value),
				new ScrapEater(Content.PsychoScrapEaterPrefab, () => configManager.PsychoSpawnWeight.Value),
				new ScrapEater(Content.ZombiesScrapEaterPrefab, () => configManager.ZombiesSpawnWeight.Value),
				new ScrapEater(Content.WolfyScrapEaterPrefab, () => configManager.WolfySpawnWeight.Value)
			};
		}

		internal static bool CanUseScrapEater()
		{
			int value = Plugin.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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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);
				Plugin.Logger.LogInfo((object)$"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 && Plugin.ConfigManager.SpeakInShip.Value)
			{
				StartOfRound.Instance.speakerAudioSource.PlayOneShot(val, 1f);
			}
			SpeakInShip = false;
			ClipIndex = -1;
			return false;
		}

		private static int GetRandomAudioClipIndex()
		{
			if (Utils.RandomPercent(Plugin.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(Content.NetworkHandlerPrefab);
			foreach (ScrapEater scrapEater in ScrapEaterManager.ScrapEaters)
			{
				AddNetworkPrefab(scrapEater.SpawnPrefab);
			}
		}

		private static void AddNetworkPrefab(GameObject prefab)
		{
			if ((Object)(object)prefab == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to register network prefab. GameObject is null.");
				return;
			}
			NetworkManager.Singleton.AddNetworkPrefab(prefab);
			Plugin.Logger.LogInfo((object)("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__1;

			private float <percent>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_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: 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__1 = 0f;
					rewardsScrollbar.value = 1f;
					break;
				case 2:
					<>1__state = -1;
					<timer>5__1 += Time.deltaTime;
					break;
				}
				if (<timer>5__1 < duration)
				{
					if (<timer>5__1 > duration)
					{
						<timer>5__1 = duration;
					}
					<percent>5__2 = 1f / duration * <timer>5__1;
					rewardsScrollbar.value = 1f - <percent>5__2;
					<>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)
		{
			Plugin.Logger.LogInfo((object)$"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 || !Plugin.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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkUtils.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(Content.NetworkHandlerPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch()
		{
			Plugin.ConfigManager.TrySetCustomValues();
			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.Instance.OnLocalDisconnect();
		}
	}
	[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 (Plugin.ConfigManager.OverrideWelcomeMessage.Value)
				{
					OverrideWelcomeTerminalNode(terminalNodes);
				}
				if (Plugin.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.Instance.OnTerminalQuit();
		}

		[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.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_00c3: 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_0151: Unknown result type (might be due to invalid IL or missing references)
				//IL_015b: Expected O, but got Unknown
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Expected O, but got Unknown
				//IL_022e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0238: Expected O, but got Unknown
				//IL_025a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0264: Expected O, but got Unknown
				//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b2: Expected O, but got Unknown
				//IL_02de: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e8: Expected O, but got Unknown
				//IL_031f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0329: Expected O, but got Unknown
				//IL_034c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0356: Expected O, but got Unknown
				//IL_0391: Unknown result type (might be due to invalid IL or missing references)
				//IL_039c: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f3: Expected O, but got Unknown
				//IL_0433: Unknown result type (might be due to invalid IL or missing references)
				//IL_043e: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.PlayOneShotSFX(<>4__this.fallSFX);
					<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.MoveToPosition(<>4__this.spawnPosition, <>4__this.startPosition, 2f));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.StopAudioSource(<>4__this.soundEffectsAudio);
					<>4__this.PlayOneShotSFX(<>4__this.landSFX, <>4__this.landIndex);
					<>4__this.ShakeCamera();
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>4__this.PlayAudioSource(<>4__this.movementAudio);
					<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.MoveToPosition(<>4__this.startPosition, <>4__this.endPosition, <>4__this.movementDuration));
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					<>4__this.StopAudioSource(<>4__this.movementAudio);
					<>2__current = (object)new WaitForSeconds(<>4__this.pauseDuration / 2f);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(<>4__this.PlayOneShotSFX(<>4__this.beforeEatSFX));
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(<>4__this.pauseDuration / 2f);
					<>1__state = 6;
					return true;
				case 6:
					<>1__state = -1;
					<>4__this.MoveTargetScrapToTargetTransform(<>4__this.mouthTransform, <>4__this.suckDuration - 0.1f);
					<>2__current = (object)new WaitForSeconds(<>4__this.suckDuration);
					<>1__state = 7;
					return true;
				case 7:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(<>4__this.PlayOneShotSFX(<>4__this.eatSFX));
					<>1__state = 8;
					return true;
				case 8:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(<>4__this.PlayOneShotSFX(<>4__this.voiceLineSFX, <>4__this._voiceLineIndex));
					<>1__state = 9;
					return true;
				case 9:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(<>4__this.pauseDuration / 2f);
					<>1__state = 10;
					return true;
				case 10:
					<>1__state = -1;
					<>4__this.PlayAudioSource(<>4__this.movementAudio);
					<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.MoveToPosition(<>4__this.endPosition, <>4__this.startPosition, <>4__this.movementDuration));
					<>1__state = 11;
					return true;
				case 11:
					<>1__state = -1;
					<>4__this.StopAudioSource(<>4__this.movementAudio);
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 12;
					return true;
				case 12:
					<>1__state = -1;
					<>4__this.PlayOneShotSFX(<>4__this.takeOffSFX);
					<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.MoveToPosition(<>4__this.startPosition, <>4__this.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";
		}
	}
	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_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(<>4__this.duration);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					Object.Destroy((Object)(object)((Component)<>4__this).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 float duration;

			public MaxwellScrapEaterBehaviour <>4__this;

			private PlayerControllerB <localPlayerScript>5__1;

			private Vector3 <startPosition>5__2;

			private Vector3 <endPosition>5__3;

			private float <timer>5__4;

			private float <percent>5__5;

			private Vector3 <newPosition>5__6;

			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__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: 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_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_010b: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<localPlayerScript>5__1 = PlayerUtils.GetLocalPlayerScript();
					<>4__this._isTarget = true;
					PlayerUtils.SetLocalPlayerMovementEnabled(enabled: false);
					PlayerUtils.SetLocalPlayerAllowDeathEnabled(enabled: false);
					<startPosition>5__2 = ((Component)<localPlayerScript>5__1).transform.position;
					<endPosition>5__3 = <>4__this.mouthTransform.position;
					<endPosition>5__3.x += 1f;
					<endPosition>5__3.y = ((Component)<>4__this).transform.position.y;
					<timer>5__4 = 0f;
					break;
				case 1:
					<>1__state = -1;
					<timer>5__4 += Time.deltaTime;
					break;
				}
				if (<timer>5__4 < duration)
				{
					<percent>5__5 = 1f / duration * <timer>5__4;
					<newPosition>5__6 = <startPosition>5__2 + (<endPosition>5__3 - <startPosition>5__2) * <percent>5__5;
					((Component)<localPlayerScript>5__1).transform.position = <newPosition>5__6;
					<>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_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_015a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0164: Expected O, but got Unknown
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0201: Unknown result type (might be due to invalid IL or missing references)
				//IL_020b: Expected O, but got Unknown
				//IL_023f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0249: Expected O, but got Unknown
				//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0304: Expected O, but got Unknown
				//IL_032c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0336: Expected O, but got Unknown
				//IL_0364: Unknown result type (might be due to invalid IL or missing references)
				//IL_036e: Expected O, but got Unknown
				//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e2: Expected O, but got Unknown
				//IL_048f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0499: Expected O, but got Unknown
				//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ce: Expected O, but got Unknown
				//IL_0437: Unknown result type (might be due to invalid IL or missing references)
				//IL_0442: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.SetAnimationIdle();
					<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.MoveToPosition(<>4__this.spawnPosition, <>4__this.startPosition, 2f));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.PlayOneShotSFX(<>4__this.landSFX, <>4__this.landIndex);
					<>4__this.PlayOneShotSFX(<>4__this.meowSFX, <>4__this._meowIndex);
					<>4__this.ShakeCamera();
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>4__this.PlayAudioSource(<>4__this.movementAudio);
					<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.MoveToPosition(<>4__this.startPosition, <>4__this.endPosition, <>4__this.movementDuration));
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					<>4__this.StopAudioSource(<>4__this.movementAudio);
					<>2__current = (object)new WaitForSeconds(<>4__this.pauseDuration / 3f);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					<>4__this.SetAnimationDance();
					<>2__current = (object)new WaitForSeconds(<>4__this.pauseDuration / 3f * 2f);
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -1;
					if (<>4__this._isTarget)
					{
						((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.MoveLocalPlayerToMaxwell(<>4__this.suckDuration - 0.1f));
					}
					<>4__this.MoveTargetScrapToTargetTransform(<>4__this.mouthTransform, <>4__this.suckDuration - 0.1f);
					<>2__current = (object)new WaitForSeconds(<>4__this.suckDuration);
					<>1__state = 6;
					return true;
				case 6:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(<>4__this.PlayOneShotSFX(<>4__this.eatSFX));
					<>1__state = 7;
					return true;
				case 7:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(<>4__this.pauseDuration / 3f * 2f);
					<>1__state = 8;
					return true;
				case 8:
					<>1__state = -1;
					<>4__this.SetAnimationIdle();
					<>2__current = (object)new WaitForSeconds(<>4__this.pauseDuration / 3f);
					<>1__state = 9;
					return true;
				case 9:
					<>1__state = -1;
					if (<>4__this._isTarget)
					{
						PlayerUtils.SetLocalPlayerAllowDeathEnabled(enabled: true);
					}
					if (<>4__this._isEvil)
					{
						<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.StartEvilMaxwell());
						<>1__state = 10;
						return true;
					}
					if (<>4__this._isTarget)
					{
						PlayerUtils.SetLocalPlayerMovementEnabled(enabled: true);
					}
					<>4__this.PlayAudioSource(<>4__this.movementAudio);
					<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.MoveToPosition(<>4__this.endPosition, <>4__this.startPosition, <>4__this.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;
					<>4__this.StopAudioSource(<>4__this.movementAudio);
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 13;
					return true;
				case 13:
					<>1__state = -1;
					<>4__this.PlayOneShotSFX(<>4__this.takeOffSFX);
					<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.MoveToPosition(<>4__this.startPosition, <>4__this.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;

			private Vector3 <position>5__1;

			private Rigidbody[] <>s__2;

			private int <>s__3;

			private Rigidbody <rb>5__4;

			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()
			{
				<>s__2 = null;
				<rb>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Expected O, but got Unknown
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Expected O, but got Unknown
				//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>4__this.bodyObject.SetActive(false);
					<>4__this.evilObject.SetActive(true);
					<>4__this.purrAudio.Stop();
					<>4__this.PlayOneShotSFX(<>4__this.evilNoise);
					<>2__current = (object)new WaitForSeconds(1.25f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (<>4__this._isTarget)
					{
						PlayerUtils.SetLocalPlayerMovementEnabled(enabled: true);
					}
					<>2__current = (object)new WaitForSeconds(0.25f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<position>5__1 = ((Component)<>4__this).transform.position;
					<position>5__1.y += 0.31f;
					Utils.CreateExplosion(<position>5__1, spawnExplosionEffect: true, 100, 0f, 6.4f, 6, (CauseOfDeath)3);
					<>4__this.evilObject.transform.SetParent((Transform)null);
					<>4__this.evilObject.AddComponent<DestroyAfterTimeBehaviour>().duration = 15f;
					<>s__2 = <>4__this.evilObject.GetComponentsInChildren<Rigidbody>();
					for (<>s__3 = 0; <>s__3 < <>s__2.Length; <>s__3++)
					{
						<rb>5__4 = <>s__2[<>s__3];
						<rb>5__4.isKinematic = false;
						<rb>5__4.AddExplosionForce(1000f, <>4__this.evilObject.transform.position, 100f);
						<rb>5__4 = null;
					}
					<>s__2 = null;
					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.HasPlayer(PlayerName.Magoroku, PlayerName.PsychoHypnotic))
				{
					_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: Unkn