Decompiled source of Kroes Utilities v1.2.0

KroesSupermarketMod.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using KroesSupermarketMod.CustomScripts;
using KroesSupermarketMod.Patches;
using Microsoft.CodeAnalysis;
using Mirror;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Playables;
using UnityEngine.UI;

[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: AssemblyCompany("KroesSupermarketMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f9bc2e9a5616e9ec80fd355f0ee883a798162435")]
[assembly: AssemblyProduct("KroesSupermarketMod")]
[assembly: AssemblyTitle("KroesSupermarketMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace KroesSupermarketMod
{
	internal class ConfigManager
	{
		private ConfigEntry<bool> customNpcHitNotificationCfg;

		private ConfigEntry<bool> doublePriceGunCfg;

		private ConfigEntry<bool> franchiseProgressBarCfg;

		private ConfigEntry<bool> chatCommandsCfg;

		private ConfigEntry<bool> euroSymbolCfg;

		private ConfigEntry<bool> throwBoxesCfg;

		private ConfigEntry<bool> thirdPersonCameraCfg;

		private ConfigEntry<float> thirdPersonCameraFollowDistanceCfg;

		private ConfigEntry<bool> betterMiniTransporterCfg;

		private ConfigEntry<int> MiniTransporterExtraBoxesCfg;

		private ConfigEntry<float> maxForwardSpeedCfg;

		private ConfigEntry<float> maxBackwardSpeedCfg;

		private ConfigEntry<float> accelerationRateCfg;

		private ConfigEntry<float> decelerationRateCfg;

		private ConfigEntry<float> maxRotationSpeedCfg;

		private ConfigEntry<bool> disableBuildingLimitsCfg;

		private ConfigEntry<bool> showWorldBordersCfg;

		private ConfigEntry<bool> customerShoppingListsCfg;

		internal bool customNpcHitNotifications => customNpcHitNotificationCfg.Value;

		internal bool doublePriceGun => doublePriceGunCfg.Value;

		internal bool franchiseProgressBar => franchiseProgressBarCfg.Value;

		internal bool chatCommands => chatCommandsCfg.Value;

		internal bool euroSymbol => euroSymbolCfg.Value;

		internal bool throwBoxes => throwBoxesCfg.Value;

		internal bool thirdPersonCamera => thirdPersonCameraCfg.Value;

		internal float thirdPersonCameraFollowDistance => thirdPersonCameraFollowDistanceCfg.Value;

		internal bool betterMiniTransporter => betterMiniTransporterCfg.Value;

		internal int MiniTransporterExtraBoxes => MiniTransporterExtraBoxesCfg.Value;

		internal float maxForwardSpeed => maxForwardSpeedCfg.Value;

		internal float maxBackwardSpeed => maxBackwardSpeedCfg.Value;

		internal float accelerationRate => accelerationRateCfg.Value;

		internal float decelerationRate => decelerationRateCfg.Value;

		internal float maxRotationSpeed => maxRotationSpeedCfg.Value;

		internal bool disableBuildingLimits => disableBuildingLimitsCfg.Value;

		internal bool showWorldBorders => showWorldBordersCfg.Value;

		internal bool customerShoppingLists => customerShoppingListsCfg.Value;

		public ConfigManager(ConfigFile config)
		{
			doublePriceGunCfg = config.Bind<bool>("General", "DoublePriceGun", true, "Enable double price gun feature.");
			franchiseProgressBarCfg = config.Bind<bool>("General", "FranchiseProgressBar", true, "Enable the franchise progress bar feature.");
			euroSymbolCfg = config.Bind<bool>("General", "EuroSymbol", false, "Replace dollar sign with euro.");
			disableBuildingLimitsCfg = config.Bind<bool>("General", "Disable Building Limits", true, "Placing builds is no longer limit to specific ranges.");
			customerShoppingListsCfg = config.Bind<bool>("General", "Customer Shopping Lists", true, "Enable customer shopping lists feature.");
			thirdPersonCameraCfg = config.Bind<bool>("Third Person Camera", "Enable Third Person Camera", true, "Allow camera switching using the mouse scroll wheel.");
			thirdPersonCameraFollowDistanceCfg = config.Bind<float>("Third Person Camera", "Camera Follow Distance", 4f, "(float) distance at which the camera follows you.");
			betterMiniTransporterCfg = config.Bind<bool>("Mini Transporter", "BetterMiniTransporter", false, "more box capacity and driving modifications.");
			MiniTransporterExtraBoxesCfg = config.Bind<int>("Mini Transporter", "Extra Boxes Amount", 2, "(int) amount of extra boxes to add. (max 6)");
			maxForwardSpeedCfg = config.Bind<float>("Mini Transporter", "Max Forward Speed", 8f, "(float) max speed going forwards. (default 8)");
			maxBackwardSpeedCfg = config.Bind<float>("Mini Transporter", "Max Backward Speed", 5f, "(float) max speed going backwards. (default 5)");
			accelerationRateCfg = config.Bind<float>("Mini Transporter", "Acceleration Rate", 6f, "(float) how fast the transporter accelerates. (default 6)");
			decelerationRateCfg = config.Bind<float>("Mini Transporter", "Deceleration Rate", 5f, "(float) how fast the transporter decelerates. (default 5)");
			maxRotationSpeedCfg = config.Bind<float>("Mini Transporter", "Max Rotation Speed", 75f, "(float) max steering speed. (default 75)");
			customNpcHitNotificationCfg = config.Bind<bool>("Experimental", "CustomNpcHitNotifications", false, "Enable custom voice lines (inside jokes).");
			throwBoxesCfg = config.Bind<bool>("Experimental", "ThrowBoxes", false, "Throw boxes instead of dropping.");
			chatCommandsCfg = config.Bind<bool>("Experimental", "ChatCommands", false, "Enable chat commands feature.");
			showWorldBordersCfg = config.Bind<bool>("Experimental", "ShowWorldBorders", false, "Toggle world border visibility with F8.");
		}
	}
	[BepInPlugin("com.chris.kroes.supermarket", "Kroes Supermarket", "1.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "com.chris.kroes.supermarket";

		private const string NAME = "Kroes Supermarket";

		private const string VERSION = "1.2.0";

		internal static ManualLogSource mls;

		internal static ConfigManager config;

		internal static Harmony harmony = new Harmony("com.chris.kroes.supermarket");

		internal static Plugin instance;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = ((BaseUnityPlugin)this).Logger;
			config = new ConfigManager(((BaseUnityPlugin)this).Config);
			HarmonyPatches();
			mls.LogInfo((object)"Loaded succesfully");
		}

		private void HarmonyPatches()
		{
			if (config.doublePriceGun)
			{
				harmony.PatchAll(typeof(PriceGunPatch));
				mls.LogInfo((object)"Patched: double price gun");
			}
			if (config.franchiseProgressBar)
			{
				harmony.PatchAll(typeof(FranchiseBarPatch));
				mls.LogInfo((object)"Patched: franchise progress bar");
			}
			if (config.euroSymbol)
			{
				harmony.PatchAll(typeof(EuroSymbolPatch));
				mls.LogInfo((object)"Patched: euro symbol");
			}
			if (config.disableBuildingLimits)
			{
				harmony.PatchAll(typeof(BuildingLimitsPatch));
				mls.LogInfo((object)"Patched: disable building limits");
			}
			if (config.customerShoppingLists)
			{
				harmony.PatchAll(typeof(CustomerShoppingListPatch));
				mls.LogInfo((object)"Patched: customer shopping lists");
			}
			if (config.thirdPersonCamera)
			{
				harmony.PatchAll(typeof(ThirdPersonCameraPatch));
				ThirdPersonCameraPatch.thirdPersonCameraDistance = config.thirdPersonCameraFollowDistance;
				mls.LogInfo((object)"Patched: third person camera");
			}
			if (config.betterMiniTransporter)
			{
				harmony.PatchAll(typeof(MiniTransporterPatch));
				MiniTransporterPatch.boxesToAdd = config.MiniTransporterExtraBoxes;
				mls.LogInfo((object)"Patched: better mini transporter");
				MiniTransporterPatch._maxForwardSpeed = config.maxForwardSpeed;
				mls.LogInfo((object)("* max forward speed: " + config.maxForwardSpeed));
				MiniTransporterPatch._maxBackwardSpeed = config.maxBackwardSpeed;
				mls.LogInfo((object)("* max backward speed: " + config.maxBackwardSpeed));
				MiniTransporterPatch._accelerationRate = config.accelerationRate;
				mls.LogInfo((object)("* acceleration rate: " + config.accelerationRate));
				MiniTransporterPatch._decelerationRate = config.decelerationRate;
				mls.LogInfo((object)("* deceleration rate: " + config.decelerationRate));
				MiniTransporterPatch._maxRotationSpeed = config.maxRotationSpeed;
				mls.LogInfo((object)("* max rotation speed: " + config.maxRotationSpeed));
			}
			if (config.customNpcHitNotifications)
			{
				harmony.PatchAll(typeof(NpcNotificationPatch));
				mls.LogInfo((object)"Patched: custom npc voice lines (EXPERIMENTAL)");
			}
			if (config.throwBoxes)
			{
				harmony.PatchAll(typeof(LayoutManagerPatch));
				harmony.PatchAll(typeof(ThrowableBoxesPatch));
				mls.LogInfo((object)"Patched: throwable boxes (EXPERIMENTAL)");
			}
			if (config.chatCommands)
			{
				harmony.PatchAll(typeof(ChatCommandsPatch));
				mls.LogInfo((object)"Patched: chat commands (EXPERIMENTAL)");
			}
			if (config.showWorldBorders)
			{
				harmony.PatchAll(typeof(WorldBordersPatch));
				mls.LogInfo((object)"Patched: show world borders (EXPERIMENTAL)");
			}
		}
	}
	internal class Utilities
	{
		public static GameObject recycleObj1 = null;

		public static GameObject recycleObj2 = null;

		public static GameObject trashObj = null;

		private static readonly string[] weatherStrings = new string[6] { "normal", "normal+", "normal++", "rain", "rain+", "snow" };

		private static readonly string[] poseStrings = new string[42]
		{
			"idle1", "CrouchIdle", "run", "walk", "CrouchWalking", "Trip", "Standing Melee Attack Horizontal", "1_HipHopDance", "2_StupidDance", "3_Salute",
			"4_TheHurricane", "5_GroovyDance", "6_OogieBoogie", "7_SalsaDance", "8_SwingDance", "9_Swimming", "10_HipHopDance2", "11_RobotDance", "12_HouseDancing", "13_Singing",
			"14_Flair", "15_UprockDance", "16_GuitarPlay", "17_Falling", "18_ClimbInPlace", "19_Hanging", "20_QuietPose_1", "21_QuietPose_2", "22_QuietPose_3", "23_QuietPose_4",
			"24_BreakDanceFreeze", "25_WaveDance", "26_SillyDance", "27_Cheering", "28_Clapping", "29_Victory", "30_SleepOnFloor", "31_Cartwheel", "32_Praying", "33_Scared",
			"34_Capoeira", "35_Statue"
		};

		private static readonly Dictionary<string, int> commonProps = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase) { { "ladder", 8 } };

		private static readonly Dictionary<string, int> commonDecorations = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
		{
			{ "tv", 3 },
			{ "train", 68 },
			{ "wagon", 275 }
		};

		private static void CreateCanvasNotification(string message)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			GameCanvas val = Object.FindFirstObjectByType<GameCanvas>();
			if ((Object)(object)val == (Object)null || (bool)AccessTools.Field(((object)val).GetType(), "inCooldown").GetValue(val))
			{
				return;
			}
			GameObject val2 = (GameObject)AccessTools.Field(((object)val).GetType(), "notificationPrefab").GetValue(val);
			Transform val3 = (Transform)AccessTools.Field(((object)val).GetType(), "notificationParentTransform").GetValue(val);
			if ((Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null)
			{
				GameObject val4 = Object.Instantiate<GameObject>(val2, val3);
				TextMeshProUGUI component = val4.GetComponent<TextMeshProUGUI>();
				if ((Object)(object)component != (Object)null)
				{
					((TMP_Text)component).text = message;
				}
				val4.SetActive(true);
				((MonoBehaviour)val).StartCoroutine("NotificationCooldown");
			}
		}

		private static void CreateImportantNotification(string message)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			GameCanvas val = Object.FindFirstObjectByType<GameCanvas>();
			if ((Object)(object)val == (Object)null || (bool)AccessTools.Field(((object)val).GetType(), "inCooldown").GetValue(val))
			{
				return;
			}
			GameObject val2 = (GameObject)AccessTools.Field(((object)val).GetType(), "importantNotificationPrefab").GetValue(val);
			Transform val3 = (Transform)AccessTools.Field(((object)val).GetType(), "importantNotificationParentTransform").GetValue(val);
			if ((Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null)
			{
				GameObject val4 = Object.Instantiate<GameObject>(val2, val3);
				TextMeshProUGUI component = val4.GetComponent<TextMeshProUGUI>();
				if ((Object)(object)component != (Object)null)
				{
					((TMP_Text)component).text = message;
				}
				val4.SetActive(true);
				((MonoBehaviour)val).StartCoroutine("NotificationCooldown");
			}
		}

		private static void PlayEmoteOnNpc(GameObject npcOBJ, string pose)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)npcOBJ == (Object)null)
			{
				return;
			}
			Animator componentInChildren = npcOBJ.GetComponentInChildren<Animator>();
			if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.runtimeAnimatorController == (Object)null)
			{
				return;
			}
			AnimationClip[] animationClips = componentInChildren.runtimeAnimatorController.animationClips;
			PlayableGraph val2 = default(PlayableGraph);
			foreach (AnimationClip val in animationClips)
			{
				if (((Object)val).name.Equals(pose, StringComparison.OrdinalIgnoreCase))
				{
					AnimationPlayableUtilities.PlayClip(componentInChildren, val, ref val2);
					return;
				}
			}
			Plugin.mls.LogInfo((object)("Clip '" + pose + "' niet gevonden op NPC!"));
		}

		private static void ResetNpcAnimator(GameObject npcOBJ)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)npcOBJ == (Object)null)
			{
				return;
			}
			Animator componentInChildren = npcOBJ.GetComponentInChildren<Animator>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return;
			}
			if (componentInChildren.hasBoundPlayables)
			{
				PlayableGraph playableGraph = componentInChildren.playableGraph;
				if (((PlayableGraph)(ref playableGraph)).IsValid())
				{
					((PlayableGraph)(ref playableGraph)).Destroy();
				}
			}
			componentInChildren.Rebind();
			componentInChildren.Update(0f);
		}

		public static void EnsureProgressBarCreated(TextMeshProUGUI targetText, ref Slider progressBar)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0064: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_010d: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			//IL_01f0: 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_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)progressBar != (Object)null))
			{
				GameObject val = new GameObject("FranchiseProgressBar", new Type[2]
				{
					typeof(RectTransform),
					typeof(Slider)
				});
				val.transform.SetParent(((TMP_Text)targetText).transform, false);
				RectTransform component = val.GetComponent<RectTransform>();
				component.anchorMin = new Vector2(0.5f, 1f);
				component.anchorMax = new Vector2(0.5f, 1f);
				component.pivot = new Vector2(0.5f, 0f);
				component.anchoredPosition = new Vector2(0f, 20f);
				component.sizeDelta = new Vector2(240f, 15f);
				GameObject val2 = new GameObject("Background", new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val2.transform.SetParent(val.transform, false);
				RectTransform component2 = val2.GetComponent<RectTransform>();
				component2.anchorMin = Vector2.zero;
				component2.anchorMax = Vector2.one;
				component2.sizeDelta = Vector2.zero;
				((Graphic)val2.GetComponent<Image>()).color = Color.white;
				GameObject val3 = new GameObject("Fill Area", new Type[1] { typeof(RectTransform) });
				val3.transform.SetParent(val.transform, false);
				RectTransform component3 = val3.GetComponent<RectTransform>();
				component3.anchorMin = Vector2.zero;
				component3.anchorMax = Vector2.one;
				component3.sizeDelta = Vector2.zero;
				GameObject val4 = new GameObject("Fill", new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val4.transform.SetParent(val3.transform, false);
				RectTransform component4 = val4.GetComponent<RectTransform>();
				component4.anchorMin = Vector2.zero;
				component4.anchorMax = Vector2.one;
				component4.sizeDelta = Vector2.zero;
				Image component5 = val4.GetComponent<Image>();
				((Graphic)component5).color = new Color(0.58f, 0.318f, 0.973f);
				progressBar = val.GetComponent<Slider>();
				progressBar.fillRect = component4;
				progressBar.minValue = 0f;
				progressBar.maxValue = 1f;
				((Selectable)progressBar).interactable = false;
			}
		}

		public static float GetLevelProgress(int currentExp)
		{
			int num = 0;
			for (int i = 1; (float)i < float.PositiveInfinity; i++)
			{
				num += i * 100;
				if (num > currentExp)
				{
					float num2 = currentExp - (num - i * 100);
					float num3 = i * 100;
					return num2 / num3;
				}
			}
			return 0f;
		}

		public static bool TryParseCommand(string rawChatMessage, out string command, out string[] args)
		{
			command = string.Empty;
			args = Array.Empty<string>();
			if (string.IsNullOrWhiteSpace(rawChatMessage) || !rawChatMessage.StartsWith("/"))
			{
				return false;
			}
			string[] array = rawChatMessage.Substring(1).Split(new char[1] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);
			if (array.Length == 0)
			{
				return false;
			}
			command = array[0].ToLower();
			if (array.Length > 1)
			{
				args = array[1].Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
			}
			return true;
		}

		public static void ChatCommand_Npc(string[] args)
		{
			NPC_Info[] array = Object.FindObjectsByType<NPC_Info>((FindObjectsSortMode)0);
			if (args.Length < 1)
			{
				NPC_Info[] array2 = array;
				foreach (NPC_Info val in array2)
				{
					ResetNpcAnimator(((Component)val).gameObject);
				}
				CreateCanvasNotification("Reset NPC animators.");
			}
			else if (args[0].Trim().ToLower() == "random")
			{
				int num = Random.Range(0, poseStrings.Length);
				string text = poseStrings[num];
				NPC_Info[] array3 = array;
				foreach (NPC_Info val2 in array3)
				{
					PlayEmoteOnNpc(((Component)val2).gameObject, text);
				}
				CreateCanvasNotification($"Random pose {num}: {text}");
			}
			else
			{
				if (!int.TryParse(args[0], out var result))
				{
					return;
				}
				if (result >= 0 && result < poseStrings.Length)
				{
					string text2 = poseStrings[result];
					NPC_Info[] array4 = array;
					foreach (NPC_Info val3 in array4)
					{
						PlayEmoteOnNpc(((Component)val3).gameObject, text2);
					}
					CreateCanvasNotification($"Performing pose {result}: {text2}");
				}
				else
				{
					CreateCanvasNotification($"Ongeldige index! Kies tussen 0 en {poseStrings.Length - 1}");
				}
			}
		}

		public static void ChatCommand_Weather(string[] args)
		{
			if (args.Length == 0 || !int.TryParse(args[0], out var result) || result >= 6)
			{
				return;
			}
			GameData val = Object.FindFirstObjectByType<GameData>();
			if ((Object)(object)val != (Object)null)
			{
				val.NetworkweatherIndex = result;
				if (result >= 4)
				{
					NPC_Manager.Instance.badWeatherDay = true;
					UpgradesManager component = ((Component)val).GetComponent<UpgradesManager>();
					if ((Object)(object)component != (Object)null && component.extraUpgrades.Length > 43 && component.extraUpgrades[43])
					{
						OrderPackaging.Instance.extraOrdersDueToWeather = Random.Range(3, 6);
					}
				}
				else
				{
					NPC_Manager.Instance.badWeatherDay = false;
					OrderPackaging.Instance.extraOrdersDueToWeather = 0;
				}
				string networktodayTemperatureData = val.NetworktodayTemperatureData;
				MethodInfo methodInfo = AccessTools.Method(typeof(GameData), "RpcSetWeather", new Type[2]
				{
					typeof(int),
					typeof(string)
				}, (Type[])null);
				if (methodInfo != null)
				{
					methodInfo.Invoke(val, new object[2] { result, networktodayTemperatureData });
				}
			}
			CreateCanvasNotification($"Weather set to {result}: {weatherStrings[result]}");
		}

		public static void ChatCommand_Notify(string[] args)
		{
			if (args.Length > 1 && int.TryParse(args[0], out var result) && result < 2)
			{
				switch (result)
				{
				case 0:
					CreateCanvasNotification(args[1]);
					break;
				case 1:
					CreateImportantNotification(args[1]);
					break;
				}
			}
		}

		public static void ChatCommand_Spawn(string[] args)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			if (args.Length >= 1 && (Object)(object)Camera.main != (Object)null)
			{
				string text = args[0].Trim().ToLower();
				int value2;
				if (commonProps.TryGetValue(text, out var value))
				{
					Transform transform = ((Component)Camera.main).transform;
					Vector3 val = transform.position + transform.forward * 3.5f;
					((Component)GameData.Instance).GetComponent<NetworkSpawner>().CmdSpawnProp(value, val, Vector3.zero);
					CreateCanvasNotification(" Spawned prop " + text + ".");
				}
				else if (commonDecorations.TryGetValue(text, out value2))
				{
					Transform transform2 = ((Component)Camera.main).transform;
					Vector3 val2 = transform2.position + transform2.forward * 3.5f;
					((Component)GameData.Instance).GetComponent<NetworkSpawner>().CmdSpawnDecoration(value2, val2, Vector3.zero);
					CreateCanvasNotification(" Spawned decoration " + text + ".");
				}
			}
		}
	}
}
namespace KroesSupermarketMod.Patches
{
	[HarmonyPatch]
	internal class BuildingLimitsPatch
	{
		[HarmonyPatch(typeof(Builder_Main), "InCorrectBounds")]
		[HarmonyPostfix]
		private static void Builder_Main_Postfix(ref bool __result)
		{
			__result = true;
		}

