Decompiled source of NewtsKitchen v1.0.0

plugins/NewtsKitchen.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RoR2;
using RoR2.ExpansionManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace NewtsKitchen
{
	[BepInPlugin("com.deltalines.newtskitchen", "Newt's Kitchen — Featuring the Grilling Goober", "0.1.13")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string GUID = "com.deltalines.newtskitchen";

		public const string VERSION = "0.1.13";

		private const string Prefix = "[NewtsKitchen] ";

		private static readonly Vector3 CookingPosition = new Vector3(-141.49f, -24.9f, -20.08f);

		private ConfigEntry<int> startingCost;

		private ConfigEntry<float> costMultiplier;

		private ConfigEntry<int> cookingLimitPerPlayer;

		private ConfigEntry<bool> flavorText;

		private ConfigEntry<bool> verbose;

		private ConfigEntry<float> offsetX;

		private ConfigEntry<float> offsetY;

		private ConfigEntry<float> offsetZ;

		private ConfigEntry<float> rotationY;

		private ConfigEntry<float> statueHeight;

		private ConfigEntry<float> statueFacingOffset;

		private ConfigEntry<float> statuePitch;

		private ConfigEntry<float> statueScale;

		private ConfigEntry<bool> solidStatue;

		private ConfigEntry<float> statueYawCorrection;

		private ConfigEntry<float> statueRollCorrection;

		private ConfigEntry<bool> preserveSourceUpright;

		private ConfigEntry<bool> aimOutputAtCustomer;

		private ConfigEntry<float> uprightWorldYaw;

		private ConfigEntry<float> uprightFootGap;

		private ConfigEntry<float> uprightVisualYawCorrection;

		private ConfigEntry<float> uprightMissingMeshLowering;

		private ConfigEntry<float> groundEmbedDepth;

		private ConfigEntry<float> fallbackGroundLowering;

		private ConfigEntry<float> foodAuraScaleXZ;

		private ConfigEntry<float> foodAuraScaleY;

		private ConfigEntry<float> foodAuraBaseOffset;

		private ConfigEntry<float> foodAuraSideOffset;

		private ConfigEntry<float> foodAuraForwardOffset;

		private ConfigEntry<float> outputYawOffset;

		private ConfigEntry<float> fallbackDropYawCorrection;

		private ConfigEntry<float> glowRange;

		private ConfigEntry<float> glowIntensity;

		private ConfigEntry<float> outputForwardDistance;

		private ConfigEntry<float> outputHeight;

		private ConfigEntry<float> outputForwardSpeed;

		private ConfigEntry<float> outputUpSpeed;

		private ConfigEntry<float> pickupSideClearance;

		private ConfigEntry<float> pickupTopClearance;

		private ConfigEntry<float> cookingDelay;

		private bool contextPatchAttempted;

		private Harmony contextHarmony;

		private int completedCooks;

		private int mostPlayersThisVisit;

		private bool hasHostKitchenState;

		private int hostNextFee;

		private int hostCookLimit;

		private float nextStateRequestTime;

		private float nextHostCapPollTime;

		private int lastBroadcastCap = -1;

		private bool sceneSpawnAttempted;

		private MealPrepController currentKitchen;

		private readonly string[] sayings = new string[13]
		{
			"NK_GOOBER_LINE_0", "NK_GOOBER_LINE_1", "NK_GOOBER_LINE_2", "NK_GOOBER_LINE_3", "NK_GOOBER_LINE_4", "NK_GOOBER_LINE_5", "NK_GOOBER_LINE_6", "NK_GOOBER_LINE_7", "NK_GOOBER_LINE_8", "NK_GOOBER_LINE_9",
			"NK_GOOBER_LINE_10", "NK_GOOBER_LINE_11", "NK_GOOBER_LINE_12"
		};

		private static Plugin _instance;

		private void Awake()
		{
			//IL_0696: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a0: Expected O, but got Unknown
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Expected O, but got Unknown
			//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c2: Expected O, but got Unknown
			//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d3: Expected O, but got Unknown
			_instance = this;
			startingCost = ((BaseUnityPlugin)this).Config.Bind<int>("Pricing", "StartingLunarCoinCost", 5, "Lunar Coins required for the first successful cook during a Bazaar visit.");
			costMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Pricing", "CostMultiplier", 2.5f, "Cost per successful cook = ceil(base * multiplier ^ completed cooks). Resets each Bazaar visit.");
			cookingLimitPerPlayer = ((BaseUnityPlugin)this).Config.Bind<int>("Cooking", "SharedCookLimitPerPlayer", 3, "Shared maximum successful cooks per Bazaar visit = this number * the number of players. Example: 3 players and a setting of 3 allow 9 cooks total, pooled across the entire team. 0 disables the cooking limit. Players joining during a visit can increase the limit; leaving does not reduce an already-granted allowance.");
			flavorText = ((BaseUnityPlugin)this).Config.Bind<bool>("Dialogue", "EnableFlavorText", true, "Broadcast the Grilling Goober's randomized snide remarks after successful cooking.");
			verbose = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "VerboseLogging", true, "Log initialization and transaction details for this experimental build.");
			offsetX = ((BaseUnityPlugin)this).Config.Bind<float>("Placement", "OffsetX", 0f, "Fine tune statue position relative to the F9 marker.");
			offsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Placement", "OffsetY", 0f, "Fine tune statue base height.");
			offsetZ = ((BaseUnityPlugin)this).Config.Bind<float>("Placement", "OffsetZ", 0f, "Fine tune statue position relative to the F9 marker.");
			rotationY = ((BaseUnityPlugin)this).Config.Bind<float>("Placement", "RotationY", 130f, "Base MealPrep orientation, in degrees. The decorative goober has its own facing offset.");
			statueHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "StatueHeight", 1.05f, "Raise the stone model relative to the MealPrep pivot. Increase if its paws are buried.");
			statueFacingOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "StatueFacingOffset", 165f, "Rotate ONLY the visible statue around its local Y axis, independently of the pickup launch direction.");
			statuePitch = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "StatuePitch", 0f, "Optional forward/back tilt in degrees; leave at 0 unless needed.");
			statueYawCorrection = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "StatueYawCorrection", 180f, "Additional horizontal turn applied after StatueFacingOffset. 180 reverses the v0.1.2 facing.");
			statueRollCorrection = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "StatueRollCorrection", -55f, "Straighten the visibly sideways stone about its local forward axis. Adjust if the feet still lean.");
			statueScale = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "StatueScale", 1.32f, "Size multiplier for the stone model. v0.1.9 defaults to roughly 1.5x the previous in-game Grilling Goober size.");
			solidStatue = ((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "SolidStatue", true, "Keep the vanilla Newt stone MeshCollider on the cloned Goober. This makes the stone physically solid while retaining its exact original collision shape, scaled with the stone.");
			preserveSourceUpright = ((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "PreserveSourceUpright", true, "Use a naturally upright vanilla Newt statue pose; ignores legacy pitch, roll, and extra-yaw correction settings.");
			uprightWorldYaw = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "UprightWorldYaw", 40f, "Compass yaw of the Goober's FRONT in the Bazaar (degrees; 0=+Z, 90=+X). Default faces the shop/Seer area.");
			uprightFootGap = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "UprightFootGap", 0.06f, "Gap between the statue's lowest visible mesh point and the alcove floor in upright mode. 0=sits on floor.");
			uprightVisualYawCorrection = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "UprightVisualYawCorrection", 45f, "Extra clockwise turn for the visible upright statue in degrees. Default +45; try -45 if it faces farther away. Does not change cooked-item direction.");
			uprightMissingMeshLowering = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "UprightMissingMeshLowering", 0.65f, "Legacy fallback if model has no usable mesh renderer; no longer controls the regular ground snap.");
			groundEmbedDepth = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "GroundEmbedDepth", 0.1f, "Lower the model this many meters into the ACTUAL sloped Bazaar ground. 0 = mesh base on floor; try 0.2 if a tiny gap remains.");
			fallbackGroundLowering = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "GroundFallbackLowering", 0.65f, "If no Bazaar floor collider can be detected, lower the statue mesh this far below the cooking station Y rather than leaving it floating.");
			foodAuraScaleXZ = ((BaseUnityPlugin)this).Config.Bind<float>("Cooked Item Aura", "AuraHorizontalScale", 6.4f, "Scale of the borrowed cooked-item particle loops around the Grilling Goober (same horizontal scale as Beggar & Bouncer).");
			foodAuraScaleY = ((BaseUnityPlugin)this).Config.Bind<float>("Cooked Item Aura", "AuraVerticalScale", 7.1f, "Vertical scale of the cooked-item particle loops (same vertical scale as Beggar & Bouncer).");
			foodAuraBaseOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Cooked Item Aura", "AuraBaseOffset", -0.18f, "Height relative to the grounded stone's lowest mesh point. Negative places the aura origin below the paws.");
			foodAuraSideOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Cooked Item Aura", "AuraSideOffset", 0f, "Optional horizontal adjustment of the particle effect (world X direction).");
			foodAuraForwardOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Cooked Item Aura", "AuraForwardOffset", 0f, "Optional depth adjustment of the particle effect (world Z direction).");
			glowRange = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "GlowRange", 10.5f, "Radius of the warm orange/red fire light.");
			glowIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "GlowIntensity", 5f, "Brightness of the warm fire light.");
			cookingDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Cooking", "OutputDelaySeconds", 1f, "Delay after payment/ingredient consumption before the cooked result appears. 0=immediate; max 10 seconds.");
			outputForwardDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Cooking", "OutputForwardDistance", 1.85f, "Minimum release distance measured from the statue collider center toward the open floor; actual release automatically clears the mesh.");
			pickupSideClearance = ((BaseUnityPlugin)this).Config.Bind<float>("Cooking", "PickupColliderSideClearance", 0.65f, "Extra horizontal distance beyond the enlarged stone mesh before cooked items spawn.");
			pickupTopClearance = ((BaseUnityPlugin)this).Config.Bind<float>("Cooking", "PickupColliderTopClearance", 0.45f, "Extra vertical height above the real stone collision bounds before cooked items spawn.");
			outputYawOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Cooking", "OutputYawOffset", 0f, "Extra horizontal offset for cooked item launch in degrees (positive turns right).");
			fallbackDropYawCorrection = ((BaseUnityPlugin)this).Config.Bind<float>("Cooking", "FallbackDropYawCorrection", 35f, "Rotate the DEFAULT fallback pickup direction horizontally (degrees, positive toward world +X) to send food farther to the right/open shop floor. Does not change customer-aimed drops. Added in v0.1.8; change this alone if the fallback still misses the floor.");
			aimOutputAtCustomer = ((BaseUnityPlugin)this).Config.Bind<bool>("Cooking", "AimOutputAtCustomer", true, "Launch toward the player who confirmed the craft, when they stand in front of the statue; otherwise launch outward toward the shop.");
			outputHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Cooking", "OutputHeight", 2.7f, "Height of the cooked item release point above the MealPrep pivot.");
			outputForwardSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Cooking", "OutputForwardSpeed", 10.25f, "Horizontal speed of the cooked item toward the open shop floor.");
			outputUpSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Cooking", "OutputUpSpeed", 7f, "Vertical launch speed of the cooked item.");
			LanguageAPI.Add("NK_NAME", "The Grilling Goober");
			LanguageAPI.Add("NK_GOOBER_LINE_0", "The Grilling Goober: I wouldn't eat that. But I'm not the one paying.");
			LanguageAPI.Add("NK_GOOBER_LINE_1", "The Grilling Goober: Really? Outsiders have such strange tastes.");
			LanguageAPI.Add("NK_GOOBER_LINE_2", "The Grilling Goober: I've cooked for creatures with six stomachs. You're somehow worse.");
			LanguageAPI.Add("NK_GOOBER_LINE_3", "The Grilling Goober: A culinary crime. At least the coins are real.");
			LanguageAPI.Add("NK_GOOBER_LINE_4", "The Grilling Goober: The boss says I can't serve that. Fortunately, he's not looking.");
			LanguageAPI.Add("NK_GOOBER_LINE_5", "The Grilling Goober: Finally, something that almost looks edible.");
			LanguageAPI.Add("NK_GOOBER_LINE_6", "The Grilling Goober: I don't ask what goes into it. You shouldn't either.");
			LanguageAPI.Add("NK_GOOBER_LINE_7", "The Grilling Goober: Next time, try something with less... screaming.");
			LanguageAPI.Add("NK_GOOBER_LINE_8", "The Grilling Goober: Newt insists I call this fine dining. I disagree.");
			LanguageAPI.Add("NK_GOOBER_LINE_9", "The Grilling Goober: You're paying extra for the ambience. Don't look around.");
			LanguageAPI.Add("NK_GOOBER_LINE_10", "The Grilling Goober: And they say *my* cooking is questionable.");
			LanguageAPI.Add("NK_GOOBER_LINE_11", "The Grilling Goober: No refunds. Especially not after tasting.");
			LanguageAPI.Add("NK_GOOBER_LINE_12", "The Grilling Goober: Don't mind the crunch. I sometimes put Lunar Coins in for extra flavour.");
			NetworkingAPI.RegisterMessageType<KitchenStateSync>();
			NetworkingAPI.RegisterMessageType<KitchenStateRequest>();
			contextHarmony = new Harmony("com.deltalines.newtskitchen.contexttext");
			PickupPickerController.OnInteractionBegin += new hook_OnInteractionBegin(InterceptMenuOpen);
			CraftingController.OnConfirmServer += new hook_OnConfirmServer(GuardConfirm);
			MealPrepController.BeginCookingServer += new hook_BeginCookingServer(InterceptCooking);
			SceneManager.sceneLoaded += OnSceneLoaded;
			((MonoBehaviour)this).StartCoroutine(BootstrapExistingScene());
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[NewtsKitchen] v0.1.13 loaded. Waiting for Bazaar / Alloyed Collective.");
		}

		private void OnDestroy()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			if ((Object)(object)_instance == (Object)(object)this)
			{
				_instance = null;
			}
			SceneManager.sceneLoaded -= OnSceneLoaded;
			try
			{
				Harmony obj = contextHarmony;
				if (obj != null)
				{
					obj.UnpatchSelf();
				}
			}
			catch
			{
			}
			PickupPickerController.OnInteractionBegin -= new hook_OnInteractionBegin(InterceptMenuOpen);
			CraftingController.OnConfirmServer -= new hook_OnConfirmServer(GuardConfirm);
			MealPrepController.BeginCookingServer -= new hook_BeginCookingServer(InterceptCooking);
		}

		private void Update()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			if (!IsBazaar() || !Object.op_Implicit((Object)(object)currentKitchen))
			{
				return;
			}
			if (NetworkServer.active)
			{
				if (!(Time.time < nextHostCapPollTime))
				{
					nextHostCapPollTime = Time.time + 1f;
					if (GetSharedCookingLimit() != lastBroadcastCap)
					{
						BroadcastKitchenState();
					}
				}
			}
			else
			{
				if (!NetworkClient.active || !(Time.time >= nextStateRequestTime))
				{
					return;
				}
				nextStateRequestTime = Time.time + (hasHostKitchenState ? 10f : 2f);
				NetworkIdentity component = ((Component)currentKitchen).GetComponent<NetworkIdentity>();
				if (Object.op_Implicit((Object)(object)component))
				{
					NetMessageExtensions.Send((INetMessage)(object)new KitchenStateRequest(component.netId), (NetworkDestination)2);
					if (verbose.Value && !hasHostKitchenState)
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Requested initial server kitchen price/cap snapshot for " + ((object)component.netId/*cast due to .constrained prefix*/).ToString()));
					}
				}
			}
		}

		internal static void HandleKitchenStateRequest(NetworkInstanceId kitchenId)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_instance == (Object)null || !NetworkServer.active || !IsBazaar())
			{
				return;
			}
			NetworkIdentity val = (Object.op_Implicit((Object)(object)_instance.currentKitchen) ? ((Component)_instance.currentKitchen).GetComponent<NetworkIdentity>() : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				NetworkInstanceId netId = val.netId;
				if (((NetworkInstanceId)(ref netId)).Equals(kitchenId))
				{
					_instance.BroadcastKitchenState();
				}
			}
		}

		internal static void ReceiveKitchenState(NetworkInstanceId kitchenId, int cooks, int limit, int nextFee)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_instance == (Object)null || NetworkServer.active || !IsBazaar())
			{
				return;
			}
			NetworkIdentity val = (Object.op_Implicit((Object)(object)_instance.currentKitchen) ? ((Component)_instance.currentKitchen).GetComponent<NetworkIdentity>() : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			NetworkInstanceId netId = val.netId;
			if (((NetworkInstanceId)(ref netId)).Equals(kitchenId) && (!_instance.hasHostKitchenState || cooks >= _instance.completedCooks))
			{
				_instance.completedCooks = Mathf.Max(0, cooks);
				_instance.hostCookLimit = Mathf.Max(0, limit);
				_instance.hostNextFee = Mathf.Max(0, nextFee);
				_instance.hasHostKitchenState = true;
				if (_instance.verbose.Value)
				{
					((BaseUnityPlugin)_instance).Logger.LogInfo((object)("[NewtsKitchen] Received host kitchen state: " + cooks + "/" + limit + " cooks, next fee " + nextFee + " Lunar Coins."));
				}
			}
		}

		private void BroadcastKitchenState()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || !IsBazaar() || !Object.op_Implicit((Object)(object)currentKitchen))
			{
				return;
			}
			NetworkIdentity component = ((Component)currentKitchen).GetComponent<NetworkIdentity>();
			if (Object.op_Implicit((Object)(object)component))
			{
				int sharedCookingLimit = GetSharedCookingLimit();
				int price = CurrentCost();
				lastBroadcastCap = sharedCookingLimit;
				NetMessageExtensions.Send((INetMessage)(object)new KitchenStateSync(component.netId, completedCooks, sharedCookingLimit, price), (NetworkDestination)1);
				if (verbose.Value)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Broadcast kitchen state: " + completedCooks + "/" + sharedCookingLimit + " cooks, next fee=" + price));
				}
			}
		}

		private static bool IsBazaar()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			return ((Scene)(ref activeScene)).name.Equals("bazaar", StringComparison.OrdinalIgnoreCase);
		}

		private Vector3 DesiredPosition()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			return CookingPosition + new Vector3(offsetX.Value, offsetY.Value, offsetZ.Value);
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			completedCooks = 0;
			mostPlayersThisVisit = 0;
			hasHostKitchenState = false;
			hostNextFee = 0;
			hostCookLimit = 0;
			nextStateRequestTime = 0f;
			nextHostCapPollTime = 0f;
			lastBroadcastCap = -1;
			sceneSpawnAttempted = false;
			currentKitchen = null;
			if (((Scene)(ref scene)).name.Equals("bazaar", StringComparison.OrdinalIgnoreCase))
			{
				((MonoBehaviour)this).StartCoroutine(SetupBazaar());
			}
		}

		private IEnumerator BootstrapExistingScene()
		{
			yield return (object)new WaitForSeconds(2f);
			if (IsBazaar())
			{
				yield return SetupBazaar();
			}
		}

		private IEnumerator SetupBazaar()
		{
			yield return (object)new WaitForSeconds(2.5f);
			if (!IsBazaar())
			{
				yield break;
			}
			if (NetworkServer.active && !sceneSpawnAttempted)
			{
				sceneSpawnAttempted = true;
				try
				{
					SpawnVanillaChefLogic();
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)("[NewtsKitchen] Spawn failed: " + ex));
				}
			}
			for (int i = 0; i < 50; i++)
			{
				if (!IsBazaar())
				{
					break;
				}
				try
				{
					AttachPresentationToNearbyChef();
				}
				catch (Exception ex2)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("[NewtsKitchen] Presentation install failed: " + ex2.Message));
				}
				if (Object.op_Implicit((Object)(object)currentKitchen))
				{
					break;
				}
				yield return (object)new WaitForSeconds(0.4f);
			}
		}

		private void SpawnVanillaChefLogic()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[NewtsKitchen] Run isn't available, skipped.");
				return;
			}
			ExpansionDef val = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC3/DLC3.asset").WaitForCompletion();
			if (!Object.op_Implicit((Object)(object)val) || !Run.instance.IsExpansionEnabled(val))
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"[NewtsKitchen] Alloyed Collective is not enabled; kitchen omitted.");
				return;
			}
			GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC3/MealPrep/MealPrep.prefab").WaitForCompletion();
			if (!Object.op_Implicit((Object)(object)val2))
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"[NewtsKitchen] MealPrep.prefab wasn't found.");
				return;
			}
			GameObject val3 = Object.Instantiate<GameObject>(val2, DesiredPosition(), Quaternion.Euler(0f, rotationY.Value, 0f));
			((Object)val3).name = "NK_GrillingGoober_CookingController";
			if (!Object.op_Implicit((Object)(object)val3.GetComponent<MealPrepController>()) || !Object.op_Implicit((Object)(object)val3.GetComponent<CraftingController>()))
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"[NewtsKitchen] DLC3 cooking components missing; removing incomplete spawn.");
				Object.Destroy((Object)(object)val3);
			}
			else
			{
				NetworkServer.Spawn(val3);
				((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Spawned vanilla networked MealPrep at " + ((object)val3.transform.position/*cast due to .constrained prefix*/).ToString()));
			}
		}

		private void AttachPresentationToNearbyChef()
		{
			//IL_002a: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			if (!IsBazaar())
			{
				return;
			}
			MealPrepController[] array = Object.FindObjectsOfType<MealPrepController>();
			foreach (MealPrepController val in array)
			{
				if (!Object.op_Implicit((Object)(object)val) || Vector3.Distance(((Component)val).transform.position, DesiredPosition()) > 3.5f)
				{
					continue;
				}
				currentKitchen = val;
				if (Object.op_Implicit((Object)(object)((Component)val).GetComponent<KitchenMarker>()))
				{
					break;
				}
				((Component)val).gameObject.AddComponent<KitchenMarker>();
				Transform val2 = ((Component)val).transform.Find("mdlChef");
				if (Object.op_Implicit((Object)(object)val2))
				{
					((Component)val2).gameObject.SetActive(false);
				}
				MonoBehaviour[] components = ((Component)val).GetComponents<MonoBehaviour>();
				foreach (MonoBehaviour val3 in components)
				{
					if (Object.op_Implicit((Object)(object)val3) && ((object)val3).GetType().FullName.Contains("CharacterSpeech"))
					{
						((Behaviour)val3).enabled = false;
					}
				}
				TryAddStatueVisual(((Component)val).transform);
				AddInteractionCollider(((Component)val).transform);
				AddCookedPickupAura(((Component)val).transform);
				((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Grilling Goober visual and interaction installed at " + ((object)((Component)val).transform.position/*cast due to .constrained prefix*/).ToString()));
				TryPatchContextText(((Component)val).gameObject);
				if (NetworkServer.active)
				{
					BroadcastKitchenState();
				}
				break;
			}
		}

		private Vector3 ShopFacing()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return Quaternion.Euler(0f, uprightWorldYaw.Value, 0f) * Vector3.forward;
		}

		private void TryAddStatueVisual(Transform parent)
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_040e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ca: Expected O, but got Unknown
			//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_070c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0711: Unknown result type (might be due to invalid IL or missing references)
			Transform val = null;
			float num = float.PositiveInfinity;
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(-57.26f, -25.07f, -0.92f);
			Transform[] array = Object.FindObjectsOfType<Transform>(true);
			foreach (Transform val3 in array)
			{
				if (Object.op_Implicit((Object)(object)val3) && !(((Object)val3).name != "mdlNewtStatue") && !val3.IsChildOf(parent) && ((Component)val3).gameObject.activeInHierarchy && !(((Component)val3).gameObject.scene != SceneManager.GetActiveScene()))
				{
					float num2 = Vector3.SqrMagnitude(val3.position - val2);
					if (num2 < num)
					{
						num = num2;
						val = val3;
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[NewtsKitchen] No active Bazaar entrance mdlNewtStatue was found; invisible cooking UI remains.");
				return;
			}
			GameObject val4 = Object.Instantiate<GameObject>(((Component)val).gameObject, parent, false);
			((Object)val4).name = "NK_StoneGooberVisual";
			val4.transform.localScale = val.localScale * Mathf.Clamp(statueScale.Value, 0.1f, 3f);
			val4.transform.position = parent.position + Vector3.up * statueHeight.Value;
			if (preserveSourceUpright.Value)
			{
				Vector3 val5 = val.forward;
				Transform val6 = (Object.op_Implicit((Object)(object)val.parent) ? val.parent.Find("Camera Focus") : null);
				if (Object.op_Implicit((Object)(object)val6))
				{
					val5 = val6.position - val.parent.position;
				}
				val5.y = 0f;
				if (((Vector3)(ref val5)).sqrMagnitude < 0.01f)
				{
					val5 = Vector3.right;
				}
				float num3 = Vector3.SignedAngle(((Vector3)(ref val5)).normalized, ShopFacing(), Vector3.up);
				val4.transform.rotation = Quaternion.AngleAxis(num3 + uprightVisualYawCorrection.Value, Vector3.up) * val.rotation;
				if (TryGetStoneBounds(val4.transform, out var result))
				{
					float floorY;
					string colliderName;
					bool flag = TryGetBazaarFloor(val4.transform.position, parent, out floorY, out colliderName);
					float num4 = (flag ? floorY : (parent.position.y - Mathf.Max(0f, fallbackGroundLowering.Value))) - Mathf.Max(0f, groundEmbedDepth.Value);
					float num5 = num4 - ((Bounds)(ref result)).min.y;
					Transform transform = val4.transform;
					transform.position += Vector3.up * num5;
					((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Floor alignment: anchorY=" + parent.position.y.ToString("F3") + " worldFloor=" + (flag ? floorY.ToString("F3") : "not found") + " floorCollider=" + colliderName + " meshBottomBefore=" + ((Bounds)(ref result)).min.y.ToString("F3") + " targetMeshBottom=" + num4.ToString("F3") + " moveY=" + num5.ToString("+0.000;-0.000;0.000") + " embedDepth=" + groundEmbedDepth.Value.ToString("F2")));
				}
				else
				{
					Transform transform2 = val4.transform;
					transform2.position += Vector3.down * Mathf.Max(0f, uprightMissingMeshLowering.Value);
					((BaseUnityPlugin)this).Logger.LogWarning((object)"[NewtsKitchen] No stone mesh bounds; using fallback lowering.");
				}
				if (verbose.Value)
				{
					ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
					string[] obj = new string[12]
					{
						"[NewtsKitchen] Upright statue from ",
						((object)val.position/*cast due to .constrained prefix*/).ToString(),
						" originalEuler=",
						null,
						null,
						null,
						null,
						null,
						null,
						null,
						null,
						null
					};
					Quaternion rotation = val.rotation;
					obj[3] = ((object)((Quaternion)(ref rotation)).eulerAngles/*cast due to .constrained prefix*/).ToString();
					obj[4] = " newEuler=";
					rotation = val4.transform.rotation;
					obj[5] = ((object)((Quaternion)(ref rotation)).eulerAngles/*cast due to .constrained prefix*/).ToString();
					obj[6] = " visualOriginY=";
					obj[7] = val4.transform.position.y.ToString("F2");
					obj[8] = " visualYawCorrection=";
					obj[9] = uprightVisualYawCorrection.Value.ToString();
					obj[10] = " shopFacing=";
					obj[11] = ((object)ShopFacing()/*cast due to .constrained prefix*/).ToString();
					logger.LogInfo((object)string.Concat(obj));
				}
			}
			else
			{
				val4.transform.localPosition = new Vector3(0f, statueHeight.Value, 0f);
				val4.transform.localRotation = Quaternion.Euler(statuePitch.Value, statueFacingOffset.Value + statueYawCorrection.Value, statueRollCorrection.Value);
			}
			MonoBehaviour[] componentsInChildren = val4.GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val7 in componentsInChildren)
			{
				if (Object.op_Implicit((Object)(object)val7))
				{
					((Behaviour)val7).enabled = false;
				}
			}
			int num6 = 0;
			Collider[] componentsInChildren2 = val4.GetComponentsInChildren<Collider>(true);
			foreach (Collider val8 in componentsInChildren2)
			{
				MeshCollider val9 = (MeshCollider)(object)((val8 is MeshCollider) ? val8 : null);
				if (Object.op_Implicit((Object)(object)val9) && Object.op_Implicit((Object)(object)val9.sharedMesh))
				{
					num6++;
					if (solidStatue.Value)
					{
						GameObject val10 = new GameObject("NK_GrillingGoober_OriginalMeshCollider");
						val10.transform.SetPositionAndRotation(((Component)val9).transform.position, ((Component)val9).transform.rotation);
						val10.transform.localScale = ((Component)val9).transform.lossyScale;
						int num7 = LayerMask.NameToLayer("World");
						if (num7 >= 0)
						{
							val10.layer = num7;
						}
						MeshCollider val11 = val10.AddComponent<MeshCollider>();
						val11.sharedMesh = val9.sharedMesh;
						val11.convex = val9.convex;
						((Collider)val11).isTrigger = false;
						((Collider)val11).enabled = true;
						KitchenMarker component = ((Component)parent).GetComponent<KitchenMarker>();
						if (Object.op_Implicit((Object)(object)component))
						{
							component.SolidStoneColliders.Add((Collider)(object)val11);
						}
						val10.AddComponent<EntityLocator>().entity = ((Component)parent).gameObject;
						if (verbose.Value)
						{
							((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Native stone collider restored as static mesh: mesh=" + ((Object)val9.sharedMesh).name + " convex=" + val11.convex + " worldPosition=" + ((object)val10.transform.position/*cast due to .constrained prefix*/).ToString() + " worldScale=" + ((object)val10.transform.localScale/*cast due to .constrained prefix*/).ToString() + " layer=" + LayerMask.LayerToName(val10.layer)));
						}
					}
				}
				if (Object.op_Implicit((Object)(object)val8))
				{
					val8.enabled = false;
				}
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Source Newt stone MeshColliders=" + num6 + "; solid=" + solidStatue.Value + "; interaction sphere is still a separate trigger."));
		}

		private static bool TryGetStoneBounds(Transform visual, out Bounds result)
		{
			//IL_0001: 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)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			result = default(Bounds);
			bool flag = false;
			Renderer[] componentsInChildren = ((Component)visual).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (!Object.op_Implicit((Object)(object)val) || (!(val is MeshRenderer) && !(val is SkinnedMeshRenderer)))
				{
					continue;
				}
				Bounds bounds = val.bounds;
				Vector3 size = ((Bounds)(ref bounds)).size;
				if (!(((Vector3)(ref size)).sqrMagnitude < 0.0001f))
				{
					if (!flag)
					{
						result = bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref result)).Encapsulate(bounds);
					}
				}
			}
			return flag;
		}

		private static bool TryGetBazaarFloor(Vector3 statuePosition, Transform chef, out float floorY, out string colliderName)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			floorY = 0f;
			colliderName = "none";
			int num = LayerMask.NameToLayer("World");
			RaycastHit[] array = Physics.RaycastAll(statuePosition + Vector3.up * 9f, Vector3.down, 25f, -1, (QueryTriggerInteraction)1);
			bool flag = false;
			bool flag2 = false;
			float num2 = float.NegativeInfinity;
			string text = "none";
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val = array2[i];
				Collider collider = ((RaycastHit)(ref val)).collider;
				if (Object.op_Implicit((Object)(object)collider) && !collider.isTrigger && !((Component)collider).transform.IsChildOf(chef) && !(((RaycastHit)(ref val)).point.y > chef.position.y + 0.25f) && !(((RaycastHit)(ref val)).point.y < chef.position.y - 5f))
				{
					bool flag3 = num >= 0 && ((Component)collider).gameObject.layer == num;
					bool flag4 = collider is MeshCollider || collider is TerrainCollider;
					if ((flag3 || flag4) && ((flag3 && !flag) || (flag3 == flag && ((RaycastHit)(ref val)).point.y > num2)))
					{
						flag = flag3;
						flag2 = true;
						num2 = ((RaycastHit)(ref val)).point.y;
						text = ((Object)collider).name;
					}
				}
			}
			if (!flag2)
			{
				return false;
			}
			floorY = num2;
			colliderName = text;
			return true;
		}

		private static void AddInteractionCollider(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("NK_InteractionArea");
			val.transform.SetParent(parent, false);
			val.transform.localPosition = new Vector3(0f, 1.6f, 0f);
			SphereCollider obj = val.AddComponent<SphereCollider>();
			((Collider)obj).isTrigger = true;
			obj.radius = 2.55f;
			val.AddComponent<EntityLocator>().entity = ((Component)parent).gameObject;
		}

		private void AddCookedPickupAura(Transform parent)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_009b: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find("NK_StoneGooberVisual");
			Vector3 val2 = parent.position;
			if (Object.op_Implicit((Object)(object)val) && TryGetStoneBounds(val, out var result))
			{
				((Vector3)(ref val2))..ctor(((Bounds)(ref result)).center.x, ((Bounds)(ref result)).min.y, ((Bounds)(ref result)).center.z);
			}
			val2 += new Vector3(foodAuraSideOffset.Value, foodAuraBaseOffset.Value, foodAuraForwardOffset.Value);
			GameObject val3 = new GameObject("NK_GrillingGoober_CookedPickupAura");
			val3.transform.SetParent(parent, true);
			val3.transform.position = val2;
			val3.transform.rotation = Quaternion.identity;
			GameObject val4 = new GameObject("NK_WarmCookingLight");
			val4.transform.SetParent(val3.transform, false);
			val4.transform.localPosition = new Vector3(0f, 1f, 0f);
			Light obj = val4.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.color = new Color(1f, 0.34f, 0.065f);
			obj.range = Mathf.Max(0.5f, glowRange.Value);
			obj.intensity = Mathf.Max(0f, glowIntensity.Value);
			if (!TryInstallCookedPickupLoops(val3.transform))
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[NewtsKitchen] Cooked pickup aura unavailable; warm lighting remains. No custom flame particles are spawned in v0.1.7.");
			}
		}

		private GameObject LoadGenericPickupVisualPrefab()
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			string[] array = new string[2] { "Prefabs/NetworkedObjects/GenericPickup", "Prefabs/GenericPickup" };
			foreach (string text in array)
			{
				try
				{
					GameObject val = LegacyResourcesAPI.Load<GameObject>(text);
					if (Object.op_Implicit((Object)(object)val))
					{
						if (verbose.Value)
						{
							((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Pickup VFX source: " + text));
						}
						return val;
					}
				}
				catch (Exception ex)
				{
					if (verbose.Value)
					{
						((BaseUnityPlugin)this).Logger.LogWarning((object)("[NewtsKitchen] Lookup " + text + ": " + ex.Message));
					}
				}
			}
			try
			{
				GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Common/GenericPickup.prefab").WaitForCompletion();
				if (Object.op_Implicit((Object)(object)val2))
				{
					if (verbose.Value)
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)"[NewtsKitchen] Pickup VFX source: addressable GenericPickup");
					}
					return val2;
				}
			}
			catch (Exception ex2)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("[NewtsKitchen] Pickup VFX addressable failed: " + ex2.Message));
			}
			return null;
		}

		private bool TryInstallCookedPickupLoops(Transform aura)
		{
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = LoadGenericPickupVisualPrefab();
			if (!Object.op_Implicit((Object)(object)val))
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[NewtsKitchen] No GenericPickup prefab found for cooked aura.");
				return false;
			}
			string[] obj = new string[7] { "FoodSystem", "MealSystem", "CookedSystem", "CookingSystem", "FoodTierSystem", "MealTierSystem", "CookedItemSystem" };
			Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true);
			Transform val2 = null;
			string[] array = obj;
			foreach (string name in array)
			{
				val2 = ((IEnumerable<Transform>)componentsInChildren).FirstOrDefault((Func<Transform, bool>)((Transform t) => Object.op_Implicit((Object)(object)t) && string.Equals(((Object)t).name, name, StringComparison.OrdinalIgnoreCase)));
				if (Object.op_Implicit((Object)(object)val2) && ((Component)val2).GetComponentsInChildren<ParticleSystem>(true).Length != 0)
				{
					break;
				}
				val2 = null;
			}
			if (!Object.op_Implicit((Object)(object)val2))
			{
				val2 = ((IEnumerable<Transform>)componentsInChildren).FirstOrDefault((Func<Transform, bool>)((Transform t) => Object.op_Implicit((Object)(object)t) && (((Object)t).name.IndexOf("food", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)t).name.IndexOf("meal", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)t).name.IndexOf("cook", StringComparison.OrdinalIgnoreCase) >= 0) && ((Component)t).GetComponentsInChildren<ParticleSystem>(true).Length != 0));
			}
			if (!Object.op_Implicit((Object)(object)val2))
			{
				string[] value = (from t in componentsInChildren
					where Object.op_Implicit((Object)(object)t) && ((Object)t).name.EndsWith("System", StringComparison.OrdinalIgnoreCase)
					select ((Object)t).name).Distinct().ToArray();
				((BaseUnityPlugin)this).Logger.LogWarning((object)("[NewtsKitchen] No Food/Meal pickup VFX system detected in GenericPickup. Available systems: " + string.Join(", ", value)));
				return false;
			}
			Transform val3 = val2.Find("Loops");
			if (!Object.op_Implicit((Object)(object)val3))
			{
				val3 = ((IEnumerable<Transform>)((Component)val2).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => Object.op_Implicit((Object)(object)t) && ((Object)t).name == "Loops" && ((Component)t).GetComponentsInChildren<ParticleSystem>(true).Length != 0));
			}
			Transform val4 = (Object.op_Implicit((Object)(object)val3) ? val3 : val2);
			GameObject val5 = Object.Instantiate<GameObject>(((Component)val4).gameObject, aura, false);
			((Object)val5).name = "NK_CookedPickupStyleLoops";
			val5.transform.localPosition = Vector3.zero;
			val5.transform.localRotation = Quaternion.identity;
			val5.transform.localScale = new Vector3(Mathf.Clamp(foodAuraScaleXZ.Value, 0.1f, 10f), Mathf.Clamp(foodAuraScaleY.Value, 0.1f, 10f), Mathf.Clamp(foodAuraScaleXZ.Value, 0.1f, 10f));
			MonoBehaviour[] componentsInChildren2 = val5.GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val6 in componentsInChildren2)
			{
				if (Object.op_Implicit((Object)(object)val6))
				{
					((Behaviour)val6).enabled = false;
				}
			}
			Collider[] componentsInChildren3 = val5.GetComponentsInChildren<Collider>(true);
			foreach (Collider val7 in componentsInChildren3)
			{
				if (Object.op_Implicit((Object)(object)val7))
				{
					val7.enabled = false;
				}
			}
			Transform[] componentsInChildren4 = val5.GetComponentsInChildren<Transform>(true);
			foreach (Transform val8 in componentsInChildren4)
			{
				if (Object.op_Implicit((Object)(object)val8))
				{
					((Component)val8).gameObject.SetActive(true);
				}
			}
			MeshRenderer[] componentsInChildren5 = val5.GetComponentsInChildren<MeshRenderer>(true);
			foreach (MeshRenderer val9 in componentsInChildren5)
			{
				if (Object.op_Implicit((Object)(object)val9))
				{
					((Renderer)val9).enabled = false;
				}
			}
			SkinnedMeshRenderer[] componentsInChildren6 = val5.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val10 in componentsInChildren6)
			{
				if (Object.op_Implicit((Object)(object)val10))
				{
					((Renderer)val10).enabled = false;
				}
			}
			int num = 0;
			ParticleSystem[] componentsInChildren7 = val5.GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem val11 in componentsInChildren7)
			{
				if (Object.op_Implicit((Object)(object)val11))
				{
					ParticleSystemRenderer component = ((Component)val11).GetComponent<ParticleSystemRenderer>();
					if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)((Renderer)component).sharedMaterial) && Object.op_Implicit((Object)(object)((Renderer)component).sharedMaterial.shader) && !((Renderer)component).sharedMaterial.shader.isSupported)
					{
						((Renderer)component).enabled = false;
						continue;
					}
					MainModule main = val11.main;
					((MainModule)(ref main)).loop = true;
					((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0;
					val11.Clear(true);
					val11.Play(true);
					num++;
				}
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Borrowed cooked pickup VFX: " + ((Object)val2).name + "/" + ((Object)val4).name + ", particleSystems=" + num + ", scale=(" + foodAuraScaleXZ.Value + "," + foodAuraScaleY.Value + "," + foodAuraScaleXZ.Value + "), anchor=" + ((object)aura.position/*cast due to .constrained prefix*/).ToString()));
			return num > 0;
		}

		private void TryPatchContextText(GameObject cook)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			if (contextPatchAttempted)
			{
				return;
			}
			contextPatchAttempted = true;
			try
			{
				MethodInfo method = typeof(Plugin).GetMethod("ContextTextPostfix", BindingFlags.Static | BindingFlags.NonPublic);
				MonoBehaviour[] componentsInChildren = cook.GetComponentsInChildren<MonoBehaviour>(true);
				foreach (MonoBehaviour val in componentsInChildren)
				{
					if (Object.op_Implicit((Object)(object)val) && val is IInteractable)
					{
						MethodInfo method2 = ((object)val).GetType().GetMethod("GetContextString", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(Interactor) }, null);
						if (!(method2 == null) && !(method2.ReturnType != typeof(string)))
						{
							contextHarmony.Patch((MethodBase)method2, (HarmonyMethod)null, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
							((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Dynamic Lunar price prompt attached to " + method2.DeclaringType.FullName));
							return;
						}
					}
				}
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[NewtsKitchen] Could not locate cooking interactable context method; vanilla prompt retained.");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("[NewtsKitchen] Custom prompt unavailable; vanilla prompt preserved. " + ex.Message));
			}
		}

		private static void ContextTextPostfix(object __instance, ref string __result)
		{
			Component val = (Component)((__instance is Component) ? __instance : null);
			if (!Object.op_Implicit((Object)(object)val) || !IsBazaar() || !Object.op_Implicit((Object)(object)val.GetComponent<KitchenMarker>()) || (Object)(object)_instance == (Object)null)
			{
				return;
			}
			if (!NetworkServer.active && !_instance.hasHostKitchenState)
			{
				__result = "Grilling Goober: Syncing kitchen prices...";
				return;
			}
			int sharedCookingLimit = _instance.GetSharedCookingLimit();
			if (_instance.completedCooks >= sharedCookingLimit)
			{
				__result = "Grilling Goober: Kitchen Closed (" + sharedCookingLimit + " cooks used)";
			}
			else
			{
				__result = "Grilling Goober: Cook Items (" + _instance.CurrentCost() + " Lunar Coins)";
			}
		}

		private int CurrentCost()
		{
			if (!NetworkServer.active && hasHostKitchenState)
			{
				return hostNextFee;
			}
			double num = Math.Max(0, startingCost.Value);
			double x = Math.Max(1.0, costMultiplier.Value);
			double num2 = Math.Ceiling(num * Math.Pow(x, Math.Max(0, completedCooks)));
			if (double.IsNaN(num2) || double.IsInfinity(num2))
			{
				return int.MaxValue;
			}
			return (int)Math.Min(2147483647.0, num2);
		}

		private int GetSharedCookingLimit()
		{
			if (!NetworkServer.active && hasHostKitchenState)
			{
				return hostCookLimit;
			}
			int num = Mathf.Max(0, cookingLimitPerPlayer.Value);
			if (num == 0)
			{
				return int.MaxValue;
			}
			int num2 = 1;
			try
			{
				num2 = Mathf.Max(1, NetworkUser.readOnlyInstancesList.Count);
			}
			catch (Exception ex)
			{
				if (verbose.Value)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("[NewtsKitchen] Player count unavailable: " + ex.Message));
				}
			}
			if (num2 > mostPlayersThisVisit)
			{
				mostPlayersThisVisit = num2;
				if (NetworkServer.active && verbose.Value)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Shared cooking allowance: " + num + " cooks/player x " + mostPlayersThisVisit + " players = " + (long)num * (long)mostPlayersThisVisit + " cooks this Bazaar visit."));
				}
			}
			long num3 = (long)num * (long)Mathf.Max(1, mostPlayersThisVisit);
			if (num3 < int.MaxValue)
			{
				return (int)num3;
			}
			return int.MaxValue;
		}

		private bool CanCookMore()
		{
			if (NetworkServer.active || hasHostKitchenState)
			{
				return completedCooks < GetSharedCookingLimit();
			}
			return false;
		}

		private static bool IsOurKitchen(Component c)
		{
			if (Object.op_Implicit((Object)(object)c) && IsBazaar())
			{
				return (Object)(object)c.GetComponent<KitchenMarker>() != (Object)null;
			}
			return false;
		}

		private bool CanAfford(Interactor interactor, int price, out NetworkUser user)
		{
			user = (Object.op_Implicit((Object)(object)interactor) ? Util.LookUpBodyNetworkUser(((Component)interactor).gameObject) : null);
			if (Object.op_Implicit((Object)(object)user))
			{
				return (ulong)user.lunarCoins >= (ulong)price;
			}
			return false;
		}

		private void InterceptMenuOpen(orig_OnInteractionBegin orig, PickupPickerController self, Interactor activator)
		{
			if (!IsOurKitchen((Component)(object)self))
			{
				orig.Invoke(self, activator);
				return;
			}
			if (!CanCookMore())
			{
				if (verbose.Value)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] " + ((!NetworkServer.active && !hasHostKitchenState) ? "Cooking menu waiting for server state." : ("Denied cooking menu: shared limit " + completedCooks + "/" + GetSharedCookingLimit() + " reached."))));
				}
				return;
			}
			int price = CurrentCost();
			if (!CanAfford(activator, price, out var _))
			{
				if (verbose.Value)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Denied cooking menu: not enough Lunar Coins, price=" + price));
				}
			}
			else
			{
				orig.Invoke(self, activator);
			}
		}

		private void GuardConfirm(orig_OnConfirmServer orig, CraftingController self)
		{
			if (!NetworkServer.active || !IsOurKitchen((Component)(object)self))
			{
				orig.Invoke(self);
				return;
			}
			if (!CanCookMore())
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Rejected recipe confirm: shared cooking limit reached (" + completedCooks + "/" + GetSharedCookingLimit() + ")."));
				return;
			}
			NetworkUIPromptController component = ((Component)self).GetComponent<NetworkUIPromptController>();
			CharacterMaster val = (Object.op_Implicit((Object)(object)component) ? component.currentParticipantMaster : null);
			GameObject val2 = (Object.op_Implicit((Object)(object)val) ? val.GetBodyObject() : null);
			Interactor interactor = (Object.op_Implicit((Object)(object)val2) ? val2.GetComponent<Interactor>() : null);
			if (!CanAfford(interactor, CurrentCost(), out var _))
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"[NewtsKitchen] Rejected recipe confirm (Lunar Coin fee unavailable).");
			}
			else
			{
				orig.Invoke(self);
			}
		}

		private unsafe void InterceptCooking(orig_BeginCookingServer orig, MealPrepController self, Interactor actor, PickupIndex[] ingredients, PickupIndex reward, int quantity)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Invalid comparison between Unknown and I4
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: 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)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Expected O, but got Unknown
			if (!NetworkServer.active || !IsOurKitchen((Component)(object)self))
			{
				orig.Invoke(self, actor, ingredients, reward, quantity);
				return;
			}
			if (!CanCookMore())
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Cook canceled: team has used " + completedCooks + "/" + GetSharedCookingLimit() + " successful cooks this visit."));
				return;
			}
			int num = CurrentCost();
			if (!CanAfford(actor, num, out var user))
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[NewtsKitchen] Cook canceled: insufficient Lunar Coins at confirmation.");
				return;
			}
			CharacterBody val = (Object.op_Implicit((Object)(object)actor) ? ((Component)actor).GetComponent<CharacterBody>() : null);
			Inventory inventory = (Object.op_Implicit((Object)(object)val) ? val.inventory : null);
			if (!Object.op_Implicit((Object)(object)inventory) || ingredients == null || ingredients.Length == 0 || quantity < 1 || reward == PickupIndex.none)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[NewtsKitchen] Cook canceled: invalid actor, recipe input, or result.");
				return;
			}
			Dictionary<ItemIndex, int> dictionary = new Dictionary<ItemIndex, int>();
			for (int i = 0; i < ingredients.Length; i++)
			{
				PickupDef pickupDef = PickupCatalog.GetPickupDef(ingredients[i]);
				if (pickupDef == null || (int)pickupDef.itemIndex == -1)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"[NewtsKitchen] Recipe contains non-item ingredient; safely canceled in v0.1.");
					return;
				}
				if (!dictionary.ContainsKey(pickupDef.itemIndex))
				{
					dictionary[pickupDef.itemIndex] = 0;
				}
				dictionary[pickupDef.itemIndex]++;
			}
			foreach (KeyValuePair<ItemIndex, int> item in dictionary)
			{
				if (inventory.GetItemCount(item.Key) < item.Value)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"[NewtsKitchen] Cook canceled: ingredients changed while menu was open.");
					return;
				}
			}
			Dictionary<ItemIndex, int> before = dictionary.ToDictionary((KeyValuePair<ItemIndex, int> p) => p.Key, (KeyValuePair<ItemIndex, int> p) => inventory.GetItemCount(p.Key));
			try
			{
				orig.Invoke(self, actor, ingredients, reward, quantity);
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("[NewtsKitchen] Vanilla BeginCookingServer threw. No Lunar Coins charged: " + ex));
				return;
			}
			if (!dictionary.All((KeyValuePair<ItemIndex, int> p) => inventory.GetItemCount(p.Key) <= before[p.Key] - p.Value))
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[NewtsKitchen] Native craft did not immediately remove the expected items. No fee or manual reward applied; leaving vanilla state intact for safety.");
				return;
			}
			user.DeductLunarCoins((uint)num);
			completedCooks++;
			BroadcastKitchenState();
			if (verbose.Value)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("[NewtsKitchen] Confirmed cook #" + completedCooks + "/" + GetSharedCookingLimit() + ": fee=" + num + " nextFee=" + CurrentCost() + " reward=" + ((object)(*(PickupIndex*)(&reward))/*cast due to .constrained prefix*/).ToString() + " quantity=" + quantity));
			}
			Vector3 customerPosition = (Object.op_Implicit((Object)(object)actor) ? ((Component)actor).transform.position : (((Component)self).transform.position + ShopFacing() * 4f));
			((MonoBehaviour)this).StartCoroutine(FinishCookingAfterDelay(self, reward, quantity, customerPosition));
			if (flavorText.Value)
			{
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = sayings[Random.Range(0, sayings.Length)]
				});
			}
		}

		private unsafe Vector3 GetClearCookedPickupOrigin(MealPrepController mealPrep, Vector3 direction)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_003b: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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)
			//IL_02ba: 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_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)mealPrep).transform.position + Vector3.up * outputHeight.Value + direction * outputForwardDistance.Value;
			KitchenMarker component = ((Component)mealPrep).GetComponent<KitchenMarker>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return val;
			}
			Bounds val2 = default(Bounds);
			bool flag = false;
			foreach (Collider solidStoneCollider in component.SolidStoneColliders)
			{
				if (Object.op_Implicit((Object)(object)solidStoneCollider) && solidStoneCollider.enabled)
				{
					if (!flag)
					{
						val2 = solidStoneCollider.bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref val2)).Encapsulate(solidStoneCollider.bounds);
					}
				}
			}
			if (!flag)
			{
				return val;
			}
			float num = float.PositiveInfinity;
			if (Mathf.Abs(direction.x) > 0.0001f)
			{
				float num2 = ((direction.x > 0f) ? ((Bounds)(ref val2)).max.x : ((Bounds)(ref val2)).min.x);
				num = Mathf.Min(num, (num2 - ((Bounds)(ref val2)).center.x) / direction.x);
			}
			if (Mathf.Abs(direction.z) > 0.0001f)
			{
				float num3 = ((direction.z > 0f) ? ((Bounds)(ref val2)).max.z : ((Bounds)(ref val2)).min.z);
				num = Mathf.Min(num, (num3 - ((Bounds)(ref val2)).center.z) / direction.z);
			}
			if (float.IsInfinity(num) || float.IsNaN(num))
			{
				return val;
			}
			float num4 = Mathf.Max(Mathf.Max(0f, outputForwardDistance.Value), Mathf.Max(0f, num) + Mathf.Max(0.15f, pickupSideClearance.Value));
			Vector3 val3 = ((Bounds)(ref val2)).center + direction * num4;
			val.x = val3.x;
			val.z = val3.z;
			val.y = Mathf.Max(val.y, ((Bounds)(ref val2)).max.y + Mathf.Max(0.15f, pickupTopClearance.Value));
			if (verbose.Value)
			{
				ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
				string[] obj = new string[8] { "[NewtsKitchen] Pickup release cleared stone: colliderBounds=", null, null, null, null, null, null, null };
				Bounds val4 = val2;
				obj[1] = ((object)(*(Bounds*)(&val4))/*cast due to .constrained prefix*/).ToString();
				obj[2] = " exitDistance=";
				obj[3] = num.ToString("F2");
				obj[4] = " origin=";
				Vector3 val5 = val;
				obj[5] = ((object)(*(Vector3*)(&val5))/*cast due to .constrained prefix*/).ToString();
				obj[6] = " launchDirection=";
				val5 = direction;
				obj[7] = ((object)(*(Vector3*)(&val5))/*cast due to .constrained prefix*/).ToString();
				logger.LogInfo((object)string.Concat(obj));
			}
			return val;
		}

		private unsafe IEnumerator FinishCookingAfterDelay(MealPrepController mealPrep, PickupIndex reward, int amount, Vector3 customerPosition)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitForFixedUpdate();
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)mealPrep) || !IsBazaar())
			{
				yield break;
			}
			EntityStateMachine component = ((Component)mealPrep).GetComponent<EntityStateMachine>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.SetNextStateToMain();
			}
			float delay = Mathf.Clamp(cookingDelay.Value, 0f, 10f);
			if (delay > 0f)
			{
				yield return (object)new WaitForSeconds(delay);
			}
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)mealPrep) || !IsBazaar())
			{
				yield break;
			}
			Vector3 val = Quaternion.AngleAxis(fallbackDropYawCorrection.Value, Vector3.up) * ShopFacing();
			if (aimOutputAtCustomer.Value)
			{
				Vector3 val2 = customerPosition - ((Component)mealPrep).transform.position;
				val2.y = 0f;
				if (((Vector3)(ref val2)).sqrMagnitude > 0.25f && Vector3.Angle(val2, val) <= 80f)
				{
					val = ((Vector3)(ref val2)).normalized;
				}
			}
			val = Quaternion.AngleAxis(outputYawOffset.Value, Vector3.up) * val;
			val.y = 0f;
			((Vector3)(ref val)).Normalize();
			Vector3 clearCookedPickupOrigin = GetClearCookedPickupOrigin(mealPrep, val);
			UniquePickup val5 = default(UniquePickup);
			for (int i = 0; i < Mathf.Clamp(amount, 1, 30); i++)
			{
				Vector3 val3 = clearCookedPickupOrigin;
				Vector3 val4 = Vector3.up * outputUpSpeed.Value + val * outputForwardSpeed.Value;
				((UniquePickup)(ref val5))..ctor(reward);
				val5.ignoreArtifactBasedPickupReplacements = true;
				UniquePickup pickup = val5;
				CreatePickupInfo val6 = default(CreatePickupInfo);
				((CreatePickupInfo)(ref val6)).pickup = pickup;
				val6.position = val3;
				val6.rotation = Quaternion.identity;
				PickupDropletController.CreatePickupDroplet(val6, val3, val4);
			}
			if (verbose.Value)
			{
				ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
				string[] obj = new string[8]
				{
					"[NewtsKitchen] Exact non-Command cooked pickup spawned after ",
					delay.ToString(),
					"s: ",
					((object)(*(PickupIndex*)(&reward))/*cast due to .constrained prefix*/).ToString(),
					" launchDirection=",
					null,
					null,
					null
				};
				Vector3 val7 = val;
				obj[5] = ((object)(*(Vector3*)(&val7))/*cast due to .constrained prefix*/).ToString();
				obj[6] = " target=";
				val7 = customerPosition;
				obj[7] = ((object)(*(Vector3*)(&val7))/*cast due to .constrained prefix*/).ToString();
				logger.LogInfo((object)string.Concat(obj));
			}
		}
	}
	public sealed class KitchenStateSync : INetMessage, ISerializableObject
	{
		private NetworkInstanceId kitchenId;

		private int completed;

		private int maximum;

		private int nextFee;

		public KitchenStateSync()
		{
		}

		public KitchenStateSync(NetworkInstanceId id, int completedCooks, int limit, int price)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			kitchenId = id;
			completed = completedCooks;
			maximum = limit;
			nextFee = price;
		}

		public void Serialize(NetworkWriter writer)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(kitchenId);
			writer.Write(completed);
			writer.Write(maximum);
			writer.Write(nextFee);
		}

		public void Deserialize(NetworkReader reader)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			kitchenId = reader.ReadNetworkId();
			completed = reader.ReadInt32();
			maximum = reader.ReadInt32();
			nextFee = reader.ReadInt32();
		}

		public void OnReceived()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Plugin.ReceiveKitchenState(kitchenId, completed, maximum, nextFee);
		}
	}
	public sealed class KitchenStateRequest : INetMessage, ISerializableObject
	{
		private NetworkInstanceId kitchenId;

		public KitchenStateRequest()
		{
		}

		public KitchenStateRequest(NetworkInstanceId id)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			kitchenId = id;
		}

		public void Serialize(NetworkWriter writer)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(kitchenId);
		}

		public void Deserialize(NetworkReader reader)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			kitchenId = reader.ReadNetworkId();
		}

		public void OnReceived()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Plugin.HandleKitchenStateRequest(kitchenId);
		}
	}
	public sealed class KitchenMarker : MonoBehaviour
	{
		public readonly List<Collider> SolidStoneColliders = new List<Collider>();
	}
}