Decompiled source of BetterSMT v1.6.2

BepInEx/plugins/ViViKo.BetterSMT.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HighlightPlus;
using Microsoft.CodeAnalysis;
using Mirror;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Mirror")]
[assembly: IgnoresAccessChecksTo("PlayMaker")]
[assembly: IgnoresAccessChecksTo("Rewired_Core")]
[assembly: AssemblyCompany("ViViKo.BetterSMT")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("BetterSMT")]
[assembly: AssemblyFileVersion("1.6.2.0")]
[assembly: AssemblyInformationalVersion("1.6.2")]
[assembly: AssemblyProduct("BetterSMT")]
[assembly: AssemblyTitle("ViViKo.BetterSMT")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.6.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BetterSMT
{
	[BepInPlugin("ViViKo.BetterSMT", "BetterSMT", "1.6.2")]
	public class BetterSMT : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("ViViKo.BetterSMT");

		public static BetterSMT Instance;

		public static ConfigEntry<int> EmployeesPerPerk;

		public static ConfigEntry<int> CustomersPerPerk;

		public static ConfigEntry<float> EmployeeSpeedPerPerk;

		public static ConfigEntry<float> EmployeeRestockPerPerk;

		public static ConfigEntry<float> EmployeeCheckoutPerPerk1;

		public static ConfigEntry<float> EmployeeCheckoutPerPerk2;

		public static ConfigEntry<float> EmployeeCheckoutPerPerk3;

		public static ConfigEntry<bool> OneHitThief;

		public static ConfigEntry<bool> ReplaceCommasWithPeriods;

		public static ConfigEntry<bool> FasterCheckout;

		public static ConfigEntry<bool> ShowFPS;

		public static ConfigEntry<bool> ShowPing;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Expected O, but got Unknown
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Expected O, but got Unknown
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			EmployeesPerPerk = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "Employees Per Perk", 1, new ConfigDescription("Adjust the amount of employees you gain per perk", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), Array.Empty<object>()));
			EmployeeSpeedPerPerk = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "Employee Speed Per Perk", 0.2f, new ConfigDescription("Adjust the amount of speed employees gain per perk", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>()));
			EmployeeRestockPerPerk = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "Employee Restock Time Reduction Per Perk", 0.05f, new ConfigDescription("Adjust the amount of time it takes for employees to restock per perk", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 0.1f), Array.Empty<object>()));
			EmployeeCheckoutPerPerk1 = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "Employee Checkout Time Reduction Perk 1", 0.15f, new ConfigDescription("Adjust the amount of time employees wait to scan items in checkout (Perk 1) (Lower = slower)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 0.25f), Array.Empty<object>()));
			EmployeeCheckoutPerPerk2 = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "Employee Checkout Time Reduction Perk 2", 0.2f, new ConfigDescription("Adjust the amount of time employees wait to scan items in checkout (Perk 2) (Lower = slower)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 0.25f), Array.Empty<object>()));
			EmployeeCheckoutPerPerk3 = ((BaseUnityPlugin)this).Config.Bind<float>("Perks", "Employee Checkout Time Reduction Perk 3", 0.15f, new ConfigDescription("Adjust the amount of time employees wait to scan items in checkout (Perk 3) (Lower = slower)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 0.25f), Array.Empty<object>()));
			CustomersPerPerk = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "Extra Customers per perk", 1, new ConfigDescription("Adjust the amount of customers you gain per perk", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), Array.Empty<object>()));
			OneHitThief = ((BaseUnityPlugin)this).Config.Bind<bool>("Thiefs", "Thiefs Drop Everything On Hit", true, (ConfigDescription)null);
			FasterCheckout = ((BaseUnityPlugin)this).Config.Bind<bool>("Customers", "Faster Checkout", true, new ConfigDescription("Customers place all items instantly on to the checkout", (AcceptableValueBase)null, Array.Empty<object>()));
			ReplaceCommasWithPeriods = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Replace Commas with Periods", true, (ConfigDescription)null);
			ShowFPS = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Show FPS Counter", false, (ConfigDescription)null);
			ShowPing = ((BaseUnityPlugin)this).Config.Bind<bool>("Other", "Show Ping Counter", false, (ConfigDescription)null);
			harmony.PatchAll();
			Logger.LogInfo((object)"Plugin BetterSMT v1.6.2 is loaded!");
		}

		public static string ReplaceCommas(string text)
		{
			if (!ReplaceCommasWithPeriods.Value)
			{
				return text;
			}
			text = text.Replace("$", string.Empty);
			text = text.Replace(char.Parse(","), char.Parse("."));
			if (!text.Contains("."))
			{
				text += ".00";
			}
			return "$" + text;
		}

		public static void CreateCanvasNotification(string text)
		{
			GameObject obj = Object.Instantiate<GameObject>(GameCanvas.Instance.notificationPrefab, GameCanvas.Instance.notificationParentTransform);
			((TMP_Text)obj.GetComponent<TextMeshProUGUI>()).text = text;
			obj.SetActive(true);
		}

		public static void CreateImportantNotification(string text)
		{
			GameObject obj = Object.Instantiate<GameObject>(GameCanvas.Instance.importantNotificationPrefab, GameCanvas.Instance.importantNotificationParentTransform);
			((TMP_Text)obj.GetComponent<TextMeshProUGUI>()).text = text;
			obj.SetActive(true);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ViViKo.BetterSMT";

		public const string PLUGIN_NAME = "BetterSMT";

		public const string PLUGIN_VERSION = "1.6.2";
	}
}
namespace BetterSMT.Patches
{
	[HarmonyPatch(typeof(GameData))]
	public class GameDataPatch
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__1_0;

