Decompiled source of BetterMarket v1.1.1

BepInEx/plugins/ViViKo.BetterMarket.dll

Decompiled 6 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
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: AssemblyCompany("ViViKo.BetterMarket")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Fixes and Tweaks")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("BetterMarket")]
[assembly: AssemblyTitle("ViViKo.BetterMarket")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.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 BetterMarket
{
	[BepInPlugin("ViViKo.BetterMarket", "BetterMarket", "1.1.1")]
	public class BetterMarket : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("ViViKo.BetterMarket");

		public static BetterMarket Instance;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			harmony.PatchAll();
			Logger.LogInfo((object)"Plugin BetterMarket v1.1.1 is loaded!");
		}

		public static int GetProductAmount(ProductSO product)
		{
			return (from x in Object.FindObjectsOfType<Item>()
				where x.itemSO is ProductSO && x.itemSO.itemName == ((ItemSO)product).itemName
				select x).Sum((Item item) => item.amount.Value);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ViViKo.BetterMarket";

		public const string PLUGIN_NAME = "BetterMarket";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}
namespace BetterMarket.Patches
{
	[HarmonyPatch(typeof(BlockAlcoholMachine))]
	public class BlockJamMachinePatch
	{
		[HarmonyPatch("GetDescription")]
		[HarmonyPostfix]
		private static void GetDescriptionPatch(BlockAlcoholMachine __instance, ref string __result)
		{
			if (__instance.currentOutput.Value != -1)
			{
				ItemSO itemById = GameManager.Instance.GetItemById(__instance.currentOutput.Value);
				__result = itemById.GetLocalizedName();
				if (__instance.remainingDays.Value > 0)
				{
					int value = __instance.remainingDays.Value;
					string text = string.Format("{0} {1} left", value, (value == 1) ? "day" : "days");
					__result = __result + " <i><color=yellow>" + text + "</color></i>";
				}
			}
		}
	}
	[HarmonyPatch(typeof(BlockAnimal))]
	public class BlockAnimalPatch
	{
		[HarmonyPatch("GetDescription")]
		[HarmonyPostfix]
		private static void GetDescriptionPatch(BlockAnimal __instance, ref string __result)
		{
			if (__instance.dayCounter.Value < __instance.animalSO.daysToHarvestAfterGrowth)
			{
				int num = __instance.animalSO.daysToHarvestAfterGrowth - __instance.dayCounter.Value;
				string text = string.Format("{0} {1} left", num, (num == 1) ? "day" : "days");
				__result = __result + " <i><color=yellow>" + text + "</color></i>";
			}
		}
	}
	[HarmonyPatch(typeof(BlockDirt))]
	public class BlockDirtPatch
	{
		[HarmonyPatch("GetDescription")]
		[HarmonyPostfix]
		private static void GetDescriptionPatch(BlockDirt __instance, ref string __result)
		{
			if (__instance.currentSeed.Value != -1)
			{
				ItemSO itemById = GameManager.Instance.GetItemById(__instance.currentSeed.Value);
				SeedSO val = (SeedSO)(object)((itemById is SeedSO) ? itemById : null);
				if (__instance.dayCounter.Value < val.daysToFullGrowth)
				{
					int num = val.daysToFullGrowth - __instance.dayCounter.Value;
					string text = string.Format("{0} {1} left", num, (num == 1) ? "day" : "days");
					__result = __result + " <i><color=yellow>" + text + "</color></i>";
				}
			}
		}
	}
	[HarmonyPatch(typeof(BlockTree))]
	public class BlockTreePatch
	{
		[HarmonyPatch("GetDescription")]
		[HarmonyPostfix]
		private static void GetDescriptionPatch(BlockTree __instance, ref string __result)
		{
			if (__instance.dayCounter.Value < __instance.treeSO.daysToHarvestAfterGrowth)
			{
				int num = __instance.treeSO.daysToHarvestAfterGrowth - __instance.dayCounter.Value;
				string text = string.Format("{0} {1} left", num, (num == 1) ? "day" : "days");
				__result = __result + " <i><color=yellow>" + text + "</color></i>";
			}
		}
	}
	[HarmonyPatch(typeof(DockOrderTile))]
	public class DockOrderTilePatch
	{
		[HarmonyPatch("SetData")]
		[HarmonyPostfix]
		private static void SetDataPatch(DockOrderTile __instance, ProductSO productSO)
		{
			int productAmount = GetProductAmount(productSO);
			TextMeshProUGUI textTitle = __instance.textTitle;
			((TMP_Text)textTitle).text = ((TMP_Text)textTitle).text + $" <color=yellow>[{productAmount}]</color>";
		}

		public static int GetProductAmount(ProductSO product)
		{
			return (from x in Object.FindObjectsOfType<Item>()
				where x.itemSO is ProductSO && x.itemSO.itemName == ((ItemSO)product).itemName
				select x).Sum((Item item) => item.amount.Value);
		}
	}
	[HarmonyPatch(typeof(PlayerInventory))]
	public class PlayerInventoryPatch
	{
		private const float angleToRotate = 45f;

		private static readonly List<string> AllowPlacementAnywhere = new List<string>(7) { "floor_sign", "wall_sign", "big_fence", "chandelier", "lantern", "small_fence", "wall_candle" };

		[HarmonyPatch("HandleNewBlockPlacement")]
		[HarmonyPrefix]
		private static bool HandleNewBlockPlacementPatch(PlayerInventory __instance)
		{
			HandleNewBlockPlacement(__instance);
			return false;
		}

		private static void HandleNewBlockPlacement(PlayerInventory __instance)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_0553: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			PlayerActions player = InputManager.Instance.inputMaster.Player;
			if (((PlayerActions)(ref player)).Place.IsPressed() || (Object)(object)__instance.itemBlueprint != (Object)null)
			{
				return;
			}
			InventorySlot currentInventorySlot = __instance.GetCurrentInventorySlot();
			if (currentInventorySlot.itemId == -1)
			{
				return;
			}
			ItemSO itemById = GameManager.Instance.GetItemById(currentInventorySlot.itemId);
			BlockSO val = (BlockSO)(object)((itemById is BlockSO) ? itemById : null);
			if ((Object)(object)val == (Object)null || val == null)
			{
				return;
			}
			bool flag = AllowPlacementAnywhere.Contains(((ItemSO)val).itemName);
			Ray val2 = __instance.playerCamera.ViewportPointToRay(Vector3.one / 2f);
			LayerMask val3 = LayerMask.op_Implicit(~LayerMask.op_Implicit(__instance.blockIgnoredLayerMask));
			LayerMask val4 = LayerMask.op_Implicit(-1 & LayerMask.op_Implicit(val3));
			QueryTriggerInteraction val5 = (QueryTriggerInteraction)1;
			int num = 1;
			if (((ItemSO)val).prefab.CompareTag("Boat") || ((ItemSO)val).prefab.CompareTag("Floatable"))
			{
				val5 = (QueryTriggerInteraction)2;
				num = 2;
			}
			RaycastHit val6 = default(RaycastHit);
			if (Physics.Raycast(val2, ref val6, __instance.buildDistance * (float)num, flag ? (-1) : LayerMask.op_Implicit(val4), val5))
			{
				if (!flag && !LayerMaskExtensions.Includes(val.placementLayerMask, ((Component)((RaycastHit)(ref val6)).collider).gameObject.layer))
				{
					__instance.DestroyBlockBlueprint();
					return;
				}
				if ((Object)(object)__instance.blockBlueprint == (Object)null)
				{
					Quaternion rotation = ((RaycastHit)(ref val6)).transform.rotation;
					string text = LayerMask.LayerToName(((Component)((RaycastHit)(ref val6)).collider).gameObject.layer);
					if (text == "Water" || text == "Terrain")
					{
						((Quaternion)(ref rotation)).eulerAngles = new Vector3(((Quaternion)(ref rotation)).eulerAngles.x, ((Quaternion)(ref rotation)).eulerAngles.y - 28.85f, ((Quaternion)(ref rotation)).eulerAngles.z);
					}
					__instance.blockBlueprint = Object.Instantiate<GameObject>(((ItemSO)val).prefab, ((RaycastHit)(ref val6)).point, rotation);
					__instance.blockBlueprintHit = ((RaycastHit)(ref val6)).transform;
					Collider[] componentsInChildren = __instance.blockBlueprint.GetComponentsInChildren<Collider>();
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						componentsInChildren[i].enabled = false;
					}
					__instance.blockBlueprint.GetComponent<NetworkObject>().AutoObjectParentSync = false;
					__instance.blueprintTrigger = null;
					__instance.blueprintTrigger = __instance.blockBlueprint.GetComponent<Block>().blueprintTrigger;
					((Component)__instance.blueprintTrigger).gameObject.layer = LayerMask.NameToLayer("IgnoreBlockCollision");
					ObstacleColliderVisualizer val7 = default(ObstacleColliderVisualizer);
					if (((Component)__instance.blueprintTrigger).TryGetComponent<ObstacleColliderVisualizer>(ref val7))
					{
						((Behaviour)val7).enabled = true;
					}
					if ((Object)(object)__instance.blueprintTrigger != (Object)null)
					{
						((Collider)__instance.blueprintTrigger).enabled = true;
					}
					__instance.meshRenderersBlockBlueprint = __instance.blockBlueprint.GetComponentsInChildren<MeshRenderer>().ToList();
					__instance.ShowObstacleVisualizers(true);
					return;
				}
				__instance.blockBlueprint.transform.position = ((RaycastHit)(ref val6)).point;
				if ((Object)(object)__instance.blockBlueprintHit != (Object)(object)((RaycastHit)(ref val6)).transform)
				{
					__instance.blockBlueprintHit = ((RaycastHit)(ref val6)).transform;
					string text2 = LayerMask.LayerToName(((Component)((RaycastHit)(ref val6)).collider).gameObject.layer);
					Quaternion rotation2 = ((RaycastHit)(ref val6)).transform.rotation;
					if (text2 == "Water" || text2 == "Terrain")
					{
						((Quaternion)(ref rotation2)).eulerAngles = new Vector3(((Quaternion)(ref rotation2)).eulerAngles.x, ((Quaternion)(ref rotation2)).eulerAngles.y - 28.85f, ((Quaternion)(ref rotation2)).eulerAngles.z);
					}
					__instance.blockBlueprint.transform.rotation = rotation2;
				}
				player = InputManager.Instance.inputMaster.Player;
				if (((PlayerActions)(ref player)).Rotate.WasPerformedThisFrame() && !val.disableRotation)
				{
					LeanTweenExt.LeanRotateAroundLocal(__instance.blockBlueprint, Vector3.up, 45f, 0.1f);
				}
				bool flag2 = true;
				if ((Object)(object)__instance.blueprintTrigger == (Object)null)
				{
					Debug.LogError((object)"Block needs a blueprint collider!");
				}
				else
				{
					Vector3 val8 = Vector3.Scale(__instance.blueprintTrigger.size, ((Component)__instance.blueprintTrigger).transform.lossyScale) / 2f;
					Bounds bounds = ((Collider)__instance.blueprintTrigger).bounds;
					flag2 = Physics.CheckBox(((Bounds)(ref bounds)).center, val8, ((Component)__instance.blueprintTrigger).transform.rotation, LayerMask.op_Implicit(val4), (QueryTriggerInteraction)2);
				}
				if (flag2)
				{
					foreach (MeshRenderer item in __instance.meshRenderersBlockBlueprint)
					{
						int num2 = ((Renderer)item).sharedMaterials.Length;
						Material[] array = (Material[])(object)new Material[num2];
						for (int j = 0; j < num2; j++)
						{
							array[j] = __instance.materialBlueprintInvalid;
						}
						((Renderer)item).materials = array;
					}
					return;
				}
				foreach (MeshRenderer item2 in __instance.meshRenderersBlockBlueprint)
				{
					int num3 = ((Renderer)item2).sharedMaterials.Length;
					Material[] array2 = (Material[])(object)new Material[num3];
					for (int k = 0; k < num3; k++)
					{
						array2[k] = __instance.materialBlueprintValid;
					}
					((Renderer)item2).materials = array2;
				}
				player = InputManager.Instance.inputMaster.Player;
				if (((PlayerActions)(ref player)).Put.WasPerformedThisFrame())
				{
					__instance.audioSource.PlayOneShot(__instance.placementSound, 0.2f);
					__instance.PlaceBlockServerRpc(((ItemSO)val).id, __instance.blockBlueprint.transform.position, __instance.blockBlueprint.transform.rotation, currentInventorySlot.dayCounter);
					__instance.UseItem();
					__instance.DestroyBlockBlueprint();
				}
			}
			else
			{
				__instance.DestroyBlockBlueprint();
			}
		}

		[HarmonyPatch("HandleItemPlacement")]
		[HarmonyPrefix]
		private static bool HandleItemPlacementPatch(PlayerInventory __instance)
		{
			HandleItemPlacement(__instance);
			return false;
		}

		private static void HandleItemPlacement(PlayerInventory __instance)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: 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_008c: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
			PlayerActions player = InputManager.Instance.inputMaster.Player;
			if (((PlayerActions)(ref player)).Place.WasPerformedThisFrame())
			{
				ItemSO itemById = GameManager.Instance.GetItemById(__instance.GetCurrentInventorySlot().itemId);
				if ((Object)(object)itemById != (Object)null && itemById is ProductSO && (Object)(object)__instance.cameraHolder != (Object)null)
				{
					__instance.cameraHolder.SetActive(false);
					__instance.DestroyBlockBlueprint();
				}
			}
			player = InputManager.Instance.inputMaster.Player;
			if (((PlayerActions)(ref player)).Place.IsPressed())
			{
				InventorySlot currentInventorySlot = __instance.GetCurrentInventorySlot();
				if (currentInventorySlot.itemId == -1)
				{
					return;
				}
				ItemSO itemById2 = GameManager.Instance.GetItemById(__instance.GetCurrentInventorySlot().itemId);
				if (!(itemById2 is ProductSO))
				{
					return;
				}
				if ((Object)(object)__instance.blockBlueprint != (Object)null)
				{
					__instance.DestroyBlockBlueprint();
				}
				RaycastHit val = default(RaycastHit);
				if (Physics.Raycast(__instance.playerCamera.ViewportPointToRay(Vector3.one / 2f), ref val, __instance.buildDistance, LayerMask.op_Implicit(__instance.itemPlacementLayerMask), (QueryTriggerInteraction)1))
				{
					if ((Object)(object)__instance.itemBlueprint == (Object)null)
					{
						((Component)__instance.localToolHolder).gameObject.SetActive(false);
						if (itemById2 is BlockSO)
						{
							__instance.itemBlueprint = Object.Instantiate<GameObject>(GameManager.Instance.blockBox);
						}
						else
						{
							__instance.itemBlueprint = Object.Instantiate<GameObject>(itemById2.prefab, ((RaycastHit)(ref val)).point, ((RaycastHit)(ref val)).transform.rotation);
							__instance.itemBlueprintHit = ((RaycastHit)(ref val)).transform;
							ItemCrate component = __instance.itemBlueprint.GetComponent<ItemCrate>();
							if ((Object)(object)component != (Object)null)
							{
								component.EnableDummyItems(currentInventorySlot.amount);
							}
						}
						__instance.itemCollider = null;
						__instance.itemCollider = __instance.itemBlueprint.GetComponentInChildren<BoxCollider>();
						((Collider)__instance.itemCollider).isTrigger = true;
						__instance.meshRenderersItemBlueprint = __instance.itemBlueprint.GetComponentsInChildren<MeshRenderer>().ToList();
					}
					else
					{
						__instance.itemBlueprint.transform.position = ((RaycastHit)(ref val)).point;
						if ((Object)(object)__instance.itemBlueprintHit != (Object)(object)((RaycastHit)(ref val)).transform)
						{
							__instance.itemBlueprintHit = ((RaycastHit)(ref val)).transform;
							__instance.itemBlueprint.transform.rotation = ((RaycastHit)(ref val)).transform.rotation;
						}
						player = InputManager.Instance.inputMaster.Player;
						if (((PlayerActions)(ref player)).Rotate.WasPerformedThisFrame())
						{
							LeanTweenExt.LeanRotateAroundLocal(__instance.itemBlueprint, Vector3.up, 45f, 0.1f);
						}
						if (((Component)((RaycastHit)(ref val)).collider).tag == "Terrain")
						{
							__instance.itemBlueprint.transform.rotation = Quaternion.Lerp(__instance.itemBlueprint.transform.rotation, Quaternion.FromToRotation(Vector3.up, ((RaycastHit)(ref val)).normal), 0.5f);
						}
						bool flag = true;
						if ((Object)(object)__instance.itemCollider == (Object)null)
						{
							Debug.LogError((object)"Item needs a collider!");
						}
						else
						{
							Vector3 val2 = Vector3.Scale(__instance.itemCollider.size, __instance.itemBlueprint.transform.lossyScale) / 2f;
							Bounds bounds = ((Collider)__instance.itemCollider).bounds;
							flag = Physics.CheckBox(((Bounds)(ref bounds)).center, val2, __instance.itemBlueprint.transform.rotation, LayerMask.op_Implicit(__instance.itemObstacleLayerMask), (QueryTriggerInteraction)1);
						}
						if (!flag)
						{
							ProductSO val3 = (ProductSO)(object)((itemById2 is ProductSO) ? itemById2 : null);
							if (val3 == null || LayerMaskExtensions.Includes(val3.placementLayerMask, ((Component)((RaycastHit)(ref val)).collider).gameObject.layer))
							{
								foreach (MeshRenderer item in __instance.meshRenderersItemBlueprint)
								{
									int num = ((Renderer)item).sharedMaterials.Length;
									Material[] array = (Material[])(object)new Material[num];
									for (int i = 0; i < num; i++)
									{
										array[i] = __instance.materialBlueprintValid;
									}
									((Renderer)item).materials = array;
								}
								player = InputManager.Instance.inputMaster.Player;
								if (((PlayerActions)(ref player)).Put.WasPerformedThisFrame())
								{
									Block componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Block>();
									if ((Object)(object)componentInParent != (Object)null && componentInParent.blockSO.isStand && itemById2 is ProductSO)
									{
										Vector3 position = __instance.itemBlueprint.transform.position;
										Quaternion rotation = __instance.itemBlueprint.transform.rotation;
										Quaternion rotation2 = ((Component)componentInParent).transform.rotation;
										__instance.PlaceItemOnStandServerRpc(currentInventorySlot, position, rotation, ((Quaternion)(ref rotation2)).eulerAngles.y);
									}
									else
									{
										__instance.PlaceItemOnContainerServerRpc(currentInventorySlot, __instance.itemBlueprint.transform.position, __instance.itemBlueprint.transform.rotation);
									}
									__instance.audioSource.PlayOneShot(__instance.placementSound, 0.2f);
									__instance.UseItem();
									__instance.DestroyItemBlueprint();
								}
								goto IL_0526;
							}
						}
						foreach (MeshRenderer item2 in __instance.meshRenderersItemBlueprint)
						{
							int num2 = ((Renderer)item2).sharedMaterials.Length;
							Material[] array2 = (Material[])(object)new Material[num2];
							for (int j = 0; j < num2; j++)
							{
								array2[j] = __instance.materialBlueprintInvalid;
							}
							((Renderer)item2).materials = array2;
						}
					}
				}
				else
				{
					__instance.DestroyItemBlueprint();
				}
			}
			goto IL_0526;
			IL_0526:
			player = InputManager.Instance.inputMaster.Player;
			if (((PlayerActions)(ref player)).Place.WasReleasedThisFrame())
			{
				if ((Object)(object)__instance.cameraHolder != (Object)null)
				{
					__instance.cameraHolder.SetActive(true);
				}
				__instance.DestroyItemBlueprint();
				((Component)__instance.localToolHolder).gameObject.SetActive(true);
			}
		}

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePatch(PlayerInventory __instance)
		{
			//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_0027: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			InputActionMap val = new InputActionMap();
			InputActionSetupExtensions.AddAction(val, "slot0", (InputActionType)1, "<Keyboard>/1", (string)null, (string)null, (string)null, (string)null);
			InputActionSetupExtensions.AddAction(val, "slot1", (InputActionType)1, "<Keyboard>/2", (string)null, (string)null, (string)null, (string)null);
			InputActionSetupExtensions.AddAction(val, "slot2", (InputActionType)1, "<Keyboard>/3", (string)null, (string)null, (string)null, (string)null);
			InputActionSetupExtensions.AddAction(val, "slot3", (InputActionType)1, "<Keyboard>/4", (string)null, (string)null, (string)null, (string)null);
			InputActionSetupExtensions.AddAction(val, "slot4", (InputActionType)1, "<Keyboard>/5", (string)null, (string)null, (string)null, (string)null);
			InputActionSetupExtensions.AddAction(val, "slot5", (InputActionType)1, "<Keyboard>/6", (string)null, (string)null, (string)null, (string)null);
			InputActionSetupExtensions.AddAction(val, "slot6", (InputActionType)1, "<Keyboard>/7", (string)null, (string)null, (string)null, (string)null);
			InputActionSetupExtensions.AddAction(val, "slot7", (InputActionType)1, "<Keyboard>/8", (string)null, (string)null, (string)null, (string)null);
			val.actionTriggered += delegate(CallbackContext context)
			{
				if (((CallbackContext)(ref context)).performed)
				{
					int num = int.Parse(((CallbackContext)(ref context)).action.name.Replace("slot", ""));
					if (num < __instance.activeSlots)
					{
						__instance.currentSlot.Value = num;
					}
				}
			};
			val.Enable();
		}
	}
	[HarmonyPatch(typeof(RecipeTile))]
	public class RecipeTilePatch
	{
		[HarmonyPatch("UpdateSlot")]
		[HarmonyPostfix]
		private static void UpdateSlotPatch(RecipeTile __instance, RecipeSO recipeSO)
		{
			if (recipeSO.requiredDays > 0)
			{
				string text = string.Format("{0} {1}", recipeSO.requiredDays, (recipeSO.requiredDays == 1) ? "day" : "days");
				Text textOutputName = __instance.textOutputName;
				textOutputName.text = textOutputName.text + "\n<color=yellow>" + text + "</color>";
			}
		}
	}
	[HarmonyPatch(typeof(UIManager))]
	public class UIManagerPatch
	{
		[HarmonyPatch("SetCoinTooltip")]
		[HarmonyPostfix]
		private static void SetCoinTooltipPatch(UIManager __instance)
		{
			//IL_005f: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			int num = 0;
			foreach (long activeEmployee in GameManager.Instance.GetActiveEmployees())
			{
				EmployeeSO employeeById = GameManager.Instance.GetEmployeeById(activeEmployee);
				num += employeeById.price;
			}
			string localizedString = LocalizationSettings.StringDatabase.GetLocalizedString(TableReference.op_Implicit("Translations"), TableEntryReference.op_Implicit("employees"), (Locale)null, (FallbackBehavior)0, Array.Empty<object>());
			text += $"\n<color=#8A5125>{localizedString}</color>\n-{num} C";
			EventSO currentEvent = GameManager.Instance.GetCurrentEvent();
			float num2 = 1f;
			if ((Object)(object)currentEvent != (Object)null)
			{
				num2 = currentEvent.taxMultiplier;
			}
			string localizedString2 = LocalizationSettings.StringDatabase.GetLocalizedString(TableReference.op_Implicit("Translations"), TableEntryReference.op_Implicit("tax_rate"), (Locale)null, (FallbackBehavior)0, Array.Empty<object>());
			int num3 = Mathf.RoundToInt((float)GameManager.Instance.initialTaxPercentage * num2);
			text += $"\n<color=#8A5125>{localizedString2}</color>\n{num3}%";
			int rent = GameManager.Instance.GetRent();
			int maintenanceValue = GameManager.Instance.GetMaintenanceValue();
			int num4 = 0;
			foreach (Transaction dailyTransaction in GameManager.Instance.dailyTransactions)
			{
				num4 += dailyTransaction.Amount;
			}
			num4 = GameManager.Instance.CalculateTax(num4);
			int num5 = rent + maintenanceValue + num4;
			text += $"\n<color=#8A5125>TAXED SALES</color>\n-{num4} C";
			text += $"\n<color=#8A5125>TOTAL EXPENSES</color>\n-{num5} C";
			TooltipTrigger tooltipTriggerCoins = __instance.tooltipTriggerCoins;
			tooltipTriggerCoins.content += text;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}