Decompiled source of GabrielFoodStand v1.0.0

plugins/GabrielFoodStand.dll

Decompiled 5 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GabrielFoodStand.Agent;
using GabrielFoodStand.Hydra;
using GabrielFoodStand.Properties;
using HarmonyLib;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.Networking;
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("GabrielFoodStand")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("GabrielFoodStand")]
[assembly: AssemblyCopyright("Copyright © HP 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6c84934c-a819-4927-9e9b-82b02bf568ae")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace GabrielFoodStand
{
	public static class BestUtilityEverCreated
	{
		public enum UltrakillLevelType
		{
			Intro,
			MainMenu,
			Level,
			Endless,
			Sandbox,
			Custom,
			Intermission,
			Unknown
		}

		public delegate void OnLevelChangedHandler(UltrakillLevelType uKLevelType);

		public delegate void OnLevelCompleteHandler();

		public delegate void PlayerEventHanler();

		public static class TextureLoader
		{
			private static Texture2D[] cachedTextures = (Texture2D[])(object)new Texture2D[0];

			private static bool initialized = false;

			private static List<Texture2D> additionalTextures = new List<Texture2D>();

			public static string GetTextureFolder()
			{
				return FoodData.GetDataPath("tex");
			}

			public static void Init()
			{
				if (!initialized)
				{
					BestUtilityEverCreated.OnLevelChanged = (OnLevelChangedHandler)Delegate.Combine(BestUtilityEverCreated.OnLevelChanged, new OnLevelChangedHandler(OnLevelChanged));
					initialized = true;
				}
			}

			private static void OnLevelChanged(UltrakillLevelType ltype)
			{
				if (InLevel())
				{
					RefreshTextures();
				}
			}

			public static void RefreshTextures()
			{
				CleanCachedTextures();
				cachedTextures = FindTextures();
			}

			public static bool TryLoadTexture(string path, out Texture2D tex, bool checkerIfNull = false)
			{
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Expected O, but got Unknown
				tex = null;
				if (!File.Exists(path))
				{
					Debug.Log((object)("Invalid location: " + path));
					return false;
				}
				byte[] array = null;
				try
				{
					array = File.ReadAllBytes(path);
				}
				catch (Exception)
				{
					Debug.Log((object)("Invalid path: " + path));
				}
				tex = new Texture2D(16, 16);
				if (!ImageConversion.LoadImage(tex, array))
				{
					Debug.Log((object)"texture loading failed!");
					if (checkerIfNull)
					{
						Checker(ref tex);
					}
					return false;
				}
				return true;
			}

			public static Texture2D PullRandomTexture()
			{
				if (cachedTextures.Length != 0)
				{
					int num = Random.Range(0, cachedTextures.Length);
					return cachedTextures[num];
				}
				return null;
			}

			public static void AddTextureToCache(Texture2D texture)
			{
				List<Texture2D> list = new List<Texture2D>(cachedTextures);
				list.Add(texture);
				additionalTextures.Add(texture);
				cachedTextures = list.ToArray();
			}

			private static void CleanCachedTextures()
			{
				if (cachedTextures == null)
				{
					return;
				}
				int num = cachedTextures.Length;
				for (int i = 0; i < num; i++)
				{
					if ((Object)(object)cachedTextures[i] != (Object)null && !additionalTextures.Contains(cachedTextures[i]))
					{
						Object.Destroy((Object)(object)cachedTextures[i]);
					}
				}
				cachedTextures = null;
			}

			private static Texture2D[] FindTextures()
			{
				List<Texture2D> list = new List<Texture2D>();
				string path = GetTextureFolder();
				string[] files = Directory.GetFiles(path, "*.png", SearchOption.AllDirectories);
				string[] files2 = Directory.GetFiles(path, "*.jpg", SearchOption.AllDirectories);
				for (int i = 0; i < files.Length; i++)
				{
					if (TryLoadTexture(ImagePath(files[i]), out var tex))
					{
						list.Add(tex);
					}
				}
				for (int j = 0; j < files2.Length; j++)
				{
					if (TryLoadTexture(ImagePath(files2[j]), out var tex2))
					{
						list.Add(tex2);
					}
				}
				for (int k = 0; k < additionalTextures.Count; k++)
				{
					list.Add(additionalTextures[k]);
				}
				return list.ToArray();
				string ImagePath(string filename)
				{
					string textureFolder = GetTextureFolder();
					return Path.Combine(path, filename);
				}
			}

			private static void Checker(ref Texture2D tex)
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				for (int i = 0; i < ((Texture)tex).height; i++)
				{
					for (int j = 0; j < ((Texture)tex).width; j++)
					{
						bool flag = j % 2 == 0;
						bool flag2 = i % 2 == 0;
						if (flag2 != flag)
						{
							flag = !flag;
						}
						Color val = (flag ? Color.white : Color.black);
						tex.SetPixel(j, i, val);
					}
				}
				tex.Apply();
			}
		}

		private static bool initalized;

		public static UltrakillLevelType CurrentLevelType;

		public static OnLevelChangedHandler OnLevelTypeChanged;

		public static OnLevelChangedHandler OnLevelChanged;

		public static OnLevelCompleteHandler OnLevelComplete;

		public static PlayerEventHanler OnPlayerActivated;

		public static PlayerEventHanler OnPlayerDied;

		public static PlayerEventHanler OnPlayerParry;

		private static bool Initialized
		{
			get
			{
				return initalized;
			}
			set
			{
				initalized = value;
			}
		}

		public static void Initialize()
		{
			if (!Initialized)
			{
				Initialized = true;
				TextureLoader.Init();
				SceneManager.sceneLoaded += OnSceneLoad;
			}
		}

		private static void OnSceneLoad(Scene scene, LoadSceneMode loadSceneMode)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			string currentScene = SceneHelper.CurrentScene;
			Debug.Log((object)$"SCENE:[{currentScene}]");
			UltrakillLevelType uKLevelType = GetUKLevelType(currentScene);
			if (!(scene != SceneManager.GetActiveScene()))
			{
				if (uKLevelType != CurrentLevelType)
				{
					CurrentLevelType = uKLevelType;
					OnLevelTypeChanged?.Invoke(uKLevelType);
				}
				OnLevelChanged?.Invoke(CurrentLevelType);
			}
		}

		public static UltrakillLevelType GetUKLevelType(string sceneName)
		{
			sceneName = (sceneName.Contains("Level") ? "Level" : (sceneName.Contains("Intermission") ? "Intermission" : sceneName));
			return sceneName switch
			{
				"Main Menu" => UltrakillLevelType.MainMenu, 
				"Custom Content" => UltrakillLevelType.Custom, 
				"Intro" => UltrakillLevelType.Intro, 
				"Endless" => UltrakillLevelType.Endless, 
				"uk_construct" => UltrakillLevelType.Sandbox, 
				"Intermission" => UltrakillLevelType.Intermission, 
				"Level" => UltrakillLevelType.Level, 
				_ => UltrakillLevelType.Unknown, 
			};
		}

		public static bool InLevel()
		{
			bool flag = CurrentLevelType == UltrakillLevelType.MainMenu || CurrentLevelType == UltrakillLevelType.Intro || CurrentLevelType == UltrakillLevelType.Intermission || CurrentLevelType == UltrakillLevelType.Unknown;
			return !flag;
		}
	}
	public static class FoodData
	{
		public delegate void OnDataChangedHandler(FoodPersistentData newData);

		private const string folderName = "Foodstand_Data";

		private static string dataFilePath = GetDataPath("data", "save.food");

		private static string[] dataToCheck = new string[3] { "tex", "data", "audio" };

		private static FoodPersistentData data;

		public static bool AutoSave = true;

		public static OnDataChangedHandler OnDataChanged;

		public static FoodPersistentData Data
		{
			get
			{
				if (data == null)
				{
					LoadData();
				}
				return data;
			}
			set
			{
				if (value != null && data != value)
				{
					data = value;
					OnDataChanged?.Invoke(data);
					if (AutoSave)
					{
						SaveData();
					}
				}
			}
		}

		public static string GetDataPath(params string[] subpath)
		{
			string location = Assembly.GetExecutingAssembly().Location;
			location = Path.GetDirectoryName(location);
			string text = Path.Combine(location, "Foodstand_Data");
			if (subpath.Length != 0)
			{
				string path = Path.Combine(subpath);
				text = Path.Combine(text, path);
			}
			ValidatePath(text);
			return text;
		}

		private static void ValidatePath(string path)
		{
			DirectoryInfo directoryInfo = new DirectoryInfo(path);
			if (!directoryInfo.Exists)
			{
				if (!directoryInfo.Name.Contains("."))
				{
					directoryInfo.Create();
				}
				else if (!directoryInfo.Parent.Exists)
				{
					directoryInfo.Parent.Create();
				}
			}
		}

		public static bool IsFirstTime()
		{
			if (!File.Exists(dataFilePath))
			{
				return true;
			}
			return false;
		}

		public static void SaveData()
		{
			string contents = JsonConvert.SerializeObject((object)Data);
			if (!Directory.Exists(GetDataPath("data")))
			{
				Directory.CreateDirectory(GetDataPath("data"));
			}
			File.WriteAllText(dataFilePath, contents);
			Debug.Log((object)("Foodstand_Save: Game data saved to " + dataFilePath));
		}

		public static void LoadData()
		{
			Debug.Log((object)"Foodstand_Save: Searching for datafile.");
			if (File.Exists(dataFilePath))
			{
				string text;
				using (StreamReader streamReader = new StreamReader(dataFilePath))
				{
					text = streamReader.ReadToEnd();
				}
				data = JsonConvert.DeserializeObject<FoodPersistentData>(text);
			}
			if (data == null)
			{
				NewData();
			}
		}

		public static void NewData()
		{
			Debug.Log((object)"GabrielFoodStand: Creating new save-file.");
			Data = FoodPersistentData.Default;
			SaveData();
		}
	}
	[Serializable]
	public class FoodPersistentData
	{
		public List<string> standsIncomplete;

		public static FoodPersistentData Default => new FoodPersistentData
		{
			standsIncomplete = new List<string>
			{
				"Level 0-1", "Level 0-2", "Level 0-3", "Level 0-4", "Level 0-5", "Level 1-1", "Level 1-2", "Level 1-3", "Level 1-4", "Level 2-1",
				"Level 2-2", "Level 2-3", "Level 2-4", "Level 3-1", "Level 3-2", "Level 4-1", "Level 4-2", "Level 4-3", "Level 4-4", "Level 5-1",
				"Level 5-2", "Level 5-3", "Level 5-4", "Level 6-1", "Level 6-2"
			}
		};
	}
	public static class HydraLoader
	{
		public class CustomAssetPrefab
		{
			public Component[] modules;

			public string name;

			public CustomAssetPrefab(string assetName, Component[] componentsToAdd)
			{
				name = assetName;
				modules = componentsToAdd;
				assetsToRegister.Add(this);
			}
		}

		public class CustomAssetData
		{
			public string name;

			public DataFile dataFile;

			public bool hasData = false;

			public Type dataType;

			public CustomAssetData(string dataName, DataFile dataFile)
			{
				hasData = true;
				name = dataName;
				this.dataFile = dataFile;
				dataToRegister.Add(this);
			}

			public CustomAssetData(string dataName, Type type)
			{
				name = dataName;
				dataType = type;
				dataToRegister.Add(this);
			}
		}

		private static List<CustomAssetPrefab> assetsToRegister = new List<CustomAssetPrefab>();

		private static List<CustomAssetData> dataToRegister = new List<CustomAssetData>();

		public static Dictionary<string, Object> dataRegistry = new Dictionary<string, Object>();

		public static Dictionary<string, GameObject> prefabRegistry = new Dictionary<string, GameObject>();

		private static AssetBundle assetBundle;

		public static bool dataRegistered = false;

		public static bool assetsRegistered = false;

		public static bool RegisterAll(byte[] assetBundleObject)
		{
			try
			{
				Debug.Log((object)"HydraLoader: loading mod files");
				assetBundle = AssetBundle.LoadFromMemory(assetBundleObject);
				RegisterDataFiles();
				RegisterCustomAssets();
				Debug.Log((object)"HydraLoader: loading complete");
				return true;
			}
			catch (Exception)
			{
				Debug.Log((object)"HydraLoader: loading failed");
				return false;
			}
		}

		public static void RegisterDataFiles()
		{
			if (dataRegistered)
			{
				return;
			}
			foreach (CustomAssetData item in dataToRegister)
			{
				if (item.hasData)
				{
					dataRegistry.Add(item.name, (Object)(object)item.dataFile);
				}
				else
				{
					dataRegistry.Add(item.name, assetBundle.LoadAsset(item.name, item.dataType));
				}
			}
			Debug.Log((object)$"HydraLoader: {dataRegistry.Count} asset datas registered successfully");
			dataRegistered = true;
		}

		public static void RegisterCustomAssets()
		{
			if (assetsRegistered)
			{
				return;
			}
			foreach (CustomAssetPrefab item in assetsToRegister)
			{
				GameObject val = assetBundle.LoadAsset<GameObject>(item.name);
				for (int i = 0; i < item.modules.Length; i++)
				{
					val.AddComponent(((object)item.modules[i]).GetType());
				}
				prefabRegistry.Add(item.name, val);
			}
			Debug.Log((object)$"HydraLoader: {prefabRegistry.Count} prefabs registered successfully");
			assetsRegistered = true;
		}
	}
	public class DataFile : Object
	{
	}
	[BepInPlugin("agent.gabriel_food_stand", "Gabriel Food Stand", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			Instance = this;
			BestUtilityEverCreated.Initialize();
			Harmony val = new Harmony("gabriel_food_stand");
			val.PatchAll();
			((MonoBehaviour)this).StartCoroutine(AgentRegistry.GetAudio());
			FoodStandInitializer.Init();
			RegisterAssets();
			MonoSingleton<CoinCollectorManager>.Initialize();
		}

		private void RegisterAssets()
		{
			new HydraLoader.CustomAssetPrefab("CollectableCoin", (Component[])(object)new Component[1] { (Component)new CollectableCoin() });
			new HydraLoader.CustomAssetPrefab("CollectableCoinUI", (Component[])(object)new Component[1] { (Component)new CollectableCoinUI() });
			new HydraLoader.CustomAssetPrefab("CollectableCoinFX", (Component[])(object)new Component[2]
			{
				(Component)new CollectableCoinUI(),
				(Component)new DestroyAfterTime
				{
					timeLeft = 4f
				}
			});
			HydraLoader.RegisterAll(Resources.hydrabundle);
		}
	}
}
namespace GabrielFoodStand.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("GabrielFoodStand.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] brownie
		{
			get
			{
				object @object = ResourceManager.GetObject("brownie", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] chicken
		{
			get
			{
				object @object = ResourceManager.GetObject("chicken", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] coconut
		{
			get
			{
				object @object = ResourceManager.GetObject("coconut", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] cookies
		{
			get
			{
				object @object = ResourceManager.GetObject("cookies", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] donut
		{
			get
			{
				object @object = ResourceManager.GetObject("donut", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] egg
		{
			get
			{
				object @object = ResourceManager.GetObject("egg", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] error
		{
			get
			{
				object @object = ResourceManager.GetObject("error", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] fish
		{
			get
			{
				object @object = ResourceManager.GetObject("fish", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] fries
		{
			get
			{
				object @object = ResourceManager.GetObject("fries", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] gabrielStand
		{
			get
			{
				object @object = ResourceManager.GetObject("gabrielStand", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] hamburger
		{
			get
			{
				object @object = ResourceManager.GetObject("hamburger", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] hotdog
		{
			get
			{
				object @object = ResourceManager.GetObject("hotdog", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] hydrabundle
		{
			get
			{
				object @object = ResourceManager.GetObject("hydrabundle", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] icecream
		{
			get
			{
				object @object = ResourceManager.GetObject("icecream", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] karj
		{
			get
			{
				object @object = ResourceManager.GetObject("karj", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] leip
		{
			get
			{
				object @object = ResourceManager.GetObject("leip", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] lemonade
		{
			get
			{
				object @object = ResourceManager.GetObject("lemonade", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] pancake
		{
			get
			{
				object @object = ResourceManager.GetObject("pancake", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] pickle
		{
			get
			{
				object @object = ResourceManager.GetObject("pickle", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] pizza
		{
			get
			{
				object @object = ResourceManager.GetObject("pizza", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] pudding
		{
			get
			{
				object @object = ResourceManager.GetObject("pudding", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] rakm
		{
			get
			{
				object @object = ResourceManager.GetObject("rakm", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] salmon
		{
			get
			{
				object @object = ResourceManager.GetObject("salmon", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] soda
		{
			get
			{
				object @object = ResourceManager.GetObject("soda", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] sweetroll
		{
			get
			{
				object @object = ResourceManager.GetObject("sweetroll", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] trifle
		{
			get
			{
				object @object = ResourceManager.GetObject("trifle", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] water
		{
			get
			{
				object @object = ResourceManager.GetObject("water", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace GabrielFoodStand.Hydra
{
	[ConfigureSingleton(/*Could not decode attribute arguments.*/)]
	public class CoinCollectorManager : MonoSingleton<CoinCollectorManager>
	{
		private GameObject coinPrefab;

		private GameObject coinCollectFX;

		private GameObject coinUIPrefab;

		private AudioClip coinFanfare;

		private CollectableCoinUI coinUI;

		private List<CollectableCoin> coins = new List<CollectableCoin>();

		private Transform coinParent;

		public int maxCoins = 420;

		public int positionResolveAttempts = 6;

		public float initalRange = 1000f;

		public float resolveRange = 45f;

		public static int CollectedCoins { get; private set; }

		public override void Awake()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			base.Awake();
			Debug.Log((object)"AWAKENING COIN MANAGER");
			HydraLoader.prefabRegistry.TryGetValue("CollectableCoin", out coinPrefab);
			HydraLoader.prefabRegistry.TryGetValue("CollectableCoinUI", out coinUIPrefab);
			HydraLoader.prefabRegistry.TryGetValue("CollectableCoinFX", out coinCollectFX);
			if (HydraLoader.dataRegistry.TryGetValue("CoinFanfare", out var value))
			{
				coinFanfare = (AudioClip)value;
			}
		}

		private void Reset(bool sceneLoad)
		{
			Debug.Log((object)"COIN MANAGER RESET");
			CollectedCoins = 0;
			if (!sceneLoad)
			{
				if ((Object)(object)coinParent != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)coinParent).gameObject);
				}
				if ((Object)(object)coinUI != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)coinUI).gameObject);
				}
			}
			coins = new List<CollectableCoin>();
			coinUI = null;
			coinParent = null;
		}

		public void ManualReset()
		{
			Reset(sceneLoad: false);
			DeployPrefabs();
		}

		private void OnLevelChanged(BestUtilityEverCreated.UltrakillLevelType ltype)
		{
			Reset(sceneLoad: true);
			DeployPrefabs();
		}

		private void DeployPrefabs()
		{
			Debug.Log((object)"DEPLOYING COIN PREFABS");
			if (BestUtilityEverCreated.InLevel() && (Object)(object)coinPrefab != (Object)null && (Object)(object)coinUIPrefab != (Object)null)
			{
				maxCoins = 420;
				DeployUI();
				DeployCoins();
			}
		}

		private void DeployUI()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"DEPLOYING COIN UI");
			GameObject val = Object.Instantiate<GameObject>(coinUIPrefab, Vector3.zero, Quaternion.identity);
			coinUI = val.GetComponent<CollectableCoinUI>();
			coinUI.Refresh();
		}

		private void DeployCoins()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"DEPLOYING COINS");
			NavMeshHit val = default(NavMeshHit);
			if (!NavMesh.SamplePosition(Vector3.zero, ref val, float.PositiveInfinity, 1))
			{
				Debug.Log((object)"Nav mesh missing. No coins spawned.");
				return;
			}
			GameObject val2 = new GameObject("CollectableCoins");
			coinParent = val2.transform;
			for (int i = 0; i < maxCoins; i++)
			{
				if (TryGetCoinPlacementPosition(out var pos))
				{
					GameObject val3 = Object.Instantiate<GameObject>(coinPrefab, pos, Quaternion.identity);
					CollectableCoin component = val3.GetComponent<CollectableCoin>();
					component.SetManager(this);
					((Component)component).transform.parent = coinParent;
					coins.Add(component);
				}
				else
				{
					i = Mathf.Clamp(i - 1, 0, maxCoins);
				}
			}
			Debug.Log((object)$"{coins.Count} coins placed.");
		}

		private bool TryGetCoinPlacementPosition(out Vector3 pos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0039: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Random.insideUnitSphere * initalRange;
			pos = Vector3.zero;
			NavMeshHit val2 = default(NavMeshHit);
			if (NavMesh.SamplePosition(val, ref val2, initalRange, 1))
			{
				pos = ((NavMeshHit)(ref val2)).position;
				NavMeshHit val4 = default(NavMeshHit);
				for (int i = 0; i < positionResolveAttempts; i++)
				{
					Vector3 val3 = Random.insideUnitSphere * Random.Range(1f, resolveRange);
					if (NavMesh.SamplePosition(pos + val3, ref val4, resolveRange, 1))
					{
						pos = ((NavMeshHit)(ref val4)).position;
					}
				}
				return true;
			}
			return false;
		}

		public void CoinCollected(CollectableCoin coin)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)coin != (Object)null && coins.Contains(coin))
			{
				Vector3 position = ((Component)coin).transform.position;
				Object.Instantiate<GameObject>(coinCollectFX, position, Quaternion.identity);
				CollectedCoins++;
				if (CollectedCoins % 100 == 0 && (Object)(object)coinFanfare != (Object)null)
				{
					AudioSource.PlayClipAtPoint(coinFanfare, position);
				}
				if ((Object)(object)coinUI != (Object)null)
				{
					coinUI.Refresh();
				}
			}
		}

		public bool SpendCoins(int amountToSpend)
		{
			if (amountToSpend > CollectedCoins)
			{
				return false;
			}
			CollectedCoins -= amountToSpend;
			if ((Object)(object)coinUI != (Object)null)
			{
				coinUI.Refresh();
			}
			return true;
		}

		public override void OnEnable()
		{
			base.OnEnable();
			BestUtilityEverCreated.OnLevelChanged = (BestUtilityEverCreated.OnLevelChangedHandler)Delegate.Combine(BestUtilityEverCreated.OnLevelChanged, new BestUtilityEverCreated.OnLevelChangedHandler(OnLevelChanged));
		}

		public override void OnDestroy()
		{
			base.OnDestroy();
			BestUtilityEverCreated.OnLevelChanged = (BestUtilityEverCreated.OnLevelChangedHandler)Delegate.Remove(BestUtilityEverCreated.OnLevelChanged, new BestUtilityEverCreated.OnLevelChangedHandler(OnLevelChanged));
		}
	}
	public class CollectableCoin : MonoBehaviour
	{
		private CoinCollectorManager manager;

		public bool IsCollected { get; private set; } = false;


		public void SetManager(CoinCollectorManager manager)
		{
			if ((Object)(object)this.manager == (Object)null)
			{
				this.manager = manager;
			}
		}

		private void Collected()
		{
			IsCollected = true;
			if ((Object)(object)manager != (Object)null)
			{
				manager.CoinCollected(this);
			}
			((Component)this).gameObject.SetActive(false);
		}

		private void OnTriggerEnter(Collider other)
		{
			if ((Object)(object)((Component)other).gameObject == (Object)(object)((Component)MonoSingleton<NewMovement>.Instance).gameObject)
			{
				Collected();
			}
		}
	}
	public class CollectableCoinUI : MonoBehaviour
	{
		private Text coinText;

		private string fmt = "000";

		private void Awake()
		{
			coinText = ((Component)this).GetComponentInChildren<Text>();
		}

		public void Refresh()
		{
			if ((Object)(object)coinText != (Object)null)
			{
				coinText.text = "x" + CoinString(CoinCollectorManager.CollectedCoins);
			}
		}

		private string CoinString(int coins)
		{
			if (coins > 99)
			{
				return coins.ToString();
			}
			if (coins > 9)
			{
				return "0" + coins;
			}
			if (coins > 0)
			{
				return "00" + coins;
			}
			return "000";
		}
	}
	public class DestroyAfterTime : MonoBehaviour
	{
		public float timeLeft = 15f;

		private bool dying;

		private void Start()
		{
			KillAfterTime();
		}

		public void KillAfterTime()
		{
			if (!dying)
			{
				dying = true;
				((MonoBehaviour)this).StartCoroutine(KillTimer());
			}
		}

		private IEnumerator KillTimer()
		{
			yield return (object)new WaitForSeconds(1f);
			while (timeLeft > 0f)
			{
				yield return (object)new WaitForEndOfFrame();
				timeLeft -= Time.deltaTime;
			}
		}

		private void Kill()
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
namespace GabrielFoodStand.Agent
{
	public static class AgentRegistry
	{
		public static Dictionary<string, int> Costs = new Dictionary<string, int>
		{
			{ "Level 0-1", 10 },
			{ "Level 0-2", 20 },
			{ "Level 0-3", 30 },
			{ "Level 0-4", 40 },
			{ "Level 0-5", 50 },
			{ "Level 1-1", 10 },
			{ "Level 1-2", 20 },
			{ "Level 1-3", 30 },
			{ "Level 1-4", 40 },
			{ "Level 2-1", 50 },
			{ "Level 2-2", 60 },
			{ "Level 2-3", 70 },
			{ "Level 2-4", 80 },
			{ "Level 3-1", 90 },
			{ "Level 3-2", 100 },
			{ "Level 4-1", 10 },
			{ "Level 4-2", 20 },
			{ "Level 4-3", 30 },
			{ "Level 4-4", 40 },
			{ "Level 5-1", 50 },
			{ "Level 5-2", 60 },
			{ "Level 5-3", 70 },
			{ "Level 5-4", 80 },
			{ "Level 6-1", 90 },
			{ "Level 6-2", 100 }
		};

		public static Dictionary<string, Vector3> Positions = new Dictionary<string, Vector3>
		{
			{
				"Level 0-1",
				new Vector3(16.5f, 8.2f, 589.2f)
			},
			{
				"Level 0-2",
				new Vector3(-38.8f, -11.2f, 243.8f)
			},
			{
				"Level 0-3",
				new Vector3(-10.6f, 46.8f, 366.8f)
			},
			{
				"Level 0-4",
				new Vector3(-16.8f, 21.8f, 502.9f)
			},
			{
				"Level 0-5",
				new Vector3(260.5f, -20.6f, 388.6f)
			},
			{
				"Level 1-1",
				new Vector3(-89.4f, -4.6f, 381.3f)
			},
			{
				"Level 1-2",
				new Vector3(-25.7f, -21.7f, 404.8f)
			},
			{
				"Level 1-3",
				new Vector3(-169.8f, 20f, 344.5f)
			},
			{
				"Level 1-4",
				new Vector3(65.7f, -13.2f, 483.8f)
			},
			{
				"Level 2-1",
				new Vector3(166.7f, 39.8f, 626.6f)
			},
			{
				"Level 2-2",
				new Vector3(-257f, 80.8f, 383.7f)
			},
			{
				"Level 2-3",
				new Vector3(-14.7f, 2.5f, 518.4f)
			},
			{
				"Level 2-4",
				new Vector3(60f, -19.9f, 343.3f)
			},
			{
				"Level 3-1",
				new Vector3(-206.1f, -119.2f, 347.8f)
			},
			{
				"Level 3-2",
				new Vector3(4.9f, 64.8f, 639.3f)
			},
			{
				"Level 4-1",
				new Vector3(-290.2f, 11.5f, 530f)
			},
			{
				"Level 4-2",
				new Vector3(138.7f, 41.2f, 1011.4f)
			},
			{
				"Level 4-3",
				new Vector3(112.3f, -26.7f, 616.3f)
			},
			{
				"Level 4-4",
				new Vector3(124f, 648.5f, 432.6f)
			},
			{
				"Level 5-1",
				new Vector3(151.8f, -150.2f, 235.4f)
			},
			{
				"Level 5-2",
				new Vector3(-369f, -13.9f, 677.9f)
			},
			{
				"Level 5-3",
				new Vector3(-101.1f, 282.8f, 279.2f)
			},
			{
				"Level 5-4",
				new Vector3(11.9f, 48.1f, 624.4f)
			},
			{
				"Level 6-1",
				new Vector3(168f, -205.2f, 270f)
			},
			{
				"Level 6-2",
				new Vector3(-25.5f, 29.8f, 303.7f)
			}
		};

		public static Dictionary<string, Vector3> Rotations = new Dictionary<string, Vector3>
		{
			{
				"Level 0-1",
				new Vector3(0f, 90f, 0f)
			},
			{
				"Level 0-2",
				new Vector3(0f, 270f, 0f)
			},
			{
				"Level 0-3",
				new Vector3(0f, 90f, 0f)
			},
			{
				"Level 0-4",
				new Vector3(0f, 90f, 0f)
			},
			{
				"Level 0-5",
				new Vector3(0f, 180f, 0f)
			},
			{
				"Level 1-1",
				new Vector3(0f, 90f, 0f)
			},
			{
				"Level 1-2",
				new Vector3(0f, 0f, 0f)
			},
			{
				"Level 1-3",
				new Vector3(0f, 270f, 0f)
			},
			{
				"Level 1-4",
				new Vector3(0f, 0f, 0f)
			},
			{
				"Level 2-1",
				new Vector3(0f, 0f, 0f)
			},
			{
				"Level 2-2",
				new Vector3(0f, 0f, 0f)
			},
			{
				"Level 2-3",
				new Vector3(0f, 180f, 0f)
			},
			{
				"Level 2-4",
				new Vector3(0f, 0f, 0f)
			},
			{
				"Level 3-1",
				new Vector3(0f, 270f, 0f)
			},
			{
				"Level 3-2",
				new Vector3(0f, 180f, 0f)
			},
			{
				"Level 4-1",
				new Vector3(0f, 0f, 0f)
			},
			{
				"Level 4-2",
				new Vector3(15f, 180f, 0f)
			},
			{
				"Level 4-3",
				new Vector3(0f, 180f, 0f)
			},
			{
				"Level 4-4",
				new Vector3(0f, 270f, 0f)
			},
			{
				"Level 5-1",
				new Vector3(0f, 90f, 0f)
			},
			{
				"Level 5-2",
				new Vector3(0f, 87f, 0f)
			},
			{
				"Level 5-3",
				new Vector3(0f, 180f, 0f)
			},
			{
				"Level 5-4",
				new Vector3(4.5f, 243.5f, 0f)
			},
			{
				"Level 6-1",
				new Vector3(0f, 0f, 0f)
			},
			{
				"Level 6-2",
				new Vector3(0f, 0f, 0f)
			}
		};

		public static Dictionary<string, string> PrePurchaseDialogue = new Dictionary<string, string>
		{
			{ "Level 0-1", "Machine, I can't afford my security deposit. Please buy a soda." },
			{ "Level 0-2", "Machine, I'm three months behind on rent. Please buy a hamburger." },
			{ "Level 0-3", "Machine, taxes went up three-hundred percent. Please buy a áÔðÙjÐÚuË»àÜ®." },
			{ "Level 0-4", "Machine, heaven is undergoing a housing crisis. Please buy some fish and chips." },
			{ "Level 0-5", "Machine, I need to pay off my speeding tickets or they'll revoke my license. Please buy some blood pudding." },
			{ "Level 1-1", "Machine, I overcharged my credit card. Please buy a pizza." },
			{ "Level 1-2", "Machine, I've been convicted of arson and can't afford a lawyer. Please buy some chicken tenders." },
			{ "Level 1-3", "Machine, I can't afford tuition. Please buy some cookies." },
			{ "Level 1-4", "Machine, I need the start-up money for a farm. Please buy this hard-boiled egg." },
			{ "Level 2-1", "Machine, the council is repossessing my car. Please buy some salmon rolls." },
			{ "Level 2-2", "Machine, I've been fined for littering. Please buy some brownies." },
			{ "Level 2-3", "Machine, I parked in a no-parking zone. Please buy a Leipäjuusto." },
			{ "Level 2-4", "Machine, my electricity has been shut off. Please buy some water." },
			{ "Level 3-1", "Machine, I need groceries. Please buy a pickle." },
			{ "Level 3-2", "Machine, I'm in trouble with the Irish mafia. Please buy some lemonade." },
			{ "Level 4-1", "Machine, my light has been repossessed. Please buy some ice cream." },
			{ "Level 4-2", "Machine, I got fired from my job. Please buy a Räkmacka." },
			{ "Level 4-3", "Machine, I've been evicted and need to find an apartment. Please buy a coconut bar." },
			{ "Level 4-4", "Machine, my washing device broke and I need a replacement. Please buy a trifle." },
			{ "Level 5-1", "Machine, Minos sued me and won. Please buy a sweet roll." },
			{ "Level 5-2", "Machine, I've been denied insurance coverage. Please buy a Karjalanpiirakka." },
			{ "Level 5-3", "Machine, I owe a friend some money. Please buy a hot dog." },
			{ "Level 5-4", "Machine, I lost my wallet and phone. Please buy a pancake." },
			{ "Level 6-1", "Machine, I can't afford my phone's data plan. Please buy a donut." },
			{ "Level 6-2", "Machine, I have hours to live and things I want to do. Please buy some fries." }
		};

		public static Dictionary<string, string> PostPurchaseDialogue = new Dictionary<string, string>
		{
			{ "Level 0-1", "I won't forget this, Machine." },
			{ "Level 0-2", "May your woes be few, and your days many." },
			{ "Level 0-3", "Thank you, Machine." },
			{ "Level 0-4", "Many thanks, Machine." },
			{ "Level 0-5", "You have my gratitude, Machine. Now I can get to work on time." },
			{ "Level 1-1", "I made a wish, and you delivered. Maybe you should try it sometime." },
			{ "Level 1-2", "You have my thanks." },
			{ "Level 1-3", "Will you come to my graduation, Machine?" },
			{ "Level 1-4", "I look forward to serving you fresh produce, Machine." },
			{ "Level 2-1", "Thank you for saving my car again, Machine." },
			{ "Level 2-2", "I'll use the rubbish bins from now on." },
			{ "Level 2-3", "I'm grateful, Machine." },
			{ "Level 2-4", "Thank you, Machine. Now I can use my oven again." },
			{ "Level 3-1", "I'll remember your kindness, Machine." },
			{ "Level 3-2", "I'm sorry for what's about to happen, Machine. It's nothing personal." },
			{ "Level 4-1", "I apologize for earlier." },
			{ "Level 4-2", "My time is limited, Machine." },
			{ "Level 4-3", "Thank you for helping me find my footing, Machine." },
			{ "Level 4-4", "Be careful, Machine." },
			{ "Level 5-1", "It's a good thing you don't rust, Machine." },
			{ "Level 5-2", "Please show my friend the same kindness you showed me." },
			{ "Level 5-3", "I'll pay you back for all you've done, Machine." },
			{ "Level 5-4", "I was able to use FindMyiPhone thanks to you, Machine." },
			{ "Level 6-1", "You smell good today, Machine." },
			{ "Level 6-2", "Thank you, Machine. We will meet again." }
		};

		public static Dictionary<string, Sprite> Icons = new Dictionary<string, Sprite>
		{
			{
				"Level 0-1",
				LoadToSprite(Resources.soda)
			},
			{
				"Level 0-2",
				LoadToSprite(Resources.hamburger)
			},
			{
				"Level 0-3",
				LoadToSprite(Resources.error)
			},
			{
				"Level 0-4",
				LoadToSprite(Resources.fish)
			},
			{
				"Level 0-5",
				LoadToSprite(Resources.pudding)
			},
			{
				"Level 1-1",
				LoadToSprite(Resources.pizza)
			},
			{
				"Level 1-2",
				LoadToSprite(Resources.chicken)
			},
			{
				"Level 1-3",
				LoadToSprite(Resources.cookies)
			},
			{
				"Level 1-4",
				LoadToSprite(Resources.egg)
			},
			{
				"Level 2-1",
				LoadToSprite(Resources.salmon)
			},
			{
				"Level 2-2",
				LoadToSprite(Resources.brownie)
			},
			{
				"Level 2-3",
				LoadToSprite(Resources.leip)
			},
			{
				"Level 2-4",
				LoadToSprite(Resources.water)
			},
			{
				"Level 3-1",
				LoadToSprite(Resources.pickle)
			},
			{
				"Level 3-2",
				LoadToSprite(Resources.lemonade)
			},
			{
				"Level 4-1",
				LoadToSprite(Resources.icecream)
			},
			{
				"Level 4-2",
				LoadToSprite(Resources.rakm)
			},
			{
				"Level 4-3",
				LoadToSprite(Resources.coconut)
			},
			{
				"Level 4-4",
				LoadToSprite(Resources.trifle)
			},
			{
				"Level 5-1",
				LoadToSprite(Resources.sweetroll)
			},
			{
				"Level 5-2",
				LoadToSprite(Resources.karj)
			},
			{
				"Level 5-3",
				LoadToSprite(Resources.hotdog)
			},
			{
				"Level 5-4",
				LoadToSprite(Resources.pancake)
			},
			{
				"Level 6-1",
				LoadToSprite(Resources.donut)
			},
			{
				"Level 6-2",
				LoadToSprite(Resources.fries)
			}
		};

		public static Dictionary<int, string> LevelDatabase = new Dictionary<int, string>
		{
			{ 1, "Level 0-1" },
			{ 2, "Level 0-2" },
			{ 3, "Level 0-3" },
			{ 4, "Level 0-4" },
			{ 5, "Level 0-5" },
			{ 6, "Level 1-1" },
			{ 7, "Level 1-2" },
			{ 8, "Level 1-3" },
			{ 9, "Level 1-4" },
			{ 10, "Level 2-1" },
			{ 11, "Level 2-2" },
			{ 12, "Level 2-3" },
			{ 13, "Level 2-4" },
			{ 14, "Level 3-1" },
			{ 15, "Level 3-2" },
			{ 16, "Level 4-1" },
			{ 17, "Level 4-2" },
			{ 18, "Level 4-3" },
			{ 19, "Level 4-4" },
			{ 20, "Level 5-1" },
			{ 21, "Level 5-2" },
			{ 22, "Level 5-3" },
			{ 23, "Level 5-4" },
			{ 24, "Level 6-1" },
			{ 25, "Level 6-2" }
		};

		public static AudioClip eat_clip;

		private static Sprite LoadToSprite(byte[] bytes)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(256, 256);
			ImageConversion.LoadImage(val, bytes);
			return Sprite.Create(val, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f));
		}

		public static void CompleteLevel(string name)
		{
			if (FoodData.Data.standsIncomplete.Contains(name))
			{
				FoodData.Data.standsIncomplete.Remove(name);
				FoodData.SaveData();
			}
		}

		public static IEnumerator GetAudio()
		{
			Debug.Log((object)"INITIALIZING EAT AUDIO");
			string clipPath = Path.Combine(FoodData.GetDataPath("assets"), "eat.wav");
			UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(clipPath, (AudioType)20);
			try
			{
				yield return www.SendWebRequest();
				Debug.Log((object)clipPath);
				if (www.isNetworkError)
				{
					Debug.Log((object)("Failed to load " + Path.GetFileName(clipPath)));
					Debug.Log((object)www.error);
				}
				else
				{
					AudioClip newAudioClip = DownloadHandlerAudioClip.GetContent(www);
					if ((Object)(object)newAudioClip != (Object)null)
					{
						eat_clip = newAudioClip;
					}
				}
			}
			finally
			{
				((IDisposable)www)?.Dispose();
			}
			yield return null;
		}
	}
	public static class FoodStandInitializer
	{
		private static bool _initialized;

		public static AssetBundle _bundle;

		private static GameObject _foodStand;

		public static void Init()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"INITIALIZING FOOD STAND");
			if (!_initialized)
			{
				_bundle = AssetBundle.LoadFromMemory(Resources.gabrielStand);
				_foodStand = _bundle.LoadAsset<GameObject>("foodstand.prefab");
				((Component)_foodStand.transform.Find("icon")).gameObject.AddComponent<AlwaysLookAtCamera>();
				_foodStand.AddComponent<FoodStand>().Trigger = ((Component)_foodStand.transform.Find("trigger")).gameObject;
				RenderObject(_foodStand, LayerMask.op_Implicit(LayerMask.NameToLayer("Outdoors")));
				((Component)_foodStand.transform.Find("icon")).gameObject.layer = LayerMask.NameToLayer("AlwaysOnTop");
				BestUtilityEverCreated.OnLevelChanged = (BestUtilityEverCreated.OnLevelChangedHandler)Delegate.Combine(BestUtilityEverCreated.OnLevelChanged, new BestUtilityEverCreated.OnLevelChangedHandler(PlaceFoodStand));
				_initialized = true;
				Debug.Log((object)"INITIALIZED FOOD STAND");
			}
		}

		public static void PlaceFoodStand(BestUtilityEverCreated.UltrakillLevelType level)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			string currentScene = SceneHelper.CurrentScene;
			if (level == BestUtilityEverCreated.UltrakillLevelType.Level && !currentScene.Contains("-S") && !currentScene.Contains("P-"))
			{
				Debug.Log((object)"PLACING FOOD STAND");
				Debug.Log((object)"FOOD STAND OKAY");
				Transform transform = Object.Instantiate<GameObject>(_foodStand).transform;
				transform.parent = null;
				transform.position = AgentRegistry.Positions[currentScene];
				transform.rotation = Quaternion.Euler(AgentRegistry.Rotations[currentScene]);
				Debug.Log((object)transform);
			}
		}

		public static void RenderObject(GameObject obj, LayerMask layer)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				((Component)val).gameObject.layer = LayerMask.op_Implicit(layer);
				val.material.shader = Shader.Find(((Object)val.material.shader).name);
			}
		}
	}
	public class FoodStand : MonoBehaviour
	{
		public GameObject Trigger;

		public SpriteRenderer Icon;

		public GameObject Poster;

		public GameObject Bible;

		public int Cost;

		public string PrePurchaseSub;

		public string PostPurchaseSub;

		private AudioSource source;

		private bool posterBool = false;

		private bool bibleBool = false;

		private void Awake()
		{
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			string currentScene = SceneHelper.CurrentScene;
			Trigger.AddComponent<FoodStandTrigger>().foodStand = this;
			Icon = ((Component)((Component)this).transform.Find("icon")).GetComponent<SpriteRenderer>();
			Icon.flipX = true;
			Cost = AgentRegistry.Costs[currentScene];
			PrePurchaseSub = AgentRegistry.PrePurchaseDialogue[currentScene];
			PostPurchaseSub = AgentRegistry.PostPurchaseDialogue[currentScene];
			Icon.sprite = AgentRegistry.Icons[currentScene];
			source = ((Component)this).gameObject.AddComponent<AudioSource>();
			source.volume = 3f;
			source.clip = AgentRegistry.eat_clip;
			Poster = Object.Instantiate<GameObject>(FoodStandInitializer._bundle.LoadAsset<GameObject>("poster.prefab"), new Vector3(-14.84f, 2.86f, 258.1f), Quaternion.Euler(0f, 90f, 0f), (Transform)null);
			Transform transform = Poster.transform;
			transform.localScale *= 3f;
			FoodStandInitializer.RenderObject(Poster, LayerMask.op_Implicit(LayerMask.NameToLayer("Outdoors")));
			Poster.SetActive(false);
			CheckPoster();
			Bible = AssetHelper.LoadPrefab("Assets/Prefabs/Items/Book.prefab");
		}

		public void ButtonPressed()
		{
			if (MonoSingleton<CoinCollectorManager>.Instance.SpendCoins(Cost))
			{
				Purchase();
			}
			else
			{
				MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("YOU'RE TOO BROKE", "", "", 0, false);
			}
		}

		public void Purchase()
		{
			Trigger.SetActive(false);
			((Component)Icon).gameObject.SetActive(false);
			MonoSingleton<SubtitleController>.Instance.DisplaySubtitle(PostPurchaseSub, (AudioSource)null);
			source.Play();
			AgentRegistry.CompleteLevel(SceneHelper.CurrentScene);
			CheckComplete();
		}

		public void CheckComplete()
		{
			//IL_0070: 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)
			string[] array = FoodData.Data.standsIncomplete.Where((string s) => s.Contains("0-") || s.Contains("1-") || s.Contains("2-") || s.Contains("3-")).ToArray();
			if (array.Length == 0)
			{
				if (!bibleBool)
				{
					MonoSingleton<SubtitleController>.Instance.DisplaySubtitle("Machine, I want to give you something. It's very important to me.", (AudioSource)null);
				}
				GameObject val = Object.Instantiate<GameObject>(Bible, ((Component)Icon).transform.position, Quaternion.identity, (Transform)null);
				if (!Object.op_Implicit((Object)(object)MonoSingleton<ScanningStuff>.Instance))
				{
					val.AddComponent<ScanningStuff>();
				}
				Readable component = val.GetComponent<Readable>();
				component.content = "<b>Text Scanned - Unique Passage:</b>\n\n<i>\"The angel Gabriel was sent from God\r\nto a town of Galilee called Nazareth,\r\nto a virgin betrothed to a man named Joseph,\r\nof the house of David,\r\nand the virgin’s name was Mary.\r\nAnd coming to her, he said,\r\n'Hail, full of grace! The Lord is with you.'\r\nBut she was greatly troubled at what was said\r\nand pondered what sort of greeting this might be.\r\nThen the angel said to her,\r\n'Do not be afraid, Mary,\r\nfor you have found favor with God...\"</i>\n\n<b>Remaining text: Irrelevant.</b>";
			}
			if (!posterBool && CheckPoster())
			{
				MonoSingleton<SubtitleController>.Instance.DisplaySubtitle("Machine, I can never thank you enough.", (AudioSource)null);
				MonoSingleton<SubtitleController>.Instance.DisplaySubtitle("Please, take this as a token of my gratitude.", (AudioSource)null);
				MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("Acquired Poster!", "", "", 0, false);
			}
		}

		public bool CheckPoster()
		{
			string[] array = FoodData.Data.standsIncomplete.Where((string s) => s.Contains("0-") || s.Contains("1-") || s.Contains("2-") || s.Contains("3-")).ToArray();
			string[] array2 = FoodData.Data.standsIncomplete.Where((string s) => s.Contains("4-") || s.Contains("5-") || s.Contains("6-")).ToArray();
			if (array.Length == 0)
			{
				bibleBool = true;
			}
			if (array2.Length == 0)
			{
				Poster.SetActive(true);
				posterBool = true;
				return true;
			}
			return false;
		}
	}
	public class FoodStandTrigger : MonoBehaviour
	{
		public FoodStand foodStand;

		private HudMessage message;

		private bool active = false;

		private bool first_active = false;

		private void Awake()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			message = ((Component)this).gameObject.AddComponent<HudMessage>();
			message.playerPref = "";
			message.deactiveOnTriggerExit = true;
			message.notOneTime = true;
			message.dontActivateOnTriggerEnter = false;
			message.timed = true;
			message.timerTime = 3f;
			message.message = "Press [PUNCH]";
			InputActionReference val = ScriptableObject.CreateInstance<InputActionReference>();
			FistActions fist = MonoSingleton<InputManager>.Instance.InputSource.Actions.Fist;
			val.Set(((FistActions)(ref fist)).Punch);
			message.actionReference = val;
			message.message2 = " to purchase.";
		}

		private void OnTriggerEnter(Collider other)
		{
			if (!(((Component)other).tag != "Player"))
			{
				active = true;
				((Component)foodStand.Icon).gameObject.SetActive(true);
				if (!first_active)
				{
					MonoSingleton<SubtitleController>.Instance.DisplaySubtitle(foodStand.PrePurchaseSub, (AudioSource)null);
					first_active = true;
				}
			}
		}

		private void OnTriggerExit(Collider other)
		{
			if (!(((Component)other).tag != "Player"))
			{
				active = false;
				((Component)foodStand.Icon).gameObject.SetActive(false);
			}
		}

		private void Update()
		{
			if (active && MonoSingleton<InputManager>.Instance.InputSource.Punch.WasPerformedThisFrame)
			{
				foodStand.ButtonPressed();
			}
		}

		private void OnDisable()
		{
			message.timerTime = 0f;
		}
	}
	public static class ReflectionExtensions
	{
		public static void SetPrivate(this object obj, string name, object value)
		{
			obj.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(obj, value);
		}

		public static T GetPrivate<T>(this object obj, string name)
		{
			return (T)obj.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(obj);
		}
	}
}
namespace GabrielFoodStand.Patches
{
	[HarmonyPatch(typeof(LevelSelectPanel))]
	public static class LevelSelectPanelPatch
	{
		[HarmonyPatch("OnEnable")]
		[HarmonyPostfix]
		private static void OnEnablePostfix(LevelSelectPanel __instance)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			Text component = ((Component)((Component)__instance).transform.Find("Name")).GetComponent<Text>();
			string item = AgentRegistry.LevelDatabase[__instance.levelNumber];
			if (!FoodData.Data.standsIncomplete.Contains(item))
			{
				((Graphic)component).color = Color.green;
			}
		}
	}
	[HarmonyPatch(typeof(FinalPit), "SendInfo")]
	public static class FinalPitEventPatch
	{
		public static void Postfix()
		{
			BestUtilityEverCreated.OnLevelComplete?.Invoke();
		}
	}
	[HarmonyPatch(typeof(PlayerActivatorRelay), "Activate")]
	public static class PlayerActivatorEventPatch
	{
		public static void Postfix()
		{
			BestUtilityEverCreated.OnPlayerActivated?.Invoke();
		}
	}
}