Decompiled source of Odds And Ends v0.3.2

OddsAndEnds.dll

Decompiled 8 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using HarmonyLib;
using OddsAndEndsTrue;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
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: AssemblyTitle("OddsAndEnds")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OddsAndEnds")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c6ff218e-780c-48ad-be27-6f6a178b97dd")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("1.0.0.0")]
public class CharacterSettingUI : UI_GamemodeSetting
{
	public void Initialize(GamemodeSetting setting, UI_GamemodeScreen_Panel gp)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		setting.color = Color.yellow;
		((UI_GamemodeSetting)this).Initialize(setting, gp);
		if ((Object)(object)base.toggle != (Object)null)
		{
			((UnityEventBase)base.toggle.onValueChanged).RemoveAllListeners();
			((UnityEvent<bool>)(object)base.toggle.onValueChanged).AddListener((UnityAction<bool>)OnToggleChanged);
		}
	}

	private void OnToggleChanged(bool b)
	{
		if (!b)
		{
			bool flag = false;
			CharacterSettingUI[] componentsInChildren = ((Component)((Component)this).transform.parent).GetComponentsInChildren<CharacterSettingUI>();
			CharacterSettingUI[] array = componentsInChildren;
			foreach (CharacterSettingUI characterSettingUI in array)
			{
				if ((Object)(object)characterSettingUI != (Object)(object)this && (Object)(object)((UI_GamemodeSetting)characterSettingUI).toggle != (Object)null && ((UI_GamemodeSetting)characterSettingUI).toggle.isOn)
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				base.toggle.SetIsOnWithoutNotify(true);
				return;
			}
		}
		((UI_GamemodeSetting)this).ToggleSetting(b);
		if (!b)
		{
			return;
		}
		CharacterSettingUI[] componentsInChildren2 = ((Component)((Component)this).transform.parent).GetComponentsInChildren<CharacterSettingUI>();
		CharacterSettingUI[] array2 = componentsInChildren2;
		foreach (CharacterSettingUI characterSettingUI2 in array2)
		{
			if ((Object)(object)characterSettingUI2 != (Object)(object)this && (Object)(object)((UI_GamemodeSetting)characterSettingUI2).toggle != (Object)null && ((UI_GamemodeSetting)characterSettingUI2).toggle.isOn)
			{
				((UI_GamemodeSetting)characterSettingUI2).toggle.isOn = false;
			}
		}
	}
}
[HarmonyPatch(typeof(UI_GamemodeSetting), "Initialize")]
public static class UI_GamemodeSetting_Initialize_Patch
{
	public static void Postfix(UI_GamemodeSetting __instance, GamemodeSetting setting, UI_GamemodeScreen_Panel gp)
	{
		if (__instance is CharacterSettingUI || (Object)(object)((Component)__instance).transform.parent == (Object)null)
		{
			return;
		}
		CharacterSettingUI[] componentsInChildren = ((Component)((Component)__instance).transform.parent).GetComponentsInChildren<CharacterSettingUI>(true);
		if (componentsInChildren == null || componentsInChildren.Length == 0)
		{
			string gamemodeName = gp.GetGamemode().gamemodeName;
			bool flag = gp.GetGamemode().HasActiveSetting("Climber");
			bool flag2 = gp.GetGamemode().HasActiveSetting("Student");
			if (gp.GetGamemode().HasActiveSetting("Stoner"))
			{
				StatManager.saveData.SetSetting(gamemodeName, "Stoner", false);
			}
			if (!flag && !flag2)
			{
				StatManager.saveData.SetSetting(gamemodeName, "Climber", true);
				StatManager.saveData.SetSetting(gamemodeName, "Student", false);
			}
			CreateCharacterUI(__instance, "Climber", "Climber", "Play as the Climber.", gp);
			CreateCharacterUI(__instance, "Student", "Student", "COMBINE COMBINE COMBINE", gp);
		}
	}

	private static void CreateCharacterUI(UI_GamemodeSetting template, string id, string title, string description, UI_GamemodeScreen_Panel gp)
	{
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Expected O, but got Unknown
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, ((Component)template).transform.parent);
		UI_GamemodeSetting component = val.GetComponent<UI_GamemodeSetting>();
		CharacterSettingUI characterSettingUI = val.AddComponent<CharacterSettingUI>();
		((UI_GamemodeSetting)characterSettingUI).toggle = component.toggle;
		((UI_GamemodeSetting)characterSettingUI).lockObject = component.lockObject;
		((UI_GamemodeSetting)characterSettingUI).titleText = component.titleText;
		((UI_GamemodeSetting)characterSettingUI).descriptionText = component.descriptionText;
		((UI_GamemodeSetting)characterSettingUI).unlockHint = component.unlockHint;
		((UI_GamemodeSetting)characterSettingUI).outline = component.outline;
		((UI_GamemodeSetting)characterSettingUI).unselectedHeight = component.unselectedHeight;
		((UI_GamemodeSetting)characterSettingUI).selectedHeight = component.selectedHeight;
		((UI_GamemodeSetting)characterSettingUI).onActivated = component.onActivated;
		((UI_GamemodeSetting)characterSettingUI).onDeactivated = component.onDeactivated;
		Object.DestroyImmediate((Object)(object)component);
		GamemodeSetting val2 = new GamemodeSetting();
		val2.id = id;
		val2.title = title;
		val2.description = description;
		val2.color = Color.yellow;
		if ((Object)(object)template.gamemodeSetting != (Object)null)
		{
			val2.unlock = template.gamemodeSetting.unlock;
			val2.exclusiveSettings = template.gamemodeSetting.exclusiveSettings;
		}
		characterSettingUI.Initialize(val2, gp);
	}
}
public static class AwakenedAmalgamator
{
	public sealed class CombinationRecipe
	{
		public string Id;

		public string[] Inputs;

		public string[] Outputs;

		public string[] ReservedInputs;

		public Action<Vector3> CreateFunction;

		public int InputCount;

		public int RegistrationOrder;

		public int Priority;

		public string[] PreservedInputs;

		public Func<List<GameEntity>, Vector3, GameEntity> SpecialCreate;
	}

	public sealed class CraftMatchCache
	{
		public List<GameEntity> Held;

		public CombinationRecipe Recipe;

		public List<GameEntity> Matched;

		public Func<List<GameEntity>, Vector3, GameEntity> CombineFunction;

		public Func<List<GameEntity>, Vector3, GameEntity> SpecialCreate;
	}

	private sealed class CombinableItemType
	{
		public Type HandItemType;

		public Func<List<GameEntity>, Vector3, GameEntity> CombineFunction;
	}

	private sealed class CollisionPair
	{
		public Collider Prop;

		public Collider Player;
	}