		[HarmonyPatch(typeof(Builder_Decoration), "InCorrectBounds")]
		[HarmonyPostfix]
		private static void Builder_Decoration_Postfix(ref bool __result)
		{
			__result = true;
		}
	}
	[HarmonyPatch]
	internal class ChatCommandsPatch
	{
		[HarmonyPatch(typeof(PlayerObjectController), "SendChatMsg")]
		[HarmonyPrefix]
		private static bool SendChatMsg_Prefix(PlayerObjectController __instance, ref string message)
		{
			if (Utilities.TryParseCommand(message, out string command, out string[] args))
			{
				switch (command)
				{
				case "npc":
					Plugin.mls.LogInfo((object)("/npc: " + string.Join(", ", args)));
					Utilities.ChatCommand_Npc(args);
					return false;
				case "weather":
					Plugin.mls.LogInfo((object)("/weather: " + string.Join(", ", args)));
					Utilities.ChatCommand_Weather(args);
					return false;
				case "notify":
					Plugin.mls.LogInfo((object)("/notify: " + string.Join(", ", args)));
					Utilities.ChatCommand_Notify(args);
					return false;
				case "spawn":
					Plugin.mls.LogInfo((object)("/spawn: " + string.Join(", ", args)));
					Utilities.ChatCommand_Spawn(args);
					return false;
				default:
					return true;
				}
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal class CustomerShoppingListPatch
	{
		private static GameObject shoppingListUI;

		private static NPC_Info currentTargetNPC;

		private static Transform shoppingListContentParent;

		private static Transform cartListContentParent;

		private static LayoutElement shoppingScrollViewLayout;

		private static LayoutElement cartScrollViewLayout;

		private static int lastKnownToBuyCount = -1;

		private static int lastKnownCarryingCount = -1;

		private static readonly string[] names = new string[21]
		{
			"Jensen Ackles", "Jared Padalecki", "Misha Collins", "Mark Sheppard", "Jeffrey Dean Morgan", "Jim Beaver", "Genevieve Padalecki", "Alexander Calvert", "Ruth Connell", "Danneel Ackles",
			"Mark Pellegrino", "Samantha Smith", "Adrianne Palicki", "Rob Benedict", "Richard Speight Jr.", "Katie Cassidy", "Lauren Cohan", "Felicia Day", "David Haydn-Jones", "DJ Qualls",
			"Ty Olsson"
		};

		[HarmonyPatch(typeof(PlayerNetwork), "Update")]
		[HarmonyPostfix]
		private static void UpdatePostfix(PlayerNetwork __instance)
		{
			//IL_00e2: 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)
			if ((Object)(object)shoppingListUI != (Object)null)
			{
				if (Input.GetKeyDown((KeyCode)27))
				{
					CloseShoppingList();
				}
				else if ((Object)(object)currentTargetNPC != (Object)null)
				{
					int num = ((currentTargetNPC.productsIDToBuy != null) ? currentTargetNPC.productsIDToBuy.Count : 0);
					int num2 = ((currentTargetNPC.productsIDCarrying != null) ? currentTargetNPC.productsIDCarrying.Count : 0);
					if (num != lastKnownToBuyCount || num2 != lastKnownCarryingCount)
					{
						RefreshBothLists();
					}
				}
			}
			else
			{
				if (!Input.GetMouseButtonDown(0) || __instance.equippedItem != 0)
				{
					return;
				}
				int mask = LayerMask.GetMask(new string[1] { "Default" });
				RaycastHit val = default(RaycastHit);
				if (!Physics.Raycast(((Component)Camera.main).transform.position, ((Component)Camera.main).transform.forward, ref val, 10f, mask) || !((Component)((RaycastHit)(ref val)).transform).CompareTag("Interactable") || !((Object)((Component)((RaycastHit)(ref val)).transform).gameObject).name.Equals("HitTrigger") || !((Object)(object)((RaycastHit)(ref val)).transform.parent != (Object)null))
				{
					return;
				}
				Transform parent = ((RaycastHit)(ref val)).transform.parent;
				NPC_Info component = ((Component)parent).GetComponent<NPC_Info>();
				if ((Object)(object)component != (Object)null && component.isCustomer)
				{
					CustomCameraController component2 = ((Component)Camera.main).GetComponent<CustomCameraController>();
					if ((Object)(object)component2 != (Object)null)
					{
						component2.isInCameraEvent = true;
					}
					currentTargetNPC = component;
					shoppingListUI = CreateShoppingListUI(component);
					Cursor.lockState = (CursorLockMode)0;
					Cursor.visible = true;
				}
			}
		}

		private static string ProductIdToName(int productID)
		{
			string text = "product" + productID;
			return LocalizationManager.instance.GetLocalizationString(text);
		}

		private static Sprite ProductIdToSprite(int productID)
		{
			return ProductListing.Instance.productsData[productID].productSprite;
		}

		private static Color ProductIdToColor(int productID)
		{
			//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_0015: Unknown result type (might be due to invalid IL or missing references)
			return ProductListing.Instance.productsData[productID].productColor;
		}

		private static GameObject CreateShoppingListUI(NPC_Info npcInfo)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_0079: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Expected O, but got Unknown
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Expected O, but got Unknown
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Expected O, but got Unknown
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Expected O, but got Unknown
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Expected O, but got Unknown
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Expected O, but got Unknown
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Expected O, but got Unknown
			string text = names[npcInfo.NPCID % names.Length];
			Transform transform = ((Component)GameCanvas.Instance).transform;
			GameObject val = new GameObject("ShoppingListUI", new Type[3]
			{
				typeof(RectTransform),
				typeof(VerticalLayoutGroup),
				typeof(ContentSizeFitter)
			});
			val.transform.SetParent(transform, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			VerticalLayoutGroup component2 = val.GetComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component2).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component2).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component2).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)component2).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)component2).spacing = 12f;
			ContentSizeFitter component3 = val.GetComponent<ContentSizeFitter>();
			component3.horizontalFit = (FitMode)2;
			component3.verticalFit = (FitMode)2;
			GameObject val2 = new GameObject("HeaderRow", new Type[3]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup),
				typeof(LayoutElement)
			});
			val2.transform.SetParent(val.transform, false);
			LayoutElement component4 = val2.GetComponent<LayoutElement>();
			component4.preferredWidth = 1000f;
			component4.preferredHeight = 65f;
			HorizontalLayoutGroup component5 = val2.GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component5).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component5).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component5).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)component5).childForceExpandHeight = true;
			((LayoutGroup)component5).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)component5).spacing = 12f;
			GameObject val3 = new GameObject("NamePanel", new Type[4]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(HorizontalLayoutGroup),
				typeof(LayoutElement)
			});
			val3.transform.SetParent(val2.transform, false);
			Image component6 = val3.GetComponent<Image>();
			((Graphic)component6).color = Color.white;
			LayoutElement component7 = val3.GetComponent<LayoutElement>();
			component7.flexibleWidth = 1f;
			component7.preferredHeight = 65f;
			HorizontalLayoutGroup component8 = val3.GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component8).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component8).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component8).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)component8).childForceExpandHeight = true;
			((LayoutGroup)component8).childAlignment = (TextAnchor)3;
			((LayoutGroup)component8).padding = new RectOffset(20, 20, 0, 0);
			GameObject val4 = new GameObject("CustomerHeader", new Type[2]
			{
				typeof(RectTransform),
				typeof(TextMeshProUGUI)
			});
			val4.transform.SetParent(val3.transform, false);
			TextMeshProUGUI component9 = val4.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component9).text = text;
			((TMP_Text)component9).fontSize = 28f;
			((TMP_Text)component9).fontStyle = (FontStyles)1;
			((Graphic)component9).color = Color.black;
			((TMP_Text)component9).alignment = (TextAlignmentOptions)513;
			((TMP_Text)component9).enableWordWrapping = false;
			GameObject val5 = new GameObject("CloseButton", new Type[4]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Button),
				typeof(LayoutElement)
			});
			val5.transform.SetParent(val2.transform, false);
			Image component10 = val5.GetComponent<Image>();
			((Graphic)component10).color = Color.red;
			((Graphic)component10).raycastTarget = true;
			Button component11 = val5.GetComponent<Button>();
			((UnityEvent)component11.onClick).AddListener(new UnityAction(CloseShoppingList));
			LayoutElement component12 = val5.GetComponent<LayoutElement>();
			component12.preferredWidth = 65f;
			component12.preferredHeight = 65f;
			component12.flexibleWidth = 0f;
			GameObject val6 = new GameObject("Text", new Type[2]
			{
				typeof(RectTransform),
				typeof(TextMeshProUGUI)
			});
			val6.transform.SetParent(val5.transform, false);
			RectTransform component13 = val6.GetComponent<RectTransform>();
			component13.anchorMin = Vector2.zero;
			component13.anchorMax = Vector2.one;
			component13.sizeDelta = Vector2.zero;
			TextMeshProUGUI component14 = val6.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component14).text = "X";
			((TMP_Text)component14).fontStyle = (FontStyles)1;
			((TMP_Text)component14).fontSize = 38f;
			((Graphic)component14).color = Color.white;
			((TMP_Text)component14).alignment = (TextAlignmentOptions)514;
			((Graphic)component14).raycastTarget = false;
			GameObject val7 = new GameObject("ListsBody", new Type[3]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup),
				typeof(LayoutElement)
			});
			val7.transform.SetParent(val.transform, false);
			LayoutElement component15 = val7.GetComponent<LayoutElement>();
			component15.preferredWidth = 1000f;
			HorizontalLayoutGroup component16 = val7.GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component16).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component16).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component16).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)component16).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)component16).spacing = 16f;
			((LayoutGroup)component16).childAlignment = (TextAnchor)0;
			shoppingListContentParent = CreateListColumn(val7.transform, "Shopping List", out shoppingScrollViewLayout);
			cartListContentParent = CreateListColumn(val7.transform, "In Cart", out cartScrollViewLayout);
			RefreshBothLists();
			return val;
		}

		private static Transform CreateListColumn(Transform parent, string titleText, out LayoutElement scrollViewLayout)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_0109: 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_0174: Expected O, but got Unknown
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Expected O, but got Unknown
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Expected O, but got Unknown
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Expected O, but got Unknown
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: 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_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Expected O, but got Unknown
			GameObject val = new GameObject(titleText + "_Column", new Type[3]
			{
				typeof(RectTransform),
				typeof(VerticalLayoutGroup),
				typeof(LayoutElement)
			});
			val.transform.SetParent(parent, false);
			LayoutElement component = val.GetComponent<LayoutElement>();
			component.flexibleWidth = 1f;
			VerticalLayoutGroup component2 = val.GetComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component2).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component2).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component2).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)component2).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)component2).spacing = 8f;
			GameObject val2 = new GameObject("TitleBar", new Type[4]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(HorizontalLayoutGroup),
				typeof(LayoutElement)
			});
			val2.transform.SetParent(val.transform, false);
			Image component3 = val2.GetComponent<Image>();
			((Graphic)component3).color = new Color(0.2f, 0.2f, 0.2f, 1f);
			LayoutElement component4 = val2.GetComponent<LayoutElement>();
			component4.preferredHeight = 40f;
			component4.minHeight = 40f;
			HorizontalLayoutGroup component5 = val2.GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component5).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component5).childControlHeight = false;
			((HorizontalOrVerticalLayoutGroup)component5).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)component5).childForceExpandHeight = false;
			((LayoutGroup)component5).padding = new RectOffset(16, 16, 0, 0);
			((LayoutGroup)component5).childAlignment = (TextAnchor)3;
			GameObject val3 = new GameObject("TitleText", new Type[3]
			{
				typeof(RectTransform),
				typeof(TextMeshProUGUI),
				typeof(LayoutElement)
			});
			val3.transform.SetParent(val2.transform, false);
			LayoutElement component6 = val3.GetComponent<LayoutElement>();
			component6.preferredHeight = 40f;
			TextMeshProUGUI component7 = val3.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component7).text = titleText;
			((TMP_Text)component7).fontSize = 20f;
			((TMP_Text)component7).fontStyle = (FontStyles)1;
			((Graphic)component7).color = Color.white;
			((TMP_Text)component7).alignment = (TextAlignmentOptions)513;
			GameObject val4 = new GameObject("ScrollView", new Type[5]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(ScrollRect),
				typeof(Mask),
				typeof(LayoutElement)
			});
			val4.transform.SetParent(val.transform, false);
			Image component8 = val4.GetComponent<Image>();
			((Graphic)component8).color = Color.white;
			Mask component9 = val4.GetComponent<Mask>();
			component9.showMaskGraphic = true;
			scrollViewLayout = val4.GetComponent<LayoutElement>();
			scrollViewLayout.preferredHeight = 40f;
			scrollViewLayout.minHeight = 40f;
			GameObject val5 = new GameObject("Viewport", new Type[1] { typeof(RectTransform) });
			val5.transform.SetParent(val4.transform, false);
			RectTransform component10 = val5.GetComponent<RectTransform>();
			component10.anchorMin = Vector2.zero;
			component10.anchorMax = Vector2.one;
			component10.sizeDelta = Vector2.zero;
			GameObject val6 = new GameObject("Content", new Type[3]
			{
				typeof(RectTransform),
				typeof(VerticalLayoutGroup),
				typeof(ContentSizeFitter)
			});
			val6.transform.SetParent(val5.transform, false);
			RectTransform component11 = val6.GetComponent<RectTransform>();
			component11.anchorMin = new Vector2(0f, 1f);
			component11.anchorMax = new Vector2(1f, 1f);
			component11.pivot = new Vector2(0f, 1f);
			component11.sizeDelta = Vector2.zero;
			VerticalLayoutGroup component12 = val6.GetComponent<VerticalLayoutGroup>();
			((LayoutGroup)component12).padding = new RectOffset(12, 12, 12, 12);
			((HorizontalOrVerticalLayoutGroup)component12).spacing = 8f;
			((HorizontalOrVerticalLayoutGroup)component12).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component12).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component12).childForceExpandWidth = true;
			ContentSizeFitter component13 = val6.GetComponent<ContentSizeFitter>();
			component13.verticalFit = (FitMode)2;
			ScrollRect component14 = val4.GetComponent<ScrollRect>();
			component14.viewport = component10;
			component14.content = component11;
			component14.horizontal = false;
			component14.vertical = true;
			return val6.transform;
		}

		private static void RefreshBothLists()
		{
			if (!((Object)(object)currentTargetNPC == (Object)null))
			{
				if ((Object)(object)shoppingListContentParent != (Object)null && currentTargetNPC.productsIDToBuy != null)
				{
					PopulateListContent(shoppingListContentParent, currentTargetNPC.productsIDToBuy);
					lastKnownToBuyCount = currentTargetNPC.productsIDToBuy.Count;
					AdjustScrollViewHeight(shoppingListContentParent, shoppingScrollViewLayout);
				}
				if ((Object)(object)cartListContentParent != (Object)null && currentTargetNPC.productsIDCarrying != null)
				{
					PopulateListContent(cartListContentParent, currentTargetNPC.productsIDCarrying);
					lastKnownCarryingCount = currentTargetNPC.productsIDCarrying.Count;
					AdjustScrollViewHeight(cartListContentParent, cartScrollViewLayout);
				}
			}
		}

		private static void PopulateListContent(Transform contentParent, List<int> productIds)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Expected O, but got Unknown
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Expected O, but got Unknown
			//IL_0226: 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_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Expected O, but got Unknown
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			for (int num = contentParent.childCount - 1; num >= 0; num--)
			{
				Object.Destroy((Object)(object)((Component)contentParent.GetChild(num)).gameObject);
			}
			for (int i = 0; i < productIds.Count; i++)
			{
				int productID = productIds[i];
				GameObject val = new GameObject($"Item_{i}", new Type[5]
				{
					typeof(RectTransform),
					typeof(Image),
					typeof(HorizontalLayoutGroup),
					typeof(LayoutElement),
					typeof(ContentSizeFitter)
				});
				val.transform.SetParent(contentParent, false);
				Image component = val.GetComponent<Image>();
				((Graphic)component).color = new Color(0.95f, 0.95f, 0.95f, 1f);
				LayoutElement component2 = val.GetComponent<LayoutElement>();
				component2.minHeight = 52f;
				ContentSizeFitter component3 = val.GetComponent<ContentSizeFitter>();
				component3.verticalFit = (FitMode)2;
				HorizontalLayoutGroup component4 = val.GetComponent<HorizontalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)component4).childControlWidth = false;
				((HorizontalOrVerticalLayoutGroup)component4).childControlHeight = false;
				((HorizontalOrVerticalLayoutGroup)component4).childForceExpandWidth = false;
				((HorizontalOrVerticalLayoutGroup)component4).childForceExpandHeight = false;
				((LayoutGroup)component4).childAlignment = (TextAnchor)3;
				((LayoutGroup)component4).padding = new RectOffset(8, 8, 6, 6);
				((HorizontalOrVerticalLayoutGroup)component4).spacing = 12f;
				GameObject val2 = new GameObject("IconBox", new Type[3]
				{
					typeof(RectTransform),
					typeof(Image),
					typeof(LayoutElement)
				});
				val2.transform.SetParent(val.transform, false);
				Image component5 = val2.GetComponent<Image>();
				((Graphic)component5).color = ProductIdToColor(productID);
				LayoutElement component6 = val2.GetComponent<LayoutElement>();
				component6.preferredWidth = 42f;
				component6.preferredHeight = 42f;
				GameObject val3 = new GameObject("ProductIcon", new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val3.transform.SetParent(val2.transform, false);
				RectTransform component7 = val3.GetComponent<RectTransform>();
				component7.anchorMin = Vector2.zero;
				component7.anchorMax = Vector2.one;
				component7.sizeDelta = new Vector2(-6f, -6f);
				Image component8 = val3.GetComponent<Image>();
				component8.sprite = ProductIdToSprite(productID);
				component8.preserveAspect = true;
				GameObject val4 = new GameObject("ProductName", new Type[3]
				{
					typeof(RectTransform),
					typeof(TextMeshProUGUI),
					typeof(LayoutElement)
				});
				val4.transform.SetParent(val.transform, false);
				TextMeshProUGUI component9 = val4.GetComponent<TextMeshProUGUI>();
				((TMP_Text)component9).text = ProductIdToName(productID);
				((TMP_Text)component9).fontSize = 18f;
				((TMP_Text)component9).fontStyle = (FontStyles)1;
				((Graphic)component9).color = Color.black;
				((TMP_Text)component9).alignment = (TextAlignmentOptions)513;
				((TMP_Text)component9).enableWordWrapping = true;
				((TMP_Text)component9).overflowMode = (TextOverflowModes)0;
				LayoutElement component10 = val4.GetComponent<LayoutElement>();
				component10.preferredWidth = 360f;
			}
		}

		private static void AdjustScrollViewHeight(Transform contentParent, LayoutElement layoutElement)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			Canvas.ForceUpdateCanvases();
			if ((Object)(object)layoutElement != (Object)null && (Object)(object)contentParent != (Object)null)
			{
				RectTransform component = ((Component)contentParent).GetComponent<RectTransform>();
				float y = component.sizeDelta.y;
				if (contentParent.childCount == 0)
				{
					layoutElement.preferredHeight = 40f;
				}
				else
				{
					layoutElement.preferredHeight = Mathf.Min(y, 500f);
				}
			}
		}

		private static void CloseShoppingList()
		{
			if (!((Object)(object)shoppingListUI == (Object)null))
			{
				Object.Destroy((Object)(object)shoppingListUI);
				shoppingListUI = null;
				currentTargetNPC = null;
				shoppingListContentParent = null;
				cartListContentParent = null;
				shoppingScrollViewLayout = null;
				cartScrollViewLayout = null;
				lastKnownToBuyCount = -1;
				lastKnownCarryingCount = -1;
				CustomCameraController component = ((Component)Camera.main).GetComponent<CustomCameraController>();
				if ((Object)(object)component != (Object)null)
				{
					component.isInCameraEvent = false;
				}
				Cursor.lockState = (CursorLockMode)1;
				Cursor.visible = false;
			}
		}
	}
	[HarmonyPatch]
	internal class EuroSymbolPatch
	{
		[HarmonyPatch(typeof(ProductListing), "ConvertFloatToTextPrice")]
		[HarmonyPrefix]
		public static bool Prefix(float price, ref string __result)
		{
			__result = "€" + price.ToString("F2", new CultureInfo("nl-NL"));
			return false;
		}
	}
	[HarmonyPatch]
	internal class FranchiseBarPatch
	{
		private static int lastKnownExp = -1;

		private static Slider franchiseProgressBar;

		[HarmonyPatch(typeof(GameData), "Update")]
		[HarmonyPostfix]
		public static void Update_Postfix(GameData __instance, int ___gameFranchiseExperience)
		{
			if (lastKnownExp == -1)
			{
				lastKnownExp = ___gameFranchiseExperience;
			}
			else if (___gameFranchiseExperience != lastKnownExp)
			{
				int num = lastKnownExp;
				lastKnownExp = ___gameFranchiseExperience;
				AccessTools.Method(typeof(GameData), "UpdateFranchisePoints", (Type[])null, (Type[])null)?.Invoke(__instance, new object[2] { num, ___gameFranchiseExperience });
			}
		}

		[HarmonyPatch(typeof(GameData), "UpdateFranchisePoints")]
		[HarmonyPostfix]
		public static void UpdateFranchisePoints_Postfix(GameData __instance, TextMeshProUGUI ___UIFranchisePointsOBJ, int ___gameFranchiseExperience)
		{
			if (!((Object)(object)___UIFranchisePointsOBJ == (Object)null))
			{
				Utilities.EnsureProgressBarCreated(___UIFranchisePointsOBJ, ref franchiseProgressBar);
				float levelProgress = Utilities.GetLevelProgress(___gameFranchiseExperience);
				if ((Object)(object)franchiseProgressBar != (Object)null)
				{
					franchiseProgressBar.value = Mathf.Clamp01(levelProgress);
				}
			}
		}
	}
	[HarmonyPatch(typeof(LayoutManager))]
	internal class LayoutManagerPatch
	{
		[HarmonyPatch("AssignReferences")]
		[HarmonyPostfix]
		public static void Postfix(LayoutManager __instance)
		{
			if ((Object)(object)__instance.trashRecycle1 != (Object)null)
			{
				Utilities.recycleObj1 = ((Component)__instance.trashRecycle1).gameObject;
			}
			if ((Object)(object)__instance.trashRecycle2 != (Object)null)
			{
				Utilities.recycleObj2 = ((Component)__instance.trashRecycle2).gameObject;
			}
			if ((Object)(object)__instance.trashNormal != (Object)null)
			{
				Utilities.trashObj = ((Component)__instance.trashNormal).gameObject;
			}
		}
	}
	[HarmonyPatch]
	internal class MiniTransporterPatch
	{
		public static int boxesToAdd = 2;

		public static float _maxForwardSpeed = 8f;

		public static float _maxBackwardSpeed = 5f;

		public static float _accelerationRate = 6f;

		public static float _decelerationRate = 5f;

		public static float _maxRotationSpeed = 75f;

		private static readonly HashSet<int> ProcessedVehicles = new HashSet<int>();

		[HarmonyPatch(typeof(MiniTransportRework), "Update")]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count - 2; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == -1f && list[i + 1].opcode == OpCodes.Mul)
				{
					list[i].opcode = OpCodes.Nop;
					list[i + 1].opcode = OpCodes.Nop;
					break;
				}
			}
			return list;
		}

		[HarmonyPatch(typeof(MiniTransportRework), "OnStartClient")]
		[HarmonyPrefix]
		private static void Prefix(MiniTransportRework __instance)
		{
			if (boxesToAdd >= 1)
			{
				int instanceID = ((Object)__instance).GetInstanceID();
				if (!ProcessedVehicles.Contains(instanceID))
				{
					ProcessedVehicles.Add(instanceID);
					UpdateVehicle(__instance);
				}
			}
		}

		private static void UpdateVehicle(MiniTransportRework vehicleRework)
		{
			GameObject gameObject = ((Component)vehicleRework).gameObject;
			Transform val = gameObject.transform.Find("BoxContainer");
			Transform val2 = gameObject.transform.Find("Highlights");
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				Plugin.mls.LogInfo((object)"Mini Transporter: failed to find BoxContainer or Highlights!");
				return;
			}
			vehicleRework.maxForwardSpeed = _maxForwardSpeed;
			vehicleRework.maxBackwardSpeed = _maxBackwardSpeed;
			vehicleRework.accelerationRate = _accelerationRate;
			vehicleRework.decelerationRate = _decelerationRate;
			vehicleRework.maxRotationSpeed = _maxRotationSpeed;
			float yOffset = 1.95f;
			int num = Math.Min(boxesToAdd, 6);
			AddBoxSubContainers(val, yOffset, num);
			AddHighlights(val2, yOffset, num);
			AddUIContainerSlots(vehicleRework, num);
			AddCanvasSignSlots(gameObject.transform, num);
			if (((NetworkBehaviour)vehicleRework).isServer)
			{
				AddNewSlotsToProductInfoArray(vehicleRework, num);
				int num2 = vehicleRework.productInfoArray.Length / 2 - num;
				for (int i = 0; i < num; i++)
				{
					int slotIndex = num2 + i;
					UpdateSlotViaReflection(vehicleRework, slotIndex, -1, -1);
				}
				Plugin.mls.LogInfo((object)$"Added {num} new slots to product info on server.");
			}
		}

		private static int AddBoxSubContainers(Transform parent, float yOffset, int count)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			List<Transform> list = new List<Transform>();
			foreach (Transform item in parent)
			{
				Transform val = item;
				if (((Object)val).name.Contains("BoxSubcontainer"))
				{
					list.Add(val);
				}
			}
			List<Collider> list2 = new List<Collider>();
			for (int i = 0; i < count; i++)
			{
				Transform val2 = list[i];
				GameObject val3 = Object.Instantiate<GameObject>(((Component)val2).gameObject, parent);
				Vector3 localPosition = val2.localPosition;
				localPosition.y += yOffset;
				val3.transform.localPosition = localPosition;
				val3.transform.localRotation = val2.localRotation;
				val3.layer = ((Component)val2).gameObject.layer;
				foreach (Transform item2 in val3.transform)
				{
					Transform val4 = item2;
					((Component)val4).gameObject.layer = ((Component)val2).gameObject.layer;
				}
				Collider[] componentsInChildren = val3.GetComponentsInChildren<Collider>();
				if (componentsInChildren != null && componentsInChildren.Length != 0)
				{
					list2.AddRange(componentsInChildren);
				}
			}
			Plugin.mls.LogInfo((object)$"Added {list2.Count} new BoxSubcontainer colliders.");
			return list2.Count;
		}

		private static void AddHighlights(Transform parent, float yOffset, int count)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			List<Transform> list = new List<Transform>();
			foreach (Transform item2 in parent)
			{
				Transform item = item2;
				list.Add(item);
			}
			int count2 = list.Count;
			for (int i = 0; i < count; i++)
			{
				Transform val = list[i];
				GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, parent);
				Vector3 localPosition = val.localPosition;
				localPosition.y += yOffset;
				val2.transform.localPosition = localPosition;
				val2.transform.localRotation = val.localRotation;
				((Object)val2).name = count2++.ToString();
			}
			Plugin.mls.LogInfo((object)"Highlights updated.");
		}

		private static void AddUIContainerSlots(MiniTransportRework vehicleRework, int count)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)vehicleRework.UIboxContainerParent).gameObject;
			float num = 1f - (float)count / 11f;
			gameObject.transform.localScale = new Vector3(num, num, 1f);
			if (gameObject.transform.childCount > 0)
			{
				Transform child = gameObject.transform.GetChild(0);
				Image component = ((Component)child).GetComponent<Image>();
				for (int i = 0; i < count; i++)
				{
					GameObject val = Object.Instantiate<GameObject>(((Component)child).gameObject, gameObject.transform);
					Image component2 = val.GetComponent<Image>();
				}
			}
			Plugin.mls.LogInfo((object)$"Added {count} UI containers.");
		}

		private static void AddCanvasSignSlots(Transform vehicleTransform, int count)
		{
			Transform val = vehicleTransform.Find("CanvasSigns");
			if (!((Object)(object)val == (Object)null) && val.childCount != 0)
			{
				Transform child = val.GetChild(0);
				for (int i = 0; i < count; i++)
				{
					Object.Instantiate<GameObject>(((Component)child).gameObject, val);
				}
				Plugin.mls.LogInfo((object)$"Added {count} slots in CanvasSigns.");
			}
		}

		private static void AddNewSlotsToProductInfoArray(MiniTransportRework vehicleRework, int count)
		{
			int num = vehicleRework.productInfoArray.Length;
			int num2 = num + count * 2;
			int[] array = new int[num2];
			for (int i = 0; i < num; i++)
			{
				array[i] = vehicleRework.productInfoArray[i];
			}
			for (int j = num; j < num2; j++)
			{
				array[j] = -1;
			}
			vehicleRework.productInfoArray = array;
			Plugin.mls.LogInfo((object)$"Added {count} slots to productInfoArray.");
		}

		private static void UpdateSlotViaReflection(MiniTransportRework vehicleRework, int slotIndex, int PID, int PNUMBER)
		{
			int[] productInfoArray = vehicleRework.productInfoArray;
			productInfoArray[slotIndex * 2] = PID;
			productInfoArray[slotIndex * 2 + 1] = PNUMBER;
			vehicleRework.productInfoArray = productInfoArray;
			MethodInfo method = typeof(MiniTransportRework).GetMethod("UserCode_RpcUpdateArrayValuesStorage__Int32__Int32__Int32", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method == null)
			{
				Plugin.mls.LogInfo((object)"Failed to find method: RpcUpdateArrayValueStorage");
				return;
			}
			method.Invoke(vehicleRework, new object[3] { slotIndex, PID, PNUMBER });
			Plugin.mls.LogInfo((object)$"Slot {slotIndex} updated via RPC.");
		}
	}
	[HarmonyPatch]
	internal class NpcNotificationPatch
	{
		private static readonly string[] CustomNotifications = new string[9] { "Kanker!", "Het is de echter gangster, Klaas!", "Ik ben vergeten in m'n bed te pissen...", "What stays in Kos stays in Kos.", "Waar bemoei jij je mee?!", "Krebsratte!", "Josh zitten!", "Ik mag thuis niet lachen.", "Bruinjoekel!" };

		[HarmonyPatch(typeof(NPC_Info), "UserCode_RPCNotificationAboveHead__String__String")]
		[HarmonyPrefix]
		public static bool Prefix(NPC_Info __instance, string message1, GameObject ___messagePrefab)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			if (message1 != null && message1.StartsWith("NPCmessagehit"))
			{
				if ((Object)(object)___messagePrefab == (Object)null)
				{
					return false;
				}
				string s = message1.Substring("NPCmessagehit".Length);
				int num = 0;
				if (int.TryParse(s, out var result))
				{
					num = result % CustomNotifications.Length;
				}
				string text = CustomNotifications[num];
				GameObject val = Object.Instantiate<GameObject>(___messagePrefab, ((Component)__instance).transform.position + Vector3.up * 1.8f, Quaternion.identity);
				((TMP_Text)val.GetComponent<TextMeshPro>()).text = text;
				val.SetActive(true);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal class PriceGunPatch
	{
		[HarmonyPatch(typeof(PlayerNetwork), "Update")]
		[HarmonyPostfix]
		public static void Postfix(ref float ___pPrice, TextMeshProUGUI ___marketPriceTMP, TextMeshProUGUI ___yourPriceTMP)
		{
			if (!((Object)(object)___marketPriceTMP == (Object)null) && !string.IsNullOrEmpty(((TMP_Text)___marketPriceTMP).text) && float.TryParse(((TMP_Text)___marketPriceTMP).text.Substring(1).Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				string text = "$";
				CultureInfo cultureInfo = (Plugin.config.euroSymbol ? new CultureInfo("nl-NL") : CultureInfo.InvariantCulture);
				if (Plugin.config.euroSymbol)
				{
					text = "€";
					((TMP_Text)___marketPriceTMP).text = text + result.ToString("F2", cultureInfo);
				}
				___pPrice = result * 2f;
				if ((Object)(object)___yourPriceTMP != (Object)null)
				{
					((TMP_Text)___yourPriceTMP).text = text + ___pPrice.ToString("F2", cultureInfo);
				}
			}
		}
	}
	[HarmonyPatch]
	internal class ThirdPersonCameraPatch
	{
		private static bool isCameraInThirdPerson = false;

		public static float thirdPersonCameraDistance = 4f;

		[HarmonyPatch(typeof(CustomCameraController), "ThirdPersonEmoteVisualize")]
		[HarmonyPostfix]
		private static void ThirdPersonEmoteVisualize_Postfix()
		{
			isCameraInThirdPerson = false;
		}

		private static bool ReturnInstances(CustomCameraController controller)
		{
			object obj = AccessTools.Field(typeof(CustomCameraController), "IsInOptions")?.GetValue(controller);
			bool flag = default(bool);
			int num;
			if (obj is bool)
			{
				flag = (bool)obj;
				num = 1;
			}
			else
			{
				num = 0;
			}
			if (((uint)num & (flag ? 1u : 0u)) != 0)
			{
				return true;
			}
			GameCanvas instance = GameCanvas.Instance;
			if (instance != null)
			{
				Transform obj2 = ((Component)instance).transform.Find("Builder");
				if (((obj2 != null) ? new bool?(((Component)obj2).gameObject.activeSelf) : ((bool?)null)) == true)
				{
					return true;
				}
			}
			if (controller.isInCameraEvent)
			{
				return true;
			}
			if (controller.inEmoteEvent)
			{
				return true;
			}
			if (controller.inVehicle)
			{
				return true;
			}
			return false;
		}

		[HarmonyPatch(typeof(CustomCameraController), "LateUpdate")]
		[HarmonyPostfix]
		private static void LateUpdate_Postfix(CustomCameraController __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			float y = Input.mouseScrollDelta.y;
			if (y < 0f && !isCameraInThirdPerson)
			{
				UpdateCamera(__instance, doThirdPerson: true);
			}
			else if (y > 0f && isCameraInThirdPerson)
			{
				UpdateCamera(__instance, doThirdPerson: false);
			}
		}

		private static void UpdateCamera(CustomCameraController controller, bool doThirdPerson)
		{
			if (ReturnInstances(controller))
			{
				return;
			}
			isCameraInThirdPerson = doThirdPerson;
			object obj = AccessTools.Field(typeof(CustomCameraController), "thirdPersonFollow")?.GetValue(controller);
			if (obj != null)
			{
				float num = (doThirdPerson ? thirdPersonCameraDistance : 0f);
				AccessTools.Field(obj.GetType(), "CameraDistance")?.SetValue(obj, num);
				string text = (doThirdPerson ? "thirdPersonDefaultLayerMask" : "thirdPersonNullLayerMask");
				object obj2 = AccessTools.Field(typeof(CustomCameraController), text)?.GetValue(controller);
				if (obj2 != null)
				{
					AccessTools.Field(obj.GetType(), "CameraCollisionFilter")?.SetValue(obj, obj2);
				}
				AccessTools.Method(typeof(CustomCameraController), "ShowCharacter", new Type[1] { typeof(bool) }, (Type[])null)?.Invoke(controller, new object[1] { doThirdPerson });
			}
		}
	}
	[HarmonyPatch]
	internal class ThrowableBoxesPatch
	{
		private static float throwForce = 10f;

		private static float spinStrength = 5f;

		[HarmonyPatch(typeof(ManagerBlackboard), "CmdSpawnBoxFromPlayer")]
		[HarmonyPrefix]
		public static void CmdSpawnBoxFromPlayer_Prefix(ref Vector3 spawnpoint)
		{
			//IL_001e: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Camera.main != (Object)null)
			{
				Transform transform = ((Component)Camera.main).transform;
				spawnpoint = transform.position + transform.forward * 1f;
			}
		}

		[HarmonyPatch(typeof(ManagerBlackboard), "UserCode_CmdSpawnBoxFromPlayer__Vector3__Int32__Int32__Single")]
		[HarmonyPostfix]
		public static void UserCode_CmdSpawnBoxFromPlayer_Postfix(Vector3 spawnpoint, int productID, int numberOfProductsInBox, float YRotation)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapSphere(spawnpoint, 0.3f);
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				BoxData componentInParent = ((Component)val).GetComponentInParent<BoxData>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					Rigidbody component = ((Component)componentInParent).GetComponent<Rigidbody>();
					if ((Object)(object)component != (Object)null)
					{
						Plugin.mls.LogInfo((object)"throwing box server-side");
						Vector3 val2 = Quaternion.Euler(0f, YRotation, 0f) * Vector3.forward;
						Vector3 val3 = val2 * 1f + Vector3.up * 0.3f;
						component.velocity = val3 * throwForce;
						component.angularVelocity = new Vector3(Random.Range(0f - spinStrength, spinStrength), Random.Range(0f - spinStrength, spinStrength), Random.Range(0f - spinStrength, spinStrength));
					}
				}
			}
		}

		[HarmonyPatch(typeof(ManagerBlackboard), "UserCode_RpcParentBoxOnClient__GameObject")]
		[HarmonyPostfix]
		public static void UserCode_RpcParentBoxOnClient_Postfix(GameObject boxOBJ)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_0053: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)boxOBJ == (Object)null))
			{
				Rigidbody component = boxOBJ.GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					Plugin.mls.LogInfo((object)"throwing box client-side");
					Vector3 val = -boxOBJ.transform.right;
					Vector3 val2 = val * 1f + Vector3.up * 0.3f;
					component.velocity = val2 * throwForce;
					component.angularVelocity = new Vector3(Random.Range(0f - spinStrength, spinStrength), Random.Range(0f - spinStrength, spinStrength), Random.Range(0f - spinStrength, spinStrength));
				}
			}
		}

		[HarmonyPatch(typeof(BoxData), "OnStartClient")]
		[HarmonyPostfix]
		public static void OnStartClient_Postfix(BoxData __instance)
		{
			if ((Object)(object)((Component)__instance).gameObject.GetComponent<ThrowableBoxBehaviour>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<ThrowableBoxBehaviour>();
			}
		}
	}
	[HarmonyPatch]
	internal class WorldBordersPatch
	{
		[HarmonyPatch(typeof(GameCanvas), "Awake")]
		[HarmonyPostfix]
		private static void Prefix()
		{
			Collider[] array = Object.FindObjectsByType<Collider>((FindObjectsSortMode)0);
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				GameObject gameObject = ((Component)val).gameObject;
				string name = ((Object)gameObject).name;
				if (val is BoxCollider && name.StartsWith("Base_Collider"))
				{
					gameObject.AddComponent<BoxColliderVisualizer>();
					Plugin.mls.LogInfo((object)("Assigned BoxColliderVisualizer to '" + name + "'"));
				}
				else if (val is MeshCollider && name.StartsWith("WeatherPlane_"))
				{
					gameObject.AddComponent<MeshColliderVisualizer>();
					Plugin.mls.LogInfo((object)("Assigned MeshColliderVisualizer to '" + name + "'"));
				}
			}
		}
	}
}
namespace KroesSupermarketMod.CustomScripts
{
	internal class BoxColliderVisualizer : MonoBehaviour
	{
		private LineRenderer lineRenderer;

