Decompiled source of Melanie Crafting Core v1.0.1

MelanieMeliciousCraft.dll

Decompiled 9 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dawn;
using GameNetcodeStuff;
using HarmonyLib;
using InjectionLibrary.Attributes;
using MelanieMeliciousCraft.NetcodePatcher;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RequiresInjections]
[assembly: AssemblyTitle("MelanieMeliciousCraft")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("MelanieMelicious")]
[assembly: AssemblyProduct("Melanie Crafting Progression Core")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
[CompilerGenerated]
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
	{
		object IEnumerator.Current => _item;

		T IEnumerator<T>.Current => _item;

		public Enumerator(T item)
		{
			_item = item;
		}

		bool IEnumerator.MoveNext()
		{
			return !_moveNextCalled && (_moveNextCalled = true);
		}

		void IEnumerator.Reset()
		{
			_moveNextCalled = false;
		}

		void IDisposable.Dispose()
		{
		}
	}

	int ICollection.Count => 1;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => 1;

	T IReadOnlyList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
	}

	int ICollection<T>.Count => 1;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlySingleElementList(T item)
	{
		_item = item;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection.CopyTo(Array array, int index)
	{
		array.SetValue(_item, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return EqualityComparer<T>.Default.Equals(_item, (T)value);
	}

	int IList.IndexOf(object value)
	{
		return (!EqualityComparer<T>.Default.Equals(_item, (T)value)) ? (-1) : 0;
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return EqualityComparer<T>.Default.Equals(_item, item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		array[arrayIndex] = _item;
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		return (!EqualityComparer<T>.Default.Equals(_item, item)) ? (-1) : 0;
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
internal static class MelanieCraftCfg
{
	internal static ConfigEntry<int> workbench0Cost;

	internal static ConfigEntry<float> craftMin;

	internal static ConfigEntry<float> craftMax;

	internal static ConfigEntry<int> refineMin;

	internal static ConfigEntry<int> refineMax;

	internal static ConfigEntry<string> hammerList;

	internal static ConfigEntry<string> sawList;

	internal static ConfigEntry<string> axeList;

	internal static ConfigEntry<string> logList;

	internal static ConfigEntry<string> plankList;

	internal static ConfigEntry<string> metalSheetList;

	internal static ConfigEntry<bool> rakeEnable;

	internal static ConfigEntry<int> rakeSpawn0;

	internal static ConfigEntry<string> rakeSpawn1;

	internal static ConfigEntry<string> rakeSpawn2;

	internal static ConfigEntry<int> hammer0Spawn;

	internal static ConfigEntry<int> saw0Spawn;

	internal static ConfigEntry<int> axe0Spawn;

	internal static ConfigEntry<int> hammer0Cost;

	internal static ConfigEntry<int> saw0Cost;

	internal static ConfigEntry<int> axe0Cost;

	internal static void SetupConfig(ConfigFile config)
	{
		workbench0Cost = config.Bind<int>("Prices", "Workbench", 120, "Modify the price for the workbench.");
		craftMin = config.Bind<float>("Item Value", "Crafting Value Minimum", 10f, "Directly change the first random range value (usually minimum) for how much value is added when crafting.");
		craftMax = config.Bind<float>("Item Value", "Crafting Value Maximum MULTIPLIER", 0.25f, "Change the multiplier applied to the second random range value (usually maximum) applied to a copy of total craft value.");
		refineMin = config.Bind<int>("Item Value", "Refine Value Minimum", 0, "Change the minimum value added when refining.");
		refineMax = config.Bind<int>("Item Value", "Refine Value Maximum", 20, "Change the maximum value added when refining.");
		hammerList = config.Bind<string>("Custom Tools", "Works as Hammer", "", "This is hammer.");
		sawList = config.Bind<string>("Custom Tools", "Works as Saw", "", "This is saw.");
		axeList = config.Bind<string>("Custom Tools", "Works as Axe", "", "This item can chop down trees. (Not 100% drop rate!)");
		logList = config.Bind<string>("Custom Ingredients", "Craft as Log", "", "This is log.");
		plankList = config.Bind<string>("Custom Ingredients", "Craft as Plank", "", "This is plank.");
		metalSheetList = config.Bind<string>("Custom Ingredients", "Craft as Metal Sheet", "", "This is metal sheet.");
		rakeEnable = config.Bind<bool>("Hazard Spawn", "Rake Traps Enabled", true, "Modify if rake traps spawn.");
		rakeSpawn0 = config.Bind<int>("Hazard Spawn", "Rake Trap Global", 8, "Modify the weights for rake traps spawning on any moon.");
		rakeSpawn1 = config.Bind<string>("Hazard Spawn", "Rake Trap By Tag", "lethal_company:wasteland:10,lethal_company:marsh:10", "Modify the weights for rake traps spawning on moons with certain tags.");
		rakeSpawn2 = config.Bind<string>("Hazard Spawn", "Rake Trap By Key", "", "Modify the weights for rake traps spawning on moons by certain keys.");
		hammer0Spawn = config.Bind<int>("Scrap Spawn", "Hammer Global Spawns", 40, "Modify the weights for hammers to spawn as scrap.");
		saw0Spawn = config.Bind<int>("Scrap Spawn", "Saw Global Spawns", 30, "Modify the weights for saw to spawn as scrap.");
		axe0Spawn = config.Bind<int>("Scrap Spawn", "Axe Global Spawns", 30, "Modify the weights for axe to spawn as scrap.");
		hammer0Cost = config.Bind<int>("Store Setup", "Hammer Price", -1, "Modify the price for hammers in the store. Set -1 to not register into the store.");
		saw0Cost = config.Bind<int>("Store Setup", "Saw Price", -1, "Modify the price for saws in the store. Set -1 to not register into the store.");
		axe0Cost = config.Bind<int>("Store Setup", "Axe Price", -1, "Modify the price for axes in the store. Set -1 to not register into the store.");
	}
}
namespace MelMelCraft
{
	public class Crafter : NetworkBehaviour
	{
		public List<short> tools = new List<short>();

		public Transform spawnPos;

		public Recipe[] recipeList;

		public float craftMin;

		public float craftMax;

		public void Craft()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			List<NetworkObject> list = new List<NetworkObject>();
			List<short[]> list2 = new List<short[]>();
			int num = 0;
			short num2 = 0;
			bool flag = false;
			Ingredient ingredient = default(Ingredient);
			GrabbableObject val2 = default(GrabbableObject);
			foreach (Transform item2 in ((Component)this).transform)
			{
				Transform val = item2;
				if (!((Component)val).TryGetComponent<Ingredient>(ref ingredient) || !((Component)val).TryGetComponent<GrabbableObject>(ref val2))
				{
					continue;
				}
				foreach (short item3 in ingredient.ingredient)
				{
					flag = false;
					foreach (short[] item4 in list2)
					{
						if (item4[0] == item3)
						{
							item4[1]++;
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						list2.Add(new short[2] { item3, 1 });
					}
				}
				if (ingredient.consumable)
				{
					list.Add(((Component)val).GetComponent<NetworkObject>());
					num += val2.scrapValue;
				}
				num2++;
			}
			if (num2 == 0)
			{
				return;
			}
			Recipe[] array = recipeList;
			foreach (Recipe recipe in array)
			{
				if (num2 < recipe.min || num2 > recipe.max)
				{
					continue;
				}
				flag = true;
				short[] array2 = recipe.tools;
				foreach (short item in array2)
				{
					if (!tools.Contains(item))
					{
						flag = false;
						break;
					}
				}
				if (!flag)
				{
					continue;
				}
				short[][] ingredients = recipe.ingredients;
				foreach (short[] array3 in ingredients)
				{
					flag = false;
					foreach (short[] item5 in list2)
					{
						if (item5[0] == array3[0] && item5[1] >= array3[1])
						{
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						break;
					}
				}
				if (!flag)
				{
					continue;
				}
				for (int l = 0; l < recipe.quantity; l++)
				{
					SpawnItemServerRpc(Array.IndexOf(recipeList, recipe), (int)((float)num + Random.Range(craftMin, (float)num * craftMax)) / recipe.quantity);
				}
				{
					foreach (NetworkObject item6 in list)
					{
						if ((Object)(object)item6 != (Object)null)
						{
							DeleteItemServerRpc(NetworkObjectReference.op_Implicit(item6));
						}
					}
					break;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		internal void DeleteItemServerRpc(NetworkObjectReference netObj)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1677710912u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netObj, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1677710912u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				NetworkObject val3 = default(NetworkObject);
				if (((NetworkObjectReference)(ref netObj)).TryGet(ref val3, (NetworkManager)null))
				{
					val3.Despawn(true);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SpawnItemServerRpc(int itemList, int dishValue)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2569922090u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, itemList);
					BytePacker.WriteValueBitPacked(val2, dishValue);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2569922090u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					GameObject val3 = Object.Instantiate<GameObject>(recipeList[itemList].product.spawnPrefab, spawnPos.position, spawnPos.rotation, spawnPos);
					val3.GetComponent<NetworkObject>().Spawn(false);
					SpawnItemClientRpc(NetworkObjectReference.op_Implicit(val3.GetComponent<NetworkObject>()), dishValue);
				}
			}
		}

		[ClientRpc]
		private void SpawnItemClientRpc(NetworkObjectReference netObjRef, int value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(531173574u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netObjRef, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, value);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 531173574u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				NetworkObject val3 = default(NetworkObject);
				if (((NetworkObjectReference)(ref netObjRef)).TryGet(ref val3, (NetworkManager)null))
				{
					((Component)val3).GetComponent<GrabbableObject>().SetScrapValue(value);
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1677710912u, new RpcReceiveHandler(__rpc_handler_1677710912), "DeleteItemServerRpc");
			((NetworkBehaviour)this).__registerRpc(2569922090u, new RpcReceiveHandler(__rpc_handler_2569922090), "SpawnItemServerRpc");
			((NetworkBehaviour)this).__registerRpc(531173574u, new RpcReceiveHandler(__rpc_handler_531173574), "SpawnItemClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_1677710912(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference netObj = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netObj, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Crafter)(object)target).DeleteItemServerRpc(netObj);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2569922090(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int itemList = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemList);
				int dishValue = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref dishValue);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Crafter)(object)target).SpawnItemServerRpc(itemList, dishValue);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_531173574(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_005c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference netObjRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netObjRef, default(ForNetworkSerializable));
				int value = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref value);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Crafter)(object)target).SpawnItemClientRpc(netObjRef, value);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "Crafter";
		}
	}
	public class GlobalSpawner : NetworkBehaviour
	{
		public static GlobalSpawner Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)Instance).gameObject);
			}
			Instance = this;
		}

		[ServerRpc(RequireOwnership = false)]
		public void SpawnItemServerRpc(int itemList, float posX, float posY, float posZ)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_008a: 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)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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)
			//IL_00da: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4034897490u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, itemList);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref posX, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref posY, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref posZ, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4034897490u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					Item val3 = Plugin.itemList[itemList];
					GameObject val4 = Object.Instantiate<GameObject>(val3.spawnPrefab, new Vector3(posX, posY, posZ), Quaternion.identity, RoundManager.Instance.spawnedScrapContainer);
					val4.GetComponent<NetworkObject>().Spawn(false);
					SpawnItemClientRpc(NetworkObjectReference.op_Implicit(val4.GetComponent<NetworkObject>()), Random.Range(val3.minValue, val3.maxValue));
				}
			}
		}

		[ClientRpc]
		private void SpawnItemClientRpc(NetworkObjectReference netObjRef, int value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(978084037u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netObjRef, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, value);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 978084037u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				NetworkObject val3 = default(NetworkObject);
				if (((NetworkObjectReference)(ref netObjRef)).TryGet(ref val3, (NetworkManager)null))
				{
					((Component)val3).GetComponent<GrabbableObject>().SetScrapValue(value);
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(4034897490u, new RpcReceiveHandler(__rpc_handler_4034897490), "SpawnItemServerRpc");
			((NetworkBehaviour)this).__registerRpc(978084037u, new RpcReceiveHandler(__rpc_handler_978084037), "SpawnItemClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_4034897490(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int itemList = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemList);
				float posX = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref posX, default(ForPrimitives));
				float posY = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref posY, default(ForPrimitives));
				float posZ = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref posZ, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((GlobalSpawner)(object)target).SpawnItemServerRpc(itemList, posX, posY, posZ);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_978084037(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_005c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference netObjRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netObjRef, default(ForNetworkSerializable));
				int value = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref value);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((GlobalSpawner)(object)target).SpawnItemClientRpc(netObjRef, value);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "GlobalSpawner";
		}
	}
	public class HarmonyPatches
	{
		internal static Workbench workbench;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		private static void PostStart(StartOfRound __instance)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (GameNetworkManager.Instance.isHostingGame)
			{
				GameObject val = Object.Instantiate<GameObject>(Plugin.bundle.LoadAsset<GameObject>("Assets/MelanieCrafting/Prefab/MMCraftSpawn.prefab"), Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
				return;
			}
			GrabbableObject[] array = (GrabbableObject[])(object)Object.FindObjectsOfType(typeof(GrabbableObject));
			GrabbableObject[] array2 = array;
			Ingredient ingredient = default(Ingredient);
			foreach (GrabbableObject val2 in array2)
			{
				if ((Object)(object)val2.itemProperties != (Object)null && (Object)(object)val2.itemProperties.spawnPrefab != (Object)null && val2.itemProperties.spawnPrefab.TryGetComponent<Ingredient>(ref ingredient))
				{
					Ingredient ingredient2 = ((Component)val2).gameObject.AddComponent<Ingredient>();
					ingredient2.ingredient = ingredient.ingredient;
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		private static void PreStart()
		{
			if (GameNetworkManager.Instance.isHostingGame)
			{
				workbench = null;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(TerrainObstacleTrigger), "Awake")]
		private static void TreeAwake(TerrainObstacleTrigger __instance)
		{
			((Component)__instance).gameObject.layer = 21;
			((Component)__instance).gameObject.AddComponent<TreeHit>();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(SandSpiderWebTrap), "OnDestroy")]
		private static void WebBreak(SandSpiderWebTrap __instance)
		{
			//IL_000c: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			GlobalSpawner.Instance.SpawnItemServerRpc(0, ((Component)__instance).transform.position.x, ((Component)__instance).transform.position.y + 1f, ((Component)__instance).transform.position.z);
		}
	}
	[InjectInterface(typeof(TerrainObstacleTrigger))]
	public interface IAwake
	{
		void Awake();
	}
	public class Ingredient : MonoBehaviour
	{
		public List<short> ingredient = new List<short>();

		public bool consumable = true;

		public short tool = -1;
	}
	[BepInPlugin("MelanieMelicious.CraftCore", "MelanieMelicious - Crafting Progression Core", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "MelanieMelicious.CraftCore";

		private const string NAME = "MelanieMelicious - Crafting Progression Core";

		private const string VERSION = "1.0.1";

		public const string NAMESPACE = "melaniecrafting";

		private readonly Harmony harmony = new Harmony("MelanieMelicious.CraftCore");

		internal static ManualLogSource mls;

		public static AssetBundle bundle;

		public UnlockablesList unlockList;

		public static List<Item> itemList;

		public static Plugin instance;

		public static List<Recipe> workbench = new List<Recipe>();

		private void Awake()
		{
			instance = this;
			MelanieCraftCfg.SetupConfig(((BaseUnityPlugin)this).Config);
			mls = Logger.CreateLogSource("MelanieMelicious - Crafting Progression Core");
			mls = ((BaseUnityPlugin)this).Logger;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "melaniecrafting");
			bundle = AssetBundle.LoadFromFile(text);
			unlockList = bundle.LoadAsset<UnlockablesList>("Assets/MelanieCrafting/Asset/Unlockable.asset");
			itemList = bundle.LoadAsset<AllItemsList>("Assets/MelanieCrafting/Asset/Item.asset").itemsList;
			harmony.PatchAll(typeof(HarmonyPatches));
			harmony.PatchAll(typeof(SavePatches));
			Unlockable(0, MelanieCraftCfg.workbench0Cost.Value);
			RegisterItem(itemList[0]);
			RegisterItem(itemList[1], MelanieCraftCfg.hammer0Spawn.Value, MelanieCraftCfg.hammer0Cost.Value);
			RegisterItem(itemList[2], MelanieCraftCfg.saw0Spawn.Value, MelanieCraftCfg.saw0Cost.Value);
			RegisterItem(itemList[3]);
			RegisterItem(itemList[4]);
			RegisterItem(itemList[5]);
			RegisterItem(itemList[6]);
			RegisterItem(itemList[7], MelanieCraftCfg.axe0Spawn.Value, MelanieCraftCfg.axe0Cost.Value);
			RegisterItem(itemList[8]);
			RegisterRecipe(workbench, itemList[4], new short[1][] { new short[2] { 19, 1 } }, new short[1] { 1 }, 1, 1, 1, 5);
			RegisterRecipe(workbench, itemList[5], new short[1][] { new short[2] { 20, 1 } }, new short[1] { 1 }, 1, 1, 2, 5);
			RegisterRecipe(workbench, itemList[2], new short[1][] { new short[2] { 27, 2 } }, Array.Empty<short>(), 2, 2, 1, 5);
			RegisterRecipe(workbench, itemList[7], new short[2][]
			{
				new short[2] { 27, 2 },
				new short[2] { 25, 1 }
			}, Array.Empty<short>(), 3, 3, 1, 5);
			if (MelanieCraftCfg.rakeEnable.Value)
			{
				GameObject val = bundle.LoadAsset<GameObject>("Assets/MelanieCrafting/Prefab/Hazard/RakeTrap0.prefab");
				DawnLib.RegisterNetworkPrefab(val);
				DawnLib.DefineMapObject(NamespacedKey<DawnMapObjectInfo>.From("melaniecrafting", "RakeTrap0"), val, (Action<MapObjectInfoBuilder>)delegate(MapObjectInfoBuilder mapObject)
				{
					mapObject.DefineOutside((Action<OutsideBuilder>)delegate(OutsideBuilder outsideBuild)
					{
						outsideBuild.SetWeights((Action<CurveTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(CurveTableBuilder<DawnMoonInfo, SpawnWeightContext> spawnWeight)
						{
							spawnWeight.SetGlobalCurve(AnimationCurve.Constant(0f, 1f, (float)MelanieCraftCfg.rakeSpawn0.Value));
							string[] array = MelanieCraftCfg.rakeSpawn1.Value.Split(',');
							foreach (string text2 in array)
							{
								if (text2 == "")
								{
									break;
								}
								try
								{
									string[] array2 = text2.Split(':');
									spawnWeight.AddTagCurve(NamespacedKey.From(array2[0], array2[1]), AnimationCurve.Constant(0f, 1f, (float)short.Parse(array2[2])));
								}
								catch
								{
									mls.LogError((object)"Invalid config input for rake trap by tag. Skipping this iteration");
								}
							}
							string[] array3 = MelanieCraftCfg.rakeSpawn2.Value.Split(',');
							foreach (string text3 in array3)
							{
								if (text3 == "")
								{
									break;
								}
								try
								{
									string[] array4 = text3.Split(':');
									spawnWeight.AddCurve(NamespacedKey<DawnMoonInfo>.From(array4[0], array4[1]), AnimationCurve.Constant(0f, 1f, (float)short.Parse(array4[2])));
								}
								catch
								{
									mls.LogError((object)"Invalid config input for rake trap by key. Skipping this iteration");
								}
							}
						}).OverrideAlignWithTerrain(true);
					});
				});
			}
			((Registry<DawnItemInfo>)(object)LethalContent.Items).OnFreeze += CustomIngredients;
		}

		public static void RegisterRecipe(List<Recipe> addToCookerRecipes, Item product, short[][] ingredientsAndCount, short[] tools, short min = 3, short max = 3, short productQuantity = 1, short priority = 0)
		{
			addToCookerRecipes.Add(new Recipe
			{
				ingredients = ingredientsAndCount,
				min = min,
				max = max,
				product = product,
				quantity = productQuantity,
				priority = priority,
				tools = tools
			});
		}

		private void RegisterItem(Item item, int weight = 0, int cost = -1)
		{
			NamespacedKey<DawnItemInfo> val = NamespacedKey<DawnItemInfo>.From("melaniecrafting", ((Object)item).name);
			DawnLib.RegisterNetworkPrefab(item.spawnPrefab);
			DawnLib.DefineItem(val, item, (Action<ItemInfoBuilder>)delegate(ItemInfoBuilder itemInfo)
			{
				if (cost != -1)
				{
					itemInfo.DefineShop((Action<ShopBuilder>)delegate(ShopBuilder shop)
					{
						shop.OverrideCost(cost);
					});
				}
				if (weight != 0)
				{
					itemInfo.DefineScrap((Action<ScrapBuilder>)delegate(ScrapBuilder scrap)
					{
						scrap.SetWeights((Action<WeightTableBuilder<DawnMoonInfo, SpawnWeightContext>>)delegate(WeightTableBuilder<DawnMoonInfo, SpawnWeightContext> weights)
						{
							weights.SetGlobalWeight(weight);
						});
					});
				}
			});
		}

		private void CustomIngredients()
		{
			foreach (DawnItemInfo value in ((Registry<DawnItemInfo>)(object)LethalContent.Items).Values)
			{
				Item item = value.Item;
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				string[] array = MelanieCraftCfg.hammerList.Value.Split(',');
				foreach (string text in array)
				{
					if (item.itemName == text)
					{
						AddTool(item, 0);
					}
				}
				string[] array2 = MelanieCraftCfg.sawList.Value.Split(',');
				foreach (string text2 in array2)
				{
					if (item.itemName == text2)
					{
						AddTool(item, 1);
					}
				}
				string[] array3 = MelanieCraftCfg.axeList.Value.Split(',');
				foreach (string text3 in array3)
				{
					if (item.itemName == text3)
					{
						AddTool(item, 2);
					}
				}
				string[] array4 = MelanieCraftCfg.logList.Value.Split(',');
				foreach (string text4 in array4)
				{
					if (item.itemName == text4)
					{
						AddIngredient(item, 19);
					}
				}
				string[] array5 = MelanieCraftCfg.plankList.Value.Split(',');
				foreach (string text5 in array5)
				{
					if (item.itemName == text5)
					{
						AddIngredient(item, 20);
					}
				}
				foreach (string item2 in MelanieCraftCfg.metalSheetList.Value.Split(',').Concat(new <>z__ReadOnlySingleElementList<string>("Metal sheet")))
				{
					if (item.itemName == item2)
					{
						AddIngredient(item, 27);
					}
				}
			}
		}

		private void AddIngredient(Item item, short ID)
		{
			Ingredient ingredient = default(Ingredient);
			if (item.spawnPrefab.TryGetComponent<Ingredient>(ref ingredient))
			{
				ingredient.ingredient.Add(ID);
			}
			else
			{
				item.spawnPrefab.AddComponent<Ingredient>().ingredient.Add(ID);
			}
		}

		private void AddTool(Item item, short ID)
		{
			Ingredient ingredient = default(Ingredient);
			if (!item.spawnPrefab.TryGetComponent<Ingredient>(ref ingredient))
			{
				ingredient = item.spawnPrefab.AddComponent<Ingredient>();
			}
			ingredient.tool = ID;
		}

		private void Unlockable(short ID, int cost)
		{
			DawnLib.RegisterNetworkPrefab(unlockList.unlockables[ID].prefabObject);
			DawnLib.DefineUnlockable(NamespacedKey<DawnUnlockableItemInfo>.From("melaniecrafting", unlockList.unlockables[ID].unlockableName), unlockList.unlockables[ID], (Action<UnlockableInfoBuilder>)delegate(UnlockableInfoBuilder info)
			{
				info.SetCost(cost);
			});
		}
	}
	public class RakeTrap : NetworkBehaviour
	{
		[SerializeField]
		private Animator animator;

		[SerializeField]
		private int damage;

		private const string play = "play";

		public void Hit(PlayerControllerB player)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			HitServerRpc(state: true);
			player.DamagePlayer(damage, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
		}

		public void Hit2()
		{
			HitServerRpc(state: false);
		}

		[ServerRpc(RequireOwnership = false)]
		private void HitServerRpc(bool state)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2237943435u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref state, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2237943435u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					HitClientRpc(state);
				}
			}
		}

		[ClientRpc]
		private void HitClientRpc(bool state)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3834622412u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref state, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3834622412u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					animator.SetBool("play", state);
				}
			}
		}

		public void Dismantle()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			GlobalSpawner.Instance.SpawnItemServerRpc(Random.Range(5, 8), ((Component)this).transform.position.x, ((Component)this).transform.position.y + 1f, ((Component)this).transform.position.z);
			((Component)this).GetComponent<NetworkObject>().Despawn(true);
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2237943435u, new RpcReceiveHandler(__rpc_handler_2237943435), "HitServerRpc");
			((NetworkBehaviour)this).__registerRpc(3834622412u, new RpcReceiveHandler(__rpc_handler_3834622412), "HitClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_2237943435(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool state = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref state, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RakeTrap)(object)target).HitServerRpc(state);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3834622412(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool state = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref state, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((RakeTrap)(object)target).HitClientRpc(state);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "RakeTrap";
		}
	}
	public class Recipe
	{
		internal short[][] ingredients;

		internal short[] tools = new short[0];

		internal short min;

		internal short max;

		internal short quantity;

		internal short priority;

		internal Item product;
	}
	public class Refine : NetworkBehaviour
	{
		public Transform spawnPos;

		public Recipe[] recipeList;

		public float refineMin;

		public float refineMax;

		public void Craft(PlayerControllerB playerWhoTriggered)
		{
			if (!playerWhoTriggered.isHoldingObject)
			{
				return;
			}
			GrabbableObject currentlyHeldObjectServer = playerWhoTriggered.currentlyHeldObjectServer;
			Ingredient ingredient = default(Ingredient);
			if (!((Component)currentlyHeldObjectServer).TryGetComponent<Ingredient>(ref ingredient))
			{
				return;
			}
			Recipe[] array = recipeList;
			foreach (Recipe recipe in array)
			{
				if (ingredient.ingredient.Contains(recipe.ingredients[0][0]))
				{
					for (int j = 0; j < recipe.quantity; j++)
					{
						SpawnItemServerRpc(Array.IndexOf(recipeList, recipe), (int)((float)currentlyHeldObjectServer.scrapValue + Random.Range(refineMin, refineMax)) / recipe.quantity);
					}
					playerWhoTriggered.DespawnHeldObject();
					break;
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SpawnItemServerRpc(int itemList, int dishValue)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(891307308u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, itemList);
					BytePacker.WriteValueBitPacked(val2, dishValue);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 891307308u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					GameObject val3 = Object.Instantiate<GameObject>(recipeList[itemList].product.spawnPrefab, spawnPos.position, spawnPos.rotation, spawnPos);
					val3.GetComponent<NetworkObject>().Spawn(false);
					SpawnItemClientRpc(NetworkObjectReference.op_Implicit(val3.GetComponent<NetworkObject>()), dishValue);
				}
			}
		}

		[ClientRpc]
		private void SpawnItemClientRpc(NetworkObjectReference netObjRef, int value)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1707190453u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netObjRef, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, value);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1707190453u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				NetworkObject val3 = default(NetworkObject);
				if (((NetworkObjectReference)(ref netObjRef)).TryGet(ref val3, (NetworkManager)null))
				{
					((Component)val3).GetComponent<GrabbableObject>().SetScrapValue(value);
				}
			}
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			refineMin = MelanieCraftCfg.refineMin.Value;
			refineMax = MelanieCraftCfg.refineMax.Value;
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(891307308u, new RpcReceiveHandler(__rpc_handler_891307308), "SpawnItemServerRpc");
			((NetworkBehaviour)this).__registerRpc(1707190453u, new RpcReceiveHandler(__rpc_handler_1707190453), "SpawnItemClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_891307308(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int itemList = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref itemList);
				int dishValue = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref dishValue);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Refine)(object)target).SpawnItemServerRpc(itemList, dishValue);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1707190453(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_005c: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference netObjRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netObjRef, default(ForNetworkSerializable));
				int value = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref value);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((Refine)(object)target).SpawnItemClientRpc(netObjRef, value);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "Refine";
		}
	}
	public class SaveCrafter : Crafter
	{
		public List<GameObject> upgrades = new List<GameObject>();

		public List<short> canAddTools = new List<short>();

		private bool synced = false;

		public void AddTool(PlayerControllerB player)
		{
			Ingredient ingredient = default(Ingredient);
			if (player.isHoldingObject && ((Component)player.currentlyHeldObjectServer).TryGetComponent<Ingredient>(ref ingredient) && ingredient.tool != -1 && canAddTools.Contains(ingredient.tool) && !tools.Contains(ingredient.tool))
			{
				AddToolServerRpc(ingredient.tool);
				player.DespawnHeldObject();
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void AddToolServerRpc(short tool)
		{
			//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)
			//IL_00ce: 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 != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3300359901u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, tool);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3300359901u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					AddToolClientRpc(tool);
				}
			}
		}

		[ClientRpc]
		private void AddToolClientRpc(short tool)
		{
			//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)
			//IL_00ce: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2782130414u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, tool);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2782130414u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					tools.Add(tool);
					upgrades[canAddTools.IndexOf(tool)].SetActive(true);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void SyncToolServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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 != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3574493460u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3574493460u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					SyncToolClientRpc(tools.ToArray());
				}
			}
		}

		[ClientRpc]
		private void SyncToolClientRpc(short[] addedTools)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2960638172u, val, (RpcDelivery)0);
				bool flag = addedTools != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<short>(addedTools, default(ForPrimitives));
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2960638172u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (!synced)
			{
				foreach (short item in addedTools)
				{
					tools.Add(item);
					upgrades[canAddTools.IndexOf(item)].SetActive(true);
				}
				synced = true;
			}
		}

		public void LoadTools()
		{
			foreach (short tool in tools)
			{
				upgrades[canAddTools.IndexOf(tool)].SetActive(true);
			}
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			if (!((NetworkBehaviour)this).IsHost)
			{
				SyncToolServerRpc();
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3300359901u, new RpcReceiveHandler(__rpc_handler_3300359901), "AddToolServerRpc");
			((NetworkBehaviour)this).__registerRpc(2782130414u, new RpcReceiveHandler(__rpc_handler_2782130414), "AddToolClientRpc");
			((NetworkBehaviour)this).__registerRpc(3574493460u, new RpcReceiveHandler(__rpc_handler_3574493460), "SyncToolServerRpc");
			((NetworkBehaviour)this).__registerRpc(2960638172u, new RpcReceiveHandler(__rpc_handler_2960638172), "SyncToolClientRpc");
			base.__initializeRpcs();
		}

		private static void __rpc_handler_3300359901(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)
			{
				short tool = default(short);
				ByteUnpacker.ReadValueBitPacked(reader, ref tool);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SaveCrafter)(object)target).AddToolServerRpc(tool);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2782130414(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)
			{
				short tool = default(short);
				ByteUnpacker.ReadValueBitPacked(reader, ref tool);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SaveCrafter)(object)target).AddToolClientRpc(tool);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3574493460(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SaveCrafter)(object)target).SyncToolServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2960638172(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				short[] addedTools = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<short>(ref addedTools, default(ForPrimitives));
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SaveCrafter)(object)target).SyncToolClientRpc(addedTools);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "SaveCrafter";
		}
	}
	public class SavePatches
	{
		private const string versionSaveKey = "MelanieMeliciousCraftVersion";

		private const string workbenchSaveKey = "MelanieMeliciousCraftWorkbench";

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")]
		private static void SaveCrafters()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			if (!((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				return;
			}
			try
			{
				string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName;
				ES3.Save<short>("MelanieMeliciousCraftVersion", (short)0, currentSaveFileName);
				if ((Object)(object)HarmonyPatches.workbench == (Object)null)
				{
					ES3.DeleteKey("MelanieMeliciousCraftWorkbench", currentSaveFileName);
					return;
				}
				ES3.Save<string>("MelanieMeliciousCraftWorkbench", JsonConvert.SerializeObject((object)HarmonyPatches.workbench.tools.ToArray()), currentSaveFileName, new ES3Settings(new Enum[1] { (Enum)(object)(ReferenceMode)0 }));
			}
			catch
			{
				Plugin.mls.LogError((object)"Issue while saving Melanie Crafting Progression Core custom info. Aborting to prevent save break.");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "LoadAttachedVehicle")]
		private static void LoadCrafters(StartOfRound __instance)
		{
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return;
			}
			try
			{
				string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName;
				if (ES3.KeyExists("MelanieMeliciousCraftWorkbench", currentSaveFileName) && (Object)(object)HarmonyPatches.workbench != (Object)null)
				{
					Workbench workbench = HarmonyPatches.workbench;
					workbench.tools.AddRange(JsonConvert.DeserializeObject<short[]>(ES3.Load<string>("MelanieMeliciousCraftWorkbench", currentSaveFileName)).ToArray());
					workbench.LoadTools();
				}
			}
			catch
			{
				Plugin.mls.LogError((object)"Issue while loading Melanie Crafting Progression Core custom info. Aborting to prevent save break.");
			}
		}
	}
	public class TreeHit : MonoBehaviour, IHittable
	{
		bool IHittable.Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX, int hitID = -1)
		{
			//IL_0034: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			Ingredient ingredient = default(Ingredient);
			if (playerWhoHit.isHoldingObject && ((Component)playerWhoHit.currentlyHeldObjectServer).TryGetComponent<Ingredient>(ref ingredient) && ingredient.tool == 2)
			{
				RoundManager.Instance.DestroyTreeOnLocalClient(((Component)this).transform.position);
				if (Random.Range(0, 2) == 0)
				{
					GlobalSpawner.Instance.SpawnItemServerRpc(3, ((Component)this).transform.position.x, ((Component)this).transform.position.y + 3f, ((Component)this).transform.position.z);
				}
				return true;
			}
			return false;
		}
	}
	public class Workbench : SaveCrafter
	{
		public override void OnNetworkSpawn()
		{
			base.OnNetworkSpawn();
			recipeList = Plugin.workbench.ToArray();
			HarmonyPatches.workbench = this;
			craftMin = MelanieCraftCfg.craftMin.Value;
			craftMax = MelanieCraftCfg.craftMax.Value;
		}

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

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

		protected internal override string __getTypeName()
		{
			return "Workbench";
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace MelanieMeliciousCraft.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}