Decompiled source of Farming and Cooking Mod MelanieMelicious v0.2.0

MelanieMeliciousCooked.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
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 GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using MelanieMeliciousCooked;
using MelanieMeliciousCooked.NetcodePatcher;
using Microsoft.CodeAnalysis;
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: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class HarmonyPatches
{
	[HarmonyPostfix]
	[HarmonyPatch(typeof(TimeOfDay), "OnHourChanged")]
	private static void HourPatch()
	{
		//IL_0054: 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_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_028e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		if (!GameNetworkManager.Instance.isHostingGame)
		{
			return;
		}
		try
		{
			if (Random.Range(0, 99) < MelanieCookedConfig.carrotGrow.Value)
			{
				GameObject val = Object.Instantiate<GameObject>(Plugin.itemList.itemsList[1].spawnPrefab, GameObject.Find("PlotCarrot0Spawn").transform.position, new Quaternion(0f, 0f, 0f, 0f));
				Transform transform = val.transform;
				transform.localPosition += new Vector3(Random.Range(-0.3f, 0.3f), 0f, Random.Range(-0.3f, 0.3f));
				val.transform.localEulerAngles = new Vector3(-90f, 0f, 0f);
				val.GetComponent<NetworkObject>().Spawn(false);
				val.GetComponent<GrabbableObject>().SetScrapValue(Random.Range(5, 30));
			}
		}
		catch
		{
		}
		try
		{
			if (Random.Range(0, 99) < MelanieCookedConfig.potatoGrow.Value)
			{
				GameObject val2 = Object.Instantiate<GameObject>(Plugin.itemList.itemsList[5].spawnPrefab, GameObject.Find("PlotPotato0Spawn").transform.position, new Quaternion(0f, 0f, 0f, 0f));
				Transform transform2 = val2.transform;
				transform2.localPosition += new Vector3(Random.Range(-0.3f, 0.3f), 0f, Random.Range(-0.3f, 0.3f));
				val2.transform.localEulerAngles = new Vector3(-90f, 0f, 0f);
				val2.GetComponent<NetworkObject>().Spawn(false);
				val2.GetComponent<GrabbableObject>().SetScrapValue(Random.Range(5, 25));
			}
		}
		catch
		{
		}
		try
		{
			if (Random.Range(0, 99) < MelanieCookedConfig.wheatGrow.Value)
			{
				GameObject val3 = Object.Instantiate<GameObject>(Plugin.itemList.itemsList[6].spawnPrefab, GameObject.Find("PlotWheat0Spawn").transform.position, new Quaternion(0f, 0f, 0f, 0f));
				Transform transform3 = val3.transform;
				transform3.localPosition += new Vector3(Random.Range(-0.3f, 0.3f), 0f, Random.Range(-0.3f, 0.3f));
				val3.transform.localEulerAngles = new Vector3(-90f, 0f, 0f);
				val3.GetComponent<NetworkObject>().Spawn(false);
				val3.GetComponent<GrabbableObject>().SetScrapValue(Random.Range(5, 20));
			}
		}
		catch
		{
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(GameNetworkManager), "Start")]
	private static void NetworkPatch(ref GameNetworkManager __instance)
	{
		((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.unlockList.unlockables[0].prefabObject);
		((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.unlockList.unlockables[1].prefabObject);
		((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.unlockList.unlockables[3].prefabObject);
		((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.unlockList.unlockables[6].prefabObject);
		((Component)__instance).GetComponent<NetworkManager>().AddNetworkPrefab(Plugin.unlockList.unlockables[8].prefabObject);
	}
}
public static class MelanieCookedConfig
{
	public static ConfigEntry<int> grinder0Cost;

	public static ConfigEntry<int> crockpot0Cost;

	public static ConfigEntry<int> oven0Cost;

	public static ConfigEntry<int> oven1Cost;

	public static ConfigEntry<int> grill0Cost;

	public static ConfigEntry<int> fridge0Cost;

	public static ConfigEntry<int> plotCarrot0Cost;

	public static ConfigEntry<int> plotPotato0Cost;

	public static ConfigEntry<int> plotWheat0Cost;

	public static ConfigEntry<int> carrotGrow;

	public static ConfigEntry<int> potatoGrow;

	public static ConfigEntry<int> wheatGrow;

	public static void SetupConfig(ConfigFile config)
	{
		grinder0Cost = config.Bind<int>("Prices", "Meat Grinder", 120, "Modify the price for the meat grinder.");
		crockpot0Cost = config.Bind<int>("Prices", "Crockpot", 100, "Modify the price for the crockpot.");
		oven0Cost = config.Bind<int>("Prices", "Mini Oven", 100, "Modify the price for the mini oven.");
		oven1Cost = config.Bind<int>("Prices", "Oven", 200, "Modify the price for the oven.");
		grill0Cost = config.Bind<int>("Prices", "Mini Grill", 100, "Modify the price for the grill.");
		fridge0Cost = config.Bind<int>("Prices", "Fridge", 120, "Modify the price for the fridge.");
		plotCarrot0Cost = config.Bind<int>("Prices", "Carrot Plot", 100, "Modify the price for carrot plots.");
		plotPotato0Cost = config.Bind<int>("Prices", "Potato Plot", 100, "Modify the price for potato plots.");
		plotWheat0Cost = config.Bind<int>("Prices", "Wheat Plot", 100, "Modify the price for wheat plots.");
		carrotGrow = config.Bind<int>("Growth Chance", "Carrot", 10, "Modify the chance for carrots to progress growing phase per hour.");
		potatoGrow = config.Bind<int>("Growth Chance", "Potato", 15, "Modify the chance for potatoes to progress growing phase per hour.");
		wheatGrow = config.Bind<int>("Growth Chance", "Wheat", 20, "Modify the chance for wheat to progress growing phase per hour.");
	}
}
namespace MelanieMeliciousCooked
{
	public class ItemManager : NetworkBehaviour
	{
		public Transform oldParent;

		public Transform newParent;

		public char cookType;

		public void Parent(PlayerControllerB playerWhoTriggered)
		{
			if (!((NetworkBehaviour)this).IsServer)
			{
				((Component)this).GetComponent<PlaceableObjectsSurface>().PlaceObject(playerWhoTriggered);
			}
			GrabbableObject currentlyHeldObjectServer = playerWhoTriggered.currentlyHeldObjectServer;
			char c = cookType;
			char c2 = c;
			if (c2 != '0')
			{
				return;
			}
			if (((Object)currentlyHeldObjectServer).name.StartsWith("Ragdoll") || ((Object)currentlyHeldObjectServer).name.StartsWith("CaveDwellerEnemy") || ((Object)currentlyHeldObjectServer).name.StartsWith("ManticoilBody") || ((Object)currentlyHeldObjectServer).name.StartsWith("TulipSnakeBody") || ((Object)currentlyHeldObjectServer).name.StartsWith("CentipedeBody") || ((Object)currentlyHeldObjectServer).name.StartsWith("HoarderingBugBody") || ((Object)currentlyHeldObjectServer).name.StartsWith("CaveDwellerBody") || ((Object)currentlyHeldObjectServer).name.StartsWith("CrawlerBody") || ((Object)currentlyHeldObjectServer).name.StartsWith("BaboonHawkBody") || ((Object)currentlyHeldObjectServer).name.StartsWith("BunkerSpiderBody"))
			{
				((Component)currentlyHeldObjectServer).transform.parent = oldParent;
				SpawnItemServerRpc(0, Random.Range(((Component)playerWhoTriggered.currentlyHeldObjectServer).GetComponent<GrabbableObject>().scrapValue, ((Component)playerWhoTriggered.currentlyHeldObjectServer).GetComponent<GrabbableObject>().scrapValue + 30), ((Object)currentlyHeldObjectServer).name);
				if (((NetworkBehaviour)this).IsServer)
				{
					((Component)this).GetComponent<PlaceableObjectsSurface>().PlaceObject(playerWhoTriggered);
				}
			}
			else if (((Object)currentlyHeldObjectServer).name.StartsWith("Wheat0"))
			{
				((Component)currentlyHeldObjectServer).transform.parent = oldParent;
				SpawnItemServerRpc(7, Random.Range(((Component)playerWhoTriggered.currentlyHeldObjectServer).GetComponent<GrabbableObject>().scrapValue, ((Component)playerWhoTriggered.currentlyHeldObjectServer).GetComponent<GrabbableObject>().scrapValue + 30), ((Object)currentlyHeldObjectServer).name);
				if (((NetworkBehaviour)this).IsServer)
				{
					((Component)this).GetComponent<PlaceableObjectsSurface>().PlaceObject(playerWhoTriggered);
				}
			}
		}

		public void Cook()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0665: Unknown result type (might be due to invalid IL or missing references)
			//IL_0671: Unknown result type (might be due to invalid IL or missing references)
			//IL_067d: Unknown result type (might be due to invalid IL or missing references)
			string[] array = new string[4] { "", "", "", "" };
			int num = 0;
			ushort num2 = 0;
			ushort num3 = 0;
			ushort num4 = 0;
			ushort num5 = 0;
			ushort num6 = 0;
			ushort num7 = 0;
			ushort num8 = 0;
			ushort num9 = 0;
			foreach (Transform item in oldParent)
			{
				Transform val = item;
				if (num9 >= 4)
				{
					continue;
				}
				string name = ((Object)val).name;
				string text = name;
				switch (text)
				{
				case "Meat0(Clone)":
				case "Meat1(Clone)":
				case "PackagedMeatMealPrefab(Clone)":
					array[num9] = ((Object)val).name;
					num += ((Component)val).gameObject.GetComponent<GrabbableObject>().scrapValue;
					num2++;
					num9++;
					continue;
				case "MeatCube(Clone)":
					array[num9] = ((Object)val).name;
					num += ((Component)val).gameObject.GetComponent<GrabbableObject>().scrapValue;
					num2++;
					num9++;
					continue;
				case "Carrot0(Clone)":
					array[num9] = "Carrot0(Clone)";
					num += ((Component)val).gameObject.GetComponent<GrabbableObject>().scrapValue;
					num3++;
					num6++;
					num9++;
					continue;
				case "Potato0(Clone)":
					array[num9] = "Potato0(Clone)";
					num += ((Component)val).gameObject.GetComponent<GrabbableObject>().scrapValue;
					num3++;
					num7++;
					num9++;
					continue;
				case "Tomato(Clone)":
				case "Golden Tomato(Clone)":
					array[num9] = ((Object)val).name;
					num += ((Component)val).gameObject.GetComponent<GrabbableObject>().scrapValue;
					num3++;
					num8++;
					num9++;
					continue;
				case "Flour0(Clone)":
				case "LoafBread0(Clone)":
					array[num9] = ((Object)val).name;
					num += ((Component)val).gameObject.GetComponent<GrabbableObject>().scrapValue;
					num4++;
					num9++;
					continue;
				}
				if (text == null)
				{
					continue;
				}
				if (!((Object)val).name.StartsWith("ModdedEnemy") && !((Object)val).name.EndsWith("Sample(Clone)"))
				{
					switch (text)
					{
					case "SampleDriftWoodGiant(Clone)":
						break;
					case "PickleJar(Clone)":
					case "Corn(Clone)":
					case "PackagedVeganMealPrefab(Clone)":
						array[num9] = ((Object)val).name;
						num += ((Component)val).gameObject.GetComponent<GrabbableObject>().scrapValue;
						num3++;
						num9++;
						continue;
					case "PackagedSurvivalMealPrefab(Clone)":
						array[num9] = "PackagedSurvivalMealPrefab(Clone)";
						num += ((Component)val).gameObject.GetComponent<GrabbableObject>().scrapValue;
						num2++;
						num3++;
						num9++;
						continue;
					case "BlueCheesePrefab(Clone)":
					case "CheeseHammerPrefab(Clone)":
					case "CheesePuffPrefab(Clone)":
					case "CheeseWedgePrefab(Clone)":
					case "CheeseWheelPrefab(Clone)":
					case "DoaWKPrefab(Clone)":
					case "MrTwistyPrefab(Clone)":
					case "StinkyCheeseManPrefab(Clone)":
						array[num9] = ((Object)val).name;
						num += ((Component)val).gameObject.GetComponent<GrabbableObject>().scrapValue;
						num5++;
						num9++;
						continue;
					case "Gazpacho(Clone)":
						BoomClientRpc(val.position.x, val.position.y, val.position.z);
						continue;
					default:
						continue;
					}
				}
				SpawnItemServerRpc(12, ((Component)val).gameObject.GetComponent<GrabbableObject>().scrapValue + 5, ((Object)val).name);
			}
			switch (cookType)
			{
			case '0':
				if (num2 > 1 && num9 == 4)
				{
					SpawnItemServerRpc(3, num + Random.Range(10, num / 4), array[0], array[1], array[2], array[3]);
				}
				else if (num3 > 2)
				{
					SpawnItemServerRpc(2, num + Random.Range(10, num / 4), array[0], array[1], array[2], array[3]);
				}
				break;
			case '1':
				if (num2 == 1 && num3 == 1 && num4 == 1)
				{
					SpawnItemServerRpc(9, num + Random.Range(10, num / 4), array[0], array[1], array[2], array[3]);
				}
				else if (num2 > 2 || (num2 > 0 && num3 > 1))
				{
					SpawnItemServerRpc(4, num + Random.Range(10, num / 4), array[0], array[1], array[2], array[3]);
				}
				else if (num4 > 2)
				{
					SpawnItemServerRpc(8, num + Random.Range(10, num / 4), array[0], array[1], array[2], array[3]);
				}
				break;
			case '2':
				if (num2 > 0 && num3 > 0 && num4 > 0)
				{
					switch (num9)
					{
					case 3:
						SpawnItemServerRpc(10, (num + Random.Range(10, num / 4)) / 2, array[0], array[1], array[2], array[3]);
						SpawnItemServerRpc(10, (num + Random.Range(10, num / 4)) / 2);
						break;
					case 4:
						SpawnItemServerRpc(11, num + Random.Range(10, num / 4), array[0], array[1], array[2], array[3]);
						break;
					}
				}
				if (num4 > 0 && num5 > 0 && num9 == num4 + num5)
				{
					SpawnItemServerRpc(13, num + Random.Range(10, num / 4), array[0], array[1], array[2], array[3]);
				}
				break;
			}
		}

		private IEnumerator Boom(Vector3 position)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitForSeconds(2f);
			Landmine.SpawnExplosion(position, true, 1f, 5f, 50, 0f, (GameObject)null, false);
		}

		[ClientRpc]
		public void BoomClientRpc(float x, float y, float z)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1220024282u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref x, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref y, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref z, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1220024282u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					AudioSource.PlayClipAtPoint(Plugin.bundle.LoadAsset<AudioClip>("Assets/MelanieCooked/Audio/spanishsound.ogg"), new Vector3(x, y, z));
					((MonoBehaviour)this).StartCoroutine(Boom(new Vector3(x, y, z)));
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void SpawnItemServerRpc(int itemList, int dishValue, string delete0 = "", string delete1 = "", string delete2 = "", string delete3 = "")
		{
			//IL_02eb: 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)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Expected O, but got Unknown
			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(828491791u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, itemList);
				BytePacker.WriteValueBitPacked(val2, dishValue);
				bool flag = delete0 != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(delete0, false);
				}
				bool flag2 = delete1 != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(delete1, false);
				}
				bool flag3 = delete2 != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag3, default(ForPrimitives));
				if (flag3)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(delete2, false);
				}
				bool flag4 = delete3 != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag4, default(ForPrimitives));
				if (flag4)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(delete3, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 828491791u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			string[] array = new string[4] { delete0, delete1, delete2, delete3 };
			GameObject val3 = Object.Instantiate<GameObject>(Plugin.itemList.itemsList[itemList].spawnPrefab, newParent.position, newParent.rotation, RoundManager.Instance.spawnedScrapContainer);
			val3.GetComponent<NetworkObject>().Spawn(false);
			val3.GetComponent<GrabbableObject>().SetScrapValue(dishValue);
			try
			{
				string[] array2 = array;
				foreach (string text in array2)
				{
					bool flag5 = false;
					foreach (Transform item in oldParent)
					{
						Transform val4 = item;
						if (!flag5 && ((Object)val4).name == text)
						{
							((Object)val4).name = "delete";
							Object.Destroy((Object)(object)((Component)val4).gameObject);
							flag5 = true;
						}
					}
				}
			}
			catch
			{
			}
			DeleteItemClientRpc(NetworkObjectReference.op_Implicit(val3.GetComponent<NetworkObject>()), dishValue, delete0, delete1, delete2, delete3);
		}

		[ClientRpc]
		public void DeleteItemClientRpc(NetworkObjectReference netObjectRef, int dishValue, string delete0 = "", string delete1 = "", string delete2 = "", string delete3 = "")
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: 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_00b0: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Expected O, but got Unknown
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2178165484u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref netObjectRef, default(ForNetworkSerializable));
				BytePacker.WriteValueBitPacked(val2, dishValue);
				bool flag = delete0 != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(delete0, false);
				}
				bool flag2 = delete1 != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(delete1, false);
				}
				bool flag3 = delete2 != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag3, default(ForPrimitives));
				if (flag3)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(delete2, false);
				}
				bool flag4 = delete3 != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag4, default(ForPrimitives));
				if (flag4)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(delete3, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2178165484u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost) || ((NetworkBehaviour)this).IsServer)
			{
				return;
			}
			try
			{
				string[] array = new string[4] { delete0, delete1, delete2, delete3 };
				string[] array2 = array;
				foreach (string text in array2)
				{
					bool flag5 = false;
					foreach (Transform item in oldParent)
					{
						Transform val3 = item;
						if (!flag5 && ((Object)val3).name == text)
						{
							((Object)val3).name = "delete";
							Object.Destroy((Object)(object)((Component)val3).gameObject);
							flag5 = true;
						}
					}
				}
			}
			catch
			{
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ItemManager()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1220024282u, new RpcReceiveHandler(__rpc_handler_1220024282));
			NetworkManager.__rpc_func_table.Add(828491791u, new RpcReceiveHandler(__rpc_handler_828491791));
			NetworkManager.__rpc_func_table.Add(2178165484u, new RpcReceiveHandler(__rpc_handler_2178165484));
		}

		private static void __rpc_handler_1220024282(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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float x = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref x, default(ForPrimitives));
				float y = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref y, default(ForPrimitives));
				float z = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref z, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ItemManager)(object)target).BoomClientRpc(x, y, z);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_828491791(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_0049: 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_0081: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			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);
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string delete = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref delete, false);
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				string delete2 = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref delete2, false);
				}
				bool flag3 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag3, default(ForPrimitives));
				string delete3 = null;
				if (flag3)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref delete3, false);
				}
				bool flag4 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag4, default(ForPrimitives));
				string delete4 = null;
				if (flag4)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref delete4, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ItemManager)(object)target).SpawnItemServerRpc(itemList, dishValue, delete, delete2, delete3, delete4);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2178165484(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_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_008f: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				NetworkObjectReference netObjectRef = default(NetworkObjectReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref netObjectRef, default(ForNetworkSerializable));
				int dishValue = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref dishValue);
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string delete = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref delete, false);
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				string delete2 = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref delete2, false);
				}
				bool flag3 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag3, default(ForPrimitives));
				string delete3 = null;
				if (flag3)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref delete3, false);
				}
				bool flag4 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag4, default(ForPrimitives));
				string delete4 = null;
				if (flag4)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref delete4, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ItemManager)(object)target).DeleteItemClientRpc(netObjectRef, dishValue, delete, delete2, delete3, delete4);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ItemManager";
		}
	}
	[BepInPlugin("MelanieMelicious.FarmAndCook", "MelanieMelicious - Farming and Cooking Mod", "0.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "MelanieMelicious.FarmAndCook";

		private const string NAME = "MelanieMelicious - Farming and Cooking Mod";

		private const string VERSION = "0.2.0";

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

		public static ManualLogSource mls;

		public static AssetBundle bundle;

		public static UnlockablesList unlockList;

		public static AllItemsList itemList;

		public static Plugin instance;

		private void Awake()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			instance = this;
			MelanieCookedConfig.SetupConfig(((BaseUnityPlugin)this).Config);
			mls = Logger.CreateLogSource("MelanieMelicious - Farming and Cooking Mod");
			mls = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll(typeof(HarmonyPatches));
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "melaniecooked");
			bundle = AssetBundle.LoadFromFile(text);
			unlockList = bundle.LoadAsset<UnlockablesList>("Assets/MelanieCooked/Asset/Furniture.asset");
			itemList = bundle.LoadAsset<AllItemsList>("Assets/MelanieCooked/Asset/Food.asset");
			NetworkPrefabs.RegisterNetworkPrefab(unlockList.unlockables[0].prefabObject);
			Unlockables.RegisterUnlockable(unlockList.unlockables[0], (StoreType)1, (TerminalNode)null, (TerminalNode)null, (TerminalNode)null, MelanieCookedConfig.grinder0Cost.Value);
			NetworkPrefabs.RegisterNetworkPrefab(unlockList.unlockables[1].prefabObject);
			Unlockables.RegisterUnlockable(unlockList.unlockables[1], (StoreType)1, (TerminalNode)null, (TerminalNode)null, (TerminalNode)null, MelanieCookedConfig.crockpot0Cost.Value);
			NetworkPrefabs.RegisterNetworkPrefab(unlockList.unlockables[2].prefabObject);
			Unlockables.RegisterUnlockable(unlockList.unlockables[2], (StoreType)1, (TerminalNode)null, (TerminalNode)null, (TerminalNode)null, MelanieCookedConfig.plotCarrot0Cost.Value);
			NetworkPrefabs.RegisterNetworkPrefab(unlockList.unlockables[3].prefabObject);
			Unlockables.RegisterUnlockable(unlockList.unlockables[3], (StoreType)1, (TerminalNode)null, (TerminalNode)null, (TerminalNode)null, MelanieCookedConfig.oven0Cost.Value);
			NetworkPrefabs.RegisterNetworkPrefab(unlockList.unlockables[4].prefabObject);
			Unlockables.RegisterUnlockable(unlockList.unlockables[4], (StoreType)1, (TerminalNode)null, (TerminalNode)null, (TerminalNode)null, MelanieCookedConfig.plotPotato0Cost.Value);
			NetworkPrefabs.RegisterNetworkPrefab(unlockList.unlockables[5].prefabObject);
			Unlockables.RegisterUnlockable(unlockList.unlockables[5], (StoreType)1, (TerminalNode)null, (TerminalNode)null, (TerminalNode)null, MelanieCookedConfig.plotWheat0Cost.Value);
			NetworkPrefabs.RegisterNetworkPrefab(unlockList.unlockables[6].prefabObject);
			Unlockables.RegisterUnlockable(unlockList.unlockables[6], (StoreType)1, (TerminalNode)null, (TerminalNode)null, (TerminalNode)null, MelanieCookedConfig.grill0Cost.Value);
			NetworkPrefabs.RegisterNetworkPrefab(unlockList.unlockables[7].prefabObject);
			Unlockables.RegisterUnlockable(unlockList.unlockables[7], (StoreType)1, (TerminalNode)null, (TerminalNode)null, (TerminalNode)null, MelanieCookedConfig.fridge0Cost.Value);
			NetworkPrefabs.RegisterNetworkPrefab(unlockList.unlockables[8].prefabObject);
			Unlockables.RegisterUnlockable(unlockList.unlockables[8], (StoreType)1, (TerminalNode)null, (TerminalNode)null, (TerminalNode)null, MelanieCookedConfig.oven1Cost.Value);
			foreach (Item items in itemList.itemsList)
			{
				NetworkPrefabs.RegisterNetworkPrefab(items.spawnPrefab);
				Items.RegisterItem(items);
			}
		}
	}
}
namespace MelanieMeliciousCooked.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}