		private Renderer targetRenderer;

		private GameObject lineChildContainer;

		private bool showLines = false;

		private static readonly Vector3[] BoxVertices = (Vector3[])(object)new Vector3[16]
		{
			new Vector3(-0.5f, -0.5f, -0.5f),
			new Vector3(0.5f, -0.5f, -0.5f),
			new Vector3(0.5f, -0.5f, 0.5f),
			new Vector3(-0.5f, -0.5f, 0.5f),
			new Vector3(-0.5f, -0.5f, -0.5f),
			new Vector3(-0.5f, 0.5f, -0.5f),
			new Vector3(0.5f, 0.5f, -0.5f),
			new Vector3(0.5f, -0.5f, -0.5f),
			new Vector3(0.5f, 0.5f, -0.5f),
			new Vector3(0.5f, 0.5f, 0.5f),
			new Vector3(0.5f, -0.5f, 0.5f),
			new Vector3(0.5f, 0.5f, 0.5f),
			new Vector3(-0.5f, 0.5f, 0.5f),
			new Vector3(-0.5f, -0.5f, 0.5f),
			new Vector3(-0.5f, 0.5f, 0.5f),
			new Vector3(-0.5f, 0.5f, -0.5f)
		};

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			lineChildContainer = new GameObject("SelectionOutlineContainer");
			lineChildContainer.transform.SetParent(((Component)this).transform, false);
			lineRenderer = lineChildContainer.AddComponent<LineRenderer>();
			lineRenderer.useWorldSpace = true;
			lineRenderer.startWidth = 0.03f;
			lineRenderer.endWidth = 0.03f;
			lineRenderer.positionCount = BoxVertices.Length;
			Material val = new Material(Shader.Find("Sprites/Default"));
			val.color = Color.green;
			((Renderer)lineRenderer).material = val;
			lineRenderer.startColor = Color.green;
			lineRenderer.endColor = Color.green;
			targetRenderer = ((Component)this).GetComponentInChildren<Renderer>();
		}

