Decompiled source of Llong v1.0.2

Mods/Llong.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using Llong;
using Llong.Unlocks;
using MelonLoader;
using Microsoft.CodeAnalysis;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
using nickeltin.SDF.Runtime;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "Llong", "1.0.0", "Orange", null)]
[assembly: MelonGame("Buried Things", "Cursed Words")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Llong")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1d3e7038b164523067d60460b525f11e705c34fd")]
[assembly: AssemblyProduct("Llong")]
[assembly: AssemblyTitle("Llong")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	int ICollection.Count => _items.Length;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

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

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

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

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

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

	bool ICollection<T>.IsReadOnly => true;

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

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

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

	void ICollection.CopyTo(Array array, int index)
	{
		((ICollection)_items).CopyTo(array, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return ((IList)_items).Contains(value);
	}

	int IList.IndexOf(object value)
	{
		return ((IList)_items).IndexOf(value);
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

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

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

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

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

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

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

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

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

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

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Llong
{
	internal class CodeGraveyard
	{
	}
	public class Core : MelonMod
	{
		public static AssetBundle LlongAssetBundle = null;

		public static RuntimeAnimatorController LlongAnimator = null;

		public static Sprite LlongSprite = null;

		public static Sprite LlongDialogueSprite = null;

		public static Sprite LlongDialogueFlipSprite = null;

		public static SDFSpriteMetadataAsset LlongDialogueSdf = null;

		public static SDFSpriteMetadataAsset LlongDialogueFlipSdf = null;

		public static Dictionary<string, Sprite> ItemSprites = new Dictionary<string, Sprite>();

		public static Dictionary<string, SDFSpriteMetadataAsset> ItemSdfs = new Dictionary<string, SDFSpriteMetadataAsset>();

		public static Emotions EmotionLlongFlip = (Emotions)11079;

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("Initialized Llong::Core.");
		}

		public override void OnApplicationStart()
		{
			string text = Path.Combine(new string[2]
			{
				Application.dataPath,
				"../Mods/noodleassets"
			});
			string text2 = Path.Combine(new string[2]
			{
				Application.dataPath,
				"../Mods/Siveran/noodleassets"
			});
			AssetBundle val = AssetBundle.LoadFromFile(text) ?? AssetBundle.LoadFromFile(text2);
			Object[] array;
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Warning("[Llong] We couldn't find the bundle from " + text);
			}
			else
			{
				LlongAssetBundle = val;
				array = val.LoadAllAssets();
				foreach (Object val2 in array)
				{
					MelonLogger.Msg(val2.name);
					if (((object)val2).GetType() == typeof(RuntimeAnimatorController))
					{
						MelonLogger.Msg("[Llong] We found an animator controller!");
						LlongAnimator = (RuntimeAnimatorController)(object)((val2 is RuntimeAnimatorController) ? val2 : null);
					}
					if (((object)val2).GetType() == typeof(Sprite) && val2.name == "Noodle")
					{
						MelonLogger.Msg("[Llong] We found a main sprite!");
						LlongSprite = (Sprite)(object)((val2 is Sprite) ? val2 : null);
					}
				}
			}
			string text3 = Path.Combine(new string[2]
			{
				Application.dataPath,
				"../Mods/noodleitems"
			});
			string text4 = Path.Combine(new string[2]
			{
				Application.dataPath,
				"../Mods/Siveran/noodleitems"
			});
			AssetBundle obj = AssetBundle.LoadFromFile(text3) ?? AssetBundle.LoadFromFile(text4);
			if ((Object)(object)obj == (Object)null)
			{
				MelonLogger.Warning("[Llong] We couldn't find the item bundle from " + text3);
			}
			array = obj.LoadAllAssets();
			foreach (Object val3 in array)
			{
				if (((object)val3).GetType() == typeof(Sprite))
				{
					if (val3.name == "NoodleDialogue2")
					{
						MelonLogger.Msg("[Llong] We found a dialogue sprite!");
						LlongDialogueSprite = (Sprite)(object)((val3 is Sprite) ? val3 : null);
					}
					else if (val3.name == "NoodleDialogue1")
					{
						MelonLogger.Msg("[Llong] We found a flipped dialogue sprite!");
						LlongDialogueFlipSprite = (Sprite)(object)((val3 is Sprite) ? val3 : null);
					}
					else if (!val3.name.Contains("(SDFSprite)"))
					{
						MelonLogger.Msg("[Llong] The items file had a Sprite named " + val3.name + "!");
						ItemSprites[val3.name] = (Sprite)(object)((val3 is Sprite) ? val3 : null);
					}
				}
				else if (((object)val3).GetType() == typeof(SDFSpriteMetadataAsset))
				{
					string text5 = StringUtility.PartBefore(val3.name, '(');
					if (text5 == "NoodleDialogue2")
					{
						MelonLogger.Msg("[Llong] We found a dialogue SDF!");
						LlongDialogueSdf = (SDFSpriteMetadataAsset)(object)((val3 is SDFSpriteMetadataAsset) ? val3 : null);
					}
					else if (text5 == "NoodleDialogue1")
					{
						MelonLogger.Msg("[Llong] We found a flipped dialogue SDF!");
						LlongDialogueFlipSdf = (SDFSpriteMetadataAsset)(object)((val3 is SDFSpriteMetadataAsset) ? val3 : null);
					}
					else
					{
						MelonLogger.Msg("[Llong] The items file had an SDF named " + val3.name + "!");
						ItemSdfs[StringUtility.PartBefore(val3.name, '(')] = (SDFSpriteMetadataAsset)(object)((val3 is SDFSpriteMetadataAsset) ? val3 : null);
					}
				}
			}
		}

		public static Type GetType(string typeName)
		{
			return Assembly.GetExecutingAssembly().GetType(typeName);
		}
	}
	[HarmonyPatch(typeof(RunsHistoryController), "PopulateOverallStats")]
	internal static class RunsHistoryController_PopulateOverallStats_Patch
	{
		private static void Postfix(Image ____mostPlayedCharacterPortrait)
		{
			if (SaveManager.GetMostPlayedCharacterType() == typeof(LlongCharacter))
			{
				____mostPlayedCharacterPortrait.sprite = Core.LlongDialogueFlipSprite;
			}
		}
	}
	[HarmonyPatch(typeof(RunParentController), "GetPortraitSprite")]
	internal static class RunParentController_GetPortraitSprite_Patch
	{
		private static bool Prefix(out SDFSpriteMetadataAsset __result, Character c)
		{
			if (c.GetName() == "Llong" && Object.op_Implicit((Object)(object)Core.LlongDialogueFlipSdf))
			{
				__result = Core.LlongDialogueFlipSdf;
				return false;
			}
			__result = null;
			return true;
		}
	}
	[HarmonyPatch(typeof(DialogueUtility), "GetEmotionSprite")]
	internal static class DialogueUtility_GetEmotionSprite_Patch
	{
		private static bool Prefix(out Sprite __result, Emotions emotion)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (emotion == Core.EmotionLlongFlip)
			{
				__result = Core.LlongDialogueFlipSprite;
				return false;
			}
			__result = null;
			return true;
		}
	}
	[HarmonyPatch(typeof(ContinueRunDetails), "OnEnable")]
	internal static class ContinueRunDetails_OnEnable_Patch
	{
		private static void Postfix(Image ____characterImage)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if ((int)SaveManager.GetCurrentRun().MyCharacter.MyEmotion == 0)
			{
				____characterImage.sprite = Core.LlongDialogueFlipSprite;
			}
		}
	}
	[HarmonyPatch(typeof(DialogueUtility), "GetEmotionSDFSprite")]
	internal static class DialogueUtility_GetEmotionSDFSprite_Patch
	{
		private static bool Prefix(out SDFSpriteMetadataAsset __result, Emotions emotion)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (emotion == Core.EmotionLlongFlip)
			{
				__result = Core.LlongDialogueFlipSdf;
				return false;
			}
			__result = null;
			return true;
		}
	}
	[HarmonyPatch(typeof(ItemSpriteData), "GetSDFSprite")]
	internal static class ItemSpriteData_GetSDFSprite_Patch
	{
		private static void Prefix(ItemSpriteData __instance)
		{
			if (__instance.AssetPath == "BLACKHOLE")
			{
				LlongItemData llongItemData = __instance as LlongItemData;
				if (Object.op_Implicit((Object)(object)llongItemData.TrueSDF))
				{
					((ItemSpriteData)llongItemData).ItemSDFSprite = llongItemData.TrueSDF;
				}
			}
		}
	}
	[HarmonyPatch(typeof(ItemSpriteData), "GetSprite")]
	internal static class ItemSpriteData_GetSprite_Patch
	{
		private static void Prefix(ItemSpriteData __instance)
		{
			if (__instance.AssetPath == "BLACKHOLE")
			{
				LlongItemData llongItemData = __instance as LlongItemData;
				if (Object.op_Implicit((Object)(object)llongItemData.TrueSprite))
				{
					((ItemSpriteData)llongItemData).ItemSprite = llongItemData.TrueSprite;
				}
			}
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPatch(new Type[] { })]
	internal static class Assembly_GetTypes_Patch
	{
		private static void Postfix(Assembly __instance, ref Type[] __result)
		{
			if (__instance.GetName().Name == "Assembly-CSharp")
			{
				Type[] array = __result;
				Type[] types = Assembly.GetAssembly(typeof(LlongCharacter)).GetTypes();
				int num = 0;
				Type[] array2 = new Type[array.Length + types.Length];
				ReadOnlySpan<Type> readOnlySpan = new ReadOnlySpan<Type>(array);
				readOnlySpan.CopyTo(new Span<Type>(array2).Slice(num, readOnlySpan.Length));
				num += readOnlySpan.Length;
				ReadOnlySpan<Type> readOnlySpan2 = new ReadOnlySpan<Type>(types);
				readOnlySpan2.CopyTo(new Span<Type>(array2).Slice(num, readOnlySpan2.Length));
				num += readOnlySpan2.Length;
				__result = array2;
			}
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPatch(new Type[] { typeof(string) })]
	internal static class Type_GetType_Patch
	{
		private static bool Prefix(string typeName, ref Type __result)
		{
			if (typeName.StartsWith("Llong."))
			{
				__result = Core.GetType(typeName);
				return false;
			}
			__result = null;
			return true;
		}
	}
	[HarmonyPatch(typeof(CharacterSelectController), "GetCharacters")]
	internal static class CharacterSelectController_GetCharacters_Patch
	{
		private static void Postfix(Dictionary<Type, bool> ____characters)
		{
			MelonLogger.Msg("[Llong] Allowing Llong to be selected");
			____characters[typeof(LlongCharacter)] = true;
		}
	}
	[HarmonyPatch(typeof(SaveManager), "LoadSaveFromFile")]
	internal static class SaveManager_LoadSaveFromFile_Patch
	{
		private static void Postfix(SaveFile ____saveFile)
		{
			if (!____saveFile.CharacterHighestCompletedAscensions.ContainsKey(typeof(LlongCharacter)))
			{
				MelonLogger.Msg("[Llong] Added Llong to the save");
				SaveManager.AddCharacterToUnlockedCharacters(typeof(LlongCharacter));
			}
			else
			{
				MelonLogger.Msg("[Llong] Saw Llong in the save");
			}
		}
	}
	[HarmonyPatch(typeof(TooltipController), "GetAppropriateToolTips")]
	internal static class TooltipController_GetAppropriateToolTips_Patch
	{
		private static void Prefix(ref Dictionary<Type, List<(string, Emotions)>> ____characterSpecificToolTips)
		{
			//IL_0035: 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)
			MelonLogger.Msg("[Llong] Adding Llong tooltips");
			if (!____characterSpecificToolTips.ContainsKey(typeof(LlongCharacter)))
			{
				____characterSpecificToolTips.Add(typeof(LlongCharacter), new List<(string, Emotions)>(2)
				{
					("Stretched letters are ALWAYS ignored when checking the dictionary", Core.EmotionLlongFlip),
					("Numbers don't count stretched letters", Core.EmotionLlongFlip)
				});
			}
		}
	}
	[HarmonyPatch(typeof(IDCard))]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal static class IDCard_CTOR_Patch
	{
		private static void Postfix(IDCard __instance)
		{
			MelonLogger.Msg("[Llong] Adding Llong's ID card");
			__instance.CharacterToSpriteUsage.Add(typeof(LlongCharacter), (ItemSpriteUsage)0);
		}
	}
	public class LlongCharacter : Character
	{
		public LlongCharacter()
			: base("Llong", "", "After his most recent decades-long slumber, Llong seeks to get updated on all the recent slang to become keeeeeen and groooooooooovy again.<br><br>...Llong you're covering up four people please move.", (Item)(object)new Spaghetti(), "llong", Color32.op_Implicit(new Color32((byte)86, (byte)63, (byte)115, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)171, (byte)150, (byte)136, byte.MaxValue)), new Vector3(-30f, 150f, 0f), new Vector3(230f, 400f, 0f), new List<Type>(4)
			{
				typeof(YellowGlasses),
				typeof(FishCake),
				typeof(AprilShower),
				typeof(GraduationCap)
			}, Core.EmotionLlongFlip, false, "")
		{
		}//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: 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_0048: 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_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)


		public override RuntimeAnimatorController GetRuntimeAnimatorController()
		{
			if (Object.op_Implicit((Object)(object)Core.LlongAnimator))
			{
				Character.CharacterRuntimeAnimators[typeof(LlongCharacter)] = Core.LlongAnimator;
				return Core.LlongAnimator;
			}
			MelonLogger.Warning("[Llong] No animation found! Are the assets in the Mods/ folder?");
			return ((Character)Activator.CreateInstance<BonesTheDog>()).GetRuntimeAnimatorController();
		}

		public override SDFSpriteMetadataAsset GetCharacterSDFSprite()
		{
			return ((Character)Activator.CreateInstance<BonesTheDog>()).GetCharacterSDFSprite();
		}

		public override Sprite GetCharacterSprite()
		{
			if (Object.op_Implicit((Object)(object)Core.LlongSprite))
			{
				Character.CharacterRuntimeAnimators[typeof(LlongCharacter)] = Core.LlongAnimator;
				return Core.LlongSprite;
			}
			MelonLogger.Warning("[Llong] No sprite found! Are the assets in the Mods/ folder?");
			return ((Character)Activator.CreateInstance<BonesTheDog>()).GetCharacterSprite();
		}
	}
	internal class Stretchability
	{
		public static int CurrentStretchability;

		private const int MAX_STRETCHABILITY_CACHE = 3;

		private static Dictionary<InventoryCache, int> StretchabilityCache = new Dictionary<InventoryCache, int>();

		private static readonly List<InventoryCache> InventoryCaches = new List<InventoryCache>();

		private static int NextIndexToSet = 0;

		public static void CacheStretchability(InventoryCache inventoryCache, int stretchability)
		{
			if (InventoryCaches.Count > NextIndexToSet)
			{
				StretchabilityCache.Remove(InventoryCaches[NextIndexToSet]);
				InventoryCaches.RemoveAt(NextIndexToSet);
			}
			InventoryCaches.Insert(NextIndexToSet, inventoryCache);
			StretchabilityCache.Add(inventoryCache, stretchability);
			NextIndexToSet = (NextIndexToSet + 1) % 3;
			CurrentStretchability = stretchability;
		}

		public static int GetStretchability(InventoryCache inventoryCache)
		{
			if (!StretchabilityCache.ContainsKey(inventoryCache))
			{
				MelonLogger.Warning("Couldn't find a cached inventory when looking up stretchability! This is likely due to a mod conflict with Llong and something else. Defaulting to current stretchability.");
				return CurrentStretchability;
			}
			return StretchabilityCache[inventoryCache];
		}

		public static List<Tile> ApplyStretching(List<Tile> tiles, InventoryCache inventoryCache)
		{
			return ApplyStretching(tiles, GetStretchability(inventoryCache));
		}

		public static List<Tile> ApplyStretching(List<Tile> tiles, int stretchability)
		{
			if (stretchability == 0)
			{
				return tiles;
			}
			List<Tile> list = new List<Tile>();
			Tile val = null;
			int num = 0;
			for (int i = 0; i < tiles.Count; i++)
			{
				if (val != null && val.GetStringRepresentation(false) == tiles[i].GetStringRepresentation(false))
				{
					if (num < stretchability)
					{
						num++;
					}
					else
					{
						num = 0;
						list.Add(tiles[i]);
					}
				}
				else
				{
					num = 0;
					list.Add(tiles[i]);
				}
				val = tiles[i];
			}
			return list;
		}

		public static int GetStretchedLength(List<Tile> tiles, int stretchability, int unstretchedLength)
		{
			string text = null;
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			for (int i = 0; i < tiles.Count; i++)
			{
				string stringRepresentation = tiles[i].GetStringRepresentation(false);
				if (text == stringRepresentation)
				{
					if (num2 < stretchability)
					{
						num2++;
					}
					else
					{
						num2 = 0;
						num++;
					}
				}
				else
				{
					num2 = 0;
					num++;
				}
				text = stringRepresentation;
				if (num > unstretchedLength)
				{
					break;
				}
				num3++;
			}
			return num3;
		}

		public static int GetStretchedLength(List<Tile> tiles, InventoryCache inventoryCache, int unstretchedLength)
		{
			return GetStretchedLength(tiles, GetStretchability(inventoryCache), unstretchedLength);
		}

		public static int GetStretchabilityFromItems(List<Item> items)
		{
			int num = 0;
			Item val = items.Find((Item item) => item is Spaghetti);
			if (val != null)
			{
				num += val.UpgradeableComponents[0].VariableValue;
			}
			Item val2 = items.Find((Item item) => item is YoYo);
			if (val2 != null)
			{
				num += val2.UpgradeableComponents[0].VariableValue;
			}
			return num;
		}
	}
	[HarmonyPatch(typeof(InventoryCache))]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPatch(new Type[] { typeof(IEnumerable<Tile>) })]
	internal class InventoryCache_CTOR_Patch
	{
		private static void Postfix(IEnumerable<Tile> currentWordTiles, InventoryCache __instance)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			List<Item> allItems = GameStatics.GetPlayer().GetAllItems(false);
			foreach (Tile currentWordTile in currentWordTiles)
			{
				if ((int)currentWordTile.GetGlyphType() == 8)
				{
					allItems.Add(currentWordTile.ScatteredItem);
				}
			}
			Item val = allItems.Find((Item item) => item is RandomAccessMemory);
			Item val2 = allItems.Find((Item item) => item is Snapshot);
			List<Item> list = allItems.Where((Item item) => item is Frankenstein).ToList();
			if (val != null)
			{
				RandomAccessMemory val3 = (RandomAccessMemory)(object)((val is RandomAccessMemory) ? val : null);
				allItems.AddRange(val3.ItemsInMemory);
			}
			if (val2 != null)
			{
				Snapshot val4 = (Snapshot)(object)((val2 is Snapshot) ? val2 : null);
				if (val4.SnapshottedItem != null)
				{
					allItems.Add(val4.SnapshottedItem);
				}
			}
			foreach (Item item in list)
			{
				Frankenstein val5 = (Frankenstein)(object)((item is Frankenstein) ? item : null);
				allItems.AddRange(val5.StitchedItems);
			}
			int stretchabilityFromItems = Stretchability.GetStretchabilityFromItems(allItems);
			Stretchability.CacheStretchability(__instance, stretchabilityFromItems);
		}
	}
	[HarmonyPatch(typeof(Vocabulary), "IsWordContainedInList")]
	internal class Vocabulary_IsWordContainedInList_Patch
	{
		private static void Prefix(ref List<Tile> tiles, InventoryCache inventoryCache)
		{
			tiles = Stretchability.ApplyStretching(tiles, Stretchability.GetStretchability(inventoryCache));
		}
	}
	[HarmonyPatch(typeof(Vocabulary), "TryGetAccumulatorWordFromTiles")]
	internal class Vocabulary_TryGetAccumulatorWordFromTiles_Patch
	{
		private static void Prefix(ref List<Tile> tiles, InventoryCache inventoryCache)
		{
			tiles = Stretchability.ApplyStretching(tiles, Stretchability.GetStretchability(inventoryCache));
		}
	}
	[HarmonyPatch(typeof(Vocabulary), "GetConcatenatedValidWordsFromTiles")]
	internal class Vocabulary_GetConcatenatedValidWordsFromTiles_Patch
	{
		public static bool Prefix(ref List<Tile> tiles, List<BossModifier> bossModifiers, out List<string> __result)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Expected O, but got Unknown
			InventoryCache val = new InventoryCache((IEnumerable<Tile>)tiles);
			if (Stretchability.GetStretchability(val) == 0)
			{
				__result = new List<string>();
				return true;
			}
			val.PertinentAccumulatorWords.Clear();
			List<string> list2 = val.PertinentAccumulatorPairs.Select((List<string> list) => list[0]).ToList();
			List<string> list3 = val.PertinentAccumulatorPairs.Select((List<string> list) => list[1]).ToList();
			MethodInfo methodInfo = AccessTools.Method(typeof(Vocabulary), "TryGetAccumulatorWordFromTiles", new Type[2]
			{
				typeof(InventoryCache),
				typeof(List<Tile>)
			}, (Type[])null);
			foreach (string item3 in list2)
			{
				val.PertinentAccumulatorWords.Clear();
				val.PertinentAccumulatorWords.Add(item3);
				int stretchedLength = Stretchability.GetStretchedLength(tiles, val, item3.Length);
				if (methodInfo.Invoke(null, new object[2]
				{
					val,
					tiles.Take(stretchedLength)
				}) is string item)
				{
					int index = list2.IndexOf(item3);
					val.PertinentAccumulatorWords.Clear();
					val.PertinentAccumulatorWords.Add(list3[index]);
					if (methodInfo.Invoke(null, new object[2]
					{
						val,
						tiles.Skip(stretchedLength)
					}) is string item2)
					{
						__result = new List<string> { item, item2 };
						return false;
					}
				}
			}
			InventoryCache val2 = new InventoryCache((IEnumerable<Tile>)tiles);
			string validWordFromTiles = Vocabulary.GetValidWordFromTiles((IEnumerable<Tile>)tiles, bossModifiers, val2);
			if (validWordFromTiles != null)
			{
				__result = new List<string> { validWordFromTiles };
				return false;
			}
			val2.PertinentAccumulatorWords.Clear();
			List<Tile> source = Stretchability.ApplyStretching(tiles, val2);
			for (int i = 1; i < source.Count(); i++)
			{
				int stretchedLength2 = Stretchability.GetStretchedLength(tiles, val2, i);
				string validWordFromTiles2 = Vocabulary.GetValidWordFromTiles((IEnumerable<Tile>)tiles.Take(stretchedLength2).ToList(), bossModifiers, val2);
				if (validWordFromTiles2 != null)
				{
					string validWordFromTiles3 = Vocabulary.GetValidWordFromTiles((IEnumerable<Tile>)tiles.Skip(stretchedLength2).ToList(), bossModifiers, val2);
					if (validWordFromTiles3 != null)
					{
						__result = new List<string> { validWordFromTiles2, validWordFromTiles3 };
						return false;
					}
				}
			}
			__result = null;
			return false;
		}
	}
	[HarmonyPatch(typeof(WordLetterController), "Populate")]
	internal class WordLetterController_Populate_Patch
	{
		private static void Prefix(Tile tile, TileSelection tileSelection)
		{
			tileSelection.IsWobbly = tile.IsDisplayingAsVariableLetter((TileSelectionManager)null);
		}
	}
	[HarmonyPatch(typeof(Tile), "IsDisplayingAsVariableLetter")]
	internal class Tile_IsDisplayingAsVariableLetter_Patch
	{
		private static bool Prefix(ref bool __result, Tile __instance, TileSelectionManager tileSelectionManager = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			if ((int)__instance.MyGlyphType == 8)
			{
				return true;
			}
			List<Item> allItems = GameStatics.GetPlayer().GetAllItems(false);
			if ((Object)(object)tileSelectionManager == (Object)null)
			{
				tileSelectionManager = Object.FindFirstObjectByType<TileSelectionManager>();
			}
			if ((Object)(object)tileSelectionManager != (Object)null)
			{
				foreach (Tile tilesFromSelectedTile in tileSelectionManager.GetTilesFromSelectedTiles())
				{
					if ((int)tilesFromSelectedTile.GetGlyphType() == 8)
					{
						allItems.Add(tilesFromSelectedTile.ScatteredItem);
					}
				}
			}
			Item val = allItems.Find((Item item) => item is RandomAccessMemory);
			Item val2 = allItems.Find((Item item) => item is Snapshot);
			allItems.Where((Item item) => item is Frankenstein).ToList();
			if (val != null)
			{
				RandomAccessMemory val3 = (RandomAccessMemory)(object)((val is RandomAccessMemory) ? val : null);
				allItems.AddRange(val3.ItemsInMemory);
			}
			if (val2 != null)
			{
				Snapshot val4 = (Snapshot)(object)((val2 is Snapshot) ? val2 : null);
				if (val4.SnapshottedItem != null)
				{
					allItems.Add(val4.SnapshottedItem);
				}
			}
			int stretchabilityFromItems = Stretchability.GetStretchabilityFromItems(allItems);
			if (stretchabilityFromItems == 0 || (Object)(object)tileSelectionManager == (Object)null)
			{
				return true;
			}
			List<Tile> tilesFromSelectedTiles = tileSelectionManager.GetTilesFromSelectedTiles();
			if (tilesFromSelectedTiles.Contains(__instance))
			{
				Tile val5 = null;
				int num = 0;
				for (int i = 0; i < tilesFromSelectedTiles.Count; i++)
				{
					num = ((val5 != null && val5.GetStringRepresentation(false) == tilesFromSelectedTiles[i].GetStringRepresentation(false)) ? ((num < stretchabilityFromItems) ? (num + 1) : 0) : 0);
					if (tilesFromSelectedTiles[i] == __instance)
					{
						if (num > 0)
						{
							__result = true;
							return false;
						}
						return true;
					}
					val5 = tilesFromSelectedTiles[i];
				}
				return true;
			}
			if (tilesFromSelectedTiles.Count == 0)
			{
				return true;
			}
			string stringRepresentation = tilesFromSelectedTiles[tilesFromSelectedTiles.Count - 1].GetStringRepresentation(false);
			if (stringRepresentation != __instance.GetStringRepresentation(false))
			{
				return true;
			}
			int num2 = 0;
			int num3 = tilesFromSelectedTiles.Count - 2;
			while (num3 >= 0 && tilesFromSelectedTiles[num3].GetStringRepresentation(false) == stringRepresentation)
			{
				num2 = ((num2 != stretchabilityFromItems) ? (num2 + 1) : 0);
				num3--;
			}
			if (num2 < stretchabilityFromItems)
			{
				__result = true;
				return false;
			}
			return true;
		}
	}
}
namespace Llong.Unlocks
{
	internal class LlongItemData : ItemSpriteData
	{
		public string TrueName;

