Decompiled source of UltraCookieClicker v1.0.2

CookieClickerConfiggy.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using Configgy;
using Configgy.UI.Template;
using CookieClickerNameSpace;
using Newtonsoft.Json;
using UnityEngine;
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("CookieClickerConfiggy")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CookieClickerConfiggy")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("adbeb322-78eb-4a4a-bf40-89979cff7bce")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CookieClickerNameSpace
{
	public class CookieClicker
	{
		public enum TowerType
		{
			Clicker,
			Grandma,
			Farm,
			Mine,
			Factory,
			Bank,
			Temple
		}

		public _Towers TowersGM;

		public GameObject TowersGameObj;

		[Configgable("", "NewsText", 0, null)]
		public static ConfigButton newsText = new ConfigButton((Action)StartNewsMessage, "News!");

		public static bool GameStarted = false;

		public static long StartTime = 0L;

		[Configgable("", "CPS", 0, null)]
		public static ConfigButton CPSLister = new ConfigButton((Action)Nothing, "CPS");

		[Configgable("", "Cookies", 0, null)]
		public static ConfigButton CookiesLister = new ConfigButton((Action)ClickCookie, "Cookies");

		public static long Cookies;

		public static long totalCookies;

		[Configgable("Buy Towers", "Buy Clicker", 0, null)]
		public static ConfigButton Buy_Clicker = new ConfigButton((Action)BuyClicker, "Buy Clicker \n" + ClickerPrice);

		public static int Clickers;

		public static float ClickerPrice = 15f;

		public static float DefaultClickerPrice = 15f;

		public static float Clicker_CPS = 1f;

		public static float DefaultClicker_CPS = 1f;

		[Configgable("Buy Towers", "Buy Grandma", 0, null)]
		public static ConfigButton Buy_Grandma = new ConfigButton((Action)BuyGrandma, "Buy Grandma \n" + GrandmaPrice);

		public static int Gradmas;

		public static float GrandmaPrice = 100f;

		public static float DefaultGrandmaPrice = 100f;

		public static float Gradmas_CPS = 3f;

		public static float DefaultGradmas_CPS = 3f;

		[Configgable("Buy Towers", "Buy Farm", 0, null)]
		public static ConfigButton Farm = new ConfigButton((Action)BuyFarm, "Buy Farm \n" + FarmPrice);

		public static int Farms;

		public static float FarmPrice = 1100f;

		public static float DefaultFarmPrice = 1100f;

		public static float Farm_CPS = 8f;

		public static float DefaultFarm_CPS = 8f;

		[Configgable("Buy Towers", "Buy Mine", 0, null)]
		public static ConfigButton Mine = new ConfigButton((Action)BuyMine, "Buy Mine \n" + MinePrice);

		public static int Mines;

		public static float MinePrice = 12000f;

		public static float DefaultMinePrice = 12000f;

		public static float Mine_CPS = 47f;

		public static float DefaultMine_CPS = 47f;

		[Configgable("Buy Towers", "Buy Factory", 0, null)]
		public static ConfigButton Factory = new ConfigButton((Action)BuyFactory, "Buy Factory \n" + FactoryPrice);

		public static int Factorys;

		public static float FactoryPrice = 130000f;

		public static float DefaultFactoryPrice = 130000f;

		public static float Factory_CPS = 260f;

		public static float DefaultFactory_CPS = 260f;

		[Configgable("Buy Towers", "Buy Bank", 0, null)]
		public static ConfigButton Bank = new ConfigButton((Action)BuyBank, "Buy Factory \n" + BankPrice);

		public static int Banks;

		public static float BankPrice = 1400000f;

		public static float DefaultBankPrice = 1400000f;

		public static float Bank_CPS = 1400f;

		public static float DefaultBank_CPS = 1400f;

		[Configgable("Buy Towers", "Buy Temple", 0, null)]
		public static ConfigButton Temple = new ConfigButton((Action)BuyTemple, "Buy Temple \n" + TemplePrice);

		public static int Temples;

		public static float TemplePrice = 20000000f;

		public static float DefaultTemplePrice = 20000000f;

		public static float Temple_CPS = 7800f;

		public static float DefaultTemple_CPS = 7800f;

		private const string SellClickers = "Sell Clicker/s";

		private const string SellGrandmas = "Sell Grandma/s";

		private const string SellFarms = "Sell Farm/s";

		private const string SellMine = "Sell Mine/s";

		private const string SellFactorys = "Sell Factory/s";

		private const string SellBank = "Sell Bank/s";

		private const string SellTemple = "Sell Temple/s";

		private static string[] TowerTypes = new string[7] { "Sell Clicker/s", "Sell Grandma/s", "Sell Farm/s", "Sell Mine/s", "Sell Factory/s", "Sell Bank/s", "Sell Temple/s" };

		private static ConfigDropdown<string> SelectedTT = new ConfigDropdown<string>(TowerTypes.ToArray(), (string[])null, 0);

		private static ConfigButton Sell_1 = new ConfigButton((Action)SellTower1, "Sell 1");

		private static ConfigButton Sell_10 = new ConfigButton((Action)SellTower10, "Sell 10");

		private static ConfigButton Sell_100 = new ConfigButton((Action)SellTower100, "Sell 100");

		public static ConfigButton SLumps = new ConfigButton((Action)CollectSugarLump, "Sugar Lumps");

		public static bool SugarLumpsCanGrow;

		public static long FallTime;

		public static bool SugarLumpMature;

		public static bool SugarLumpRipe;

		public static int SugarLumps;

		[Configgable("", "Golden Cookie", 0, null)]
		public static ConfigButton GCookie = new ConfigButton((Action)ClickGoldenCookie, "Golden Cookie");

		public static bool GoldenCookie7X;

		public static float GoldenCookie7XTimer;

		public static bool goldenCookieSpawned;

		public static float goldenCookieTimer;

		public static float nextSpawnTime;

		public static float cps = 0f;

		private static Dictionary<string, TowerType> TowerTypeMapping = new Dictionary<string, TowerType>
		{
			{
				"Sell Clicker/s",
				TowerType.Clicker
			},
			{
				"Sell Grandma/s",
				TowerType.Grandma
			},
			{
				"Sell Farm/s",
				TowerType.Farm
			},
			{
				"Sell Mine/s",
				TowerType.Mine
			},
			{
				"Sell Factory/s",
				TowerType.Factory
			},
			{
				"Sell Bank/s",
				TowerType.Bank
			},
			{
				"Sell Temple/s",
				TowerType.Temple
			}
		};

		private static TowerType SellTowerTypeControl;

		private static GameManager gam;

		private static List<string> whiteList = new List<string>
		{
			"Cookies", "Clickers", "Gradmas", "Farms", "Mines", "Factorys", "Banks", "Temples", "cps", "goldenCookieSpawned",
			"GoldenCookie7X", "goldenCookieTimer", "nextSpawnTime", "GameStarted", "StartTime", "totalCookies", "SugarLumpsCanGrow", "FallTime", "GoldenCookie7XTimer"
		};

		private static List<string> blacklist = new List<string>();

		public static bool DataLoaded = false;

		public float baseChancePerSec = 1000.005f;

		public float minSpawnTime = 40f;

		public float maxSpawnTime = 620f;

		public static ConfigBuilder configBuilder { get; private set; }

		private static string SaveFolderPath => Path.Combine(Application.dataPath, "..", "BepInEx/plugins/CookieClicker/Saves");

		private static string SaveFilePath => Path.Combine(SaveFolderPath, "playerData.json");

		private static void StartNewsMessage()
		{
			TickerMessages.GetRandomNewsMessage(Cookies);
		}

		private static void Nothing()
		{
		}

		private static void SellTower1()
		{
			SellTower(1);
		}

		private static void SellTower10()
		{
			SellTower(10);
		}

		private static void SellTower100()
		{
			SellTower(100);
		}

		public static void CollectSugarLump()
		{
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			if (SugarLumpsCanGrow)
			{
				long num = RemoveTimeToUnix(FallTime, 0L, 0L, 4L, 0L, 0L);
				long unixTime = GetUnixTime();
				if (unixTime >= num)
				{
					SugarLumpMature = true;
					Log("Sugar lump is mature");
					if (RemoveTimeToUnix(FallTime, 0L, 0L, 1L, 0L, 0L) >= unixTime)
					{
						SugarLumpRipe = true;
						Log("Sugar lump is ripe");
					}
				}
			}
			if (SugarLumpMature && !SugarLumpRipe)
			{
				bool flag = FiftyFifty();
				if (flag)
				{
					SugarLumps++;
					Log("Sucsesfully harvested mature sugar lump");
					UpdateButtonLabel(105, $"Sugar lumps {SugarLumps}. Sugar lump harvest successful", (Color?)new Color(255f, 255f, 255f), (Color?)null);
				}
				else if (!flag)
				{
					Log("Sucsesfully harvested mature sugar lump");
					UpdateButtonLabel(105, $"Sugar lumps {SugarLumps}. Failed harvesting sugar lump", (Color?)new Color(255f, 0f, 0f), (Color?)null);
				}
				SugarLumpMature = false;
			}
			else if (SugarLumpMature && SugarLumpRipe)
			{
				Log("Sucsesfully harvested ripe sugar lump");
				SugarLumps++;
			}
			else
			{
				UpdateButtonLabel(105, $"Sugar lumps {SugarLumps}. Failed harvesting sugar lump", (Color?)new Color(255f, 0f, 0f), (Color?)null);
				Log("Failed harvesting sugar lump");
			}
		}

		private static void ClickGoldenCookie()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			if (goldenCookieSpawned)
			{
				goldenCookieSpawned = false;
				goldenCookieTimer = -1f;
				GoldenCookie7X = true;
				GoldenCookie7XTimer = 90f;
				UpdateButtonLabel(103, "Clicked Golden Cookie!", (Color?)new Color(255f, 215f, 0f), (Color?)null);
				MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage("Clicked Golden Cookie!", "", "", 0, false);
			}
			else if (!GoldenCookie7X || GoldenCookie7XTimer > 0f)
			{
				UpdateButtonLabel(103, "No golden cookie here currently :(", (Color?)new Color(210f, 43f, 43f), (Color?)null);
				Log("Golden Cookie Click Failed");
			}
			if (GoldenCookie7X)
			{
				UpdateButtonLabel(103, $"Golden Cookie effect active, Time Left: {GoldenCookie7XTimer}", (Color?)new Color(210f, 43f, 43f), (Color?)null);
			}
		}

		private static void ClickCookie()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			Cookies++;
			totalCookies++;
			UpdateButtonLabel(99, (double)Cookies + " \n Cookies", (Color?)new Color(111f, 78f, 55f), (Color?)null);
		}

		private static void BuyClicker()
		{
			if ((float)Cookies >= ClickerPrice)
			{
				Clickers++;
				Cookies -= (long)ClickerPrice;
				ClickerPrice *= 1.15f;
				ClickerPrice = Mathf.CeilToInt(ClickerPrice);
				Log("Buyed Clicker. Clicker: " + Clickers);
				Log("Money left: " + Cookies);
				cps += Clicker_CPS;
				string text = ClickerPrice.ToString();
				UpdateButtonLabel(100, "CPS\n" + cps);
				UpdateButtonLabel(3, $"Buy Clicker, Amount Owned {Clickers} \n" + ClickerPrice);
				UpdateButtonLabel(99, "Cookies: " + (int)Cookies);
			}
			else
			{
				Log("Not Enough money");
			}
		}

		private static void BuyGrandma()
		{
			if ((float)Cookies >= GrandmaPrice)
			{
				Gradmas++;
				Cookies -= (long)GrandmaPrice;
				GrandmaPrice *= 1.15f;
				GrandmaPrice = Mathf.CeilToInt(GrandmaPrice);
				Log("Buyed Gradma. Gradmas: " + Gradmas);
				Log("Money left: " + Cookies);
				cps += Gradmas_CPS;
				UpdateButtonLabel(100, "CPS\n" + cps);
				UpdateButtonLabel(4, $"Buy Gradma, Amount Owned {Gradmas} \n" + GrandmaPrice);
				UpdateButtonLabel(99, "Cookies: " + (int)Cookies);
			}
			else
			{
				Log("Not Enough money");
			}
		}

		private static void BuyFarm()
		{
			if ((float)Cookies >= FarmPrice)
			{
				Farms++;
				Cookies -= (long)FarmPrice;
				FarmPrice *= 1.15f;
				FarmPrice = Mathf.CeilToInt(FarmPrice);
				Log("Buyed Farm. Farm: " + Farms);
				Log("Money left: " + Cookies);
				cps += Farm_CPS;
				UpdateButtonLabel(100, "CPS\n" + cps);
				UpdateButtonLabel(5, $"Buy Farm, Amount Owned {Farms} \n" + FarmPrice);
				UpdateButtonLabel(99, "Cookies: " + (int)Cookies);
			}
			else
			{
				Log("Not Enough money");
			}
		}

		private static void BuyMine()
		{
			if ((float)Cookies >= MinePrice)
			{
				Mines++;
				Cookies -= (long)MinePrice;
				MinePrice *= 1.15f;
				MinePrice = Mathf.CeilToInt(MinePrice);
				Log("Buyed Mine . Mine : " + Mines);
				Log("Money left: " + Cookies);
				cps += Mine_CPS;
				UpdateButtonLabel(100, "CPS\n" + cps);
				UpdateButtonLabel(6, $"Buy Mine, Amount Owned {Mines} \n" + MinePrice);
				UpdateButtonLabel(99, "Cookies: " + (int)Cookies);
			}
			else
			{
				Log("Not Enough money");
			}
		}

		private static void BuyFactory()
		{
			if ((float)Cookies >= FactoryPrice)
			{
				Factorys++;
				Cookies -= (long)FactoryPrice;
				FactoryPrice *= 1.15f;
				FactoryPrice = Mathf.CeilToInt(FactoryPrice);
				Log("Buyed Factory . Factory : " + Factorys);
				Log("Money left: " + Cookies);
				cps += Factory_CPS;
				UpdateButtonLabel(100, "CPS\n" + cps);
				UpdateButtonLabel(6, $"Buy Factory, Amount Owned {Factorys} \n" + FactoryPrice);
				UpdateButtonLabel(99, "Cookies: " + (int)Cookies);
			}
			else
			{
				Log("Not Enough money");
			}
		}

		private static void BuyBank()
		{
			if ((float)Cookies >= BankPrice)
			{
				Banks++;
				Cookies -= (long)BankPrice;
				BankPrice *= 1.15f;
				BankPrice = Mathf.CeilToInt(BankPrice);
				Log("Buyed Bank . Bank : " + Banks);
				Log("Money left: " + Cookies);
				cps += Bank_CPS;
				UpdateButtonLabel(100, "CPS\n" + cps);
				UpdateButtonLabel(8, $"Buy Bank, Amount Owned {Banks} \n" + BankPrice);
				UpdateButtonLabel(99, "Cookies: " + (int)Cookies);
			}
			else
			{
				Log("Not Enough money");
			}
		}

		private static void BuyTemple()
		{
			if ((float)Cookies >= TemplePrice)
			{
				Temples++;
				Cookies -= (long)TemplePrice;
				TemplePrice *= 1.15f;
				TemplePrice = Mathf.CeilToInt(TemplePrice);
				Log("Buyed Temple . Temple : " + Temples);
				Log("Money left: " + Cookies);
				cps += Temple_CPS;
				UpdateButtonLabel(100, "CPS\n" + cps);
				UpdateButtonLabel(9, $"Buy Temple, Amount Owned {Temples} \n" + TemplePrice);
				UpdateButtonLabel(99, "Cookies: " + (int)Cookies);
			}
			else
			{
				Log("Not Enough money");
			}
		}

		private static void SellTowerType(float price, int towerCount, float cps, int buttonIndex)
		{
			if (towerCount <= 0)
			{
				Debug.Log((object)$"Not enough {towerCount}");
				return;
			}
			towerCount--;
			price *= 0.85f;
			Cookies += (long)(price *= 0.6f);
			Debug.Log((object)$"Sold {towerCount}. {towerCount}s: {towerCount}");
			Debug.Log((object)$"Money left: {Cookies}");
			CalculateCPS();
			UpdateButtonLabel(100, "CPS\n" + cps);
			UpdateButtonLabel(buttonIndex, $"Buy {towerCount}, Amount Owned {towerCount}\n{price}");
			UpdateButtonLabel(99, "Cookies: " + (int)Cookies);
		}

		private static void SellTower(int amount)
		{
			string value = ((ConfigValueElement<string>)(object)SelectedTT).Value;
			if (TowerTypeMapping.TryGetValue(value, out var value2))
			{
				switch (value2)
				{
				case TowerType.Clicker:
					SellTowerTypeControl = TowerType.Clicker;
					break;
				case TowerType.Grandma:
					SellTowerTypeControl = TowerType.Grandma;
					break;
				case TowerType.Farm:
					SellTowerTypeControl = TowerType.Farm;
					break;
				case TowerType.Mine:
					SellTowerTypeControl = TowerType.Mine;
					break;
				case TowerType.Factory:
					SellTowerTypeControl = TowerType.Factory;
					break;
				case TowerType.Bank:
					SellTowerTypeControl = TowerType.Bank;
					break;
				case TowerType.Temple:
					SellTowerTypeControl = TowerType.Temple;
					break;
				default:
					Debug.Log((object)("Invalid tower type: " + value2));
					break;
				}
				GameManager.SellTower(SellTowerTypeControl, amount);
			}
			CalculateCPS();
		}

		private static int GetTowerCount(TowerType towerType)
		{
			return towerType switch
			{
				TowerType.Clicker => Clickers, 
				TowerType.Grandma => Gradmas, 
				TowerType.Farm => Farms, 
				TowerType.Mine => Mines, 
				TowerType.Factory => Factorys, 
				TowerType.Bank => Banks, 
				TowerType.Temple => Temples, 
				_ => 0, 
			};
		}

		public static void CalculateCPS()
		{
			float num = 0f;
			num += (float)Clickers * Clicker_CPS;
			num += (float)Gradmas * Gradmas_CPS;
			num += (float)Farms * Farm_CPS;
			num += (float)Mines * Mine_CPS;
			num += (float)Factorys * Factory_CPS;
			num += (float)Banks * Bank_CPS;
			num += (float)Temples * Temple_CPS;
			if (GoldenCookie7X)
			{
				cps = num * 7f;
			}
			else
			{
				cps = num;
			}
			UpdateButtonLabel(100, "CPS\n " + cps);
		}

		public static void UpdateOtherValues()
		{
			UpdateButtonLabel(99, "Cookies: " + (int)Cookies);
			if (Clickers == 0)
			{
				ClickerPrice = DefaultClickerPrice;
			}
			if (Gradmas == 0)
			{
				GrandmaPrice = DefaultGrandmaPrice;
			}
			if (Farms == 0)
			{
				FarmPrice = DefaultFarmPrice;
			}
			if (Mines == 0)
			{
				MinePrice = DefaultMinePrice;
			}
			if (Factorys == 0)
			{
				FactoryPrice = DefaultFactoryPrice;
			}
			if (Banks == 0)
			{
				BankPrice = DefaultBankPrice;
			}
			if (Temples == 0)
			{
				TemplePrice = DefaultTemplePrice;
			}
			if (Clicker_CPS != DefaultClicker_CPS)
			{
				Clicker_CPS = DefaultClicker_CPS;
			}
			if (Gradmas_CPS != DefaultGradmas_CPS)
			{
				Gradmas_CPS = DefaultGradmas_CPS;
			}
			if (Farm_CPS != DefaultFarm_CPS)
			{
				Farm_CPS = DefaultFarm_CPS;
			}
			if (Mine_CPS != DefaultMine_CPS)
			{
				Mine_CPS = DefaultMine_CPS;
			}
			if (Factory_CPS != DefaultFactory_CPS)
			{
				Factory_CPS = DefaultFactory_CPS;
			}
			if (Bank_CPS != DefaultBank_CPS)
			{
				Bank_CPS = DefaultBank_CPS;
			}
			if (Temple_CPS != DefaultTemple_CPS)
			{
				Temple_CPS = DefaultTemple_CPS;
			}
			GameManager.UpdateUI();
		}

		public List<float> GetFloatValues()
		{
			List<float> list = new List<float>();
			FieldInfo[] fields = GetType().GetFields();
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				if (fieldInfo.FieldType == typeof(float))
				{
					float item = (float)fieldInfo.GetValue(this);
					list.Add(item);
				}
			}
			return list;
		}

		public static void CalculatePrices()
		{
			gam = new GameManager();
			foreach (Tower value in GameManager.towers.Values)
			{
				float num = value.Count;
				float num2 = value.DefaultPrice;
				for (int i = 0; (float)i < num; i++)
				{
					num2 *= 1.15f;
				}
				value.Price = num2;
			}
		}

		public static void SavePlayerData()
		{
			CookieClicker obj = new CookieClicker();
			IEnumerable<FieldInfo> enumerable = from field in typeof(CookieClicker).GetFields()
				where whiteList.Contains(field.Name)
				select field;
			Dictionary<string, object> dictionary = new Dictionary<string, object>();
			foreach (FieldInfo item in enumerable)
			{
				object obj2 = (dictionary[item.Name] = item.GetValue(obj));
				object value2 = obj2;
				dictionary[item.Name] = value2;
			}
			string contents = JsonConvert.SerializeObject((object)dictionary, (Formatting)1);
			if (!Directory.Exists(SaveFolderPath))
			{
				Directory.CreateDirectory(SaveFolderPath);
			}
			File.WriteAllText(SaveFilePath, contents);
		}

		public static void LoadPlayerData()
		{
			try
			{
				if (File.Exists(SaveFilePath))
				{
					string text = File.ReadAllText(SaveFilePath);
					Dictionary<string, object> dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>(text);
					CookieClicker obj = new CookieClicker();
					foreach (KeyValuePair<string, object> item in dictionary)
					{
						FieldInfo field = typeof(CookieClicker).GetField(item.Key);
						if (field != null)
						{
							object value = ConvertValue(item.Value, field.FieldType);
							field.SetValue(obj, value);
						}
					}
					Log("Player data loaded successfully.");
				}
				else
				{
					Debug.LogWarning((object)("Save file not found at: " + SaveFilePath));
				}
				DataLoaded = true;
			}
			catch (NullReferenceException)
			{
			}
		}

		private static object ConvertValue(object value, Type targetType)
		{
			if (targetType == typeof(int))
			{
				return Convert.ToInt32(value);
			}
			if (targetType == typeof(long))
			{
				return Convert.ToInt64(value);
			}
			if (targetType == typeof(ulong))
			{
				return Convert.ToUInt64(value);
			}
			if (targetType == typeof(bool))
			{
				return Convert.ToBoolean(value);
			}
			if (targetType == typeof(string))
			{
				return Convert.ToString(value);
			}
			if (targetType == typeof(float))
			{
				return Convert.ToSingle(value);
			}
			throw new Exception("Unsupported type: " + targetType);
		}

		public static long GetUnixTime()
		{
			return ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds();
		}

		public static long AddTimeToUnix(long UNIX, long seconds = 0L, long mins = 0L, long hours = 0L, long days = 0L, long weeks = 0L)
		{
			long num = 0L;
			num = UNIX;
			num += seconds;
			num += mins * 60;
			num += hours * 3600;
			num += days * 86400;
			return num + weeks * 604800;
		}

		public static long RemoveTimeToUnix(long UNIX, long seconds = 0L, long mins = 0L, long hours = 0L, long days = 0L, long weeks = 0L)
		{
			long num = 0L;
			num = UNIX;
			num -= seconds;
			num -= mins * 60;
			num -= hours * 3600;
			num -= days * 86400;
			return num - weeks * 604800;
		}

		public static bool FiftyFifty()
		{
			float value = Random.value;
			if ((double)value >= 0.5)
			{
				Log("Fifty Fifty returned true");
				return true;
			}
			Log("Fifty Fifty returned false");
			return false;
		}

		public static void Log(string Message = "")
		{
			Debug.Log((object)Message);
		}

		public static void UpdateButtonLabel(int num, string text = "", Color? col = null, Color? backCol = null)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			ConfigButton buttonType = GetButtonType(num);
			if (buttonType != null && text != "")
			{
				buttonType.SetLabel(text);
				Color val = (Color)(((??)col) ?? Color.black);
				if (val != Color.black)
				{
					Text buttonLabel = buttonType.GetButtonLabel();
					if ((Object)(object)buttonLabel != (Object)null)
					{
						((Graphic)buttonLabel).color = val;
					}
				}
				else
				{
					Text buttonLabel2 = buttonType.GetButtonLabel();
					if ((Object)(object)buttonLabel2 != (Object)null)
					{
						((Graphic)buttonLabel2).color = Color.white;
					}
				}
				Color val2 = (Color)(((??)backCol) ?? Color.black);
				if (!(val2 != Color.black))
				{
					return;
				}
				Button button = buttonType.GetButton();
				if ((Object)(object)button != (Object)null)
				{
					Frame componentInParent = ((Component)button).GetComponentInParent<Frame>();
					if ((Object)(object)componentInParent != (Object)null)
					{
						componentInParent.SetBorderColor(val2);
					}
				}
			}
			else
			{
				Log("CFG IS NULL OR TEXT IS EMPTY");
			}
		}

		public static ConfigButton GetButtonType(int num)
		{
			return (ConfigButton)(num switch
			{
				105 => SLumps, 
				103 => GCookie, 
				100 => CPSLister, 
				102 => newsText, 
				99 => CookiesLister, 
				3 => Buy_Clicker, 
				4 => Buy_Grandma, 
				5 => Farm, 
				6 => Mine, 
				7 => Factory, 
				8 => Bank, 
				9 => Temple, 
				_ => null, 
			});
		}

		public void GoldenRoll()
		{
			//IL_0020: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			if (goldenCookieSpawned)
			{
				UpdateButtonLabel(103, "Golden Cookie!", (Color?)new Color(255f, 215f, 0f), (Color?)null);
			}
			if (!goldenCookieSpawned && GoldenCookie7XTimer > 0f && !GoldenCookie7X)
			{
				UpdateButtonLabel(103, "No golden cookie here currently :(", (Color?)new Color(5f, 5f, 5f), (Color?)null);
			}
			if (Time.time >= nextSpawnTime)
			{
				float value = Random.value;
				if (value < baseChancePerSec)
				{
					Log("Spawning golden cookie!");
					goldenCookieSpawned = true;
					nextSpawnTime = Time.time + Random.Range(minSpawnTime, maxSpawnTime);
					UpdateButtonLabel(103, "Golden Cookie!", (Color?)new Color(255f, 215f, 0f), (Color?)null);
					goldenCookieTimer = 14f;
				}
			}
		}
	}
	[BepInPlugin("DolfeLive.Ultrakill.CookieClicker", "CookieClicker", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class _Towers : BaseUnityPlugin
	{
		public static CookieClicker cookieClicker;

		public static int Seconds;

		public static bool StartedCPSToCookies;

		public static bool isCPSLoopRunning;

		public static ConfigBuilder configBuilder { get; private set; }

		public static IEnumerator CPSLoop()
		{
			while (true)
			{
				UltraCPSToCookies();
				yield return (object)new WaitForSeconds(1f);
			}
		}

		private void Start()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			Object.DontDestroyOnLoad((Object)(object)this);
			cookieClicker = new CookieClicker();
			configBuilder = new ConfigBuilder("Dolfelive.CookieClicker", "CookieClicker");
			configBuilder.BuildAll();
			Object.DontDestroyOnLoad((Object)(object)Object.Instantiate<GameObject>(new GameObject()).AddComponent<CPSLooperScript>());
			CookieClicker.goldenCookieSpawned = false;
			CookieClicker.goldenCookieTimer = -1f;
			CookieClicker.nextSpawnTime = 100f;
			if (!CookieClicker.GoldenCookie7X || CookieClicker.GoldenCookie7XTimer > 0f)
			{
				CookieClicker.UpdateButtonLabel(103, "No golden cookie here currently :(", (Color?)new Color(210f, 43f, 43f), (Color?)null);
				CookieClicker.Log("Golden Cookie Click Failed");
			}
			if (CookieClicker.GoldenCookie7X)
			{
				CookieClicker.UpdateButtonLabel(103, $"Golden Cookie effect active, Time Left: {CookieClicker.GoldenCookie7XTimer}", (Color?)new Color(210f, 43f, 43f), (Color?)null);
			}
			cookieClicker.GoldenRoll();
			CookieClicker.Log("Cookie Clicker Mod Started");
			CookieClicker.LoadPlayerData();
			CookieClicker.CalculateCPS();
			CookieClicker.CalculatePrices();
			CookieClicker.UpdateOtherValues();
			GameManager.UpdateUI();
			TickerMessages.GetRandomNewsMessage(CookieClicker.Cookies);
			CookieClicker.CalculatePrices();
			CookieClicker.nextSpawnTime = Time.time + Random.Range(cookieClicker.minSpawnTime, cookieClicker.maxSpawnTime);
		}

		public static void UltraCPSToCookies()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			StartedCPSToCookies = true;
			cookieClicker = new CookieClicker();
			double num = CookieClicker.cps;
			CookieClicker.Cookies += (long)num;
			CookieClicker.totalCookies += (long)num;
			CookieClicker.UpdateButtonLabel(100, $"CPS\n {num}");
			CookieClicker.UpdateButtonLabel(99, (double)CookieClicker.Cookies + " \n Cookies", (Color?)new Color(111f, 78f, 55f), (Color?)null);
			CookieClicker.CalculateCPS();
			Seconds++;
			GameManager.UpdateUI();
			if (CookieClicker.totalCookies > 1000000000 && !CookieClicker.SugarLumpsCanGrow)
			{
				CookieClicker.SugarLumpsCanGrow = true;
				long unixTime = CookieClicker.GetUnixTime();
				CookieClicker.FallTime = CookieClicker.AddTimeToUnix(unixTime, 0L, 0L, 0L, 1L, 0L);
				CookieClicker.Log($"Fall time: {CookieClicker.FallTime}");
			}
			if (!CookieClicker.GameStarted)
			{
				CookieClicker.GameStarted = true;
				DateTime utcNow = DateTime.UtcNow;
				CookieClicker.StartTime = ((DateTimeOffset)utcNow).ToUnixTimeSeconds();
			}
			if (CookieClicker.GoldenCookie7XTimer > 0f && CookieClicker.GoldenCookie7X)
			{
				CookieClicker.GoldenCookie7X = true;
				CookieClicker.UpdateButtonLabel(103, $"Golden Cookie effect active, Time Left: {CookieClicker.GoldenCookie7XTimer}", (Color?)new Color(210f, 43f, 43f), (Color?)new Color(210f, 43f, 43f));
				CookieClicker.GoldenCookie7XTimer -= 1f;
			}
			else if (CookieClicker.GoldenCookie7XTimer <= 0f && CookieClicker.GoldenCookie7X)
			{
				CookieClicker.GoldenCookie7X = false;
				CookieClicker.GoldenCookie7XTimer = -1f;
				CookieClicker.UpdateButtonLabel(103, "No golden cookie here currently :(", (Color?)new Color(5f, 5f, 5f), (Color?)null);
			}
			if (CookieClicker.goldenCookieSpawned)
			{
				CookieClicker.goldenCookieTimer -= 1f;
				CookieClicker.UpdateButtonLabel(103, "Golden Cookie!", (Color?)new Color(210f, 43f, 43f), (Color?)new Color(210f, 43f, 43f));
			}
			else if (CookieClicker.GoldenCookie7XTimer <= 0f && !CookieClicker.GoldenCookie7X)
			{
				cookieClicker.GoldenRoll();
			}
			if (CookieClicker.goldenCookieTimer == 0f)
			{
				CookieClicker.goldenCookieSpawned = false;
				CookieClicker.goldenCookieTimer = -1f;
				CookieClicker.UpdateButtonLabel(103, "No golden cookie here currently :(", (Color?)new Color(5f, 5f, 5f), (Color?)null);
			}
			if (Seconds == 5 && CookieClicker.DataLoaded)
			{
				CookieClicker.SavePlayerData();
			}
			if (Seconds >= 10)
			{
				Seconds = 0;
				TickerMessages.GetRandomNewsMessage(CookieClicker.Cookies);
				CookieClicker.CalculatePrices();
				CookieClicker.SavePlayerData();
			}
		}
	}
	public class CPSLooperScript : MonoBehaviour
	{
		private static CPSLooperScript _instance;

		private IEnumerator _CPSLoopCoroutine;

		public static CPSLooperScript Instance
		{
			get
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				if ((Object)(object)_instance == (Object)null)
				{
					_instance = Object.FindObjectOfType<CPSLooperScript>();
					if ((Object)(object)_instance == (Object)null)
					{
						GameObject val = new GameObject("CPSLooperScript");
						val.AddComponent<CPSLooperScript>();
						Object.DontDestroyOnLoad((Object)(object)val);
					}
				}
				return _instance;
			}
		}

		private void Start()
		{
			_CPSLoopCoroutine = CPSLoopCoroutine();
			if (_CPSLoopCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(_CPSLoopCoroutine);
			}
			((MonoBehaviour)this).StartCoroutine(_CPSLoopCoroutine);
		}

		private void OnDestroy()
		{
			((MonoBehaviour)this).StopCoroutine(_CPSLoopCoroutine);
		}

		private IEnumerator CPSLoopCoroutine()
		{
			while (true)
			{
				_Towers.UltraCPSToCookies();
				yield return (object)new WaitForSecondsRealtime(1f);
			}
		}
	}
	public class TickerMessages
	{
		private static Dictionary<string, long> cookieMessages = new Dictionary<string, long>
		{
			{ "You feel like making cookies. But nobody wants to eat your cookies.", 5L },
			{ "Your first batch goes in the trash. The neighborhood raccoon barely touches it.", 50L },
			{ "Your family accepts to try some of your cookies.", 100L },
			{ "Your cookies are popular in the neighborhood.", 500L },
			{ "People are starting to talk about your cookies.", 1000L },
			{ "Your cookies are talked about for miles around.", 5000L },
			{ "Your cookies are renowned in the whole town!", 10000L },
			{ "Your cookies bring all the boys to the yard.", 50000L },
			{ "Your cookies now have their own website!", 100000L },
			{ "Your cookies are worth a lot of money.", 500000L },
			{ "Your cookies sell very well in distant countries.", 1000000L },
			{ "People come from very far away to get a taste of your cookies.", 5000000L },
			{ "Kings and queens from all over the world are enjoying your cookies.", 10000000L },
			{ "There are now museums dedicated to your cookies.", 50000000L },
			{ "A national day has been created in honor of your cookies.", 100000000L },
			{ "Your cookies have been named a part of the world wonders.", 500000000L },
			{ "History books now include a whole chapter about your cookies.", 1000000000L },
			{ "Your cookies have been placed under government surveillance.", 5000000000L },
			{ "The whole planet is enjoying your cookies!", 10000000000L },
			{ "Strange creatures from neighboring planets wish to try your cookies.", 50000000000L },
			{ "Elder gods from the whole cosmos have awoken to taste your cookies.", 100000000000L },
			{ "Beings from other dimensions lapse into existence just to get a taste of your cookies.", 500000000000L },
			{ "Your cookies have achieved sentience.", 1000000000000L },
			{ "The universe has now turned into cookie dough, to the molecular level.", 5000000000000L },
			{ "Your cookies are rewriting the fundamental laws of the universe.", 10000000000000L },
			{ "It's time to stop playing.", 50000000000000L },
			{ "A local news station runs a 10-minute segment about your cookies. Success! (You win a cookie)", 100000000000000L }
		};

		private const string msg1 = "Moist cookies. -grandma";

		private const string msg2 = "We're nice grandmas. -grandma";

		private const string msg3 = "Indentured servitude. -grandma";

		private const string msg4 = "Come give grandma a kiss. -grandma";

		private const string msg5 = "Why don't you visit more often? -grandma";

		private const string msg6 = "Call me... -grandma";

		private static string[] GrandmaMessages = new string[6] { "Moist cookies. -grandma", "We're nice grandmas. -grandma", "Indentured servitude. -grandma", "Come give grandma a kiss. -grandma", "Why don't you visit more often? -grandma", "Call me... -grandma" };

		private const string CommunityMessages1 = "News: V2 is fucking dead";

		private const string CommunityMessages2 = "THIS IS 107.1 ULTRARADIO";

		private const string CommunityMessages3 = "V1 more like F1 like the grade!";

		private const string CommunityMessages4 = "The cookie spiders are everywhere, they are inside your skin. They are inside your skin. They are inside your skin. they are inside your skin. they are inside your skin";

		private const string CommunityMessages5 = "Breaking news: Sisyphean Insurrectionist Challenges Cerberus guardian of hell In a one-off ball-off In order to decide who balls the hardest!";

		private const string CommunityMessages6 = "Urgent Alert: Ultrakill Strikes Cookie Clicker, Sending Grandma Armies Into Chaos!";

		private const string CommunityMessages7 = "Sisyphus has fallen, billions will suffer!";

		private const string CommunityMessages8 = "Removed Blue Filth";

		private const string CommunityMessages9 = "Size 2 is real";

		private const string CommunityMessages10 = "Sibling Rivalry Heats Up: V1 and V2 engage in a Click Frenzy duel, shattering Heavenly Cookie records and causing minor server lag.";

		private const string CommunityMessages11 = "Sponsored by UItraRadio FM";

		private const string CommunityMessages12 = "Who Needs Sleep?: V2 discovers Coffee, leading to a 666% boost in CPS... and severe jitters.";

		private const string CommunityMessages13 = "Ult rafm is dead";

		private const string CommunityMessages14 = "The Light Is Perfection";

		private const string CommunityMessages15 = "Gabriel donates 1 million Heavenly Chips to the Skill issue Fund, confusing everyone.";

		private const string CommunityMessages16 = "Your cookies have been Certified by real Supreme Angels";

		private const string CommunityMessages17 = "V1 donates to the Skill issue fund? Is the apocalypse coming, or just a sugar rush?";

		private const string CommunityMessages18 = "Shoe Surprise: V1 munches on a Golden Cookie, unleashing a short but stylish rampage.";

		private const string CommunityMessages19 = "Benjamin accidentally obliterates lust's secret cookie stash leading to a shortage on layer 1!";

		private const string CommunityMessages20 = "V2 upgrades, calculates clicks with robotic precision. So cool, even Gabriel grudgingly approves.";

		private const string CommunityMessages21 = "V1 discovers Skill issue fund, Gabriel declares war on all skill issue suffers.";

		private const string CommunityMessages22 = "V1 and V2 trash talk each other, cookie production plummets in passive-aggressive duel.";

		private const string CommunityMessages23 = "Parry this, you filthy casual! V1 deflects a Golden Cookie with a meathook, clicks explode.";

		private const string CommunityMessages24 = "V1 Obliterates V2 in orfer to forge first ever Blood-Machine cookie!";

		private const string CommunityMessages25 = "Your actions strung people down the path of insanity leading to an existential crises and a philosophical debate.";

		private const string CommunityMessages26 = "V1 commits tax evasion! V1 invests heavily in Sugar Lump schemes";

		private const string CommunityMessages27 = "High Demon Elgrim approves of your cookies!";

		private const string CommunityMessages28 = "The crab secret";

		private const string CommunityMessages29 = "where theres a barrel theres a way";

		private const string CommunityMessages30 = "fucking bullshit that didn’t work";

		private const string CommunityMessages31 = "Riggged";

		private const string CommunityMessages32 = "Luckily, High Demon Elgrim can only be summoned by sacrificing 18 children";

		private const string CommunityMessages35 = "You can suggest more messages to go here by either dming @dolfelive on discord or commenting on the community post";

		private static string[] CommunityMessages = new string[33]
		{
			"News: V2 is fucking dead", "THIS IS 107.1 ULTRARADIO", "V1 more like F1 like the grade!", "The cookie spiders are everywhere, they are inside your skin. They are inside your skin. They are inside your skin. they are inside your skin. they are inside your skin", "Breaking news: Sisyphean Insurrectionist Challenges Cerberus guardian of hell In a one-off ball-off In order to decide who balls the hardest!", "Urgent Alert: Ultrakill Strikes Cookie Clicker, Sending Grandma Armies Into Chaos!", "Sisyphus has fallen, billions will suffer!", "Removed Blue Filth", "Size 2 is real", "Sibling Rivalry Heats Up: V1 and V2 engage in a Click Frenzy duel, shattering Heavenly Cookie records and causing minor server lag.",
			"Sponsored by UItraRadio FM", "Who Needs Sleep?: V2 discovers Coffee, leading to a 666% boost in CPS... and severe jitters.", "Ult rafm is dead", "The Light Is Perfection", "Gabriel donates 1 million Heavenly Chips to the Skill issue Fund, confusing everyone.", "Your cookies have been Certified by real Supreme Angels", "V1 donates to the Skill issue fund? Is the apocalypse coming, or just a sugar rush?", "Shoe Surprise: V1 munches on a Golden Cookie, unleashing a short but stylish rampage.", "Benjamin accidentally obliterates lust's secret cookie stash leading to a shortage on layer 1!", "V2 upgrades, calculates clicks with robotic precision. So cool, even Gabriel grudgingly approves.",
			"V1 discovers Skill issue fund, Gabriel declares war on all skill issue suffers.", "V1 and V2 trash talk each other, cookie production plummets in passive-aggressive duel.", "Parry this, you filthy casual! V1 deflects a Golden Cookie with a meathook, clicks explode.", "V1 Obliterates V2 in orfer to forge first ever Blood-Machine cookie!", "Your actions strung people down the path of insanity leading to an existential crises and a philosophical debate.", "V1 commits tax evasion! V1 invests heavily in Sugar Lump schemes", "High Demon Elgrim approves of your cookies!", "The crab secret", "where theres a barrel theres a way", "fucking bullshit that didn’t work",
			"Riggged", "Luckily, High Demon Elgrim can only be summoned by sacrificing 18 children", "You can suggest more messages to go here by either dming @dolfelive on discord or commenting on the community post"
		};

		private Dictionary<string, Tuple<string, int>> towerMessages = new Dictionary<string, Tuple<string, int>>
		{
			{
				"Grandma",
				new Tuple<string, int>("Moist cookies. -grandma", 1)
			},
			{
				"Grandma",
				new Tuple<string, int>("We're nice grandmas. -grandma", 1)
			},
			{
				"Grandma",
				new Tuple<string, int>("Indentured servitude. -grandma", 1)
			},
			{
				"Grandma",
				new Tuple<string, int>("Come give grandma a kiss. -grandma", 1)
			},
			{
				"Grandma",
				new Tuple<string, int>("Why don't you visit more often? -grandma", 1)
			},
			{
				"Grandma",
				new Tuple<string, int>("Call me... -grandma", 1)
			},
			{
				"Grandmas",
				new Tuple<string, int>("Absolutely disgusting. -grandma", 50)
			},
			{
				"Grandmas",
				new Tuple<string, int>("You make me sick. -grandma", 50)
			},
			{
				"Grandmas",
				new Tuple<string, int>("You disgust me. -grandma", 50)
			},
			{
				"Grandmas",
				new Tuple<string, int>("We rise. -grandma", 50)
			},
			{
				"Grandmas",
				new Tuple<string, int>("It begins. -grandma", 50)
			},
			{
				"Grandmas",
				new Tuple<string, int>("It'll all be over soon. -grandma", 50)
			},
			{
				"Grandmas",
				new Tuple<string, int>("You could have stopped it. -grandma", 50)
			},
			{
				"Farm",
				new Tuple<string, int>("News : cookie farms suspected of employing undeclared elderly workforce!", 1)
			},
			{
				"Farm",
				new Tuple<string, int>("News : cookie farms release harmful chocolate in our rivers, says scientist!", 1)
			},
			{
				"Farm",
				new Tuple<string, int>("News : genetically-modified chocolate controversy strikes cookie farmers!", 1)
			},
			{
				"Farm",
				new Tuple<string, int>("News : free-range farm cookies popular with today's hip youth, says specialist.", 1)
			},
			{
				"Farm",
				new Tuple<string, int>("News : farm cookies deemed unfit for vegans, says nutritionist.", 1)
			},
			{
				"Mine",
				new Tuple<string, int>("News : [between 2 and 1001, inclusive] miners dead in chocolate mine catastrophe!", 1)
			},
			{
				"Mine",
				new Tuple<string, int>("News : [between 2 and 1001, inclusive] miners trapped in collapsed chocolate mine!", 1)
			},
			{
				"Mine",
				new Tuple<string, int>("News : chocolate mines found to cause earthquakes and sink holes!", 1)
			},
			{
				"Mine",
				new Tuple<string, int>("News : chocolate mine goes awry, floods village in chocolate!", 1)
			},
			{
				"Mine",
				new Tuple<string, int>("News : depths of chocolate mines found to house peculiar, chocolaty beings!", 1)
			},
			{
				"Mine",
				new Tuple<string, int>("News : is our planet getting lighter? Experts examine the results of intensive chocolate mining.", 1)
			},
			{
				"Factory",
				new Tuple<string, int>("News : cookie factories linked to global warming!", 1)
			},
			{
				"Factory",
				new Tuple<string, int>("News : cookie factories involved in chocolate weather controversy!", 1)
			},
			{
				"Factory",
				new Tuple<string, int>("News : cookie factories on strike, robotic minions employed to replace workforce!", 1)
			},
			{
				"Factory",
				new Tuple<string, int>("News : cookie factories on strike - workers demand to stop being paid in cookies!", 1)
			},
			{
				"Factory",
				new Tuple<string, int>("News : factory-made cookies linked to obesity, says study.", 1)
			},
			{
				"Bank",
				new Tuple<string, int>("News : cookie loans on the rise as people can no longer afford them with regular money.", 1)
			},
			{
				"Bank",
				new Tuple<string, int>("News : cookies slowly creeping up their way as a competitor to traditional currency!", 1)
			},
			{
				"Bank",
				new Tuple<string, int>("News : most bakeries now fitted with ATMs to allow for easy cookie withdrawals and deposits.", 1)
			},
			{
				"Bank",
				new Tuple<string, int>("News : cookie economy now strong enough to allow for massive vaults doubling as swimming pools!", 1)
			},
			{
				"Bank",
				new Tuple<string, int>("News : Tomorrow's wealthiest people will be calculated by their worth in cookies, predict specialists.", 1)
			},
			{
				"Temple",
				new Tuple<string, int>("News : explorers bring back ancient artifact from abandoned temple; archeologists marvel at the centuries-old Magic Pizza!", 1)
			},
			{
				"Temple",
				new Tuple<string, int>("News : recently-discovered chocolate temples now sparking new cookie-related cult; thousands pray to Baker in the sky!", 1)
			},
			{
				"Temple",
				new Tuple<string, int>("News : just how extensive is the cookie pantheon? Theologians speculate about possible God of Scorpions.", 1)
			},
			{
				"Temple",
				new Tuple<string, int>("News : theists of the world discover new cookie religion - \"Oh boy, guess we were wrong all along!\"", 1)
			},
			{
				"Temple",
				new Tuple<string, int>("News : cookie heaven allegedly \"sports elevator instead of stairway\"; cookie hell \"paved with flagstone, as good intentions make for poor building material\".", 1)
			}
		};

		public static void GetRandomNewsMessage(long cookies)
		{
			List<string> list = new List<string>();
			foreach (KeyValuePair<string, long> cookieMessage in cookieMessages)
			{
				if (cookies >= cookieMessage.Value)
				{
					list.Add(cookieMessage.Key);
				}
			}
			if (CookieClicker.Gradmas > 0)
			{
				string[] grandmaMessages = GrandmaMessages;
				foreach (string item in grandmaMessages)
				{
					list.Add(item);
				}
			}
			string[] communityMessages = CommunityMessages;
			foreach (string item2 in communityMessages)
			{
				list.Add(item2);
			}
			if (list.Count > 0)
			{
				int index = Random.Range(0, list.Count);
				string text = list[index];
				CookieClicker.UpdateButtonLabel(102, text ?? "");
			}
			else
			{
				CookieClicker.UpdateButtonLabel(102, "No news available at the moment.");
			}
		}
	}
	public class Tower
	{
		public float Price { get; set; }

		public int Count { get; set; }

		public float CPS { get; set; }

		public float DefaultPrice { get; set; }

		public Tower(float price, int count, float cps, float DefPrice)
		{
			Price = price;
			Count = count;
			CPS = cps;
			DefaultPrice = DefPrice;
		}
	}
	public class GameManager
	{
		public static Dictionary<CookieClicker.TowerType, Tower> towers = new Dictionary<CookieClicker.TowerType, Tower>();

		private static GameManager gm;

		public float Cookies { get; private set; }

		public float CPS { get; private set; }

		public GameManager()
		{
			AddTowerIfNotExists(CookieClicker.TowerType.Clicker, CookieClicker.DefaultClickerPrice, CookieClicker.Clickers, CookieClicker.DefaultClicker_CPS, CookieClicker.DefaultClickerPrice);
			AddTowerIfNotExists(CookieClicker.TowerType.Grandma, CookieClicker.DefaultGrandmaPrice, CookieClicker.Gradmas, CookieClicker.DefaultGradmas_CPS, CookieClicker.DefaultGrandmaPrice);
			AddTowerIfNotExists(CookieClicker.TowerType.Farm, CookieClicker.DefaultFarmPrice, CookieClicker.Farms, CookieClicker.DefaultFarm_CPS, CookieClicker.DefaultFarmPrice);
			AddTowerIfNotExists(CookieClicker.TowerType.Mine, CookieClicker.DefaultMinePrice, CookieClicker.Mines, CookieClicker.DefaultMine_CPS, CookieClicker.DefaultMinePrice);
			AddTowerIfNotExists(CookieClicker.TowerType.Factory, CookieClicker.DefaultFactoryPrice, CookieClicker.Factorys, CookieClicker.DefaultFactory_CPS, CookieClicker.DefaultFactoryPrice);
			AddTowerIfNotExists(CookieClicker.TowerType.Bank, CookieClicker.DefaultBankPrice, CookieClicker.Banks, CookieClicker.DefaultBank_CPS, CookieClicker.DefaultBankPrice);
			AddTowerIfNotExists(CookieClicker.TowerType.Temple, CookieClicker.DefaultTemplePrice, CookieClicker.Temples, CookieClicker.DefaultTemple_CPS, CookieClicker.DefaultTemplePrice);
		}

		private void AddTowerIfNotExists(CookieClicker.TowerType type, float price, int count, float cps, float defPrice)
		{
			if (!towers.ContainsKey(type))
			{
				towers.Add(type, new Tower(price, count, cps, defPrice));
			}
		}

		public static void SellTower(CookieClicker.TowerType type, int amount)
		{
			if (towers.ContainsKey(type))
			{
				Tower tower = towers[type];
				for (int i = 0; i < amount; i++)
				{
					if (tower.Count > 0)
					{
						tower.Count--;
						long cookies = CookieClicker.Cookies;
						_ = tower.Price;
						CookieClicker.Cookies = cookies + 0;
						tower.Price *= 0.85f;
						CookieClicker.Log($"Sold 1 {type}. {type}s: {tower.Count}");
						CookieClicker.Log($"Money left: {CookieClicker.Cookies}");
						CookieClicker.CalculateCPS();
						UpdateUI();
						continue;
					}
					CookieClicker.Log($"Not enough {type}s");
					break;
				}
			}
			else
			{
				CookieClicker.Log($"Invalid tower type: {type}");
			}
		}

		public static void UpdateUI()
		{
			CookieClicker.UpdateButtonLabel(100, "CPS \n " + CookieClicker.cps);
			CookieClicker.UpdateButtonLabel(3, $"Buy Clicker, Amount Owned {CookieClicker.Clickers} \n {CookieClicker.ClickerPrice.ToString()}");
			CookieClicker.UpdateButtonLabel(4, $"Buy Grandma, Amount Owned {CookieClicker.Gradmas} \n {CookieClicker.GrandmaPrice.ToString()}");
			CookieClicker.UpdateButtonLabel(5, $"Buy Farm, Amount Owned {CookieClicker.Farms} \n {CookieClicker.FarmPrice.ToString()}");
			CookieClicker.UpdateButtonLabel(6, $"Buy Mine, Amount Owned {CookieClicker.Mines} \n {CookieClicker.MinePrice.ToString()}");
			CookieClicker.UpdateButtonLabel(7, $"Buy Factory, Amount Owned {CookieClicker.Factorys} \n {CookieClicker.FactoryPrice.ToString()}");
			CookieClicker.UpdateButtonLabel(8, $"Buy Bank, Amount Owned {CookieClicker.Banks} \n {CookieClicker.BankPrice.ToString()}");
			CookieClicker.UpdateButtonLabel(9, $"Buy Templ, Amount Owned {CookieClicker.Temples} \n {CookieClicker.TemplePrice.ToString()}");
		}
	}
}
namespace CookieClickerConfiggy.Starter
{
	public class CookieClickerStarter : BaseUnityPlugin
	{
		private CookieClicker cookieClicker = new CookieClicker();

		private void Update()
		{
			if (!((Object)(object)cookieClicker.TowersGameObj == (Object)null) && !Object.op_Implicit((Object)(object)cookieClicker.TowersGM))
			{
			}
		}
	}
}