		private void Update()
		{
			if (Input.GetKeyDown((KeyCode)289))
			{
				showLines = !showLines;
				((Renderer)lineRenderer).enabled = showLines;
			}
		}

		private void LateUpdate()
		{
			if (showLines)
			{
				UpdateOutline();
			}
		}

		private void UpdateOutline()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)lineRenderer == (Object)null))
			{
				Vector3 val;
				Vector3 val2;
				if ((Object)(object)targetRenderer != (Object)null)
				{
					Bounds bounds = targetRenderer.bounds;
					val = ((Bounds)(ref bounds)).center;
					val2 = ((Bounds)(ref bounds)).size;
				}
				else
				{
					val = ((Component)this).transform.position;
					val2 = ((Component)this).transform.lossyScale;
				}
				for (int i = 0; i < BoxVertices.Length; i++)
				{
					Vector3 val3 = Vector3.Scale(BoxVertices[i], val2);
					Vector3 val4 = val + ((Component)this).transform.rotation * val3;
					lineRenderer.SetPosition(i, val4);
				}
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)lineChildContainer != (Object)null)
			{
				Object.Destroy((Object)(object)lineChildContainer);
			}
		}
	}
	internal class MeshColliderVisualizer : MonoBehaviour
	{
		private struct Edge
		{
			public int v1;

			public int v2;

			public Edge(int a, int b)
			{
				v1 = Math.Min(a, b);
				v2 = Math.Max(a, b);
			}

			public override bool Equals(object obj)
			{
				return obj is Edge edge && v1 == edge.v1 && v2 == edge.v2;
			}

			public override int GetHashCode()
			{
				return (v1 * 397) ^ v2;
			}
		}

		private MeshCollider meshCollider;

		private GameObject lineChildContainer;

		private List<LineRenderer> lineRenderers = new List<LineRenderer>();

		private List<Edge> meshEdges = new List<Edge>();

		private bool showLines = false;

		private void Awake()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			meshCollider = ((Component)this).GetComponent<MeshCollider>();
			if ((Object)(object)meshCollider == (Object)null || (Object)(object)meshCollider.sharedMesh == (Object)null)
			{
				Debug.LogWarning((object)("[MeshColliderVisualizer] No MeshCollider or sharedMesh found on " + ((Object)((Component)this).gameObject).name));
				return;
			}
			lineChildContainer = new GameObject("MeshColliderOutlineContainer");
			lineChildContainer.transform.SetParent(((Component)this).transform, false);
			ExtractMeshEdges(meshCollider.sharedMesh);
			Material material = new Material(Shader.Find("Sprites/Default"))
			{
				color = Color.green
			};
			foreach (Edge meshEdge in meshEdges)
			{
				GameObject val = new GameObject("EdgeSegment");
				val.transform.SetParent(lineChildContainer.transform, false);
				LineRenderer val2 = val.AddComponent<LineRenderer>();
				val2.useWorldSpace = true;
				val2.startWidth = 0.03f;
				val2.endWidth = 0.03f;
				val2.positionCount = 2;
				((Renderer)val2).material = material;
				val2.startColor = Color.green;
				val2.endColor = Color.green;
				((Renderer)val2).enabled = false;
				lineRenderers.Add(val2);
			}
		}

		private void ExtractMeshEdges(Mesh mesh)
		{
			int[] triangles = mesh.triangles;
			HashSet<Edge> hashSet = new HashSet<Edge>();
			for (int i = 0; i < triangles.Length; i += 3)
			{
				int num = triangles[i];
				int num2 = triangles[i + 1];
				int num3 = triangles[i + 2];
				hashSet.Add(new Edge(num, num2));
				hashSet.Add(new Edge(num2, num3));
				hashSet.Add(new Edge(num3, num));
			}
			meshEdges.AddRange(hashSet);
		}

		private void Update()
		{
			if (Input.GetKeyDown((KeyCode)289))
			{
				showLines = !showLines;
				SetLinesEnabled(showLines);
			}
		}

		private void LateUpdate()
		{
			if (showLines)
			{
				UpdateOutline();
			}
		}

		private void SetLinesEnabled(bool enabled)
		{
			foreach (LineRenderer lineRenderer in lineRenderers)
			{
				if ((Object)(object)lineRenderer != (Object)null)
				{
					((Renderer)lineRenderer).enabled = enabled;
				}
			}
		}

		private void UpdateOutline()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)meshCollider == (Object)null) && !((Object)(object)meshCollider.sharedMesh == (Object)null))
			{
				Vector3[] vertices = meshCollider.sharedMesh.vertices;
				for (int i = 0; i < meshEdges.Count; i++)
				{
					Edge edge = meshEdges[i];
					LineRenderer val = lineRenderers[i];
					Vector3 val2 = ((Component)this).transform.TransformPoint(vertices[edge.v1]);
					Vector3 val3 = ((Component)this).transform.TransformPoint(vertices[edge.v2]);
					val.SetPosition(0, val2);
					val.SetPosition(1, val3);
				}
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)lineChildContainer != (Object)null)
			{
				Object.Destroy((Object)(object)lineChildContainer);
			}
		}
	}
	public class ThrowableBoxBehaviour : MonoBehaviour
	{
		private Rigidbody rb;

		private BoxData boxData = null;

		private GameObject recycle1Obj = null;

		private GameObject recycle2Obj = null;

		private GameObject trashObj = null;

		public bool hasAlreadyHit = false;

		private void Start()
		{
			rb = ((Component)this).GetComponent<Rigidbody>();
			boxData = ((Component)this).GetComponent<BoxData>();
		}

		private void Awake()
		{
			if ((Object)(object)Utilities.recycleObj1 != (Object)null)
			{
				recycle1Obj = Utilities.recycleObj1;
			}
			if ((Object)(object)Utilities.recycleObj2 != (Object)null)
			{
				recycle2Obj = Utilities.recycleObj2;
			}
			if ((Object)(object)Utilities.trashObj != (Object)null)
			{
				trashObj = Utilities.trashObj;
			}
		}

		private void Update()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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)
			if (((Object)(object)boxData != (Object)null && boxData.numberOfProducts > 0) || !NetworkServer.active)
			{
				return;
			}
			float num = (((Object)(object)recycle1Obj != (Object)null) ? Vector3.Distance(((Component)this).transform.position, recycle1Obj.transform.position) : float.MaxValue);
			float num2 = (((Object)(object)recycle2Obj != (Object)null) ? Vector3.Distance(((Component)this).transform.position, recycle2Obj.transform.position) : float.MaxValue);
			float num3 = (((Object)(object)trashObj != (Object)null) ? Vector3.Distance(((Component)this).transform.position, trashObj.transform.position) : float.MaxValue);
			if (num < 2.5f || num2 < 2.5f)
			{
				RecycleBox();
			}
			else if (num3 < 3f)
			{
				if (NPC_Manager.Instance.closestRecyclePerk)
				{
					RecycleBox();
					return;
				}
				Plugin.mls.LogInfo((object)"trash thrown box...");
				NetworkServer.Destroy(((Component)this).gameObject);
			}
		}

		private void RecycleBox()
		{
			Plugin.mls.LogInfo((object)"recycle thrown box...");
			float num = 1.5f * (float)((Component)GameData.Instance).GetComponent<UpgradesManager>().boxRecycleFactor;
			AchievementsManager.Instance.CmdAddAchievementPoint(2, 1);
			StatisticsManager instance = StatisticsManager.Instance;
			instance.totalBalesRecycled++;
			GameData.Instance.CmdAlterFunds(num);
			NetworkServer.Destroy(((Component)this).gameObject);
		}

		private void OnTriggerEnter(Collider other)
		{
			CheckHit(((Component)other).gameObject);
		}

		private void OnCollisionEnter(Collision collision)
		{
			CheckHit(collision.gameObject);
		}

		private void CheckHit(GameObject otherOBJ)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: 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_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: 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_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || hasAlreadyHit || (Object)(object)rb == (Object)null)
			{
				return;
			}
			Vector3 val = rb.velocity;
			if (((Vector3)(ref val)).magnitude < 1f)
			{
				return;
			}
			if (((Object)otherOBJ).name == "HitTrigger" && Object.op_Implicit((Object)(object)otherOBJ.transform.parent) && Object.op_Implicit((Object)(object)((Component)otherOBJ.transform.parent).GetComponent<NPC_Info>()))
			{
				hasAlreadyHit = true;
				NPC_Info component = ((Component)otherOBJ.transform.parent).GetComponent<NPC_Info>();
				component.CmdAnimationPlay(0);
				int num = Random.Range(0, 9);
				component.RPCNotificationAboveHead($"NPCmessagehit{num}", "");
				PlayMakerFSM component2 = otherOBJ.GetComponent<PlayMakerFSM>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.SendEvent("Send_Data_2");
				}
				Rigidbody obj = rb;
				obj.velocity *= 0.1f;
			}
			else if (((Object)otherOBJ).name == "HitTrigger" && Object.op_Implicit((Object)(object)otherOBJ.transform.parent) && Object.op_Implicit((Object)(object)((Component)otherOBJ.transform.parent).transform.parent) && Object.op_Implicit((Object)(object)((Component)((Component)otherOBJ.transform.parent).transform.parent).GetComponent<PlayerNetwork>()))
			{
				hasAlreadyHit = true;
				PlayerNetwork component3 = ((Component)((Component)otherOBJ.transform.parent).transform.parent).GetComponent<PlayerNetwork>();
				PlayMakerFSM component4 = otherOBJ.GetComponent<PlayMakerFSM>();
				if ((Object)(object)component4 != (Object)null)
				{
					component4.SendEvent("Send_Data_2");
				}
				val = otherOBJ.transform.position - ((Component)this).transform.position;
				Vector3 val2 = ((Vector3)(ref val)).normalized * 0.1f;
				component3.PushPlayer(val2);
				Rigidbody obj2 = rb;
				obj2.velocity *= 0.1f;
			}
		}
	}
}