		public Sprite TrueSprite;

		public SDFSpriteMetadataAsset TrueSDF;

		public LlongItemData(ItemSpriteUsage usage, string assetPath)
			: base(usage, assetPath)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			TrueName = assetPath;
			base.Usage = usage;
			base.AssetPath = "BLACKHOLE";
			if (Core.ItemSprites.ContainsKey(assetPath))
			{
				TrueSprite = Core.ItemSprites[assetPath];
			}
			if (Core.ItemSdfs.ContainsKey(assetPath))
			{
				TrueSDF = Core.ItemSdfs[assetPath];
			}
		}
	}
	internal class Spaghetti : Item
	{
		public Spaghetti()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			base.Name = "Spaghetti";
			base.SpriteData.Add((ItemSpriteData)(object)new LlongItemData((ItemSpriteUsage)0, "spaghetti"));
			base.Rarity = (ItemRarity)4;
			base.UpgradeableComponents = new List<UpgradeableComponent>(2)
			{
				new UpgradeableComponent(1, 1, 1),
				new UpgradeableComponent(1, 1, 1)
			};
			base.PinColors = new List<Color>(2)
			{
				Color32.op_Implicit(new Color32((byte)110, byte.MaxValue, (byte)60, byte.MaxValue)),
				Color32.op_Implicit(new Color32((byte)230, (byte)191, (byte)85, byte.MaxValue))
			};
			base.ItemFunctionTags = new List<ItemFunctionTag>();
		}

		public override string GetDescription()
		{
			string text = string.Format("You can stretch each letter up to {0}{1}{2} time{3}", GameStatics.ZeroWidthCharacter, base.UpgradeableComponents[0].VariableValue, GameStatics.ZeroWidthCharacter, Item.CheckPlural("s", base.UpgradeableComponents[0].VariableValue));
			if (base.UpgradeableComponents[1].VariableValue > 1)
			{
				string text2 = string.Format("Repeated letters get {0}x{1}{2} TILE SCORE", new object[3]
				{
					GameStatics.ZeroWidthCharacter,
					base.UpgradeableComponents[1].VariableValue,
					GameStatics.ZeroWidthCharacter
				});
				text = string.Join(". ", text, text2);
			}
			return text;
		}

		public override void Upgrade(int componentIndex, bool upgradingBoth = false)
		{
			if (upgradingBoth)
			{
				((Item)this).Upgrade(0, false);
				((Item)this).Upgrade(1, false);
				return;
			}
			((Item)this).Upgrade(componentIndex, false);
			if (base.UpgradeableComponents[1].Level >= 2 && !base.ItemFunctionTags.Contains((ItemFunctionTag)2))
			{
				base.ItemFunctionTags.Add((ItemFunctionTag)2);
			}
		}

		public override void ApplyTileBonus(ScoreCalcVizInfo step, int index, List<Tile> tiles, List<TileSelection> selections, List<HistoricWord> previousWords, GridData gridData)
		{
			if (tiles.Count > 1 && ((index > 0 && tiles[index].GetStringRepresentation(false) == tiles[index - 1].GetStringRepresentation(false)) || (index + 1 < tiles.Count && tiles[index].GetStringRepresentation(false) == tiles[index + 1].GetStringRepresentation(false))))
			{
				List<ScorePacket> tileScores = step.TileScores;
				tileScores[index] *= (long)base.UpgradeableComponents[1].VariableValue;
				step.TileScoreMultipliers[index] = base.UpgradeableComponents[1].VariableValue;
			}
		}
	}
	internal class Atria : Item
	{
		public Atria()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			base.Name = "Atria";
			base.SpriteData.Add((ItemSpriteData)(object)new LlongItemData((ItemSpriteUsage)0, "revolvinghearts"));
			base.Rarity = (ItemRarity)0;
			base.Cost = 9;
			base.Tags = new List<ItemTag>(2)
			{
				(ItemTag)20,
				(ItemTag)21
			};
			base.DependencyTags = new List<ItemTag>();
			base.UpgradeableComponents.Add(new UpgradeableComponent(1, 2, 2));
			base.ItemFunctionTags = new List<ItemFunctionTag>(1) { (ItemFunctionTag)4 };
			base.RelevantColours = new List<TileType>();
		}

		public override string GetDescription()
		{
			return $"Each set of repeated letters scatters {GameStatics.ZeroWidthCharacter}{base.UpgradeableComponents[0].VariableValue}{GameStatics.ZeroWidthCharacter} {PlayingCardUtility.GetFontTaggedSuitIcon((Suit)3)}s onto the next grid";
		}

		private int CountRepeatSets(List<Tile> tiles)
		{
			string text = null;
			string text2 = null;
			bool flag = false;
			int num = 0;
			for (int i = 0; i < tiles.Count; i++)
			{
				text2 = tiles[i].GetStringRepresentation(false);
				if (text == text2)
				{
					if (!flag)
					{
						num++;
						flag = true;
					}
				}
				else
				{
					flag = false;
				}
				text = text2;
			}
			return num;
		}

		public override GridData ApplyStartOfGridEffect(GridData gridData, int gridNumber, int numberOfGrids, List<HistoricWord> previousWords, List<BoardGenVizInfo> vizSteps, bool isReroll)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			if (previousWords.Count == 0)
			{
				return gridData;
			}
			int num = CountRepeatSets(previousWords[previousWords.Count - 1].Tiles);
			if (num == 0)
			{
				return gridData;
			}
			List<Tile> list = new List<Tile>();
			for (int i = 0; i < num * base.UpgradeableComponents[0].VariableValue; i++)
			{
				Tile tileForItemScatter = GridUtility.Singleton.GetTileForItemScatter(gridData, (TileType)0, (GlyphType)9, (List<Tile>)null, true);
				if (tileForItemScatter != null)
				{
					tileForItemScatter.SetSuit((Suit)3);
					list.Add(tileForItemScatter);
				}
			}
			if (list.Count > 0)
			{
				vizSteps.Add(new BoardGenVizInfo(gridData, (Item)(object)this, list, false, (Type)null, false, false, true, vizSteps[vizSteps.Count - 1].PlayerConsumableTiles));
			}
			return gridData;
		}
	}
	internal class AtriaUnlock : Achievement
	{
		public AtriaUnlock()
		{
			base.Name = "Contract and Expand";
			base.SteamAchievementName = "ACH_INVITATION_ONLY";
			base.TypeOfItemUnlocked = typeof(Atria);
			base.IsCrownReward = true;
			base.CrownRewardLevel = 5;
			base.CrownRewardCharacter = (Character)(object)new LlongCharacter();
		}
	}
	internal class Bookkeeper : Item
	{
		public List<Tile> TilesFound = new List<Tile>();

		public Bookkeeper()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			base.Name = "Bookkeeper";
			base.SpriteData.Add((ItemSpriteData)(object)new LlongItemData((ItemSpriteUsage)0, "books"));
			base.Rarity = (ItemRarity)2;
			base.Cost = 30;
			base.Tags = new List<ItemTag>();
			base.DependencyTags = new List<ItemTag>();
			base.ItemFunctionTags = new List<ItemFunctionTag>(1) { (ItemFunctionTag)4 };
			base.RelevantColours = new List<TileType>();
		}

		public override string GetDescription()
		{
			string text = ((TilesFound.Count <= 0) ? "Does nothing" : ("Scatters: " + string.Join(", ", TilesFound.Select((Tile tile) => tile.GetStringRepresentation(false).ToUpper()))));
			return string.Join("<br><br>", text, "(Submit a word with a double letter to improve this)");
		}

		public override GridData ApplyStartOfGridEffect(GridData gridData, int gridNumber, int numberOfGrids, List<HistoricWord> previousWords, List<BoardGenVizInfo> vizSteps, bool isReroll)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			List<Tile> list = new List<Tile>();
			for (int i = 0; i < TilesFound.Count; i++)
			{
				Tile val = TilesFound[i];
				Tile tileForItemScatter = GridUtility.Singleton.GetTileForItemScatter(gridData, val.GetTileType(), val.GetGlyphType(), (List<Tile>)null, true);
				if (tileForItemScatter != null)
				{
					tileForItemScatter.SetAsCopy(TilesFound[i], false);
					list.Add(tileForItemScatter);
				}
			}
			if (list.Count > 0)
			{
				vizSteps.Add(new BoardGenVizInfo(gridData, (Item)(object)this, list, false, (Type)null, false, false, false, vizSteps[vizSteps.Count - 1].PlayerConsumableTiles));
			}
			return gridData;
		}

		public override void ApplyWordBonus(ScoreCalcVizInfo step, int gridNumber, List<Tile> tiles, List<string> words, List<TileSelection> selections, List<HistoricWord> previousWords, GridData gridData)
		{
			if (tiles.Count < 2)
			{
				return;
			}
			string text = null;
			int num = 0;
			for (int i = 0; i < tiles.Count; i++)
			{
				string stringRepresentation = tiles[i].GetStringRepresentation(false);
				if (text == stringRepresentation)
				{
					TilesFound.Add(tiles[i - 1]);
					num = i;
					break;
				}
				text = stringRepresentation;
			}
			if (num > 0)
			{
				step.RelevantItem = (Item)(object)this;
				step.LettersInWordToPulse = new List<Tile>(2)
				{
					tiles[num - 1],
					tiles[num]
				};
			}
		}
	}
	internal class BookkeeperUnlock : Achievement
	{
		public BookkeeperUnlock()
		{
			base.Name = "Knowledge Hoard";
			base.SteamAchievementName = "ACH_INVITATION_ONLY";
			base.TypeOfItemUnlocked = typeof(Bookkeeper);
			base.IsCrownReward = true;
			base.CrownRewardLevel = 7;
			base.CrownRewardCharacter = (Character)(object)new LlongCharacter();
		}
	}
	internal class ChosenOne : Item
	{
		public string ChosenLetter = "";

		public int ChosenTotal;

		public ChosenOne()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			base.Name = "Chosen One";
			base.SpriteData.Add((ItemSpriteData)(object)new LlongItemData((ItemSpriteUsage)0, "person"));
			base.Rarity = (ItemRarity)1;
			base.Cost = 16;
			base.Tags = new List<ItemTag>();
			base.DependencyTags = new List<ItemTag>();
			base.UpgradeableComponents = new List<UpgradeableComponent>(1)
			{
				new UpgradeableComponent(1, 1, 1)
			};
			base.ItemFunctionTags = new List<ItemFunctionTag>(1) { (ItemFunctionTag)0 };
			base.RelevantColours = new List<TileType>();
		}

		public override string GetDescription()
		{
			string text = string.Format("Get {0}+{1}{2} WORD SCORE. Improved by {3}+{4}{5} for each time you've used the chosen letter<br><br>", GameStatics.ZeroWidthCharacter, ChosenTotal, GameStatics.ZeroWidthCharacter, GameStatics.ZeroWidthCharacter, base.UpgradeableComponents[0].VariableValue, GameStatics.ZeroWidthCharacter, Item.CheckPlural("y", "ies", base.UpgradeableComponents[0].VariableValue));
			if (ChosenLetter == "")
			{
				return string.Join("", text, "(The first letter you use becomes the chosen letter)");
			}
			return string.Join("", text, "(The chosen letter is " + ChosenLetter.ToUpper() + ")");
		}

		public override void ApplyWordBonus(ScoreCalcVizInfo step, int gridNumber, List<Tile> tiles, List<string> words, List<TileSelection> selections, List<HistoricWord> previousWords, GridData gridData)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			if (ChosenLetter == "")
			{
				ChosenLetter = tiles[0].GetStringRepresentation(false);
			}
			foreach (Tile tile in tiles)
			{
				if (tile.GetStringRepresentation(false) == ChosenLetter)
				{
					ChosenTotal += base.UpgradeableComponents[0].VariableValue;
					step.LettersInWordToPulse.Add(tile);
				}
			}
			if (ChosenTotal != 0)
			{
				step.WordBonus = new WordBonusToken((long)ChosenTotal, false, false);
			}
		}
	}
	internal class ChosenOneUnlock : Achievement
	{
		public ChosenOneUnlock()
		{
			base.Name = "I Need a Hero";
			base.SteamAchievementName = "ACH_INVITATION_ONLY";
			base.TypeOfItemUnlocked = typeof(ChosenOne);
			base.IsCrownReward = true;
			base.CrownRewardLevel = 2;
			base.CrownRewardCharacter = (Character)(object)new LlongCharacter();
		}
	}
	internal class CommonAccordion : Item
	{
		public CommonAccordion()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			base.Name = "Common Accordion";
			base.SpriteData.Add((ItemSpriteData)(object)new LlongItemData((ItemSpriteUsage)0, "accordion"));
			base.Rarity = (ItemRarity)0;
			base.Cost = 13;
			base.Tags = new List<ItemTag>(1) { (ItemTag)16 };
			base.DependencyTags = new List<ItemTag>();
			base.ItemFunctionTags = new List<ItemFunctionTag>(1) { (ItemFunctionTag)4 };
			base.RelevantColours = new List<TileType>();
		}

		public override string GetDescription()
		{
			return $"START OF GRID: Randomly recolor tiles that have the most common letter on the grid";
		}

		public override GridData ApplyStartOfGridEffect(GridData gridData, int gridNumber, int numberOfGrids, List<HistoricWord> previousWords, List<BoardGenVizInfo> vizSteps, bool isReroll)
		{
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			Dictionary<string, int> tileCounts = new Dictionary<string, int>();
			int largestCount = 0;
			foreach (Tile availableTile in gridData.GetAvailableTiles())
			{
				string stringRepresentation = availableTile.GetStringRepresentation(false);
				if (tileCounts.ContainsKey(stringRepresentation))
				{
					tileCounts[stringRepresentation]++;
					if (tileCounts[stringRepresentation] > largestCount)
					{
						largestCount = tileCounts[stringRepresentation];
					}
				}
				else
				{
					tileCounts[stringRepresentation] = 1;
				}
			}
			List<Tile> list = (from tile in gridData.GetAvailableTiles()
				where tileCounts[tile.GetStringRepresentation(false)] == largestCount
				select tile).ToList();
			List<Tile> list2 = new List<Tile>();
			while (list.Count > 0)
			{
				Tile val = list[Random.Range(0, list.Count)];
				val.SetTileType(ItemPools.GetRandomColouredTileTypeWeighted());
				list2.Add(val);
				list.Remove(val);
			}
			if (list2.Count > 0)
			{
				vizSteps.Add(new BoardGenVizInfo(gridData, (Item)(object)this, list2, false, (Type)null, false, false, false, vizSteps[vizSteps.Count - 1].PlayerConsumableTiles));
			}
			return gridData;
		}
	}
	internal class ClassicAccordionUnlock : Achievement
	{
		public ClassicAccordionUnlock()
		{
			base.Name = "Expand and Contract";
			base.SteamAchievementName = "ACH_INVITATION_ONLY";
			base.TypeOfItemUnlocked = typeof(CommonAccordion);
			base.IsCrownReward = true;
			base.CrownRewardLevel = 4;
			base.CrownRewardCharacter = (Character)(object)new LlongCharacter();
		}
	}
	internal class CleverDisguise : Item
	{
		public CleverDisguise()
		{
			//IL_0029: 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_0061: Expected O, but got Unknown
			base.Name = "Clever Disguise";
			base.SpriteData.Add((ItemSpriteData)(object)new LlongItemData((ItemSpriteUsage)0, "disguise"));
			base.Rarity = (ItemRarity)1;
			base.Cost = 16;
			base.Tags = new List<ItemTag>();
			base.DependencyTags = new List<ItemTag>();
			base.UpgradeableComponents = new List<UpgradeableComponent>(1)
			{
				new UpgradeableComponent(1, 1, 2)
			};
			base.ItemFunctionTags = new List<ItemFunctionTag>(1) { (ItemFunctionTag)4 };
			base.RelevantColours = new List<TileType>();
		}

		public override string GetDescription()
		{
			return string.Format("START OF GRID: Spread {0}{1}{2} cop{3} of a tile with the highest base value", GameStatics.ZeroWidthCharacter, base.UpgradeableComponents[0].VariableValue, GameStatics.ZeroWidthCharacter, Item.CheckPlural("y", "ies", base.UpgradeableComponents[0].VariableValue));
		}

		public override GridData ApplyStartOfGridEffect(GridData gridData, int gridNumber, int numberOfGrids, List<HistoricWord> previousWords, List<BoardGenVizInfo> vizSteps, bool isReroll)
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Expected O, but got Unknown
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Invalid comparison between Unknown and I4
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			List<Tile> availableTiles = gridData.GetAvailableTiles();
			List<Tile> list = new List<Tile>();
			long num = -999L;
			foreach (Tile item in availableTiles)
			{
				if (item.GetValue().Score > num)
				{
					num = item.GetValue().Score;
					list = new List<Tile>(1) { item };
				}
				else if (item.GetValue().Score == num)
				{
					list.Add(item);
				}
			}
			if (availableTiles.Count == 0)
			{
				MelonLogger.Msg("[Llong:Unlocks.CleverDisguise] Somehow we didn't find any highest value submitted tiles");
				return gridData;
			}
			Tile val = list[Random.Range(0, list.Count)];
			List<Tile> list2 = new List<Tile>();
			for (int i = 0; i < base.UpgradeableComponents[0].VariableValue; i++)
			{
				GridUtilitySingleton singleton = GridUtility.Singleton;
				TileType tileType = val.GetTileType();
				GlyphType glyphType = val.GetGlyphType();
				IEnumerable<Tile> first = availableTiles;
				List<Tile> list3 = list;
				int num2 = 0;
				Tile[] array = (Tile[])(object)new Tile[list2.Count + list3.Count];
				foreach (Tile item2 in list2)
				{
					array[num2] = item2;
					num2++;
				}
				foreach (Tile item3 in list3)
				{
					array[num2] = item3;
					num2++;
				}
				Tile tileForItemScatter = singleton.GetTileForItemScatter(gridData, tileType, glyphType, first.Except(new <>z__ReadOnlyArray<Tile>(array)).ToList(), (int)val.CardSuit != 0 && (int)val.CardSuit != 5);
				if (tileForItemScatter == null)
				{
					MelonLogger.Msg("[Llong:Unlocks.CleverDisguise] Couldn't get a tile to scatter to!");
					continue;
				}
				string stringRepresentation = val.GetStringRepresentation(false);
				Vector2Int coordinates = tileForItemScatter.GetCoordinates();
				object arg = ((Vector2Int)(ref coordinates)).x;
				coordinates = tileForItemScatter.GetCoordinates();
				MelonLogger.Msg($"[Llong:Unlocks.CleverDisguise] Scattering a {stringRepresentation} to {arg},{((Vector2Int)(ref coordinates)).y}");
				tileForItemScatter.SetAsCopy(val, false);
				list2.Add(tileForItemScatter);
			}
			vizSteps.Add(new BoardGenVizInfo(gridData, (Item)(object)this, list2, false, (Type)null, false, false, false, vizSteps[vizSteps.Count - 1].PlayerConsumableTiles));
			return gridData;
		}
	}
	internal class CleverDisguiseUnlock : Achievement
	{
		public CleverDisguiseUnlock()
		{
			base.Name = "Nice Moustache";
			base.SteamAchievementName = "ACH_INVITATION_ONLY";
			base.TypeOfItemUnlocked = typeof(CleverDisguise);
			base.IsCrownReward = true;
			base.CrownRewardLevel = 3;
			base.CrownRewardCharacter = (Character)(object)new LlongCharacter();
		}
	}
	internal class FigureEightKnot : Item
	{
		public FigureEightKnot()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			base.Name = "Figure Eight Knot";
			base.SpriteData.Add((ItemSpriteData)(object)new LlongItemData((ItemSpriteUsage)0, "knot"));
			base.Rarity = (ItemRarity)0;
			base.Cost = 16;
			base.Tags = new List<ItemTag>(2)
			{
				(ItemTag)18,
				(ItemTag)29
			};
			base.DependencyTags = new List<ItemTag>();
			base.ItemFunctionTags = new List<ItemFunctionTag>(1) { (ItemFunctionTag)5 };
			base.RelevantColours = new List<TileType>();
		}

		public override string GetDescription()
		{
			return $"START OF GRID: Double the number on all number tiles";
		}

		public override GridData ApplyStartOfGridEffect(GridData gridData, int gridNumber, int numberOfGrids, List<HistoricWord> previousWords, List<BoardGenVizInfo> vizSteps, bool isReroll)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Invalid comparison between Unknown and I4
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			List<Tile> list = (from tile in gridData.GetAvailableTiles()
				where tile.IsNumber()
				select tile).ToList();
			foreach (Tile item in list)
			{
				if ((int)item.GetGlyphType() == 2)
				{
					int num = item.GetNumber() * 2;
					if (num > 999999)
					{
						num = 999999;
					}
					item.SetNumber(num);
				}
				else if ((int)item.GetGlyphType() == 3)
				{
					List<int> fractionNumbers = item.GetFractionNumbers();
					fractionNumbers[0] *= 2;
					if (fractionNumbers[0] > 999999)
					{
						fractionNumbers[0] = 999999;
					}
					item.SetFractionNumbers(fractionNumbers);
				}
			}
			if (list.Count > 0)
			{
				vizSteps.Add(new BoardGenVizInfo(gridData, (Item)(object)this, list, false, (Type)null, false, false, false, vizSteps[vizSteps.Count - 1].PlayerConsumableTiles));
			}
			return gridData;
		}
	}
	internal class FigureEightKnotUnlock : Achievement
	{
		public FigureEightKnotUnlock()
		{
			base.Name = "Tied Up";
			base.SteamAchievementName = "ACH_INVITATION_ONLY";
			base.TypeOfItemUnlocked = typeof(FigureEightKnot);
			base.IsCrownReward = true;
			base.CrownRewardLevel = 6;
			base.CrownRewardCharacter = (Character)(object)new LlongCharacter();
		}
	}
	internal class SnoozedAlarmClock : Item
	{
		public SnoozedAlarmClock()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			base.Name = "Snoozed Alarm Clock";
			base.SpriteData.Add((ItemSpriteData)(object)new LlongItemData((ItemSpriteUsage)0, "alarmclock"));
			base.Rarity = (ItemRarity)0;
			base.Cost = 13;
			base.DependencyTags = new List<ItemTag>();
			base.ItemFunctionTags = new List<ItemFunctionTag>(1) { (ItemFunctionTag)4 };
			base.RelevantColours = new List<TileType>();
		}

		public override string GetDescription()
		{
			return "START OF GRID: The bottom row of tiles become Zs";
		}

		private bool IsBottomTile(Tile tile, GridData gridData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Vector2Int coordinates = tile.GetCoordinates();
			return ((Vector2Int)(ref coordinates)).y == 0;
		}

		public override GridData ApplyStartOfGridEffect(GridData gridData, int gridNumber, int numberOfGrids, List<HistoricWord> previousWords, List<BoardGenVizInfo> vizSteps, bool isReroll)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			List<Tile> list = new List<Tile>();
			foreach (Tile availableTile in gridData.GetAvailableTiles())
			{
				if (IsBottomTile(availableTile, gridData))
				{
					availableTile.SetLetter("z");
					list.Add(availableTile);
				}
			}
			if (list.Count > 0)
			{
				vizSteps.Add(new BoardGenVizInfo(gridData, (Item)(object)this, list, false, (Type)null, false, false, false, vizSteps[vizSteps.Count - 1].PlayerConsumableTiles));
			}
			return gridData;
		}
	}
	internal class SnoozedAlarmClockUnlock : Achievement
	{
		public SnoozedAlarmClockUnlock()
		{
			base.Name = "Just Five More Minutes";
			base.SteamAchievementName = "ACH_INVITATION_ONLY";
			base.TypeOfItemUnlocked = typeof(SnoozedAlarmClock);
			base.IsCrownReward = true;
			base.CrownRewardLevel = 0;
			base.CrownRewardCharacter = (Character)(object)new LlongCharacter();
		}
	}
	internal class YoYo : Item
	{
		public YoYo()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			base.Name = "Yo-Yo";
			base.SpriteData.Add((ItemSpriteData)(object)new LlongItemData((ItemSpriteUsage)0, "yoyo"));
			base.Rarity = (ItemRarity)0;
			base.Cost = 8;
			base.Tags = new List<ItemTag>(2)
			{
				(ItemTag)18,
				(ItemTag)20
			};
			base.DependencyTags = new List<ItemTag>();
			base.UpgradeableComponents = new List<UpgradeableComponent>(1)
			{
				new UpgradeableComponent(1, 1, 1)
			};
			base.ItemFunctionTags = new List<ItemFunctionTag>(1) { (ItemFunctionTag)5 };
			base.RelevantColours = new List<TileType>();
		}

		public override string GetDescription()
		{
			return string.Format("Letters can be stretched {0}+{1}{2} time{3}", GameStatics.ZeroWidthCharacter, base.UpgradeableComponents[0].VariableValue, GameStatics.ZeroWidthCharacter, Item.CheckPlural("s", base.UpgradeableComponents[0].VariableValue));
		}
	}
	internal class YoYoUnlock : Achievement
	{
		public YoYoUnlock()
		{
			base.Name = "Repetition";
			base.SteamAchievementName = "ACH_INVITATION_ONLY";
			base.TypeOfItemUnlocked = typeof(YoYo);
			base.IsCrownReward = true;
			base.CrownRewardLevel = 1;
			base.CrownRewardCharacter = (Character)(object)new LlongCharacter();
		}
	}
}