			internal void <UpdateEscapeMenu>b__1_0()
			{
				((MonoBehaviour)GameData.Instance).StartCoroutine(SaveGame());
			}
		}

		[HarmonyPatch("OnStartClient")]
		[HarmonyPostfix]
		private static void OnStartClientPatch(GameData __instance)
		{
			ShowCounters();
			UpdateEscapeMenu();
		}

		private static void UpdateEscapeMenu()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			GameObject val = GameObject.Find("MasterOBJ/MasterCanvas/Menus/EscapeMenu/");
			_ = ((Component)val.transform.Find("OptionsButton")).gameObject;
			GameObject gameObject = ((Component)val.transform.Find("QuitButton")).gameObject;
			gameObject.transform.localPosition = new Vector3(0f, 0f, 0f);
			((Component)val.transform.Find("MainMenuButton")).gameObject.transform.localPosition = new Vector3(0f, 85f, 0f);
			GameObject val2 = Object.Instantiate<GameObject>(gameObject, val.transform);
			((Object)val2).name = "SaveButton";
			val2.GetComponents<PlayMakerFSM>().ToList().ForEach((Action<PlayMakerFSM>)Object.Destroy);
			Object.Destroy((Object)(object)val2.GetComponent<EventTrigger>());
			val2.transform.position = gameObject.transform.position;
			val2.transform.localScale = gameObject.transform.localScale;
			val2.transform.localPosition = new Vector3(0f, -85f, 0f);
			((TMP_Text)val2.GetComponentInChildren<TextMeshProUGUI>()).text = "Save Game";
			ButtonClickedEvent onClick = val2.GetComponent<Button>().onClick;
			object obj = <>c.<>9__1_0;
			if (obj == null)
			{
				UnityAction val3 = delegate
				{
					((MonoBehaviour)GameData.Instance).StartCoroutine(SaveGame());
				};
				<>c.<>9__1_0 = val3;
				obj = (object)val3;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			if (!((NetworkBehaviour)GameData.Instance).isServer)
			{
				val2.SetActive(false);
			}
		}

		public static IEnumerator SaveGame()
		{
			NetworkSpawner nSpawnerComponent = ((Component)GameData.Instance).GetComponent<NetworkSpawner>();
			if (!nSpawnerComponent.isSaving)
			{
				BetterSMT.CreateImportantNotification("Saving Game");
				GameData.Instance.DoDaySaveBackup();
				GameData.Instance.DoDaySaveBackup();
				PlayMakerFSM fsm = GameData.Instance.SaveOBJ.GetComponent<PlayMakerFSM>();
				fsm.FsmVariables.GetFsmBool("IsSaving").Value = true;
				fsm.SendEvent("Send_Data");
				while (fsm.FsmVariables.GetFsmBool("IsSaving").Value)
				{
					yield return null;
				}
				yield return nSpawnerComponent.SavePropsCoroutine();
				BetterSMT.CreateImportantNotification("Saving Finished");
			}
			else
			{
				BetterSMT.CreateImportantNotification("Saving already in progress");
			}
		}

		public static void ShowCounters()
		{
			if (BetterSMT.ShowPing.Value)
			{
				GameObject val = GameObject.Find("MasterOBJ/MasterCanvas/Ping");
				if ((Object)(object)val == (Object)null)
				{
					BetterSMT.Logger.LogWarning((object)"Couldnt find Ping object");
					return;
				}
				val.SetActive(true);
			}
			if (BetterSMT.ShowFPS.Value)
			{
				GameObject val2 = GameObject.Find("MasterOBJ/MasterCanvas/FPSDisplay");
				if ((Object)(object)val2 == (Object)null)
				{
					BetterSMT.Logger.LogWarning((object)"Couldnt find FPSDisplay object");
				}
				else
				{
					val2.SetActive(true);
				}
			}
		}
	}
	[HarmonyPatch(typeof(NPC_Info))]
	public class NPC_InfoPatch
	{
		[HarmonyPatch("PlaceProducts")]
		[HarmonyPrefix]
		private static void PlaceProductsPatch(NPC_Info __instance)
		{
			__instance.productItemPlaceWait = (BetterSMT.FasterCheckout.Value ? 0f : 0.5f);
		}

		[HarmonyPatch("AuxiliarAnimationPlay")]
		[HarmonyPrefix]
		private static bool AuxiliarAnimationPlayPatch(NPC_Info __instance, ref int animationIndex)
		{
			//IL_0078: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			if (!BetterSMT.OneHitThief.Value)
			{
				return true;
			}
			if (!__instance.beingPushed)
			{
				((MonoBehaviour)__instance).StartCoroutine(__instance.StopSpeed());
			}
			if (__instance.isAThief && __instance.productsIDCarrying.Count > 0)
			{
				int count = __instance.productsIDCarrying.Count;
				for (int i = 0; i < count; i++)
				{
					GameObject obj = Object.Instantiate<GameObject>(__instance.stolenProductPrefab, NPC_Manager.Instance.droppedProductsParentOBJ.transform);
					obj.transform.position = ((Component)__instance).transform.position + new Vector3(Random.Range(-0.4f, 0.4f), 0f, Random.Range(-0.4f, 0.4f));
					obj.GetComponent<StolenProductSpawn>().NetworkproductID = __instance.productsIDCarrying[0];
					obj.GetComponent<StolenProductSpawn>().NetworkproductCarryingPrice = __instance.productsCarryingPrice[0] * 0.8f;
					NetworkServer.Spawn(obj, (NetworkConnection)null);
					__instance.productsIDCarrying.RemoveAt(0);
					__instance.productsCarryingPrice.RemoveAt(0);
				}
			}
			if (__instance.isAThief && __instance.productsIDCarrying.Count == 0 && Object.op_Implicit((Object)(object)((Component)((Component)__instance).transform.Find("ThiefCanvas")).gameObject) && ((Component)((Component)__instance).transform.Find("ThiefCanvas")).gameObject.activeSelf)
			{
				__instance.RpcHideThief();
			}
			int num = Random.Range(0, 9);
			__instance.RpcAnimationPlay(animationIndex);
			__instance.RPCNotificationAboveHead("NPCmessagehit" + num, "");
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerNetwork))]
	public class PlayerNetworkPatch
	{
		private static PlayerNetwork pNetwork;

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void StartPatch(PlayerNetwork __instance)
		{
			if (((NetworkBehaviour)__instance).isLocalPlayer)
			{
				pNetwork = __instance;
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch()
		{
			if (Object.op_Implicit((Object)(object)pNetwork.marketPriceTMP))
			{
				((TMP_Text)pNetwork.marketPriceTMP).text = BetterSMT.ReplaceCommas(((TMP_Text)pNetwork.marketPriceTMP).text);
			}
			if (Object.op_Implicit((Object)(object)pNetwork.yourPriceTMP))
			{
				((TMP_Text)pNetwork.yourPriceTMP).text = BetterSMT.ReplaceCommas(((TMP_Text)pNetwork.yourPriceTMP).text);
			}
		}

		[HarmonyPatch("PriceSetFromNumpad")]
		[HarmonyPrefix]
		private static void PriceSetFromNumpadPrePatch(PlayerNetwork __instance, ref int productID)
		{
			if (Input.GetKeyDown((KeyCode)101))
			{
				Data_Product component = ProductListing.Instance.productPrefabs[productID].GetComponent<Data_Product>();
				float num = ((Component)ProductListing.Instance).GetComponent<ProductListing>().tierInflation[component.productTier];
				int maxItemsPerBox = component.maxItemsPerBox;
				float num2 = Mathf.Round(component.basePricePerUnit * num * 100f) / 100f * (float)maxItemsPerBox;
				num2 = Mathf.Round(num2 * 100f) / 100f;
				((Component)GameData.Instance).GetComponent<ManagerBlackboard>().AddShoppingListProduct(productID, num2);
				string text = "product" + productID;
				string localizationString = LocalizationManager.instance.GetLocalizationString(text);
				BetterSMT.CreateCanvasNotification("Added " + localizationString + "[" + component.productBrand + "] to shopping list");
			}
		}

		[HarmonyPatch("PriceSetFromNumpad")]
		[HarmonyPostfix]
		private static void PriceSetFromNumpadPostPatch(PlayerNetwork __instance)
		{
			((TMP_Text)__instance.yourPriceTMP).text = BetterSMT.ReplaceCommas(((TMP_Text)__instance.yourPriceTMP).text);
		}

		[HarmonyPatch("ChangeEquipment")]
		[HarmonyPostfix]
		private static void ChangeEquipmentPatch(PlayerNetwork __instance, int newEquippedItem)
		{
			switch (newEquippedItem)
			{
			case 0:
				ClearHighlightedShelves();
				break;
			case 1:
				if (((NetworkBehaviour)__instance).isLocalPlayer && __instance.extraParameter1 >= 0)
				{
					HighlightShelvesByProduct(__instance.extraParameter1);
				}
				break;
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00fc: 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_011c: Expected O, but got Unknown
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Expected O, but got Unknown
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Expected O, but got Unknown
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Expected O, but got Unknown
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Expected O, but got Unknown
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Expected O, but got Unknown
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Expected O, but got Unknown
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Expected O, but got Unknown
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Expected O, but got Unknown
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Expected O, but got Unknown
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			int num = list.FindIndex((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloca_S && instruction.operand is LocalBuilder localBuilder2 && localBuilder2.LocalIndex == 0) - 6;
			CodeInstructionExtensions.MoveLabelsFrom(list[num + 42], list[num]);
			list.RemoveRange(num, 42);
			object operand = list[num].operand;
			list.InsertRange(num, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[2]
			{
				CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerNetworkPatch), "GetProductFromRaycast", (Type[])null, (Type[])null)), list[num]),
				new CodeInstruction(OpCodes.Stloc_S, operand)
			});
			int num2 = list.FindIndex((CodeInstruction i) => i.opcode == OpCodes.Ldfld && i.operand == AccessTools.Field(typeof(Data_Container), "productInfoArray")) + 6;
			Label label = generator.DefineLabel();
			CodeInstructionExtensions.WithLabels(list[num2], new Label[1] { label });
			num = new CodeMatcher((IEnumerable<CodeInstruction>)list, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)(sbyte)(-5), (string)null),
				new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(PlayerNetwork), "oldProductID"), (string)null)
			}).Pos;
			int component2Loc = ((LocalBuilder)list[list.FindLastIndex((CodeInstruction i) => CodeInstructionExtensions.Calls(i, AccessTools.Method(typeof(Component), "GetComponent", (Type[])null, new Type[1] { typeof(Data_Container) }))) + 1].operand).LocalIndex;
			int localIndex = ((LocalBuilder)list[num2].operand).LocalIndex;
			list.InsertRange(num, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[7]
			{
				CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Ldnull, (object)null), list[num]),
				new CodeInstruction(OpCodes.Stloc_S, (object)component2Loc),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerNetworkPatch), "GetProductFromRaycast", (Type[])null, (Type[])null)),
				new CodeInstruction(OpCodes.Stloc, (object)localIndex),
				new CodeInstruction(OpCodes.Ldloc, (object)localIndex),
				new CodeInstruction(OpCodes.Ldc_I4_M1, (object)null),
				new CodeInstruction(OpCodes.Bgt, (object)label)
			}));
			int index = list.FindIndex(num2, (CodeInstruction i) => i.opcode == OpCodes.Ldloc_S && i.operand is LocalBuilder localBuilder && localBuilder.LocalIndex == component2Loc) - 5;
			Label label2 = generator.DefineLabel();
			list.InsertRange(index, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[5]
			{
				CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Ldloc_S, (object)component2Loc), list[index]),
				new CodeInstruction(OpCodes.Ldnull, (object)null),
				new CodeInstruction(OpCodes.Bgt_S, (object)label2),
				new CodeInstruction(OpCodes.Ret, (object)null),
				CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Nop, (object)null), new Label[1] { label2 })
			}));
			return list;
		}

		public static int GetProductFromRaycast()
		{
			//IL_000c: 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_002c: 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_010c: 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)
			int result = -1;
			RaycastHit val = default(RaycastHit);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(((Component)Camera.main).transform.position, ((Component)Camera.main).transform.forward, ref val, 4f, LayerMask.op_Implicit(pNetwork.interactableMask)))
			{
				if (((Object)((Component)((RaycastHit)(ref val)).transform).gameObject).name == "SubContainer")
				{
					int siblingIndex = ((RaycastHit)(ref val)).transform.GetSiblingIndex();
					Transform transform = ((RaycastHit)(ref val)).transform;
					object obj;
					if (transform == null)
					{
						obj = null;
					}
					else
					{
						Transform parent = transform.parent;
						if (parent == null)
						{
							obj = null;
						}
						else
						{
							Transform transform2 = ((Component)parent).transform;
							obj = ((transform2 != null) ? transform2.parent : null);
						}
					}
					if (!Object.op_Implicit((Object)obj))
					{
						return result;
					}
					Data_Container component = ((Component)((Component)((RaycastHit)(ref val)).transform.parent).transform.parent).GetComponent<Data_Container>();
					if ((Object)(object)component != (Object)null && component.containerClass < 20)
					{
						result = component.productInfoArray[siblingIndex * 2];
						_ = component.productInfoArray[siblingIndex * 2 + 1];
					}
				}
			}
			else if (Physics.Raycast(((Component)Camera.main).transform.position, ((Component)Camera.main).transform.forward, ref val2, 4f, LayerMask.op_Implicit(pNetwork.lMask)))
			{
				if (((Component)((RaycastHit)(ref val2)).transform).gameObject.tag == "Interactable" && Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val2)).transform).GetComponent<BoxData>()))
				{
					BoxData component2 = ((Component)((RaycastHit)(ref val2)).transform).GetComponent<BoxData>();
					if ((Object)(object)component2 != (Object)null)
					{
						result = component2.productID;
					}
				}
				else
				{
					int siblingIndex2 = ((RaycastHit)(ref val2)).transform.GetSiblingIndex();
					Transform transform3 = ((RaycastHit)(ref val2)).transform;
					object obj2;
					if (transform3 == null)
					{
						obj2 = null;
					}
					else
					{
						Transform parent2 = transform3.parent;
						if (parent2 == null)
						{
							obj2 = null;
						}
						else
						{
							Transform transform4 = ((Component)parent2).transform;
							obj2 = ((transform4 != null) ? transform4.parent : null);
						}
					}
					if (!Object.op_Implicit((Object)obj2))
					{
						return result;
					}
					Data_Container component3 = ((Component)((Component)((RaycastHit)(ref val2)).transform.parent).transform.parent).GetComponent<Data_Container>();
					if ((Object)(object)component3 != (Object)null && component3.containerClass == 69)
					{
						result = component3.productInfoArray[siblingIndex2 * 2];
					}
				}
			}
			return result;
		}

		public static void HighlightShelvesByProduct(int productID)
		{
			//IL_008b: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("Level_SupermarketProps/Shelves");
			for (int i = 0; i < val.transform.childCount; i++)
			{
				Transform child = val.transform.GetChild(i);
				int[] productInfoArray = ((Component)child).gameObject.GetComponent<Data_Container>().productInfoArray;
				int num = productInfoArray.Length / 2;
				bool value = false;
				for (int j = 0; j < num; j++)
				{
					bool flag = productInfoArray[j * 2] == productID;
					Transform child2 = ((Component)child.Find("Labels")).transform.GetChild(j);
					if (flag)
					{
						value = true;
					}
					HighlightShelf(child2, flag, Color.yellow);
				}
				HighlightShelf(child, value, Color.red);
			}
			GameObject val2 = GameObject.Find("Level_SupermarketProps/StorageShelves");
			for (int k = 0; k < val2.transform.childCount; k++)
			{
				Transform child3 = val2.transform.GetChild(k);
				int[] productInfoArray2 = ((Component)child3).gameObject.GetComponent<Data_Container>().productInfoArray;
				int num2 = productInfoArray2.Length / 2;
				for (int l = 0; l < num2; l++)
				{
					bool value2 = productInfoArray2[l * 2] == productID;
					HighlightShelf(((Component)child3.Find("BoxContainer")).transform.GetChild(l), value2, Color.yellow);
				}
			}
		}

		public static void ClearHighlightedShelves()
		{
			GameObject val = GameObject.Find("Level_SupermarketProps/Shelves");
			for (int i = 0; i < val.transform.childCount; i++)
			{
				Transform child = val.transform.GetChild(i);
				int num = ((Component)child).gameObject.GetComponent<Data_Container>().productInfoArray.Length / 2;
				for (int j = 0; j < num; j++)
				{
					HighlightShelf(((Component)child.Find("Labels")).transform.GetChild(j), value: false);
				}
				HighlightShelf(child, value: false);
			}
			GameObject val2 = GameObject.Find("Level_SupermarketProps/StorageShelves");
			for (int k = 0; k < val2.transform.childCount; k++)
			{
				Transform child2 = val2.transform.GetChild(k);
				int num2 = ((Component)child2).gameObject.GetComponent<Data_Container>().productInfoArray.Length / 2;
				for (int l = 0; l < num2; l++)
				{
					Transform val3 = child2.Find("BoxContainer");
					if (!((Object)(object)val3 == (Object)null))
					{
						Transform child3 = val3.GetChild(l);
						if (!((Object)(object)child3 == (Object)null))
						{
							HighlightShelf(child3, value: false);
						}
					}
				}
			}
		}

		public static void HighlightShelf(Transform t, bool value, Color? color = null)
		{
			//IL_0034: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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)
			HighlightEffect val = ((Component)t).GetComponent<HighlightEffect>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)t).gameObject.AddComponent<HighlightEffect>();
			}
			if (color.HasValue)
			{
				val.outlineColor = color.Value;
			}
			val.outlineQuality = (QualityLevel)1;
			val.outlineVisibility = (Visibility)1;
			val.outlineContourStyle = (ContourStyle)1;
			val.outlineIndependent = true;
			val.outline = (value ? 1f : 0f);
			val.glow = (value ? 0f : 1f);
			((Behaviour)val).enabled = true;
			val.SetHighlighted(value);
			val.highlighted = value;
			val._highlighted = value;
		}
	}
	[HarmonyPatch(typeof(ProductListing))]
	public class ProductListingPatch
	{
		[HarmonyPatch("ConvertFloatToTextPrice")]
		[HarmonyPostfix]
		private static void ConvertFloatToTextPricePatch(ref string __result)
		{
			__result = BetterSMT.ReplaceCommas(__result);
		}
	}
	[HarmonyPatch(typeof(UpgradesManager))]
	public class UpgradesManagerPatch
	{
		[HarmonyPatch("ManageExtraPerks")]
		[HarmonyPrefix]
		private static bool ManageExtraPerksPatch(UpgradesManager __instance, int perkIndex)
		{
			switch (perkIndex)
			{
			case 0:
			{
				NPC_Manager instance20 = NPC_Manager.Instance;
				instance20.maxEmployees += BetterSMT.EmployeesPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeesNumberInBlackboard();
				break;
			}
			case 1:
			{
				NPC_Manager instance19 = NPC_Manager.Instance;
				instance19.maxEmployees += BetterSMT.EmployeesPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeesNumberInBlackboard();
				break;
			}
			case 2:
			{
				NPC_Manager instance18 = NPC_Manager.Instance;
				instance18.maxEmployees += BetterSMT.EmployeesPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeesNumberInBlackboard();
				break;
			}
			case 3:
			{
				NPC_Manager instance17 = NPC_Manager.Instance;
				instance17.maxEmployees += BetterSMT.EmployeesPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeesNumberInBlackboard();
				break;
			}
			case 4:
			{
				NPC_Manager instance16 = NPC_Manager.Instance;
				instance16.maxEmployees += BetterSMT.EmployeesPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeesNumberInBlackboard();
				break;
			}
			case 5:
			{
				NPC_Manager instance15 = NPC_Manager.Instance;
				instance15.extraEmployeeSpeedFactor += BetterSMT.EmployeeSpeedPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeeStats();
				break;
			}
			case 7:
			{
				NPC_Manager instance14 = NPC_Manager.Instance;
				instance14.extraEmployeeSpeedFactor += BetterSMT.EmployeeSpeedPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeeStats();
				break;
			}
			case 9:
			{
				GameData component2 = ((Component)__instance).GetComponent<GameData>();
				component2.extraCustomersPerk += BetterSMT.CustomersPerPerk.Value;
				break;
			}
			case 10:
			{
				GameData component = ((Component)__instance).GetComponent<GameData>();
				component.extraCustomersPerk += BetterSMT.CustomersPerPerk.Value;
				break;
			}
			case 11:
			{
				NPC_Manager instance13 = NPC_Manager.Instance;
				instance13.maxEmployees += BetterSMT.EmployeesPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeesNumberInBlackboard();
				break;
			}
			case 12:
			{
				NPC_Manager instance12 = NPC_Manager.Instance;
				instance12.maxEmployees += BetterSMT.EmployeesPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeesNumberInBlackboard();
				break;
			}
			case 13:
			{
				NPC_Manager instance11 = NPC_Manager.Instance;
				instance11.maxEmployees += BetterSMT.EmployeesPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeesNumberInBlackboard();
				break;
			}
			case 14:
			{
				NPC_Manager instance10 = NPC_Manager.Instance;
				instance10.maxEmployees += BetterSMT.EmployeesPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeesNumberInBlackboard();
				break;
			}
			case 15:
			{
				NPC_Manager instance9 = NPC_Manager.Instance;
				instance9.maxEmployees += BetterSMT.EmployeesPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeesNumberInBlackboard();
				break;
			}
			case 16:
			{
				NPC_Manager instance8 = NPC_Manager.Instance;
				instance8.productCheckoutWait -= BetterSMT.EmployeeCheckoutPerPerk1.Value;
				break;
			}
			case 17:
			{
				NPC_Manager instance7 = NPC_Manager.Instance;
				instance7.productCheckoutWait -= BetterSMT.EmployeeCheckoutPerPerk2.Value;
				break;
			}
			case 18:
			{
				NPC_Manager instance6 = NPC_Manager.Instance;
				instance6.productCheckoutWait -= BetterSMT.EmployeeCheckoutPerPerk3.Value;
				break;
			}
			case 19:
			{
				NPC_Manager instance5 = NPC_Manager.Instance;
				instance5.employeeItemPlaceWait -= BetterSMT.EmployeeRestockPerPerk.Value;
				break;
			}
			case 20:
			{
				NPC_Manager instance4 = NPC_Manager.Instance;
				instance4.employeeItemPlaceWait -= BetterSMT.EmployeeRestockPerPerk.Value;
				break;
			}
			case 21:
			{
				NPC_Manager instance3 = NPC_Manager.Instance;
				instance3.extraEmployeeSpeedFactor += BetterSMT.EmployeeSpeedPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeeStats();
				break;
			}
			case 22:
			{
				NPC_Manager instance2 = NPC_Manager.Instance;
				instance2.extraEmployeeSpeedFactor += BetterSMT.EmployeeSpeedPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeeStats();
				break;
			}
			case 23:
			{
				NPC_Manager instance = NPC_Manager.Instance;
				instance.extraEmployeeSpeedFactor += BetterSMT.EmployeeSpeedPerPerk.Value;
				NPC_Manager.Instance.UpdateEmployeeStats();
				break;
			}
			default:
				return true;
			}
			GameObject gameObject = ((Component)__instance.UIPerksParent.transform.GetChild(perkIndex)).gameObject;
			gameObject.GetComponent<CanvasGroup>().alpha = 1f;
			gameObject.tag = "Untagged";
			((Component)gameObject.transform.Find("Highlight2")).gameObject.SetActive(true);
			return false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int IReadOnlyCollection<T>.Count => _items.Length;

	T IReadOnlyList<T>.this[int index] => _items[index];

	int ICollection<T>.Count => _items.Length;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return ((IEnumerable)_items).GetEnumerator();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return ((IEnumerable<T>)_items).GetEnumerator();
	}

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

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

	bool ICollection<T>.Contains(T item)
	{
		return ((ICollection<T>)_items).Contains(item);
	}

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

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

	int IList<T>.IndexOf(T item)
	{
		return ((IList<T>)_items).IndexOf(item);
	}

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

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