Decompiled source of AutoScrapper v0.1.1

AutoScrapper.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[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("AutoScrapper")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fcedd3c2d248ab3360e33e0560de8c38f3113900")]
[assembly: AssemblyProduct("AutoScrapper")]
[assembly: AssemblyTitle("AutoScrapper")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AutoScrapper
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("TheAshenWolf.AutoScrapper", "AutoScrapper", "0.1.0")]
	public class AutoScrapper : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "TheAshenWolf.AutoScrapper";

		public const string PLUGIN_AUTHOR = "TheAshenWolf";

		public const string PLUGIN_NAME = "AutoScrapper";

		public const string PLUGIN_VERSION = "0.1.0";

		public AutoScrapperConfig config;

		[Client]
		private void Awake()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			ItemCatalog.SetItemRelationships += new hook_SetItemRelationships(ItemCatalog_SetItemRelationships);
			Interactor.AttemptInteraction += new hook_AttemptInteraction(Interactor_AttemptInteraction);
			if (RiskOfOptionsCompatibility.Enabled)
			{
				RiskOfOptionsCompatibility.SetModDescriptionToken("AUTO_SCRAPPER_MOD_DESCRIPTION");
				RiskOfOptionsCompatibility.SetModIcon();
			}
			NetworkingAPI.RegisterMessageType<ScrapSync>();
		}

		[Client]
		private void OnDestroy()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			ItemCatalog.SetItemRelationships -= new hook_SetItemRelationships(ItemCatalog_SetItemRelationships);
			Interactor.AttemptInteraction -= new hook_AttemptInteraction(Interactor_AttemptInteraction);
		}

		[Client]
		private void ItemCatalog_SetItemRelationships(orig_SetItemRelationships orig, ItemRelationshipProvider[] newProviders)
		{
			orig.Invoke(newProviders);
			config = new AutoScrapperConfig();
		}

		[Client]
		private void Interactor_AttemptInteraction(orig_AttemptInteraction orig, Interactor self, GameObject interactable)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			if (!config.ModEnabled)
			{
				orig.Invoke(self, interactable);
				return;
			}
			if (((Object)interactable).name.StartsWith("Scrapper"))
			{
				CharacterBody component = ((Component)self).GetComponent<CharacterBody>();
				if ((Object)(object)component == (Object)null)
				{
					Debug.LogWarning((object)"AutoScrapper: Local body is null. Cannot scrap items automatically.");
					orig.Invoke(self, interactable);
					return;
				}
				Inventory inventory = component.inventory;
				bool flag = false;
				ScrapperReportCount scrapperReportCount = default(ScrapperReportCount);
				Dictionary<ItemIndex, int> itemsToRemove = new Dictionary<ItemIndex, int>();
				for (int num = inventory.itemAcquisitionOrder.Count - 1; num >= 0; num--)
				{
					ItemIndex val = inventory.itemAcquisitionOrder[num];
					int itemCount = inventory.GetItemCount(val);
					if (itemCount != 0)
					{
						int limit = config.GetLimit(val);
						if (limit > -1)
						{
							ItemDef itemDef = ItemCatalog.GetItemDef(val);
							int count = itemCount - limit;
							if (ScrapItem(itemsToRemove, itemDef, count))
							{
								scrapperReportCount.Add(itemDef.tier, count);
								flag = true;
							}
						}
					}
				}
				if (flag)
				{
					NetMessageExtensions.Send((INetMessage)(object)new ScrapSync(component.networkIdentity.netId, itemsToRemove), (NetworkDestination)2);
					if (config.KeepScrapperClosed)
					{
						return;
					}
				}
			}
			orig.Invoke(self, interactable);
		}

		[Client]
		private bool ScrapItem(Dictionary<ItemIndex, int> itemsToRemove, ItemDef itemDef, int count)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Invalid comparison between Unknown and I4
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (count <= 0)
			{
				return false;
			}
			if (Utility.IsScrap(itemDef.itemIndex))
			{
				return false;
			}
			if (!itemDef.canRemove)
			{
				return false;
			}
			if (itemDef.isConsumed)
			{
				return false;
			}
			if (Utility.BLACKLIST.Contains(((Object)itemDef).name))
			{
				return false;
			}
			ItemTier tier = itemDef.tier;
			ItemIndex scrapItemIndex = Utility.GetScrapItemIndex(tier);
			if ((int)scrapItemIndex == -1)
			{
				return false;
			}
			itemsToRemove.Add(itemDef.itemIndex, count);
			return true;
		}
	}
	public class AutoScrapperConfig
	{
		public Dictionary<NetworkInstanceId, Dictionary<string, bool>> clientGeneralConfigs;

		public Dictionary<NetworkInstanceId, Dictionary<string, int>> clientItemConfigs;

		private ConfigFile _config;

		public Dictionary<ItemIndex, ConfigEntry<int>> configEntries;

		private ConfigEntry<bool> _keepScrapperClosedConfig;

		private ConfigEntry<bool> _modEnabledConfig;

		private ItemIndex[] _whiteItems;

		private ItemIndex[] _greenItems;

		private ItemIndex[] _redItems;

		private ItemIndex[] _yellowItems;

		public bool KeepScrapperClosed => _keepScrapperClosedConfig.Value;

		public bool ModEnabled => _modEnabledConfig.Value;

		public AutoScrapperConfig()
		{
			clientGeneralConfigs = new Dictionary<NetworkInstanceId, Dictionary<string, bool>>();
			clientItemConfigs = new Dictionary<NetworkInstanceId, Dictionary<string, int>>();
			SetupConfig();
		}

		private void SetupConfig()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			GatherItems();
			_config = new ConfigFile(Paths.ConfigPath + "\\TheAshenWolf.AutoScrapper.cfg", true);
			_keepScrapperClosedConfig = _config.Bind<bool>("General", "KeepScrapperClosed", true, new ConfigDescription("If this setting is enabled, the scrapper will not open if it automatically scrapped items. \nYou can always open it with a second interaction.", (AcceptableValueBase)null, Array.Empty<object>()));
			_modEnabledConfig = _config.Bind<bool>("General", "ModEnabled", true, new ConfigDescription("Who likes restarting the game just to see what mod does what, right? \nJust untick this box and the mod won't do anything.", (AcceptableValueBase)null, Array.Empty<object>()));
			if (RiskOfOptionsCompatibility.Enabled)
			{
				RiskOfOptionsCompatibility.AddBoolOption(_modEnabledConfig);
				RiskOfOptionsCompatibility.AddBoolOption(_keepScrapperClosedConfig);
			}
			int capacity = _whiteItems.Length + _greenItems.Length + _redItems.Length + _yellowItems.Length;
			configEntries = new Dictionary<ItemIndex, ConfigEntry<int>>(capacity);
			CreateItemGroupConfigs("White Items", _whiteItems, configEntries);
			CreateItemGroupConfigs("Green Items", _greenItems, configEntries);
			CreateItemGroupConfigs("Red Items", _redItems, configEntries);
			CreateItemGroupConfigs("Yellow Items", _yellowItems, configEntries);
		}

		private void GatherItems()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			_whiteItems = ItemCatalog.tier1ItemList.ToArray();
			_greenItems = ItemCatalog.tier2ItemList.ToArray();
			_redItems = ItemCatalog.tier3ItemList.ToArray();
			_yellowItems = (from def in (IEnumerable<ItemDef>)(object)ItemCatalog.allItemDefs
				where (int)def.tier == 4
				select def.itemIndex).ToArray();
		}

		private void CreateItemGroupConfigs(string section, ItemIndex[] items, Dictionary<ItemIndex, ConfigEntry<int>> itemConfig)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			int num = items.Length;
			for (int i = 0; i < num; i++)
			{
				ItemIndex val = items[i];
				ItemDef itemDef = ItemCatalog.GetItemDef(val);
				if (itemDef.canRemove && !itemDef.isConsumed && !itemDef.hidden && !Utility.IsScrap(val) && !Utility.BLACKLIST.Contains(((Object)itemDef).name))
				{
					int valueOrDefault = ConfigOverrides.defaultOverrides.GetValueOrDefault(((Object)itemDef).name, -1);
					ConfigEntry<int> configEntry = (itemConfig[val] = _config.Bind<int>(section, ((Object)itemDef).name, valueOrDefault, GetDescription(itemDef)));
					if (RiskOfOptionsCompatibility.Enabled)
					{
						RiskOfOptionsCompatibility.AddIntOption(configEntry);
					}
				}
			}
		}

		private ConfigDescription GetDescription(ItemDef item)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			return new ConfigDescription(Utility.GetFormattedName(item) + " <color=#DDDDDD>amount to keep before scrapping.</color> \n\n<i>" + Language.GetString(item.descriptionToken) + "</i> \n\n<color=#DDDDDD>0 = scrap all, -1 = don't scrap</color>", (AcceptableValueBase)null, Array.Empty<object>());
		}

		public int GetLimit(ItemIndex index)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return configEntries.GetValueOrDefault(index, null)?.Value ?? (-1);
		}
	}
	public static class ConfigOverrides
	{
		public static Dictionary<string, int> defaultOverrides = new Dictionary<string, int>
		{
			{ "BleedOnHit", 10 },
			{ "CritGlasses", 9 },
			{ "StickyBomb", 20 },
			{ "Bandolier", 3 },
			{ "BonusGoldPackOnKill", 25 },
			{ "EquipmentMagazine", 254 }
		};
	}
	public static class RiskOfOptionsCompatibility
	{
		private static bool? _isEnabled;

		public static bool Enabled
		{
			get
			{
				bool valueOrDefault = _isEnabled.GetValueOrDefault();
				if (!_isEnabled.HasValue)
				{
					valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
					_isEnabled = valueOrDefault;
				}
				return _isEnabled.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void SetModDescriptionToken(string descriptionToken)
		{
			ModSettingsManager.SetModDescriptionToken(descriptionToken, "TheAshenWolf.AutoScrapper", "AutoScrapper");
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void SetModIcon()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string directoryName = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location);
				string fullName = new DirectoryInfo(directoryName).FullName;
				Texture2D val = new Texture2D(0, 0);
				if (ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(fullName, "icon.png"))))
				{
					Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
					ModSettingsManager.SetModIcon(val2, "TheAshenWolf.AutoScrapper", "AutoScrapper");
				}
				else
				{
					Debug.LogWarning((object)"AutoScrapper: Failed to load icon.png");
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("AutoScrapper: Failed to load icon.png\n" + ex));
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddIntOption(ConfigEntry<int> configEntry)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(configEntry), "TheAshenWolf.AutoScrapper", "AutoScrapper");
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddBoolOption(ConfigEntry<bool> configEntry)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(configEntry), "TheAshenWolf.AutoScrapper", "AutoScrapper");
		}
	}
	public struct ScrapperReportCount
	{
		public int white;

		public int green;

		public int red;

		public int yellow;

		public void Add(ItemTier tier, int count)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected I4, but got Unknown
			switch ((int)tier)
			{
			case 0:
				white += count;
				break;
			case 1:
				green += count;
				break;
			case 2:
				red += count;
				break;
			case 4:
				yellow += count;
				break;
			case 3:
				break;
			}
		}

		public List<string> GetReportParts()
		{
			List<string> list = new List<string>(4);
			if (white > 0)
			{
				list.Add(string.Format(Language.GetString("AUTO_SCRAPPER_WHITE_ITEMS" + ((white > 1) ? "_PLURAL" : "")), white, "<color=#FFFFFF>"));
			}
			if (green > 0)
			{
				list.Add(string.Format(Language.GetString("AUTO_SCRAPPER_GREEN_ITEMS" + ((green > 1) ? "_PLURAL" : "")), green, "<color=#00FF00>"));
			}
			if (red > 0)
			{
				list.Add(string.Format(Language.GetString("AUTO_SCRAPPER_RED_ITEMS" + ((red > 1) ? "_PLURAL" : "")), red, "<color=#FF0000>"));
			}
			if (yellow > 0)
			{
				list.Add(string.Format(Language.GetString("AUTO_SCRAPPER_YELLOW_ITEMS" + ((yellow > 1) ? "_PLURAL" : "")), yellow, "<color=#FFFF00>"));
			}
			return list;
		}
	}
	public class ScrapSync : INetMessage, ISerializableObject
	{
		private NetworkInstanceId _networkId;

		private Dictionary<ItemIndex, int> _itemsToRemove;

		public ScrapSync()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			_networkId = NetworkInstanceId.Invalid;
			_itemsToRemove = new Dictionary<ItemIndex, int>();
		}

		public ScrapSync(NetworkInstanceId networkId, Dictionary<ItemIndex, int> itemsToRemove)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			_networkId = networkId;
			_itemsToRemove = itemsToRemove;
		}

		public void Serialize(NetworkWriter writer)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(_networkId);
			writer.Write(_itemsToRemove.Count);
			foreach (KeyValuePair<ItemIndex, int> item in _itemsToRemove)
			{
				NetworkExtensions.Write(writer, item.Key);
				writer.Write(item.Value);
			}
		}

		public void Deserialize(NetworkReader reader)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			_networkId = reader.ReadNetworkId();
			int num = reader.ReadInt32();
			_itemsToRemove = new Dictionary<ItemIndex, int>(num);
			for (int i = 0; i < num; i++)
			{
				ItemIndex key = NetworkExtensions.ReadItemIndex(reader);
				int value = reader.ReadInt32();
				_itemsToRemove.Add(key, value);
			}
		}

		public void OnReceived()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return;
			}
			GameObject val = NetworkServer.FindLocalObject(_networkId);
			CharacterBody val2 = ((val != null) ? val.GetComponent<CharacterBody>() : null);
			if ((Object)(object)val2 == (Object)null)
			{
				Debug.LogWarning((object)"AutoScrapper: Local body is null. Cannot scrap items automatically.");
				return;
			}
			Inventory inventory = val2.inventory;
			if ((Object)(object)inventory == (Object)null)
			{
				Debug.LogWarning((object)"AutoScrapper: Local inventory is null. Cannot scrap items automatically.");
				return;
			}
			ScrapperReportCount count = default(ScrapperReportCount);
			foreach (var (val4, num2) in _itemsToRemove)
			{
				count.Add(ItemCatalog.GetItemDef(val4).tier, num2);
				inventory.RemoveItem(val4, num2);
			}
			if (count.white > 0)
			{
				inventory.GiveItem(Items.ScrapWhite.itemIndex, count.white);
			}
			if (count.green > 0)
			{
				inventory.GiveItem(Items.ScrapGreen.itemIndex, count.green);
			}
			if (count.red > 0)
			{
				inventory.GiveItem(Items.ScrapRed.itemIndex, count.red);
			}
			if (count.yellow > 0)
			{
				inventory.GiveItem(Items.ScrapYellow.itemIndex, count.yellow);
			}
			Utility.ReportResults(val2.GetUserName(), count);
		}
	}
	public static class Utility
	{
		public const string COLOR_TEXT = "<color=#DDDDDD>";

		public const string COLOR_WHITE = "<color=#FFFFFF>";

		public const string COLOR_GREEN = "<color=#00FF00>";

		public const string COLOR_RED = "<color=#FF0000>";

		public const string COLOR_YELLOW = "<color=#FFFF00>";

		public const string COLOR_PLAYER = "<color=#2083fc>";

		public static readonly string[] BLACKLIST = new string[1] { "ArtifactKey" };

		public static ItemIndex GetScrapItemIndex(ItemTier tier)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected I4, but got Unknown
			//IL_0026: 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)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (1 == 0)
			{
			}
			ItemIndex result = (ItemIndex)((int)tier switch
			{
				0 => Items.ScrapWhite.itemIndex, 
				1 => Items.ScrapGreen.itemIndex, 
				2 => Items.ScrapRed.itemIndex, 
				4 => Items.ScrapYellow.itemIndex, 
				_ => -1, 
			});
			if (1 == 0)
			{
			}
			return result;
		}

		public static bool IsScrap(ItemIndex index)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			return index == Items.ScrapWhite.itemIndex || index == Items.ScrapGreen.itemIndex || index == Items.ScrapRed.itemIndex || index == Items.ScrapYellow.itemIndex;
		}

		public static string GetFormattedName(ItemDef item)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected I4, but got Unknown
			ItemTier tier = item.tier;
			if (1 == 0)
			{
			}
			string text = (int)tier switch
			{
				0 => "<color=#FFFFFF>", 
				1 => "<color=#00FF00>", 
				2 => "<color=#FF0000>", 
				4 => "<color=#FFFF00>", 
				_ => "<color=#FFFFFF>", 
			};
			if (1 == 0)
			{
			}
			string text2 = text;
			return text2 + Language.GetString(item.nameToken) + "</color>";
		}

		public static void ReportResults(string userName, ScrapperReportCount count)
		{
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Expected O, but got Unknown
			List<string> reportParts = count.GetReportParts();
			int count2 = reportParts.Count;
			if (count2 == 0)
			{
				return;
			}
			string text = "<color=#2083fc>" + userName + "</color> <color=#DDDDDD>" + Language.GetString("AUTO_SCRAPPER_AUTOMAGICALLY_SCRAPPED") + " ";
			if (count2 == 1)
			{
				text = text + reportParts[0] + ".";
			}
			else if (count2 == 2)
			{
				text = text + reportParts[0] + " " + Language.GetString("AUTO_SCRAPPER_AND") + " " + reportParts[1] + ".";
			}
			else if (count2 > 2)
			{
				for (int i = 0; i < count2; i++)
				{
					if (i > 0)
					{
						text = ((i != count2 - 1) ? (text + ", ") : (text + ", " + Language.GetString("AUTO_SCRAPPER_AND") + " "));
					}
					text += reportParts[i];
				}
				text += ".";
			}
			text += "</color>";
			SimpleChatMessage val = new SimpleChatMessage();
			val.baseToken = text;
			Chat.SendBroadcastChat((ChatMessageBase)(object)val);
		}
	}
}