	[HarmonyPatch(typeof(Item_Object), "OnHover")]
	private static class CraftingItemHoverDescriptionPatch
	{
		private static void Postfix(Item_Object __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && __instance.itemData != null && !((Object)(object)CL_UIManager.instance == (Object)null))
			{
				string text = GetModificationDescription(__instance.itemData) ?? GetCraftingItemDescription(__instance.itemData.prefabName);
				if (!string.IsNullOrEmpty(text))
				{
					CL_UIManager.instance.SetDescription(text);
				}
			}
		}
	}

	[HarmonyPatch(typeof(HandItem_Buff), "Activate")]
	private static class AmalgamatedBuffDurationPatch
	{
		private static void Postfix(HandItem_Buff __instance)
		{
			if ((Object)(object)__instance == (Object)null || ((HandItem)__instance).item == null)
			{
				return;
			}
			if (((HandItem)__instance).item.prefabName == CombinedBuffItemId && ((HandItem)__instance).item.data != null)
			{
				List<BuffContainer> list = new List<BuffContainer>();
				if (__instance.buff != null)
				{
					list.Add(__instance.buff);
				}
				if (__instance.secondaryBuffs != null)
				{
					list.AddRange(__instance.secondaryBuffs);
				}
				foreach (string datum in ((HandItem)__instance).item.data)
				{
					if (datum == null || !datum.StartsWith("AwakenedBuffDuration=", StringComparison.Ordinal))
					{
						continue;
					}
					int num = datum.IndexOf('=', "AwakenedBuffDuration=".Length);
					if (num < 0 || !float.TryParse(datum.Substring(num + 1), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
					{
						continue;
					}
					string text = datum.Substring("AwakenedBuffDuration=".Length, num - "AwakenedBuffDuration=".Length);
					foreach (BuffContainer item in list)
					{
						if (item != null && item.id == text)
						{
							SetAppliedBuffTime(item, result);
							break;
						}
					}
				}
			}
			ApplyInfusedBuffDuration(__instance, __instance.buff, __instance.secondaryBuffs);
		}
	}

	[HarmonyPatch(typeof(HandItem_Food), "Eat")]
	private static class InfusedFoodBuffDurationPatch
	{
		private static void Prefix(HandItem_Food __instance, ref float __state)
		{
			__state = float.NaN;
			ENT_Player player = (((Object)(object)__instance == (Object)null || ((Hand_Base)__instance).hand == null) ? null : ((Hand_Base)__instance).hand.GetPlayer());
			if (HasStudentPerk(player))
			{
				__state = __instance.gripAmountAdded;
				__instance.gripAmountAdded = 0f;
			}
		}

		private static void Postfix(HandItem_Food __instance, float __state)
		{
			if ((Object)(object)__instance != (Object)null && !float.IsNaN(__state))
			{
				__instance.gripAmountAdded = __state;
			}
			ApplyInfusedFoodDuration(__instance);
		}

		private static Exception Finalizer(HandItem_Food __instance, float __state, Exception __exception)
		{
			if ((Object)(object)__instance != (Object)null && !float.IsNaN(__state))
			{
				__instance.gripAmountAdded = __state;
			}
			return __exception;
		}
	}

	[HarmonyPatch(typeof(HandItem), "Initialize")]
	private static class InfusedHandItemPatch
	{
		private static void Postfix(HandItem __instance, Item i, Hand h)
		{
			if ((Object)(object)__instance == (Object)null || i == null || i.data == null)
			{
				return;
			}
			float result = 1f;
			float.TryParse(GetCustomData(i, "AwakenedBuffValueMultiplier"), NumberStyles.Float, CultureInfo.InvariantCulture, out result);
			if (result > 1f && GetCustomData(i, "AwakenedBuffValueApplied") != "1")
			{
				HandItem_Buff val = (HandItem_Buff)(object)((__instance is HandItem_Buff) ? __instance : null);
				if (val != null)
				{
					ScaleBuffValues(val.buff, result);
					if (val.useSecondaryBuffs && val.secondaryBuffs != null)
					{
						foreach (BuffContainer secondaryBuff in val.secondaryBuffs)
						{
							ScaleBuffValues(secondaryBuff, result);
						}
					}
				}
				else
				{
					HandItem_Food val2 = (HandItem_Food)(object)((__instance is HandItem_Food) ? __instance : null);
					if (val2 != null && val2.useBuff)
					{
						ScaleBuffValues(val2.buff, result);
					}
				}
				SetCustomData(i, "AwakenedBuffValueApplied", "1");
			}
			int num = ParseDataInt(i, "AwakenedReachBonus");
			if (num > 0)
			{
				HandItem_Shoot_Grapple val3 = (HandItem_Shoot_Grapple)(object)((__instance is HandItem_Shoot_Grapple) ? __instance : null);
				if (val3 != null)
				{
					val3.maxProjectileRange += (float)num;
					goto IL_0193;
				}
			}
			if (num > 0)
			{
				HandItem_GrapplingHook val4 = (HandItem_GrapplingHook)(object)((__instance is HandItem_GrapplingHook) ? __instance : null);
				if (val4 != null)
				{
					val4.grappleDistance += (float)num;
				}
			}
			goto IL_0193;
			IL_0193:
			float num2 = ParseCustomFloat(i, "AwakenedRangeMultiplier");
			if (num2 > 1f)
			{
				HandItem_Shoot_Grapple val5 = (HandItem_Shoot_Grapple)(object)((__instance is HandItem_Shoot_Grapple) ? __instance : null);
				if (val5 != null)
				{
					val5.maxProjectileRange *= num2;
				}
				else
				{
					HandItem_BlinkEye val6 = (HandItem_BlinkEye)(object)((__instance is HandItem_BlinkEye) ? __instance : null);
					if (val6 != null)
					{
						val6.blinkDistance *= num2;
					}
				}
			}
			float num3 = ParseCustomFloat(i, "AwakenedDashMultiplier");
			if (num3 > 1f)
			{
				HandItem_Melee_Rapier val7 = (HandItem_Melee_Rapier)(object)((__instance is HandItem_Melee_Rapier) ? __instance : null);
				if (val7 != null)
				{
					val7.dashForce *= num3;
				}
			}
			HandItem_Melee_Rapier val8 = (HandItem_Melee_Rapier)(object)((__instance is HandItem_Melee_Rapier) ? __instance : null);
			if (val8 != null && SoulPatchData.HasFlag(i, "AwakenedDashCooldown"))
			{
				val8.strainOnCharge = 0f;
			}
			float num4 = ParseCustomFloat(i, "AwakenedRecoilMultiplier");
			if (num4 > 1f)
			{
				HandItem_Shoot val9 = (HandItem_Shoot)(object)((__instance is HandItem_Shoot) ? __instance : null);
				if (val9 != null && GetCustomData(i, "AwakenedRecoilApplied") != "1")
				{
					val9.recoil *= num4;
					SetCustomData(i, "AwakenedRecoilApplied", "1");
				}
			}
			float num5 = ParseCustomFloat(i, "AwakenedPowerRecoilMultiplier");
			if (num5 > 1f)
			{
				HandItem_Shoot val10 = (HandItem_Shoot)(object)((__instance is HandItem_Shoot) ? __instance : null);
				if (val10 != null && GetCustomData(i, "AwakenedPowerRecoilApplied") != "1")
				{
					val10.recoil *= num5;
					SetCustomData(i, "AwakenedPowerRecoilApplied", "1");
				}
			}
			float num6 = ParseCustomFloat(i, "AwakenedAutoReload");
			if (!(num6 > 0f))
			{
				return;
			}
			HandItem_Shoot val11 = (HandItem_Shoot)(object)((__instance is HandItem_Shoot) ? __instance : null);
			if (val11 == null)
			{
				return;
			}
			if (((HandItem)val11).item.prefabName == "Item_Handgun" || ((HandItem)val11).item.prefabName == "Item_Cryogun")
			{
				val11.maxAmmo = Mathf.Max(1, val11.maxAmmo / 2);
				if (val11.fillAmountPerAmmo > 0)
				{
					val11.fillAmountPerAmmo = Mathf.Max(1, val11.fillAmountPerAmmo / 2);
				}
			}
			AutoReloadHandItem autoReloadHandItem = ((Component)__instance).GetComponent<AutoReloadHandItem>();
			if ((Object)(object)autoReloadHandItem == (Object)null)
			{
				autoReloadHandItem = ((Component)__instance).gameObject.AddComponent<AutoReloadHandItem>();
			}
			autoReloadHandItem.Shoot = val11;
			autoReloadHandItem.Interval = num6;
		}
	}

	[HarmonyPatch(typeof(HandItem_Shoot), "Initialize")]
	private static class InfusedShootItemPatch
	{
		private static void Postfix(HandItem_Shoot __instance)
		{
			if ((Object)(object)__instance == (Object)null || ((HandItem)__instance).item == null)
			{
				return;
			}
			int num = ParseDataInt(((HandItem)__instance).item, "AwakenedAmmoTier");
			int num2 = ParseDataInt(((HandItem)__instance).item, "AwakenedAmmoCapacity");
			if (num2 > 0)
			{
				__instance.useAmmo = true;
				__instance.canReload = false;
				__instance.destroyItemAfterShoot = false;
				__instance.dropOnlyItemAfterShoot = false;
				__instance.maxAmmo = num2;
				int num3 = num2;
				string firstDataStringByType = ((HandItem)__instance).item.GetFirstDataStringByType("ammo", false);
				if (!string.IsNullOrEmpty(firstDataStringByType) && int.TryParse(firstDataStringByType, out var result))
				{
					num3 = Mathf.Clamp(result, 0, num2);
				}
				ShootAmmoField?.SetValue(__instance, num3);
				((HandItem)__instance).item.SetFirstDataStringsofType("ammo", num3.ToString(CultureInfo.InvariantCulture));
			}
			else
			{
				if (num <= 0)
				{
					return;
				}
				if (num >= 2)
				{
					__instance.maxAmmo *= num;
					if (__instance.fillAmountPerAmmo > 0)
					{
						__instance.fillAmountPerAmmo *= num;
					}
				}
				if (num == 1)
				{
					int maxAmmo = __instance.GetMaxAmmo();
					ShootAmmoField?.SetValue(__instance, maxAmmo);
					((HandItem)__instance).item.SetFirstDataStringsofType("ammo", maxAmmo.ToString(CultureInfo.InvariantCulture));
				}
			}
		}
	}

	[HarmonyPatch(typeof(UT_DamageTrigger), "Damage")]
	private static class RatKingSpawnDamagePatch
	{
		[HarmonyPrefix]
		private static bool PreventSpawnDamage(UT_DamageTrigger __instance)
		{
			AmalgamatorRatKingSpawnGrace componentInParent = ((Component)__instance).GetComponentInParent<AmalgamatorRatKingSpawnGrace>();
			return (Object)(object)componentInParent == (Object)null || Time.time >= componentInParent.DamageEnabledAt;
		}
	}

	[HarmonyPatch(typeof(M_Gamemode), "Initialize")]
	private static class GamemodeInitializePatch
	{
		private static void Prefix()
		{
			RegisterAllRecipes();
			EnsureAssets();
			StudentPerks.EnsureRegistered();
		}
	}

	[HarmonyPatch(typeof(Item), "InitializeItemData")]
	private static class RuntimeItemDataPatch
	{
		private static void Postfix(Item __instance)
		{
			RestoreRuntimeItemReferences(__instance);
			PrepareCraftedVariant(__instance);
		}
	}

	[HarmonyPatch(typeof(Item), "InitializeInHand")]
	private static class RuntimeItemHandPatch
	{
		private static void Prefix(Item __instance)
		{
			RestoreRuntimeItemReferences(__instance);
			PrepareCraftedVariant(__instance);
			__instance?.data?.RemoveAll((string value) => value != null && (value.StartsWith("AwakenedBuffValueApplied=", StringComparison.Ordinal) || value.StartsWith("AwakenedRecoilApplied=", StringComparison.Ordinal) || value.StartsWith("AwakenedPowerRecoilApplied=", StringComparison.Ordinal)));
		}

		private static void Postfix(Item __instance, Hand h)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (__instance == null || h == null || h.id != 0 || (__instance.prefabName != "Item_Injector" && __instance.prefabName != CombinedBuffItemId))
			{
				return;
			}
			HandItem handItem = __instance.GetHandItem();
			if (!((Object)(object)handItem == (Object)null))
			{
				Vector3 localScale = ((Component)handItem).transform.localScale;
				localScale.x = Mathf.Abs(localScale.x);
				((Component)handItem).transform.localScale = localScale;
				InjectorLeftHandAnimationFix injectorLeftHandAnimationFix = ((Component)handItem).GetComponent<InjectorLeftHandAnimationFix>();
				if ((Object)(object)injectorLeftHandAnimationFix == (Object)null)
				{
					injectorLeftHandAnimationFix = ((Component)handItem).gameObject.AddComponent<InjectorLeftHandAnimationFix>();
				}
				injectorLeftHandAnimationFix.HandItem = handItem;
			}
		}
	}

	[HarmonyPatch(typeof(Inventory), "IsShowingInventory")]
	private static class AwakenedCraftingInventoryPatch
	{
		private static bool Prefix(ref bool __result)
		{
			if (!allowAwakenedCraftingWithInventoryOpen)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}

	[HarmonyPatch(typeof(M_Gamemode), "StartFreshGamemode")]
	private static class StartFreshGamemodePatch
	{
		private static void Prefix()
		{
			StudentRecipeBlacklist.Clear();
			ClearCraftBuffPerks(ENT_Player.GetPlayer());
			EnsureAssets();
		}

		private static void Postfix(M_Gamemode __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && __instance.HasActiveSetting(StudentSettingId) && !((Object)(object)Inventory.instance == (Object)null))
			{
				ENT_Player player = ENT_Player.GetPlayer();
				if ((Object)(object)player != (Object)null && (Object)(object)player.GetPerk("student_amalgamator_perk") == (Object)null)
				{
					player.AddPerk(GetStudentPerk(), 1, true);
				}
				RemoveStudentStartingHammer();
				AddStarterItem(ItemId);
				AddStarterItem(PestleItemId);
				AddStudentStarterNote();
			}
		}

		private static void RemoveStudentStartingHammer()
		{
			if (Inventory.instance.bagItems == null)
			{
				return;
			}
			Item[] array = Inventory.instance.bagItems.ToArray();
			foreach (Item val in array)
			{
				if (val != null && val.prefabName == Hammer)
				{
					val.Destroy(true);
				}
			}
		}

		private static void AddStarterItem(string id)
		{
			foreach (Item bagItem in Inventory.instance.bagItems)
			{
				if (bagItem != null && bagItem.prefabName == id)
				{
					return;
				}
			}
			Item_Object itemObjectPrefab = CL_AssetManager.GetItemObjectPrefab(id, "");
			if ((Object)(object)itemObjectPrefab != (Object)null)
			{
				Inventory.instance.AddItemToInventoryCenter(itemObjectPrefab.itemData.GetClone(itemObjectPrefab.itemData, false));
			}
		}

		private static void AddStudentStarterNote()
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			foreach (Item bagItem in Inventory.instance.bagItems)
			{
				if (bagItem != null && GetCustomData(bagItem, "AwakenedStudentNote") == "1")
				{
					return;
				}
			}
			Item_Object itemObjectPrefab = CL_AssetManager.GetItemObjectPrefab("Item_Note_01", "");
			if (!((Object)(object)itemObjectPrefab == (Object)null) && itemObjectPrefab.itemData != null)
			{
				Item clone = itemObjectPrefab.itemData.GetClone(itemObjectPrefab.itemData, false);
				clone.dataModules = new List<Item_Data> { (Item_Data)new Item_Data_Text_Random
				{
					strings = new List<string>(StudentNoteTexts)
				} };
				SetCustomData(clone, "AwakenedStudentNote", "1");
				Inventory.instance.AddItemToInventoryCenter(clone);
			}
		}
	}

	[HarmonyPatch(typeof(HandItem_Crafter), "TryCraft")]
	private static class TryCraftPatch
	{
		private static bool Prefix(HandItem_Crafter __instance)
		{
			if (!IsAwakened(__instance))
			{
				return (Object)(object)__instance == (Object)null || ((HandItem)__instance).item == null || ((HandItem)__instance).item.prefabName == "Item_Artifact_Craftcube";
			}
			return !ProcessCraft(__instance);
		}
	}

	[HarmonyPatch(typeof(Item), "Destroy")]
	private static class PreserveInfusedShootItemPatch
	{
		private static bool Prefix(Item __instance)
		{
			if (__instance == null)
			{
				return true;
			}
			int num = ParseDataInt(__instance, "AwakenedAmmoCapacity");
			int result;
			bool flag = int.TryParse(__instance.GetFirstDataStringByType("ammo", false), out result) && result > 0;
			if (num <= 0 || !flag)
			{
				if (!__instance.hasBeenDestroyed && ParseDataInt(__instance, "AwakenedSoulItemReturn") > 0)
				{
					ENT_Player player = ENT_Player.GetPlayer();
					if ((Object)(object)player != (Object)null)
					{
						player.AddPerk(GetSoulItemReturnPerk(__instance.GetClone((Item)null, false)), 1, true);
					}
				}
				return true;
			}
			__instance.SetUsed(false);
			HandItem handItem = __instance.GetHandItem();
			HandItem_Shoot val = (HandItem_Shoot)(object)((handItem is HandItem_Shoot) ? handItem : null);
			if ((Object)(object)val != (Object)null)
			{
				((HandItem)val).used = false;
				if ((Object)(object)((HandItem)val).anim != (Object)null && !string.IsNullOrEmpty(val.ammoAnimationIntegerName))
				{
					((HandItem)val).anim.SetInteger(val.ammoAnimationIntegerName, result);
				}
			}
			Inventory val2 = __instance.inventory ?? Inventory.instance;
			if ((Object)(object)val2 == (Object)null)
			{
				return false;
			}
			if (val2.itemHands != null)
			{
				ItemHand[] itemHands = val2.itemHands;
				foreach (ItemHand val3 in itemHands)
				{
					if (val3 != null && val3.currentItem == __instance)
					{
						return false;
					}
				}
				ItemHand[] itemHands2 = val2.itemHands;
				foreach (ItemHand val4 in itemHands2)
				{
					if (val4 != null && val4.currentItem == null && val4.hand != null)
					{
						val2.AddItemToHand(__instance, val4.hand);
						return false;
					}
				}
			}
			if (val2.pockets != null)
			{
				foreach (Pocket pocket in val2.pockets)
				{
					if (pocket != null && pocket.pouch != null && pocket.pouch.CanAddItemToPouch(__instance))
					{
						pocket.pouch.AddItemToPouch(__instance, true);
						return false;
					}
				}
			}
			if (val2.bagItems != null && val2.bagItems.Contains(__instance))
			{
				return false;
			}
			val2.AddItemToInventoryCenter(__instance);
			return false;
		}
	}

	[HarmonyPatch(typeof(HandItem_Crafter), "Update")]
	private static class CrafterHeldCollisionPatch
	{
		private static void Prefix(HandItem_Crafter __instance)
		{
			allowAwakenedCraftingWithInventoryOpen = IsAwakened(__instance);
			if (!allowAwakenedCraftingWithInventoryOpen)
			{
				return;
			}
			if (CrafterIsPickingUpField != null && (bool)CrafterIsPickingUpField.GetValue(__instance))
			{
				ReleaseBarnacleGrabs();
				if (((HandItem)__instance).item.prefabName == ItemId)
				{
					HammerNearbyPitons(__instance);
				}
			}
			if (__instance.tagBlacklist == null)
			{
				__instance.tagBlacklist = new List<string>();
			}
			if (!__instance.tagBlacklist.Contains("AwakenedAmalgamatorNoPickup"))
			{
				__instance.tagBlacklist.Add("AwakenedAmalgamatorNoPickup");
			}
		}

		private static void ReleaseBarnacleGrabs()
		{
			ENT_Player player = ENT_Player.GetPlayer();
			if ((Object)(object)player == (Object)null || EntityGrapplersField == null || !(EntityGrapplersField.GetValue(player) is List<Grappler> list))
			{
				return;
			}
			Grappler[] array = list.ToArray();
			foreach (Grappler val in array)
			{
				DEN_Barnacle val2 = (DEN_Barnacle)(object)((val is DEN_Barnacle) ? val : null);
				if (val2 != null)
				{
					val2.ReleaseGrapple();
				}
			}
		}

		private static void Postfix(HandItem_Crafter __instance)
		{
			UpdateHeldPropCollisions(__instance);
			allowAwakenedCraftingWithInventoryOpen = false;
		}

		private static Exception Finalizer(Exception __exception)
		{
			allowAwakenedCraftingWithInventoryOpen = false;
			return __exception;
		}
	}

	[HarmonyPatch(typeof(HandItem_Crafter), "StopUse")]
	private static class CrafterReleaseCollisionPatch
	{
		private static void Postfix(HandItem_Crafter __instance)
		{
			UpdateHeldPropCollisions(__instance);
		}
	}

	[HarmonyPatch(typeof(Item_Object), "Start")]
	private static class CraftedVariantWorldPatch
	{
		private static void Postfix(Item_Object __instance)
		{
			ApplyVariantWorldColor(__instance);
		}
	}

	[HarmonyPatch(typeof(HandItem_Piton), "PitonHit")]
	private static class VariantPitonPlacementPatch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			foreach (CodeInstruction instruction in instructions)
			{
				int num;
				if (instruction.opcode == OpCodes.Call)
				{
					object operand = instruction.operand;
					if (operand is MethodInfo method && method.DeclaringType == typeof(Object) && method.Name == "Instantiate" && method.IsGenericMethod && method.GetGenericArguments()[0] == typeof(GameObject))
					{
						num = ((method.GetParameters().Length == 3) ? 1 : 0);
						goto IL_0104;
					}
				}
				num = 0;
				goto IL_0104;
				IL_0104:
				if (num != 0)
				{
					instruction.operand = AccessTools.Method(typeof(AwakenedAmalgamator), "InstantiatePlacedPiton", (Type[])null, (Type[])null);
				}
				yield return instruction;
			}
		}
	}

	public static string ItemId = "Awakened_Amalgamator";

	private static string CombinedBuffItemId = "Item_AmalgamatedInjector";

	private static string PestleItemId = "Item_Amalgamate_Pestle";

	private static string TimeReagent = "Item_Time_Reagent";

	private static string PowerReagent = "Item_Power_Reagent";

	private static string MagicReagent = "Item_Magic_Reagent";

	private static string BodyReagent = "Item_Body_Reagent";

	private static string SoulReagent = "Item_Soul_Reagent";

	private const string ItemInput = "item:";

	private const string itemOutput = "item:";

	private const string denizenOutput = "den:";

	private const string FunctionOutput = "func:";

	private static string Or = ",";

	private static string And = "+";

	private static string Becomes = "=";

	private static string WildcardName = "*";

	private static string CountOne = ":1";

	private static string CountTwo = ":2";

	private static string CountThree = ":3";

	private static string CountFour = ":4";

	private static string CountFive = ":5";

	private static string CountSix = ":6";

	private static string CountSeven = ":7";

	private static string CountEight = ":8";

	private static string CountNine = ":9";

	private static string CountTen = ":10";

	private static string BlinkEye = "Item_BlinkEye";

	private static string BeansEmpty = "Item_Beans_Eaten";

	private static string MilkEmpty = "Item_Milk_Empty";

	private static string Beans = Quote("Item_Beans");

	private static string Milk = Quote("Item_Milk");

	private static string Meat = "Item_Food_Meat";

	private static string Candy = "Item_CandyCauldron";

	private static string FoodBar = "Item_Food_Bar";

	private static string Injector = "Item_Injector";

	private static string PillBottle = "Item_Pillbottle";

	private static string Wine = Quote("Item_Wine");

	private static string FlareAmmo = "Item_Flaregun_Ammo";

	private static string PowerCell = "Item_Powercell";

	private static string FloppyOne = "Item_Floppy_T1";

	private static string FloppyTwo = "Item_Floppy_T2";

	private static string FloppyThree = "Item_Floppy_T3";

	private static string Note = "Item_Note";

	private static string Rebar = Quote("Item_Rebar");

	private static string RebarRope = "Item_RebarRope";

	private static string RebarBone = "Item_Rebar_Bone";

	private static string RebarExplosive = "Item_Rebar_Explosive";

	private static string ReturnRebar = "Item_Artifact_Rebar_Return";

	private static string Piton = Quote("Item_Piton");

	private static string AutoPiton = "Item_AutoPiton";

	private static string GrapplePiton = "Item_GrapplePiton";

	private static string Flaregun = Quote("Item_Flaregun");

	private static string Handgun = Quote("Item_Handgun");

	private static string Cryogun = Quote("Item_Cryogun");

	private static string RhoStone = "Item_RhoStone";

	private static string Cleaver = "Item_Cleaver";

	private static string Rapier = "Item_Artifact_Rapier";

	private static string Glove = "Item_Artifact_EVAGlove";

	private static string Translocator = "Item_Artifact_Translocator";

	private static string Timepiece = "Item_Artifact_Timepiece";

	private static string Remote = "Item_Artifact_Remote";

	private static string Scanner = "Item_EntityScanner";

	private static string Brick = "Item_Rubble";

	private static string RoachRuby = "Denizen_Roach_Flying_Ruby";

	private static string RoachGold = "Denizen_Roach_Gold";

	private static string RoachLemon = "Denizen_Roach_Lemon";

	private static string RoachPlatinum = "Denizen_Roach_Platinum";

	private static string RoachRed = "Denizen_Roach_Explosive";

	private static string Grub = "Denizen_SlugGrub";

	private static string GrubSister = "Denizen_Grub_Sister";

	private static string Hammer = "Item_Hammer";

	private static string Pipewrench = "Item_Pipewrench";

	private static string Ammo10mm = "Item_10mm_Ammo";

	private static string Flashlight = "Item_Flashlight";

	private static string TrinketCarabiner = "Item_Trinket_Carabiner";

	private static string TrinketHeadlamp = "Item_Trinket_Headlamp";

	private static string TrinketChalk = "Item_Trinket_Chalk";

	private static string TrinketClimbingShoes = "Item_Trinket_ClimbingShoes";

	private static string TrinketCalmingBuddy = "Item_Trinket_CalmingBuddy";

	private static string TrinketEmployeeId = "Item_Trinket_EmployeeID";

	private static string TrinketHelmet = "Item_Trinket_Helmet";

	private static string TrinketMassDamper = "Item_Trinket_MassDamper";

	private static string TrinketMoonRock = "Item_Trinket_MoonRock";

	private static string TrinketNugget = "Item_Trinket_Nugget";

	private static string TrinketPhotoHome = "Item_Trinket_PhotoOfHome";

	private static string TrinketRhoAmulet = "Item_Trinket_RhoAmulet";

	private static string BarnacleHook = "Item_BarnacleHook";

	private static string PBeans = "Item_Beans_Periphery";

	private static string Scrap = "Item_Beans_Eaten,Item_Milk_Empty";

	private static string CommonRebar = "Item_Rebar";

	public static string StudentSettingId = "Student";

	private const string StudentPerkId = "student_amalgamator_perk";

	private const string CraftBuffPerkId = "amalgamator_craft_buff_perk";

	private const string RatKingPickupBlockTag = "AwakenedAmalgamatorNoPickup";

	private static readonly Color PurpleTint = new Color(0.48f, 0.18f, 0.78f) * 4f;

	private static readonly Color SpritePurpleTint = Color.Lerp(Color.white, PurpleTint, 0.75f);

	private static readonly List<CombinationRecipe> Recipes = new List<CombinationRecipe>();

	private static readonly Dictionary<HandItem_Crafter, float> CraftTimers = new Dictionary<HandItem_Crafter, float>();

	private static readonly Dictionary<HandItem_Crafter, CraftMatchCache> CraftMatches = new Dictionary<HandItem_Crafter, CraftMatchCache>();

	private static readonly Dictionary<HandItem_Crafter, Dictionary<long, CollisionPair>> IgnoredPropCollisions = new Dictionary<HandItem_Crafter, Dictionary<long, CollisionPair>>();

	private static readonly List<CombinableItemType> CombinableItemTypes = new List<CombinableItemType>();

	private static readonly List<BuffContainer> CraftBuffPerks = new List<BuffContainer>();

	private static readonly HashSet<string> ActiveCraftBuffIds = new HashSet<string>();

	private static readonly List<string> StudentRecipeBlacklist = new List<string>();

	private static readonly List<string> StudentNoteTexts = new List<string> { "\r\nReagents:\r\nTime\r\nPower\r\nMagic\r\nBody\r\n\r\nSoul?\r\n        ", "\r\nThe Pestle can do more than \r\ndeconstruct items into Reagents\r\n        " };

	private static Perk studentPerk;

	private static readonly FieldInfo PickedUpEntitiesField = AccessTools.Field(typeof(HandItem_Crafter), "pickedupEntities");

	private static readonly FieldInfo CrafterIsPickingUpField = AccessTools.Field(typeof(HandItem_Crafter), "isPickingUp");

	private static readonly FieldInfo EntityGrapplersField = AccessTools.Field(typeof(GameEntity), "grapplers");

	private static readonly FieldInfo CraftTimerField = AccessTools.Field(typeof(HandItem_Crafter), "craftTimer");

	private static bool recipesRegistered;

	private static CombinationRecipe RatKingFallbackRecipe;

	private static bool assetRegistered;

	private static bool combinedBuffAssetRegistered;

	private static bool cubeItemsRegistered;

	[ThreadStatic]
	private static bool allowAwakenedCraftingWithInventoryOpen;

	private static Sprite cubeHandSprite;

	private static Shader cubeShader;

	private static Texture2D cubeNoiseTexture;

	private static HandItem amalgamatorSpriteTemplate;

	private static readonly FieldInfo ShootAmmoField = AccessTools.Field(typeof(HandItem_Shoot), "ammo");

	private const string DemalgamatorId = "Item_Demalgamator";

	private static readonly string[] HolidayItemIds = new string[4] { "Item_Piton_Holiday", "Item_Rebar_Holiday", "Item_RebarRope_Holiday", "Denizen_SlugGrub_Christmas" };

	private static readonly Collider[] nearbyPitonColliders = (Collider[])(object)new Collider[128];

	private static readonly HashSet<CL_Handhold> nearbyPitons = new HashSet<CL_Handhold>();

	private static float nextPitonHammerTime;

	private static readonly Dictionary<string, string> ModificationLabels = new Dictionary<string, string>
	{
		{ "AwakenedUsesBonus", "Extra uses" },
		{ "AwakenedReachBonus", "Extra grapple reach (meters)" },
		{ "AwakenedAmmoCapacity", "Added ammunition capacity" },
		{ "AwakenedRangeMultiplier", "Range multiplier" },
		{ "AwakenedDashMultiplier", "Dash force multiplier" },
		{ "AwakenedBuffValueMultiplier", "Buff strength multiplier" },
		{ "AwakenedRechargeMultiplier", "Recharge speed multiplier" },
		{ "AwakenedPitonJumpBoost", "Handhold jump boost" }
	};

	private const string propInput = "prop:";

	private const string LargeMetalCrateId = "Prop_Crate_Metal_Large_Amalgamated";

	private const string MusicRadioItemId = "Item_Radio";

	private const string WoodenCrateProps = "Prop_Crate_Small_,Prop_Crate_Large_";

	private const string MetalCrateProps = "Prop_Crate_Metal_Small_";

	private const string BarrelProps = "Prop_Barrel_;!Explosive";

	private const string ExplosiveBarrelProps = "Prop_Barrel_Explosive";

	private const string BookProps = "Prop_Book_";

	private const string BookcaseProps = "Prop_BookcaseMedium_";

	private const string BowlingBallProps = "Prop_Bowling_Ball";

	private const string BowlingPinProps = "Prop_Bowling_Pin";

	private const string BriefcaseProps = "Prop_Briefcase";

	private const string BunsenBurnerProps = "Prop_BunsenBurner_";

	private const string CalculatorProps = "Prop_calculator_";

	private const string CardboardBoxProps = "Prop_Cardboard_Box_";

	private const string CassettePlayerProps = "Prop_CassettePlayer";

	private const string ChairProps = "Prop_Chair_";

	private const string CoffeeBrewProps = "Prop_Coffee_brew_";

	private const string CoffeePotProps = "Prop_CoffeePot_";

	private const string ComputerProps = "Prop_Computer_Desktop_";

	private const string DeskLampProps = "Prop_DeskLamp_";

	private const string FilingCabinetProps = "Prop_FilingCabinet_";

	private const string MediumPlantProps = "Prop_MediumPlantpot_";

	private const string MicroscopeProps = "Prop_Microscope_";

	private const string MugProps = "Prop_Mug_";

	private const string OfficeChairProps = "Prop_OfficeChair_";

	private const string PlankProps = "Prop_Plank_";

	private const string RadioProps = "Prop_Radio;!Artifact";

	private const string AnomalousRadioProps = "Prop_Radio_Artifact";

	private const string ShroompodProps = "Prop_Shroompod_Explosive";

	private const string ScientificEquipmentProps = "Prop_SientificEquipment_";

	private const string SofaProps = "Prop_Sofa_";

	private const string TableProps = "Prop_Table_Wood_";

	private const string TallPlantProps = "Prop_TallPlantpot_";

	private const string TelevisionProps = "Prop_tv_";

	private const string VentCoverProps = "Prop_VentCover_";

	private const string WaterCoolerProps = "Prop_waterCooler";

	private static readonly Dictionary<string, GameObject> CraftedPropPrefabs = new Dictionary<string, GameObject>(StringComparer.Ordinal);

	private static readonly Dictionary<string, int> SupplyCrateVendingPrices = new Dictionary<string, int>
	{
		{ "Item_Piton", 1 },
		{ "Item_Rebar", 3 },
		{ "Item_RebarRope", 5 },
		{ "Item_Rubble", 1 },
		{ "Item_Beans", 2 },
		{ "Item_Injector", 8 },
		{ "Item_Pillbottle", 5 },
		{ "Item_Rebar_Explosive", 6 },
		{ "Denizen_SlugGrub", 7 },
		{ "Item_AutoPiton", 3 },
		{ "Item_Food_Bar", 6 },
		{ "Item_Flaregun_Ammo", 3 },
		{ "Item_Flaregun", 8 },
		{ "Item_BlinkEye", 8 },
		{ "Item_Bandage", 5 },
		{ "Item_10mm_Ammo", 3 },
		{ "Item_GrapplePiton", 8 }
	};

	public static string Quote(string s)
	{
		return "\"" + s + "\"";
	}

	private static Item_Object GetRuntimeItemPrefab(string prefabName)
	{
		if (prefabName != ItemId && prefabName != CombinedBuffItemId && prefabName != "Item_Amalgamate_CubeBase" && prefabName != PestleItemId && prefabName != TimeReagent && prefabName != PowerReagent && prefabName != MagicReagent && prefabName != BodyReagent && prefabName != SoulReagent)
		{
			return null;
		}
		return CL_AssetManager.GetItemObjectPrefab(prefabName, "");
	}

	private static void RestoreRuntimeItemReferences(Item item)
	{
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		if (item == null)
		{
			return;
		}
		Item_Object val = GetRuntimeItemPrefab(item.prefabName);
		if ((Object)(object)val == (Object)null && (Object)(object)item.handItemAsset == (Object)null)
		{
			val = CL_AssetManager.GetItemObjectPrefab(item.prefabName, "");
		}
		if ((Object)(object)val == (Object)null || val.itemData == null)
		{
			return;
		}
		if (item.prefabName == CombinedBuffItemId && (Object)(object)item.handItemAsset != (Object)null)
		{
			item.itemAsset = val;
			item.normalSprite = val.itemData.normalSprite;
			item.pickupSounds = val.itemData.pickupSounds;
			return;
		}
		if ((Object)(object)val.itemData.handItemAsset == (Object)null && (item.prefabName == "Item_Amalgamate_CubeBase" || item.prefabName == PestleItemId || IsReagent(item.prefabName)))
		{
			Item_Object itemObjectPrefab = CL_AssetManager.GetItemObjectPrefab("Item_Trinket_Nugget", "");
			HandItem val2 = (((Object)(object)itemObjectPrefab == (Object)null || itemObjectPrefab.itemData == null) ? null : itemObjectPrefab.itemData.handItemAsset);
			if ((Object)(object)val2 != (Object)null)
			{
				if ((Object)(object)cubeHandSprite == (Object)null)
				{
					cubeHandSprite = CreateCubeSprite();
				}
				float size = ((item.prefabName == PestleItemId) ? 2f : 1f);
				Color reagentColor = GetReagentColor(item.prefabName);
				val.itemData.handItemAsset = CloneCubeHandItem(val2, val.itemData, reagentColor, size);
			}
		}
		item.itemAsset = val;
		item.handItemAsset = val.itemData.handItemAsset;
		item.normalSprite = val.itemData.normalSprite;
		item.pickupSounds = val.itemData.pickupSounds;
	}

	public static void RegisterAllRecipes()
	{
		if (!recipesRegistered)
		{
			string text = "item:" + PestleItemId + CountOne;
			recipesRegistered = true;
			RegisterAdvancedRecipes();
			AddVanillaRecipes();
			RegisterRecipeShorthand(FoodBar + And + "pestle" + Becomes + TimeReagent + And + PowerReagent);
			RegisterRecipeShorthand(Injector + And + "pestle=" + PowerReagent + CountThree);
			RegisterRecipeShorthand(BlinkEye + CountTwo + And + "pestle" + Becomes + BodyReagent + And + MagicReagent + CountTwo);
			RegisterRecipeShorthand(RoachRuby + And + "pestle" + Becomes + BodyReagent);
			RegisterRecipeShorthand(MagicReagent + CountTwo + And + "pestle" + Becomes + PowerReagent + CountTwo + And + TimeReagent + CountTwo);
			RegisterRecipeShorthand(Grub + And + "pestle" + Becomes + BodyReagent);
			RegisterFixedRecipe(new string[2]
			{
				"item:" + WildcardName + ":Trinket" + CountOne,
				text
			}, new string[1] { MagicReagent });
			RegisterRecipeShorthand(SoulReagent + And + "pestle" + Becomes + MagicReagent + And + BodyReagent + And + PowerReagent + And + TimeReagent);
			RegisterRecipeShorthand(MagicReagent + CountSeven + Becomes + SoulReagent);
			RegisterRecipeShorthand(TimeReagent + And + BeansEmpty + Becomes + Beans);
			RegisterRecipeShorthand(TimeReagent + And + MilkEmpty + Becomes + Milk);
			RegisterRecipeShorthand(PowerReagent + CountTwo + And + TimeReagent + And + BeansEmpty + Becomes + "Item_Beans_Periphery");
			RegisterRecipeShorthand(PowerReagent + CountThree + And + Flaregun + Becomes + Handgun);
			RegisterRecipeShorthand(PowerReagent + CountTwo + And + "pestle" + Becomes + MagicReagent);
			RegisterRecipeShorthand(BlinkEye + And + "pestle" + Becomes + MagicReagent + CountTwo);
			RegisterRecipeShorthand(RhoStone + And + "pestle" + Becomes + MagicReagent);
			RegisterRecipeShorthand(Cleaver + And + "pestle" + Becomes + MagicReagent + CountFour);
			RegisterRecipeShorthand(MagicReagent + And + BodyReagent + And + PowerReagent + And + TimeReagent + And + RoachRuby + And + "pestle" + Becomes + SoulReagent);
			RegisterRecipeShorthand(Rebar + CountTwo + And + "pestle" + Becomes + PowerReagent);
			RegisterRecipeShorthand(Piton + CountThree + And + "pestle" + Becomes + PowerReagent);
			RegisterRecipeShorthand(AutoPiton + "+pestle=" + PowerReagent);
			RegisterRecipeShorthand(PillBottle + "+pestle=" + TimeReagent + CountThree);
			RegisterRecipeShorthand(AutoPiton + And + RebarRope + Becomes + GrapplePiton);
			RegisterRecipeShorthand(Piton + And + AutoPiton + Becomes + Piton + CountThree);
			RegisterRecipeShorthand(Rebar + And + Piton + Becomes + RebarRope);
			RegisterRecipeShorthand(Rebar + And + PowerCell + And + MagicReagent + CountThree + Becomes + ReturnRebar);
			RegisterRecipeShorthand(Scrap + CountThree + And + PowerReagent + Becomes + PowerCell);
			RegisterRecipeShorthand(Scrap + CountFive + And + PowerReagent + Becomes + Hammer);
			RegisterRecipeShorthand(Scrap + CountThree + And + MagicReagent + CountTwo + Becomes + Cleaver);
			RegisterRecipeShorthand(Scrap + CountThree + "+pestle=" + TimeReagent);
			RegisterRecipeShorthand(Rebar + And + Piton + And + PowerReagent + Becomes + GrapplePiton);
			RegisterRecipeShorthand(GrapplePiton + And + SoulReagent + Becomes + BarnacleHook);
			RegisterRecipeShorthand("roach" + CountTwo + "+pestle=" + Beans);
			RegisterRecipeShorthand("meat:3+pestle=" + MagicReagent);
			RegisterRecipe(new string[1] { "item:roach" + CountEight }, new string[1] { DenizenOutput("Denizen_Breeder") });
			RegisterRecipe(new string[2]
			{
				"item:roach" + CountOne,
				ExactItemInput(PowerCell, CountOne)
			}, new string[1] { DenizenOutput("Denizen_Hopper_Explosive") });
			RegisterRecipe(new string[2]
			{
				"item:roach" + CountOne,
				ExactItemInput(TimeReagent, CountOne)
			}, new string[1] { DenizenOutput("Denizen_Hopper") });
			CombinationRecipe combinationRecipe = new CombinationRecipe();
			combinationRecipe.Id = "item:*:14";
			combinationRecipe.Inputs = new string[0];
			combinationRecipe.Outputs = new string[1] { DenizenOutput("DEN_RatKing") };
			combinationRecipe.ReservedInputs = new string[0];
			combinationRecipe.InputCount = 14;
			combinationRecipe.RegistrationOrder = Recipes.Count;
			combinationRecipe.PreservedInputs = new string[0];
			RatKingFallbackRecipe = combinationRecipe;
			RegisterRecipeShorthand(RebarRope + And + "pestle" + Becomes + PowerReagent);
			RegisterRecipeShorthand(RebarExplosive + And + "pestle" + Becomes + PowerReagent + CountThree);
			RegisterRecipeShorthand(GrapplePiton + And + "pestle" + Becomes + PowerReagent + CountThree);
			RegisterRecipeShorthand(Beans + CountTwo + And + "pestle" + Becomes + TimeReagent);
			RegisterRecipeShorthand(Milk + CountTwo + And + "pestle" + Becomes + TimeReagent);
			RegisterRecipeShorthand(Wine + And + "pestle" + Becomes + TimeReagent + CountTwo);
			RegisterRecipeShorthand(Meat + CountTwo + And + "pestle" + Becomes + BodyReagent);
			RegisterRecipeShorthand(TimeReagent + And + Meat + Becomes + FoodBar + CountTwo);
			RegisterRecipeShorthand(PowerReagent + And + Beans + Becomes + FoodBar);
			RegisterRecipeShorthand(PowerReagent + And + FlareAmmo + Becomes + PowerCell);
			RegisterRecipeShorthand(PowerReagent + CountTwo + And + Rebar + Becomes + RebarExplosive);
			RegisterRecipeShorthand(TimeReagent + And + BeansEmpty + Becomes + Piton + CountFour);
			RegisterRecipeShorthand(MagicReagent + And + Note + Becomes + FloppyOne);
			RegisterEffectRecipe(new string[2]
			{
				"item:" + RebarRope + Or + Wine,
				"item:" + GrapplePiton + CountOne
			}, "effect:grapple_reach");
			RegisterEffectRecipe(new string[2]
			{
				"many:item:" + TimeReagent,
				"hand:uses:1"
			}, "effect:time_uses");
			RegisterEffectRecipe(new string[2]
			{
				"many:item:" + TimeReagent,
				"hand:buff:1"
			}, "effect:time_buff_duration");
			RegisterEffectRecipe(new string[2]
			{
				"many:item:" + TimeReagent,
				"hand:foodbuff:1"
			}, "effect:time_buff_duration");
			RegisterEffectRecipe(new string[2]
			{
				"many2:item:" + TimeReagent,
				"hand:oneshotshoot:1"
			}, "effect:time_shoot_uses");
			RegisterEffectRecipe(new string[2]
			{
				"item:" + TimeReagent + CountOne,
				"hand:reloadshoot:1"
			}, "effect:time_shoot_reload");
			RegisterEffectRecipe(new string[2]
			{
				"item:" + TimeReagent + CountTwo,
				"hand:reloadshoot:1"
			}, "effect:time_shoot_double");
			RegisterEffectRecipe(new string[2]
			{
				"many:item:" + PowerReagent,
				"hand:buff:1"
			}, "effect:power_buff_values");
			RegisterEffectRecipe(new string[2]
			{
				"many:item:" + PowerReagent,
				"hand:foodbuff:1"
			}, "effect:power_buff_values");
			RegisterEffectRecipe(new string[2]
			{
				"many:item:" + PowerReagent,
				"hand:recoilshoot:1"
			}, "effect:power_recoil");
			RegisterEffectRecipe(new string[2]
			{
				"item:" + BodyReagent + CountOne,
				"hand:buff:1"
			}, "effect:body_buff_perk");
			RegisterEffectRecipe(new string[2]
			{
				"item:" + BodyReagent + CountOne,
				"hand:foodbuff:1"
			}, "effect:body_buff_perk");
			RegisterEffectRecipe(new string[2]
			{
				"many:item:" + MagicReagent,
				"item:" + BlinkEye + CountOne
			}, "effect:magic_range");
			RegisterEffectRecipe(new string[2]
			{
				"many:item:" + MagicReagent,
				"item:" + GrapplePiton + CountOne
			}, "effect:magic_range");
			RegisterEffectRecipe(new string[2]
			{
				"many:item:" + MagicReagent,
				"item:" + Translocator + CountOne
			}, "effect:magic_range");
			RegisterEffectRecipe(new string[2]
			{
				"many:item:" + MagicReagent,
				"item:" + Rapier + CountOne
			}, "effect:magic_dash");
			RegisterEffectRecipe(new string[2]
			{
				"many:item:" + MagicReagent,
				"item:" + ReturnRebar + CountOne
			}, "effect:magic_recoil");
			RegisterEffectRecipe(new string[2]
			{
				"item:" + SoulReagent + CountOne,
				"item:" + ReturnRebar + CountOne
			}, "effect:soul_no_overheat");
			RegisterEffectRecipe(new string[2]
			{
				"item:" + SoulReagent + CountOne,
				"item:" + Rapier + CountOne
			}, "effect:soul_dash");
			RegisterEffectRecipe(new string[2]
			{
				"item:" + SoulReagent + CountOne,
				ExactItemOptions(CountOne, Handgun, Flaregun, Cryogun)
			}, "effect:soul_autoreload");
			RegisterEffectRecipe(new string[2]
			{
				"item:" + SoulReagent + CountOne,
				ExactItemOptions(CountOne, Translocator, Timepiece, Remote, Glove)
			}, "effect:soul_recharge");
			RegisterEffectRecipe(new string[2]
			{
				"item:" + SoulReagent + CountOne,
				"hand:nontrinket:1"
			}, "effect:soul_item_return");
			RegisterEffectRecipe(new string[2]
			{
				"item:" + SoulReagent + CountOne,
				"hand:trinket:1"
			}, "effect:soul_trinket_triplicate");
			RegisterEffectRecipe(new string[1] { "many2:hand:buff" }, "effect:combine_buff_items");
			CombinationRecipe combinationRecipe2 = RegisterRecipe(new string[2] { "hand:recipepaper:1", "hand:recipetarget:1" }, new string[1] { "effect:recipe_note" }, null, null, new string[1] { "hand:recipetarget:1" });
			combinationRecipe2.Priority = -200;
			RegisterRecipeShorthand(AutoPiton + CountThree + And + "pestle" + Becomes + Piton + CountTen);
			RegisterRecipeShorthand(FlareAmmo + And + Scrap + CountThree + Becomes + Flaregun);
			RegisterRecipeShorthand(Rebar + CountTwo + And + Piton + And + Scrap + CountTwo + Becomes + RebarRope + CountTwo);
			RegisterRecipeShorthand(AutoPiton + CountTwo + And + Scrap + CountTwo + Becomes + GrapplePiton);
			RegisterRecipeShorthand(Piton + CountThree + And + Scrap + CountTwo + Becomes + AutoPiton + CountTwo);
			RegisterRecipeShorthand(Rebar + CountTwo + And + Scrap + CountTwo + Becomes + RebarExplosive);
			RegisterRecipeShorthand(Scrap + CountFour + And + "pestle" + Becomes + Piton + CountThree);
			RegisterRecipeShorthand(FlareAmmo + And + Scrap + CountTwo + Becomes + Ammo10mm);
			RegisterRecipeShorthand(Ammo10mm + And + Scrap + Becomes + FlareAmmo + CountTwo);
			RegisterRecipeShorthand(Flaregun + And + Ammo10mm + CountTwo + Becomes + Handgun);
			RegisterRecipeShorthand(Beans + CountTwo + And + Milk + CountTwo + Becomes + FoodBar + CountThree);
			RegisterRecipeShorthand(Beans + And + Rebar + Becomes + Wine);
			RegisterRecipeShorthand(Brick + CountThree + And + Scrap + CountTwo + Becomes + Hammer);
			RegisterRecipeShorthand(Rebar + CountTwo + And + Scrap + CountThree + Becomes + Pipewrench);
			RegisterRecipeShorthand(Wine + CountTwo + And + FoodBar + Becomes + Injector);
			RegisterRecipeShorthand(Wine + And + Beans + CountTwo + Becomes + PillBottle);
			RegisterRecipeShorthand(Flashlight + And + Scrap + CountFour + Becomes + TrinketHeadlamp);
			RegisterRecipeShorthand(Hammer + And + Scrap + CountSix + Becomes + TrinketHelmet);
			RegisterRecipeShorthand(RebarRope + CountThree + And + Scrap + CountFour + Becomes + TrinketClimbingShoes);
			RegisterRecipeShorthand(Meat + CountThree + And + Milk + CountTwo + Becomes + BodyReagent + CountTwo);
			RegisterRecipeShorthand(FloppyTwo + And + "pestle" + Becomes + MagicReagent);
			RegisterRecipeShorthand(PowerCell + And + "pestle" + Becomes + PowerReagent + CountFour);
			RegisterRecipeShorthand(FloppyThree + And + PowerReagent + CountTwo + And + Scrap + CountFour + Becomes + Scanner);
			RegisterRecipeShorthand(AutoPiton + CountTwo + And + FlareAmmo + CountTwo + And + Scrap + CountFour + Becomes + GrapplePiton + CountTwo);
			RegisterRecipeShorthand(Milk + And + Piton + Becomes + "Item_Piton_Holiday");
			RegisterRecipeShorthand(Milk + And + Rebar + Becomes + "Item_Rebar_Holiday");
			RegisterRecipeShorthand(Milk + And + RebarRope + Becomes + "Item_RebarRope_Holiday");
			RegisterRecipeShorthand(Milk + And + Grub + Becomes + "Denizen_SlugGrub_Christmas");
			RegisterPropRecipes();
			Recipes.Sort(delegate(CombinationRecipe left, CombinationRecipe right)
			{
				int num = right.InputCount.CompareTo(left.InputCount);
				return (num != 0) ? num : left.RegistrationOrder.CompareTo(right.RegistrationOrder);
			});
		}
	}

	private static CombinationRecipe RegisterEffectRecipe(string[] inputs, string output)
	{
		return RegisterRecipe(inputs, new string[1] { output });
	}

	internal static Perk GetStudentPerk()
	{
		if ((Object)(object)studentPerk == (Object)null)
		{
			studentPerk = new PerkBuilder("student_amalgamator_perk", "Student").WithDescription("The Student climbs and jumps less effectively, but has more stamina and inventory space. Crafting with the Awakened Amalgamator restores stamina and rotates its recipe blacklist (3 recipes).").WithStacking(canStack: false).WithBuff("student_amalgamator_stats", PerkBuilder.Buff("addClimb", -0.7f), PerkBuilder.Buff("addJump", -0.2f), PerkBuilder.Buff("addStaminaRegen", -1f), PerkBuilder.Buff("addStamina", 1f), PerkBuilder.Buff("addCapacity", 12f))
				.Build();
		}
		return studentPerk;
	}

	private static Perk GetCraftBuffPerk()
	{
		return new PerkBuilder("amalgamator_craft_buff_perk", "Amalgamator's Imprint").WithDescription("Crafting with the Awakened Amalgamator grants the stored buff for a short time.").WithStacking(canStack: false).Build();
	}

	private static Perk GetSoulItemReturnPerk(Item item)
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Expected O, but got Unknown
		string id = "awakened_soul_return_" + Guid.NewGuid().ToString("N");
		return new PerkBuilder(id, "Soul Reconstitution").WithDescription("The lost item returns after two minutes. This perk expires shortly afterward.").WithStacking(canStack: false).AddModule((PerkModule)(object)new SoulItemReturnModule
		{
			Template = item
		})
			.AddModule((PerkModule)new PerkModule_RemovalTimer
			{
				removeTime = 121f,
				removalTimerDisplayType = (RemovalTimerDisplayType)0
			})
			.Build();
	}

	private static void ClearCraftBuffPerks(ENT_Player player)
	{
		CraftBuffPerks.Clear();
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		foreach (string activeCraftBuffId in ActiveCraftBuffIds)
		{
			((GameEntity)player).RemoveBuff(activeCraftBuffId);
		}
		ActiveCraftBuffIds.Clear();
		player.RemovePerk("amalgamator_craft_buff_perk", true);
		player.GetOldPerks()?.RemoveAll((Perk perk) => (Object)(object)perk != (Object)null && perk.id == "amalgamator_craft_buff_perk");
	}

	private static bool HasStudentPerk(ENT_Player player)
	{
		return (Object)(object)player != (Object)null && (Object)(object)player.GetPerk("student_amalgamator_perk") != (Object)null;
	}

	private static bool IsStudentRecipeBlacklisted(string recipeId)
	{
		if (StudentPerks.Stacks("student_studious_nature") > 0)
		{
			return false;
		}
		int num = StudentRecipeBlacklist.LastIndexOf(recipeId);
		return num >= 0 && num < StudentRecipeBlacklist.Count - StudentPerks.Stacks("student_obsessive_repetition");
	}

	private static void ApplyStudentCraftReward(CombinationRecipe recipe, ENT_Player player)
	{
		if (recipe == null || IsRecipeNoteCraft(recipe) || !HasStudentPerk(player) || IsStudentRecipeBlacklisted(recipe.Id))
		{
			return;
		}
		if (player.hands != null)
		{
			Hand[] hands = player.hands;
			foreach (Hand val in hands)
			{
				if (val != null)
				{
					val.SetGripStrength(float.MaxValue);
				}
			}
		}
		if (StudentPerks.Stacks("student_studious_nature") <= 0)
		{
			StudentRecipeBlacklist.Remove(recipe.Id);
			if (StudentRecipeBlacklist.Count >= 3)
			{
				StudentRecipeBlacklist.RemoveAt(0);
			}
			StudentRecipeBlacklist.Add(recipe.Id);
		}
	}

	private static void SetRecipePriority(string id, int inputCount)
	{
		CombinationRecipe combinationRecipe = Recipes.Find((CombinationRecipe candidate) => candidate.Id == id);
		if (combinationRecipe != null)
		{
			combinationRecipe.InputCount = inputCount;
		}
	}

	private static bool IsReagent(string id)
	{
		return id == TimeReagent || id == PowerReagent || id == MagicReagent || id == BodyReagent || id == SoulReagent;
	}

	private static Color GetReagentColor(string id)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: 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_00df: Unknown result type (might be due to invalid IL or missing references)
		if (id == TimeReagent)
		{
			return new Color(0.55f, 1f, 0.12f, 1f);
		}
		if (id == PowerReagent)
		{
			return new Color(1f, 0.82f, 0.05f, 1f);
		}
		if (id == MagicReagent)
		{
			return new Color(0.82f, 0.05f, 0.12f, 1f);
		}
		if (id == BodyReagent)
		{
			return new Color(0.12f, 0.35f, 1f, 1f);
		}
		if (id == SoulReagent)
		{
			return new Color(0.58f, 0.08f, 0.72f, 1f);
		}
		return Color.white;
	}

	private static void RegisterFixedRecipe(string[] inputs, string[] outputs, Action<Vector3> action = null)
	{
		string[] array = outputs ?? new string[0];
		for (int i = 0; i < array.Length; i++)
		{
			if (!string.IsNullOrEmpty(array[i]) && array[i].IndexOf(':') < 0)
			{
				array[i] = "item:" + array[i];
			}
		}
		CombinationRecipe combinationRecipe = RegisterRecipe(inputs, array, null, action);
		if (action != null)
		{
			combinationRecipe.CreateFunction = action;
		}
	}

	private static void RegisterRecipeShorthand(string shorthand)
	{
		if (string.IsNullOrWhiteSpace(shorthand))
		{
			return;
		}
		string[] array = shorthand.Split('=');
		if (array.Length != 2)
		{
			Debug.LogWarning((object)("Invalid item recipe shorthand: " + shorthand));
			return;
		}
		string[] array2 = ParseRecipeShorthandItems(array[0], isInput: true);
		string[] array3 = ParseRecipeShorthandItems(array[1], isInput: false);
		if (array2.Length == 0 || array3.Length == 0)
		{
			Debug.LogWarning((object)("Invalid item recipe shorthand: " + shorthand));
		}
		else
		{
			RegisterFixedRecipe(array2, array3);
		}
	}

	private static string[] ParseRecipeShorthandItems(string expression, bool isInput)
	{
		List<string> list = new List<string>();
		string[] array = expression.Split('+');
		foreach (string text in array)
		{
			string text2 = text.Trim();
			if (text2.Length == 0)
			{
				continue;
			}
			int num = text2.LastIndexOf(':');
			string text3 = ((num < 0) ? text2 : text2.Substring(0, num).Trim());
			int result = 1;
			if (num >= 0 && (!int.TryParse(text2.Substring(num + 1).Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out result) || result < 1))
			{
				return new string[0];
			}
			text3 = text3.Trim();
			string text4 = text3.Trim('"');
			if (text4.Equals("pestle", StringComparison.OrdinalIgnoreCase))
			{
				text3 = PestleItemId;
			}
			if (text3.Length == 0)
			{
				return new string[0];
			}
			if (isInput)
			{
				string[] array2 = text3.Split(',');
				list.Add((array2.Length == 1) ? ExactItemInput(text3, ":" + result.ToString(CultureInfo.InvariantCulture)) : ExactItemOptions(":" + result.ToString(CultureInfo.InvariantCulture), array2));
				continue;
			}
			text3 = text4;
			for (int j = 0; j < result; j++)
			{
				list.Add(ItemOutput(text3));
			}
		}
		return list.ToArray();
	}

	public static void RegisterCombinableItemType(Type handItemType, Func<List<GameEntity>, Vector3, GameEntity> combineFunction)
	{
		if (!(handItemType == null) && combineFunction != null)
		{
			CombinableItemTypes.RemoveAll((CombinableItemType registration) => registration.HandItemType == handItemType);
			CombinableItemTypes.Add(new CombinableItemType
			{
				HandItemType = handItemType,
				CombineFunction = combineFunction
			});
			CraftMatches.Clear();
		}
	}

	private static void AddVanillaRecipes()
	{
		RegisterRecipeShorthand(Scrap + CountFour + And + Rapier + "," + AutoPiton + "," + Cleaver + "," + Hammer + "," + Pipewrench + And + BlinkEye + Becomes + Cleaver);
		RegisterRecipeShorthand(BlinkEye + CountTwo + And + Beans + Becomes + PBeans);
		RegisterRecipeShorthand(BlinkEye + CountTwo + And + AutoPiton + And + RoachPlatinum + CountTwo + Becomes + Rapier);
		RegisterRecipeShorthand(BlinkEye + CountTwo + And + FloppyTwo + And + RoachPlatinum + Becomes + Remote);
		RegisterRecipeShorthand(BlinkEye + CountTwo + And + CommonRebar + CountThree + And + RoachRuby + And + FlareAmmo + Becomes + ReturnRebar);
		RegisterRecipeShorthand(BlinkEye + CountThree + And + RoachGold + "," + RoachLemon + CountThree + And + Scrap + CountThree + Becomes + Translocator);
		RegisterRecipeShorthand(BlinkEye + CountTwo + And + Scrap + CountTwo + And + RoachPlatinum + And + FloppyOne + Becomes + Timepiece);
		RegisterRecipeShorthand(RoachPlatinum + CountThree + And + Cryogun + "," + Flaregun + "," + Handgun + And + PowerCell + Becomes + Cryogun);
		RegisterRecipeShorthand(Cryogun + "," + Flaregun + "," + Handgun + And + TrinketCalmingBuddy + "," + TrinketCarabiner + "," + TrinketChalk + "," + TrinketClimbingShoes + "," + TrinketEmployeeId + "," + TrinketHeadlamp + "," + TrinketHelmet + "," + TrinketMassDamper + "," + TrinketMoonRock + "," + TrinketNugget + "," + TrinketPhotoHome + "," + TrinketRhoAmulet + And + RoachGold + "," + RoachLemon + Becomes + Scanner);
		RegisterRecipeShorthand(Flaregun + And + RoachPlatinum + CountTwo + And + AutoPiton + "," + GrapplePiton + "," + Piton + Becomes + Handgun);
		RegisterRecipeShorthand(FlareAmmo + CountTwo + And + CommonRebar + CountTwo + Becomes + Flaregun);
		RegisterRecipeShorthand(FlareAmmo + And + Scrap + And + RoachRuby + "," + RoachGold + "," + RoachLemon + "," + RoachPlatinum + Becomes + Ammo10mm);
		RegisterRecipeShorthand(AutoPiton + "," + GrapplePiton + "," + Piton + And + Scrap + CountFour + Becomes + TrinketCarabiner);
		RegisterRecipeShorthand(Scanner + "," + Flaregun + "," + Flashlight + And + RoachRuby + "," + RoachGold + "," + RoachLemon + "," + RoachPlatinum + "," + BeansEmpty + "," + MilkEmpty + Becomes + TrinketHeadlamp);
		CombinationRecipe combinationRecipe = RegisterRecipe(new string[3]
		{
			ExactItemInput(BlinkEye, CountOne),
			ExactItemInput(Note, CountOne),
			ItemContainsInput(Scrap, CountOne)
		}, new string[1] { "func:random_trinket" });
		combinationRecipe.CreateFunction = delegate(Vector3 location)
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			string[] array = new string[8] { TrinketCarabiner, TrinketHeadlamp, TrinketChalk, TrinketClimbingShoes, TrinketCalmingBuddy, TrinketHelmet, TrinketMoonRock, TrinketPhotoHome };
			List<Item_Object> list = new List<Item_Object>();
			string[] array2 = array;
			foreach (string text in array2)
			{
				Item_Object itemObjectPrefab = CL_AssetManager.GetItemObjectPrefab(text, "");
				if ((Object)(object)itemObjectPrefab != (Object)null)
				{
					list.Add(itemObjectPrefab);
				}
			}
			if (list.Count > 0)
			{
				GameObject val = Object.Instantiate<GameObject>(((Component)list[Random.Range(0, list.Count)]).gameObject, location, Quaternion.identity, WorldLoader.GetCurrentLevelParentRoot());
				val.transform.localScale = Vector3.one * 0.05f;
				TweenSettingsExtensions.SetEase<TweenerCore<Vector3, Vector3, VectorOptions>>(ShortcutExtensions.DOScale(val.transform, Vector3.one, 0.5f), (Ease)7);
			}
		};
		RegisterRecipeShorthand(FlareAmmo + CountFour + Becomes + PowerCell);
		RegisterRecipeShorthand(PowerCell + Becomes + FlareAmmo + CountFour);
		RegisterRecipeShorthand(Beans + "," + Candy + "," + Meat + "," + Milk + CountTwo + Becomes + FoodBar);
		RegisterRecipeShorthand(FoodBar + "," + Wine + CountThree + Becomes + Injector);
		RegisterRecipeShorthand(FoodBar + "," + Wine + CountTwo + Becomes + PillBottle);
		RegisterRecipeShorthand(FloppyTwo + And + RoachGold + "," + RoachLemon + "," + FloppyOne + Becomes + FloppyThree);
		RegisterRecipeShorthand(FloppyOne + CountTwo + Becomes + FloppyTwo);
		RegisterRecipeShorthand(Note + And + Scrap + Becomes + FloppyOne);
		RegisterRecipeShorthand(Rebar + And + FlareAmmo + CountThree + Becomes + RebarExplosive);
		RegisterRecipeShorthand(Rebar + And + RebarExplosive + Becomes + RebarExplosive);
		RegisterRecipeShorthand(Rebar + CountTwo + Becomes + RebarRope);
		RegisterRecipeShorthand(AutoPiton + CountThree + Becomes + GrapplePiton);
		RegisterRecipe(new string[1] { ExactItemInput(Grub, CountTwo) }, new string[1] { DenizenOutput(GrubSister) });
		RegisterRecipe(new string[1] { ExactItemOptions(CountThree, RoachGold, RoachLemon) }, new string[1] { DenizenOutput(RoachPlatinum) });
		RegisterRecipe(new string[1] { ExactItemInput(RoachPlatinum, CountTwo) }, new string[1] { DenizenOutput(RoachRuby) });
		RegisterRecipe(new string[2]
		{
			ExactItemOptions(CountOne, RoachRuby, RoachGold, RoachLemon, RoachPlatinum),
			ExactItemInput(FlareAmmo, CountOne)
		}, new string[1] { DenizenOutput(RoachRed) });
		RegisterRecipeShorthand(Scrap + "," + Piton + CountThree + Becomes + Rebar);
		RegisterRecipeShorthand(Scrap + CountTwo + Becomes + Piton);
		RegisterRecipeShorthand(Piton + CountTwo + Becomes + AutoPiton);
		RegisterRecipeShorthand(Milk + Becomes + Beans);
		RegisterRecipeShorthand(Beans + Becomes + Milk);
		RegisterRecipeShorthand(RoachGold + CountTen + Becomes + TrinketNugget);
		RegisterRecipeShorthand(Grub + CountTwo + And + GrapplePiton + CountTwo + Becomes + BarnacleHook);
	}

	public static CombinationRecipe RegisterRecipe(string[] inputs, string[] outputs, string[] reservedInputs = null, Action<Vector3> createFunction = null, string[] preservedInputs = null)
	{
		string[] array = inputs ?? new string[0];
		int num = 0;
		string[] array2 = array;
		foreach (string input in array2)
		{
			num += GetInputCount(input, out var _);
		}
		CombinationRecipe combinationRecipe = new CombinationRecipe();
		combinationRecipe.Id = string.Join("+", array);
		combinationRecipe.Inputs = array;
		combinationRecipe.Outputs = NormalizeOutputs(outputs);
		combinationRecipe.ReservedInputs = reservedInputs ?? new string[0];
		combinationRecipe.CreateFunction = createFunction;
		combinationRecipe.InputCount = num;
		combinationRecipe.RegistrationOrder = Recipes.Count;
		combinationRecipe.PreservedInputs = preservedInputs ?? new string[0];
		CombinationRecipe combinationRecipe2 = combinationRecipe;
		Recipes.Add(combinationRecipe2);
		Recipes.Sort(delegate(CombinationRecipe left, CombinationRecipe right)
		{
			int num2 = right.InputCount.CompareTo(left.InputCount);
			return (num2 != 0) ? num2 : left.RegistrationOrder.CompareTo(right.RegistrationOrder);
		});
		return combinationRecipe2;
	}

	private static string[] NormalizeOutputs(string[] outputs)
	{
		string[] array = ((outputs == null) ? new string[0] : ((string[])outputs.Clone()));
		for (int i = 0; i < array.Length; i++)
		{
			string text = array[i];
			if (!string.IsNullOrWhiteSpace(text))
			{
				int num = text.IndexOf(':');
				if (num >= 0 && text.Substring(0, num).Trim().Equals("item", StringComparison.OrdinalIgnoreCase))
				{
					array[i] = text.Substring(0, num + 1) + text.Substring(num + 1).Trim().Trim('"');
				}
			}
		}
		return array;
	}

	public static void EnsureAssets()
	{
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: 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_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		RegisterAllRecipes();
		EnsureCombinedBuffAsset();
		if (!assetRegistered)
		{
			Item_Object itemObjectPrefab = CL_AssetManager.GetItemObjectPrefab("Item_Artifact_Craftcube", "");
			if ((Object)(object)itemObjectPrefab != (Object)null && itemObjectPrefab.itemData != null)
			{
				HandItem handItemAsset = itemObjectPrefab.itemData.handItemAsset;
				HandItem_Crafter val = (HandItem_Crafter)(object)((handItemAsset is HandItem_Crafter) ? handItemAsset : null);
				if (val != null)
				{
					Item_Object component = CloneInactive(((Component)itemObjectPrefab).gameObject).GetComponent<Item_Object>();
					((Object)((Component)component).gameObject).name = ItemId;
					((Object)component).name = ItemId;
					component.itemData = itemObjectPrefab.itemData.GetClone(itemObjectPrefab.itemData, false);
					component.itemData.itemName = ItemId;
					component.itemData.prefabName = ItemId;
					component.itemData.itemTag = "AwakenedAmalgamator";
					component.itemData.itemTags = new List<string> { "AwakenedAmalgamator", "Item" };
					component.itemData.itemAsset = component;
					HandItem_Crafter component2 = CloneInactive(((Component)val).gameObject).GetComponent<HandItem_Crafter>();
					((Object)((Component)component2).gameObject).name = ItemId;
					component2.craftables = new List<Craft_Base>();
					component2.limitToItems = false;
					component2.craftTimer = 1f;
					component2.pickupMask = LayerMask.op_Implicit(LayerMask.op_Implicit(component2.pickupMask) | LayerMask.GetMask(new string[3] { "Interactable", "Interactable Only World Collide", "Pickupable" }));
					component2.tagWhitelist = new List<string>();
					component2.tagBlacklist = new List<string>();
					((HandItem)component2).item = component.itemData;
					component.itemData.handItemAsset = (HandItem)(object)component2;
					((Component)component).gameObject.AddComponent<AwakenedAmalgamatorColorFilter>();
					((Component)component2).gameObject.AddComponent<AwakenedAmalgamatorColorFilter>();
					TintObject(((Component)component).gameObject, PurpleTint);
					TintObject(((Component)component2).gameObject, PurpleTint);
					((Component)component).gameObject.SetActive(false);
					((Component)component2).gameObject.SetActive(false);
					Object.DontDestroyOnLoad((Object)(object)((Component)component).gameObject);
					Object.DontDestroyOnLoad((Object)(object)((Component)component2).gameObject);
					WKAssetDatabase baseAssetDatabase = CL_AssetManager.GetBaseAssetDatabase();
					if ((Object)(object)baseAssetDatabase != (Object)null)
					{
						if (!baseAssetDatabase.itemPrefabs.Contains(((Component)component).gameObject))
						{
							baseAssetDatabase.itemPrefabs.Add(((Component)component).gameObject);
							CL_AssetManager.RefreshDatabaseList();
						}
						assetRegistered = true;
					}
					else
					{
						Object.Destroy((Object)(object)((Component)component).gameObject);
						Object.Destroy((Object)(object)((Component)component2).gameObject);
					}
				}
			}
		}
		EnsureCubeItems();
		EnsureDemalgamatorAsset();
		EnsureHolidayItemAssets();
	}

	private static void EnsureCombinedBuffAsset()
	{
		//IL_017c: 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)
		if (combinedBuffAssetRegistered)
		{
			return;
		}
		Item_Object itemObjectPrefab = CL_AssetManager.GetItemObjectPrefab("Item_Injector", "");
		HandItem_Buff val = (HandItem_Buff)(((Object)(object)itemObjectPrefab == (Object)null || itemObjectPrefab.itemData == null) ? null : /*isinst with value type is only supported in some contexts*/);
		WKAssetDatabase baseAssetDatabase = CL_AssetManager.GetBaseAssetDatabase();
		if (!((Object)(object)itemObjectPrefab == (Object)null) && !((Object)(object)val == (Object)null) && !((Object)(object)baseAssetDatabase == (Object)null))
		{
			Item_Object component = CloneInactive(((Component)itemObjectPrefab).gameObject).GetComponent<Item_Object>();
			((Object)((Component)component).gameObject).name = CombinedBuffItemId;
			((Object)component).name = CombinedBuffItemId;
			component.itemData = itemObjectPrefab.itemData.GetClone(itemObjectPrefab.itemData, false);
			component.itemData.itemName = "Amalgamated Injector";
			component.itemData.prefabName = CombinedBuffItemId;
			component.itemData.itemTag = "Buff";
			component.itemData.itemTags = new List<string> { "Buff", "Item" };
			component.itemData.itemAsset = component;
			HandItem_Buff component2 = CloneInactive(((Component)val).gameObject).GetComponent<HandItem_Buff>();
			((Object)((Component)component2).gameObject).name = "AmalgamatedInjectorHandItem";
			((HandItem)component2).item = component.itemData;
			component.itemData.handItemAsset = (HandItem)(object)component2;
			((Component)component).gameObject.AddComponent<AwakenedAmalgamatorColorFilter>();
			((Component)component2).gameObject.AddComponent<AwakenedAmalgamatorColorFilter>();
			TintObject(((Component)component).gameObject, PurpleTint);
			TintObject(((Component)component2).gameObject, PurpleTint);
			((Component)component).gameObject.SetActive(false);
			((Component)component2).gameObject.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)((Component)component).gameObject);
			Object.DontDestroyOnLoad((Object)(object)((Component)component2).gameObject);
			if (!baseAssetDatabase.itemPrefabs.Contains(((Component)component).gameObject))
			{
				baseAssetDatabase.itemPrefabs.Add(((Component)component).gameObject);
				CL_AssetManager.RefreshDatabaseList();
			}
			combinedBuffAssetRegistered = true;
		}
	}

	private static void TintObject(GameObject root, Color color)
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Expected O, but got Unknown
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true);
		foreach (Renderer val in componentsInChildren)
		{
			SpriteRenderer val2 = (SpriteRenderer)(object)((val is SpriteRenderer) ? val : null);
			if ((Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).GetComponentInParent<Hand_SpriteController>() != (Object)null)
			{
				continue;
			}
			Color val3 = (((Object)(object)val2 == (Object)null) ? color : SpritePurpleTint);
			if ((Object)(object)val2 != (Object)null)
			{
				val2.color = val3;
				val.SetPropertyBlock((MaterialPropertyBlock)null);
				continue;
			}
			MaterialPropertyBlock val4 = new MaterialPropertyBlock();
			val.GetPropertyBlock(val4);
			val4.SetColor("_Color", val3);
			val4.SetColor("_BaseColor", val3);
			val4.SetColor("_TintColor", val3);
			val.SetPropertyBlock(val4);
			if ((Object)(object)val2 == (Object)null)
			{
				SetRendererColor(val, color);
			}
		}
	}

	private static void EnsureCubeItems()
	{
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: 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_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		if (cubeItemsRegistered)
		{
			return;
		}
		WKAssetDatabase baseAssetDatabase = CL_AssetManager.GetBaseAssetDatabase();
		Item_Object itemObjectPrefab = CL_AssetManager.GetItemObjectPrefab("Item_Trinket_Nugget", "");
		HandItem val = (((Object)(object)itemObjectPrefab == (Object)null || itemObjectPrefab.itemData == null) ? null : itemObjectPrefab.itemData.handItemAsset);
		Item_Object itemObjectPrefab2 = CL_AssetManager.GetItemObjectPrefab(ItemId, "");
		amalgamatorSpriteTemplate = (((Object)(object)itemObjectPrefab2 == (Object)null || itemObjectPrefab2.itemData == null) ? null : itemObjectPrefab2.itemData.handItemAsset);
		if ((Object)(object)baseAssetDatabase == (Object)null || (Object)(object)itemObjectPrefab == (Object)null || itemObjectPrefab.itemData == null || (Object)(object)val == (Object)null || (Object)(object)amalgamatorSpriteTemplate == (Object)null)
		{
			return;
		}
		if ((Object)(object)cubeHandSprite == (Object)null)
		{
			cubeHandSprite = CreateCubeSprite();
		}
		if ((Object)(object)cubeShader == (Object)null)
		{
			GameObject assetGameObject = CL_AssetManager.GetAssetGameObject("Prop_Crate_Small_01", "");
			cubeShader = FindCubeShader(assetGameObject);
			if ((Object)(object)cubeShader == (Object)null)
			{
				cubeShader = FindCubeShader(((Component)itemObjectPrefab).gameObject);
			}
		}
		if ((Object)(object)cubeNoiseTexture == (Object)null)
		{
			cubeNoiseTexture = CreateCubeNoiseTexture();
		}
		Item_Object val2 = CL_AssetManager.GetItemObjectPrefab("Item_Amalgamate_CubeBase", "");
		if ((Object)(object)val2 == (Object)null)
		{
			val2 = CloneInactive(((Component)itemObjectPrefab).gameObject).GetComponent<Item_Object>();
			ConfigureCubeItem(val2, itemObjectPrefab, val, "Item_Amalgamate_CubeBase", "Item_Amalgamate_CubeBase", Color.white, 1f);
			((Component)val2).gameObject.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)((Component)val2).gameObject);
			baseAssetDatabase.itemPrefabs.Add(((Component)val2).gameObject);
		}
		CreateCubeItemVariant(val2, "Item_Amalgamate_Pestle", "Amalgamate_Pestle", Color.white, 2f, baseAssetDatabase);
		CreateCubeItemVariant(val2, TimeReagent, "Time Reagent", Color.gray, 1f, baseAssetDatabase);
		CreateCubeItemVariant(val2, PowerReagent, "Power Reagent", new Color(1f, 0.82f, 0.05f, 1f), 1f, baseAssetDatabase);
		CreateCubeItemVariant(val2, MagicReagent, "Magic Reagent", new Color(0.82f, 0.05f, 0.12f, 1f), 1f, baseAssetDatabase);
		CreateCubeItemVariant(val2, BodyReagent, "Body Reagent", new Color(0.12f, 0.35f, 1f, 1f), 1f, baseAssetDatabase);
		CreateCubeItemVariant(val2, SoulReagent, "Soul Reagent", new Color(0.58f, 0.08f, 0.72f, 1f), 1f, baseAssetDatabase);
		CL_AssetManager.RefreshDatabaseList();
		cubeItemsRegistered = true;
	}

	private static void CreateCubeItemVariant(Item_Object cubeBase, string id, string title, Color color, float size, WKAssetDatabase database)
	{
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)CL_AssetManager.GetItemObjectPrefab(id, "") != (Object)null))
		{
			Item_Object component = CloneInactive(((Component)cubeBase).gameObject).GetComponent<Item_Object>();
			((Object)((Component)component).gameObject).name = id;
			((Object)component).name = id;
			component.itemData = cubeBase.itemData.GetClone(cubeBase.itemData, false);
			component.itemData.itemName = title;
			component.itemData.prefabName = id;
			component.itemData.itemTag = "Item";
			component.itemData.itemTags = new List<string> { "Item" };
			component.itemData.itemAsset = component;
			component.itemData.normalSprite = cubeHandSprite;
			component.itemData.handItemAsset = CloneCubeHandItem(cubeBase.itemData.handItemAsset, component.itemData, color, size);
			SetCubeAppearance(((Component)component).gameObject, color, size);
			((Component)component).gameObject.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)((Component)component).gameObject);
			database.itemPrefabs.Add(((Component)component).gameObject);
		}
	}

	private static void ConfigureCubeItem(Item_Object target, Item_Object source, HandItem handTemplate, string id, string title, Color color, float size)
	{
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		((Object)((Component)target).gameObject).name = id;
		((Object)target).name = id;
		target.itemData = source.itemData.GetClone(source.itemData, false);
		target.itemData.itemName = title;
		target.itemData.prefabName = id;
		target.itemData.itemTag = "Item";
		target.itemData.itemTags = new List<string> { "Item" };
		target.itemData.data = new List<string>();
		target.itemData.allowCosmetics = false;
		target.itemData.hasBeenPickedUp = false;
		target.itemData.hasBeenDestroyed = false;
		target.itemData.respawnLimit = -1;
		target.itemData.respawnLimitFlagID = "";
		target.itemData.itemAsset = target;
		target.itemData.normalSprite = cubeHandSprite;
		target.itemData.handItemAsset = CloneCubeHandItem(handTemplate, target.itemData, color, size);
		SetCubeAppearance(((Component)target).gameObject, color, size);
	}

	private static HandItem CloneCubeHandItem(HandItem template, Item item, Color color, float size)
	{
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Expected O, but got Unknown
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_0349: Unknown result type (might be due to invalid IL or missing references)
		//IL_0358: 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_03d9: Unknown result type (might be due to invalid IL or missing references)
		HandItem component = CloneInactive(((Component)template).gameObject).GetComponent<HandItem>();
		component.item = item;
		HandItem_Crafter val = (HandItem_Crafter)(object)((component is HandItem_Crafter) ? component : null);
		if (val != null)
		{
			val.allowCrafting = false;
		}
		Transform[] componentsInChildren = ((Component)component).GetComponentsInChildren<Transform>(true);
		int num = 0;
		Transform[] array = componentsInChildren;
		foreach (Transform val2 in array)
		{
			if ((Object)(object)val2 != (Object)(object)((Component)component).transform && (Object)(object)val2.parent == (Object)(object)((Component)component).transform)
			{
				val2.SetParent((Transform)null, true);
				((Object)val2).name = "RemovedGoldHandVisuals_" + num++;
				Object.Destroy((Object)(object)((Component)val2).gameObject);
			}
		}
		SpriteRenderer val3 = null;
		Hand_SpriteController val4 = null;
		if ((Object)(object)amalgamatorSpriteTemplate != (Object)null)
		{
			Hand_SpriteController[] componentsInChildren2 = ((Component)amalgamatorSpriteTemplate).GetComponentsInChildren<Hand_SpriteController>(true);
			Hand_SpriteController[] array2 = componentsInChildren2;
			foreach (Hand_SpriteController val5 in array2)
			{
				if (((Object)((Component)val5).gameObject).name.ContainsInsensitive("Hand_Foreground"))
				{
					continue;
				}
				if ((Object)(object)val4 == (Object)null)
				{
					val4 = val5;
				}
				Transform val6 = CopySpriteTransformPath(((Component)val5).transform, ((Component)amalgamatorSpriteTemplate).transform, ((Component)component).transform);
				SpriteRenderer component2 = ((Component)val5).GetComponent<SpriteRenderer>();
				if ((Object)(object)val6 != (Object)null && (Object)(object)component2 != (Object)null)
				{
					SpriteRenderer val7 = ((Component)val6).GetComponent<SpriteRenderer>();
					if ((Object)(object)val7 == (Object)null)
					{
						val7 = ((Component)val6).gameObject.AddComponent<SpriteRenderer>();
					}
					CopySpriteRenderer(component2, val7);
					Hand_SpriteController val8 = ((Component)val6).GetComponent<Hand_SpriteController>();
					if ((Object)(object)val8 == (Object)null)
					{
						val8 = ((Component)val6).gameObject.AddComponent<Hand_SpriteController>();
					}
					val8.allowGlobalMaterialAssignments = val5.allowGlobalMaterialAssignments;
					val8.allowCustomStaminaColor = val5.allowCustomStaminaColor;
					val8.spriteName = val5.spriteName;
				}
			}
			SpriteRenderer[] componentsInChildren3 = ((Component)amalgamatorSpriteTemplate).GetComponentsInChildren<SpriteRenderer>(true);
			foreach (SpriteRenderer val9 in componentsInChildren3)
			{
				if (((Object)((Component)val9).gameObject).name.ContainsInsensitive("Item_Cube"))
				{
					val3 = val9;
					break;
				}
			}
		}
		GameObject val10 = new GameObject("Item_Cube_Sprite");
		val10.transform.SetParent(((Component)component).transform, false);
		if ((Object)(object)val3 != (Object)null && (Object)(object)amalgamatorSpriteTemplate != (Object)null)
		{
			val10.transform.localPosition = ((Component)amalgamatorSpriteTemplate).transform.InverseTransformPoint(((Component)val3).transform.position);
			val10.transform.localRotation = Quaternion.Inverse(((Component)amalgamatorSpriteTemplate).transform.rotation) * ((Component)val3).transform.rotation;
			val10.transform.localScale = ((Component)val3).transform.localScale;
		}
		SpriteRenderer val11 = val10.AddComponent<SpriteRenderer>();
		if ((Object)(object)val3 != (Object)null)
		{
			((Renderer)val11).sortingLayerID = ((Renderer)val3).sortingLayerID;
			((Renderer)val11).sortingOrder = ((Renderer)val3).sortingOrder;
			val11.drawMode = val3.drawMode;
			val11.size = val3.size;
		}
		val11.sprite = cubeHandSprite;
		val11.color = color;
		if ((Object)(object)val4 != (Object)null)
		{
			Hand_SpriteController val12 = val10.AddComponent<Hand_SpriteController>();
			val12.allowGlobalMaterialAssignments = val4.allowGlobalMaterialAssignments;
			val12.allowCustomStaminaColor = val4.allowCustomStaminaColor;
			val12.spriteName = val4.spriteName;
		}
		CubeHandSpriteOverride cubeHandSpriteOverride = ((Component)component).gameObject.AddComponent<CubeHandSpriteOverride>();
		cubeHandSpriteOverride.Sprite = cubeHandSprite;
		cubeHandSpriteOverride.Color = color;
		cubeHandSpriteOverride.Size = size;
		cubeHandSpriteOverride.TargetRenderer = val11;
		((Component)component).gameObject.SetActive(false);
		return component;
	}

	private static Transform CopySpriteTransformPath(Transform source, Transform sourceRoot, Transform targetRoot)
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Expected O, but got Unknown
		//IL_0066: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)source == (Object)null || (Object)(object)source == (Object)(object)sourceRoot)
		{
			return targetRoot;
		}
		Transform val = CopySpriteTransformPath(source.parent, sourceRoot, targetRoot);
		Transform val2 = val.Find(((Object)source).name);
		if ((Object)(object)val2 == (Object)null)
		{
			GameObject val3 = new GameObject(((Object)source).name);
			val2 = val3.transform;
			val2.SetParent(val, false);
			val2.localPosition = source.localPosition;
			val2.localRotation = source.localRotation;
			val2.localScale = source.localScale;
		}
		return val2;
	}

	private static void CopySpriteRenderer(SpriteRenderer source, SpriteRenderer target)
	{
		//IL_002d: 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_0088: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)source == (Object)null) && !((Object)(object)target == (Object)null))
		{
			target.sprite = source.sprite;
			target.color = source.color;
			target.flipX = source.flipX;
			target.flipY = source.flipY;
			((Renderer)target).sortingLayerID = ((Renderer)source).sortingLayerID;
			((Renderer)target).sortingOrder = ((Renderer)source).sortingOrder;
			target.drawMode = source.drawMode;
			target.size = source.size;
			target.maskInteraction = source.maskInteraction;
			((Renderer)target).sharedMaterial = ((Renderer)source).sharedMaterial;
		}
	}

	private static void SetCubeAppearance(GameObject root, Color color, float size)
	{
		//IL_00b1: 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_00d3: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: 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_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		Collider[] componentsInChildren = root.GetComponentsInChildren<Collider>(true);
		foreach (Collider val in componentsInChildren)
		{
			if ((Object)(object)((Component)val).gameObject != (Object)(object)root || !(val is BoxCollider))
			{
				Object.Destroy((Object)(object)val);
			}
		}
		Renderer[] componentsInChildren2 = root.GetComponentsInChildren<Renderer>(true);
		foreach (Renderer val2 in componentsInChildren2)
		{
			val2.enabled = false;
		}
		GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3);
		((Object)val3).name = "CubeModel";
		val3.transform.SetParent(root.transform, false);
		val3.transform.localPosition = Vector3.zero;
		val3.transform.localRotation = Quaternion.identity;
		val3.transform.localScale = Vector3.one * 0.06f * size;
		Collider component = val3.GetComponent<Collider>();
		if ((Object)(object)component != (Object)null)
		{
			Object.Destroy((Object)(object)component);
		}
		Renderer component2 = val3.GetComponent<Renderer>();
		if ((Object)(object)cubeShader != (Object)null)
		{
			Material val4 = new Material(cubeShader);
			if ((Object)(object)cubeNoiseTexture != (Object)null)
			{
				if (val4.HasProperty("_MainTex"))
				{
					val4.SetTexture("_MainTex", (Texture)(object)cubeNoiseTexture);
				}
				if (val4.HasProperty("_BaseMap"))
				{
					val4.SetTexture("_BaseMap", (Texture)(object)cubeNoiseTexture);
				}
			}
			component2.material = val4;
		}
		SetRendererColor(component2, color);
		Rigidbody val5 = root.GetComponent<Rigidbody>();
		if ((Object)(object)val5 == (Object)null)
		{
			val5 = root.AddComponent<Rigidbody>();
		}
		val5.useGravity = true;
		val5.isKinematic = false;
		BoxCollider val6 = root.GetComponent<BoxCollider>();
		if ((Object)(object)val6 == (Object)null)
		{
			val6 = root.AddComponent<BoxCollider>();
		}
		val6.center = Vector3.zero;
		val6.size = Vector3.one * 0.06f * size;
		GameEntity component3 = root.GetComponent<GameEntity>();
		if ((Object)(object)component3 != (Object)null)
		{
			component3.entityPrefabID = ((Object)root).name;
			component3.damageable = false;
			component3.health = Mathf.Max(component3.health, 1000f);
			component3.maxHealth = Mathf.Max(component3.maxHealth, 1000f);
			component3.dead = false;
			component3.spawnWithBounds = false;
		}
	}

	private static void UpdateHeldPropCollisions(HandItem_Crafter crafter)
	{
		if ((Object)(object)crafter == (Object)null)
		{
			return;
		}
		ENT_Player playerObject = ENT_Player.playerObject;
		Collider[] array = (Collider[])(((Object)(object)playerObject == (Object)null) ? ((Array)new Collider[0]) : ((Array)((Component)playerObject).GetComponentsInChildren<Collider>(true)));
		Dictionary<long, CollisionPair> dictionary = new Dictionary<long, CollisionPair>();
		List<GameEntity> pickedUp = GetPickedUp(crafter);
		if (pickedUp != null)
		{
			foreach (GameEntity item in pickedUp)
			{
				if ((Object)(object)item == (Object)null || (Object)(object)item == (Object)(object)playerObject)
				{
					continue;
				}
				Collider[] componentsInChildren = ((Component)item).GetComponentsInChildren<Collider>(true);
				Collider[] array2 = componentsInChildren;
				foreach (Collider val in array2)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					Collider[] array3 = array;
					foreach (Collider val2 in array3)
					{
						if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)val))
						{
							long key = ((long)((Object)val).GetInstanceID() << 32) | (uint)((Object)val2).GetInstanceID();
							dictionary[key] = new CollisionPair
							{
								Prop = val,
								Player = val2
							};
						}
					}
				}
			}
		}
		if (!IgnoredPropCollisions.TryGetValue(crafter, out var value))
		{
			value = new Dictionary<long, CollisionPair>();
			IgnoredPropCollisions[crafter] = value;
		}
		foreach (KeyValuePair<long, CollisionPair> item2 in dictionary)
		{
			if (!value.ContainsKey(item2.Key) && (Object)(object)item2.Value.Prop != (Object)null && (Object)(object)item2.Value.Player != (Object)null)
			{
				Physics.IgnoreCollision(item2.Value.Prop, item2.Value.Player, true);
			}
		}
		foreach (KeyValuePair<long, CollisionPair> item3 in value)
		{
			if (!dictionary.ContainsKey(item3.Key) && (Object)(object)item3.Value.Prop != (Object)null && (Object)(object)item3.Value.Player != (Object)null)
			{
				Physics.IgnoreCollision(item3.Value.Prop, item3.Value.Player, false);
			}
		}
		IgnoredPropCollisions[crafter] = dictionary;
	}

	private static Shader FindCubeShader(GameObject source)
	{
		Renderer[] componentsInChildren = source.GetComponentsInChildren<Renderer>(true);
		foreach (Renderer val in componentsInChildren)
		{
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			Material[] sharedMaterials = val.sharedMaterials;
			foreach (Material val2 in sharedMaterials)
			{
				if ((Object)(object)val2 != (Object)null && (val2.HasProperty("_Color") || val2.HasProperty("_BaseColor")))
				{
					return val2.shader;
				}
			}
		}
		return null;
	}

	private static Texture2D CreateCubeNoiseTexture()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		//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)
		Texture2D val = new Texture2D(16, 16, (TextureFormat)4, false);
		((Object)val).name = "AwakenedAmalgamator_CubeNoise";
		((Texture)val).wrapMode = (TextureWrapMode)0;
		((Texture)val).filterMode = (FilterMode)0;
		Random random = new Random(64123);
		Color[] array = (Color[])(object)new Color[256];
		for (int i = 0; i < array.Length; i++)
		{
			float num = Mathf.Lerp(0.5f, 1f, (float)random.NextDouble());
			array[i] = new Color(num, num, num, 1f);
		}
		val.SetPixels(array);
		val.Apply();
		return val;
	}

	private static void SetRendererColor(Renderer renderer, Color color)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)renderer == (Object)null))
		{
			SetMaterialColor(renderer.material, color);
		}
	}

	private static void SetMaterialColor(Material material, Color color)
	{
		//IL_0025: 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_0061: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)material == (Object)null))
		{
			if (material.HasProperty("_Color"))
			{
				material.SetColor("_Color", color);
			}
			if (material.HasProperty("_BaseColor"))
			{
				material.SetColor("_BaseColor", color);
			}
			if (material.HasProperty("_TintColor"))
			{
				material.SetColor("_TintColor", color);
			}
		}
	}

	private static Sprite CreateCubeSprite()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		//IL_001f: 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_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(16, 16, (TextureFormat)4, false);
		Color[] array = (Color[])(object)new Color[256];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = Color.white;
		}
		val.SetPixels(array);
		val.Apply();
		return Sprite.Create(val, new Rect(0f, 0f, 16f, 16f), new Vector2(0.5f, 0.5f), 64f);
	}

	private static GameObject CloneInactive(GameObject source)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		GameObject val = new GameObject("AwakenedAmalgamator_Staging");
		val.SetActive(false);
		GameObject val2 = Object.Instantiate<GameObject>(source, val.transform);
		val2.SetActive(false);
		val2.transform.SetParent((Transform)null, false);
		Object.Destroy((Object)(object)val);
		return val2;
	}

	public static void ApplyColorFilter(SpriteRenderer renderer)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)renderer != (Object)null)
		{
			renderer.color = SpritePurpleTint;
			((Renderer)renderer).SetPropertyBlock((MaterialPropertyBlock)null);
		}
	}

	public static void ApplyModelColorFilter(Renderer renderer)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		//IL_0023: 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_0045: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)renderer == (Object)null))
		{
			MaterialPropertyBlock val = new MaterialPropertyBlock();
			renderer.GetPropertyBlock(val);
			val.SetColor("_Color", PurpleTint);
			val.SetColor("_BaseColor", PurpleTint);
			val.SetColor("_TintColor", PurpleTint);
			renderer.SetPropertyBlock(val);
		}
	}

	private static bool IsAwakened(HandItem_Crafter crafter)
	{
		return (Object)(object)crafter != (Object)null && ((HandItem)crafter).item != null && (((HandItem)crafter).item.prefabName == ItemId || ((HandItem)crafter).item.prefabName == "Item_Demalgamator");
	}

	private static void AddRatKingPickupBlockTag(GameEntity entity)
	{
		if ((Object)(object)entity == (Object)null)
		{
			return;
		}
		ObjectTagger tagger = entity.GetTagger();
		if (!((Object)(object)tagger == (Object)null))
		{
			if (t