Decompiled source of MarkForScrap v1.0.1

MarkForScrap.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using MarkForScrap.Resources;
using MarkForScrap.Utils;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.UI;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: AssemblyTitle("MarkForScrap")]
[assembly: AssemblyProduct("MarkForScrap")]
[assembly: AssemblyInformationalVersion("1.0.0+57a0b032167c754835d61a13fad3a0fc7828bcbe")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCompany("MarkForScrap")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MarkForScrap
{
	[RequireComponent(typeof(NetworkUser))]
	[DisallowMultipleComponent]
	public class InventoryScrapCounter : NetworkBehaviour
	{
		private NetworkUser networkUser;

		private Inventory inventory;

		private readonly SyncListBool markedForScrap = new SyncListBool();

		private static int kListmarkedForScrap;

		private static int kCmdCmdSetItemMark;

		public void Awake()
		{
			networkUser = ((Component)this).GetComponent<NetworkUser>();
			CharacterMaster.onStartGlobal += OnCharacterMasterStart;
			((SyncList<bool>)(object)markedForScrap).InitializeBehaviour((NetworkBehaviour)(object)this, kListmarkedForScrap);
		}

		[ServerCallback]
		public void Start()
		{
			if (NetworkServer.active && ((NetworkBehaviour)this).isServer)
			{
				((SyncList<bool>)(object)markedForScrap).Clear();
				for (int i = 0; i < ItemCatalog.itemCount; i++)
				{
					((SyncList<bool>)(object)markedForScrap).Add(false);
				}
			}
		}

		public void OnCharacterMasterStart(CharacterMaster master)
		{
			PlayerCharacterMasterController playerCharacterMasterController = master.playerCharacterMasterController;
			if (Object.op_Implicit((Object)(object)playerCharacterMasterController) && (Object)(object)playerCharacterMasterController.networkUser == (Object)(object)networkUser)
			{
				inventory = playerCharacterMasterController.master.inventory;
			}
			if (Object.op_Implicit((Object)(object)inventory) && ((NetworkBehaviour)this).isServer)
			{
				inventory.onInventoryChanged += SyncScrapCountWithInventory;
			}
		}

		public void MarkItem(ItemIndex idx)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			CallCmdSetItemMark(idx, marked: true);
		}

		public void UnmarkItem(ItemIndex idx)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			CallCmdSetItemMark(idx, marked: false);
		}

		public void FlipMark(ItemIndex idx)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if (IsMarked(idx))
			{
				UnmarkItem(idx);
			}
			else
			{
				MarkItem(idx);
			}
		}

		public bool IsMarked(ItemIndex idx)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected I4, but got Unknown
			if ((int)idx >= ((SyncList<bool>)(object)markedForScrap).Count)
			{
				return false;
			}
			return ((SyncList<bool>)(object)markedForScrap)[(int)idx];
		}

		public bool HasItemsToScrap()
		{
			for (int i = 0; i < ((SyncList<bool>)(object)markedForScrap).Count; i++)
			{
				if (((SyncList<bool>)(object)markedForScrap)[i])
				{
					return true;
				}
			}
			return false;
		}

		[Command]
		private void CmdSetItemMark(ItemIndex idx, bool marked)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected I4, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (ItemUtils.IsScrappable(idx))
			{
				int num = (int)idx;
				while (num >= ((SyncList<bool>)(object)markedForScrap).Count)
				{
					((SyncList<bool>)(object)markedForScrap).Add(false);
				}
				if (((SyncList<bool>)(object)markedForScrap)[num] != marked)
				{
					((SyncList<bool>)(object)markedForScrap)[num] = marked;
				}
				MarkForScrapPlugin.Log.LogDebug((object)$"ScrapCounter.CmdSetItemMark() | {idx} : {marked}");
			}
		}

		[Server]
		private void SyncScrapCountWithInventory()
		{
			if (!NetworkServer.active)
			{
				Debug.LogWarning((object)"[Server] function 'System.Void MarkForScrap.InventoryScrapCounter::SyncScrapCountWithInventory()' called on client");
				return;
			}
			for (int i = 0; i < ((SyncList<bool>)(object)markedForScrap).Count; i++)
			{
				if (((SyncList<bool>)(object)markedForScrap)[i] && inventory.GetItemCount((ItemIndex)i) == 0)
				{
					((SyncList<bool>)(object)markedForScrap)[i] = false;
				}
			}
		}

		[Server]
		public ItemIndex Take()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Debug.LogWarning((object)"[Server] function 'RoR2.ItemIndex MarkForScrap.InventoryScrapCounter::Take()' called on client");
				return default(ItemIndex);
			}
			MarkForScrapPlugin.Log.LogDebug((object)"ScrapCounter.Take()");
			if (!HasItemsToScrap())
			{
				throw new Exception("No items marked for scrap");
			}
			int i;
			for (i = 0; i < ((SyncList<bool>)(object)markedForScrap).Count && !((SyncList<bool>)(object)markedForScrap)[i]; i++)
			{
			}
			return (ItemIndex)i;
		}

		private void UNetVersion()
		{
		}

		protected static void InvokeSyncListmarkedForScrap(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"SyncList markedForScrap called on server.");
			}
			else
			{
				((SyncList<bool>)(object)((InventoryScrapCounter)(object)obj).markedForScrap).HandleMsg(reader);
			}
		}

		protected static void InvokeCmdCmdSetItemMark(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"Command CmdSetItemMark called on client.");
			}
			else
			{
				((InventoryScrapCounter)(object)obj).CmdSetItemMark((ItemIndex)reader.ReadInt32(), reader.ReadBoolean());
			}
		}

		public void CallCmdSetItemMark(ItemIndex idx, bool marked)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected I4, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"Command function CmdSetItemMark called on server.");
				return;
			}
			if (((NetworkBehaviour)this).isServer)
			{
				CmdSetItemMark(idx, marked);
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)5);
			val.WritePackedUInt32((uint)kCmdCmdSetItemMark);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			val.Write((int)idx);
			val.Write(marked);
			((NetworkBehaviour)this).SendCommandInternal(val, 0, "CmdSetItemMark");
		}

		static InventoryScrapCounter()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			kCmdCmdSetItemMark = -1563546117;
			NetworkBehaviour.RegisterCommandDelegate(typeof(InventoryScrapCounter), kCmdCmdSetItemMark, new CmdDelegate(InvokeCmdCmdSetItemMark));
			kListmarkedForScrap = -291689635;
			NetworkBehaviour.RegisterSyncListDelegate(typeof(InventoryScrapCounter), kListmarkedForScrap, new CmdDelegate(InvokeSyncListmarkedForScrap));
			NetworkCRC.RegisterBehaviour("InventoryScrapCounter", 0);
		}

		public override bool OnSerialize(NetworkWriter writer, bool forceAll)
		{
			if (forceAll)
			{
				SyncListBool.WriteInstance(writer, markedForScrap);
				return true;
			}
			bool flag = false;
			if ((((NetworkBehaviour)this).syncVarDirtyBits & (true ? 1u : 0u)) != 0)
			{
				if (!flag)
				{
					writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
					flag = true;
				}
				SyncListBool.WriteInstance(writer, markedForScrap);
			}
			if (!flag)
			{
				writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
			}
			return flag;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
			if (initialState)
			{
				SyncListBool.ReadReference(reader, markedForScrap);
				return;
			}
			int num = (int)reader.ReadPackedUInt32();
			if (((uint)num & (true ? 1u : 0u)) != 0)
			{
				SyncListBool.ReadReference(reader, markedForScrap);
			}
		}
	}
	[DisallowMultipleComponent]
	[RequireComponent(typeof(ItemIcon))]
	public class ItemIconScrapSelector : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		private ItemIcon icon;

		private static Sprite markSprite;

		private Image image;

		private Image imageShadow;

		private bool isHover = false;

		public ItemIndex idx => icon.itemIndex;

		public void Awake()
		{
			icon = ((Component)this).GetComponent<ItemIcon>();
			InitUI();
		}

		public void Update()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			if (isHover && PatchedKeyboardShortcut.IsDown(PluginConfig.ToggleScrapKey.Value) && ItemUtils.IsScrappable(idx))
			{
				InventoryScrapCounter scrapCounter = LocalUser.scrapCounter;
				if (Object.op_Implicit((Object)(object)scrapCounter))
				{
					scrapCounter.FlipMark(idx);
					MarkForScrapPlugin.Log.LogDebug((object)$"Scrappable.Update() | Item: {idx}, IsMarked: {scrapCounter.IsMarked(idx)}");
				}
			}
		}

		public void LateUpdate()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			InventoryScrapCounter scrapCounter = LocalUser.scrapCounter;
			bool enabled = Object.op_Implicit((Object)(object)scrapCounter) && scrapCounter.IsMarked(idx);
			((Behaviour)image).enabled = enabled;
			((Behaviour)imageShadow).enabled = enabled;
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			isHover = true;
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			isHover = false;
		}

		public void EnsureSprite()
		{
			if (!Object.op_Implicit((Object)(object)markSprite))
			{
				markSprite = Assets.Load<Sprite>("Assets/icon-scrapper.png");
			}
		}

		public void InitUI()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_0097: 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_00af: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			EnsureSprite();
			GameObject val = new GameObject("ScrapOverlay");
			val.transform.SetParent(((Component)this).transform, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(0.05f, 0.05f);
			val2.anchorMax = new Vector2(0.95f, 0.95f);
			val2.offsetMin = Vector2.zero;
			val2.offsetMax = Vector2.zero;
			GameObject val3 = new GameObject("imageShadowOverlay");
			val3.transform.SetParent(val.transform, false);
			RectTransform val4 = val3.AddComponent<RectTransform>();
			val4.anchorMin = Vector2.zero;
			val4.anchorMax = Vector2.one;
			val4.offsetMin = Vector2.zero;
			val4.offsetMax = Vector2.zero;
			((Transform)val4).localPosition = new Vector3(2f, -9f, 0f);
			imageShadow = val3.AddComponent<Image>();
			imageShadow.sprite = markSprite;
			((Graphic)imageShadow).color = new Color(0f, 0f, 0f, 1f);
			GameObject val5 = new GameObject("imageOverlay");
			val5.transform.SetParent(val.transform, false);
			RectTransform val6 = val5.AddComponent<RectTransform>();
			val6.anchorMin = Vector2.zero;
			val6.anchorMax = Vector2.one;
			val6.offsetMin = Vector2.zero;
			val6.offsetMax = Vector2.zero;
			((Transform)val6).localPosition = new Vector3(0f, -8f, 0.1f);
			image = val5.AddComponent<Image>();
			image.sprite = markSprite;
			((Behaviour)imageShadow).enabled = false;
			((Behaviour)image).enabled = false;
		}
	}
	[BepInPlugin("com.eviegc.MarkForScrap", "MarkForScrap", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MarkForScrapPlugin : BaseUnityPlugin
	{
		private sealed class MainInventoryMarker : MonoBehaviour
		{
		}

		internal static ManualLogSource Log;

		public void Awake()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Assets.LoadAssets();
			InitConfig();
			HUD.Awake += new hook_Awake(HUD_Awake);
			ItemIcon.Awake += new hook_Awake(ItemIcon_Awake);
			NetworkUser.OnEnable += new hook_OnEnable(NetworkUser_OnEnable);
			Interactor.PerformInteraction += new hook_PerformInteraction(Interactor_PerformInteraction);
		}

		public 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
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			HUD.Awake -= new hook_Awake(HUD_Awake);
			ItemIcon.Awake -= new hook_Awake(ItemIcon_Awake);
			NetworkUser.OnEnable -= new hook_OnEnable(NetworkUser_OnEnable);
			Interactor.PerformInteraction -= new hook_PerformInteraction(Interactor_PerformInteraction);
		}

		private void Interactor_PerformInteraction(orig_PerformInteraction orig, Interactor activator, GameObject interactableObject)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				orig.Invoke(activator, interactableObject);
				return;
			}
			ScrapperController componentInParent = interactableObject.GetComponentInParent<ScrapperController>();
			if (!Object.op_Implicit((Object)(object)componentInParent))
			{
				orig.Invoke(activator, interactableObject);
				return;
			}
			CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
			NetworkUser val = (Object.op_Implicit((Object)(object)component) ? Util.LookUpBodyNetworkUser(component) : null);
			InventoryScrapCounter inventoryScrapCounter = ((val != null) ? ((Component)val).GetComponent<InventoryScrapCounter>() : null);
			if (!Object.op_Implicit((Object)(object)inventoryScrapCounter) || !inventoryScrapCounter.HasItemsToScrap())
			{
				orig.Invoke(activator, interactableObject);
				return;
			}
			ItemIndex val2 = inventoryScrapCounter.Take();
			((BaseUnityPlugin)this).Logger.LogDebug((object)$"MarkForScrapPlugin.Interactor_PerformInteraction() | Took {val2}");
			PickupIndex val3 = PickupCatalog.FindPickupIndex(val2);
			componentInParent.AssignPotentialInteractor(activator);
			componentInParent.BeginScrapping(val3.value);
		}

		private void NetworkUser_OnEnable(orig_OnEnable orig, NetworkUser self)
		{
			orig.Invoke(self);
			if (!Object.op_Implicit((Object)(object)((Component)self).GetComponent<InventoryScrapCounter>()))
			{
				((BaseUnityPlugin)this).Logger.LogDebug((object)"MarkForScrapPlugin.NetworkUser_OnEnable() | Adding InventoryScrapCounter");
				((Component)self).gameObject.AddComponent<InventoryScrapCounter>();
			}
		}

		private void HUD_Awake(orig_Awake orig, HUD self)
		{
			orig.Invoke(self);
			if (NetworkClient.active)
			{
				ItemInventoryDisplay itemInventoryDisplay = self.itemInventoryDisplay;
				if (!Object.op_Implicit((Object)(object)((Component)itemInventoryDisplay).gameObject.GetComponent<MainInventoryMarker>()))
				{
					((Component)itemInventoryDisplay).gameObject.AddComponent<MainInventoryMarker>();
				}
			}
		}

		private void ItemIcon_Awake(orig_Awake orig, ItemIcon self)
		{
			orig.Invoke(self);
			if (NetworkClient.active && Object.op_Implicit((Object)(object)((Component)self).GetComponentInParent<MainInventoryMarker>()))
			{
				((BaseUnityPlugin)this).Logger.LogDebug((object)"MarkForScrapPlugin.ItemIcon_Awake() | Got ItemIcon the main inventory");
				if (!Object.op_Implicit((Object)(object)((Component)self).GetComponent<ItemIconScrapSelector>()))
				{
					((Component)self).gameObject.AddComponent<ItemIconScrapSelector>();
				}
			}
		}

		private void InitConfig()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			ModSettingsManager.SetModDescription("Allows you to pre-select items from your inventory you want to automatically scrap the next time you use a scrapper.");
			Sprite modIcon = Assets.Load<Sprite>("Assets/icon.png");
			ModSettingsManager.SetModIcon(modIcon);
			PluginConfig.ToggleScrapKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Input", "Toggle item for scrap", new KeyboardShortcut((KeyCode)116, Array.Empty<KeyCode>()), "When mouse hovering over an item in the top bar, pressing this key will (un)mark it for scrapping.");
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(PluginConfig.ToggleScrapKey));
		}
	}
	public class PluginConfig
	{
		public static ConfigEntry<KeyboardShortcut> ToggleScrapKey;
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.eviegc.MarkForScrap";

		public const string PLUGIN_NAME = "MarkForScrap";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace MarkForScrap.Utils
{
	public static class ItemUtils
	{
		public static bool IsScrappable(ItemIndex idx)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Invalid comparison between Unknown and I4
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Invalid comparison between Unknown and I4
			ItemDef itemDef = ItemCatalog.GetItemDef(idx);
			if ((Object)(object)itemDef == (Object)null)
			{
				return false;
			}
			if (itemDef.ContainsTag((ItemTag)10))
			{
				return false;
			}
			if (itemDef.ContainsTag((ItemTag)9))
			{
				return false;
			}
			if (itemDef.hidden)
			{
				return false;
			}
			ItemTier tier = itemDef.tier;
			ItemTier val = tier;
			if ((int)val <= 2 || (int)val == 4)
			{
				return true;
			}
			return false;
		}
	}
	public static class PatchedKeyboardShortcut
	{
		public static bool IsDown(KeyboardShortcut shortcut)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_001b: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			KeyCode mainKey = ((KeyboardShortcut)(ref shortcut)).MainKey;
			if ((int)mainKey == 0)
			{
				return false;
			}
			if (UnityInput.Current.GetKeyDown(mainKey))
			{
				foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers)
				{
					if ((int)modifier != 0 && !UnityInput.Current.GetKey(modifier))
					{
						return false;
					}
				}
				return true;
			}
			return false;
		}
	}
	public static class LocalUser
	{
		public static NetworkUser networkUser
		{
			get
			{
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				return (firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null;
			}
		}

		public static CharacterMaster master
		{
			get
			{
				NetworkUser obj = networkUser;
				return (obj != null) ? obj.master : null;
			}
		}

		public static InventoryScrapCounter scrapCounter
		{
			get
			{
				NetworkUser obj = networkUser;
				return (obj != null) ? ((Component)obj).GetComponent<InventoryScrapCounter>() : null;
			}
		}
	}
}
namespace MarkForScrap.Resources
{
	internal static class Assets
	{
		private static AssetBundle _mainAssetBundle;

		internal static T Load<T>(string asset) where T : Object
		{
			return _mainAssetBundle.LoadAsset<T>(asset);
		}

		internal static void LoadAssets()
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MarkForScrap.Resources.AssetBundles.markforscrap");
			_mainAssetBundle = AssetBundle.LoadFromStream(stream);
		}
	}
}