Decompiled source of Market Mod v1.1.0

MarketMod.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using MarketMod;
using MarketMod.Patches;
using TerminalApi;
using TerminalApi.Events;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MarketMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MarketMod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("34e7d7e2-8592-4b67-a138-4d7fcfbd29d4")]
[assembly: AssemblyFileVersion("1.0.3")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.3.0")]
public class Market
{
	public struct ItemData
	{
		public int BaseValue;

		public int Modifier;
	}

	public static class ItemInfo
	{
		public static int Airhorn;

		public static int Hive;

		public static int Apparatus;

		public static int Bigbolt;

		public static int Bottles;

		public static int Bell;

		public static int Candy;

		public static int Cashregister;

		public static int Chemicaljug;

		public static int Clownhorn;

		public static int Coffeemug;

		public static int Comedy;

		public static int Cookiemold;

		public static int DIYFlashbang;

		public static int Doublebarrel;

		public static int Dustpan;

		public static int Eggbeater;

		public static int Fancylamp;

		public static int Flask;

		public static int Gift;

		public static int Goldbar;

		public static int Goldencup;

		public static int Hairbrush;

		public static int Hairdryer;

		public static int Jarofpickles;

		public static int Largeaxle;

		public static int Laserpointer;

		public static int Magic7ball;

		public static int Magnifyingglass;

		public static int Oldphone;

		public static int Painting;

		public static int Perfumebottle;

		public static int Pillbottle;

		public static int Plasticfish;

		public static int PlayerBody;

		public static int Redsoda;

		public static int Remote;

		public static int Ring;

		public static int Robot;

		public static int RubberDucky;

		public static int Steeringwheel;

		public static int Stopsign;

		public static int Metalsheet;

		public static int Teakettle;

		public static int Teeth;

		public static int Toothpaste;

		public static int Toycube;

		public static int Tragedy;

		public static int Vtypeengine;

		public static int WhoopieCushion;

		public static int Yieldsign;
	}

	public static Dictionary<string, ItemData> Items = new Dictionary<string, ItemData>();

	private static Random rnd;

	public static int MinimumDecrease;

	public static int MaximumIncrease;

	public static int MinimumModifier;

	public static int MaximumModifier;

	public static void Initialize()
	{
		if (!((Object)(object)GameNetworkManager.Instance == (Object)null) && GameNetworkManager.Instance.currentSaveFileName != null)
		{
			int num = 0;
			string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName;
			foreach (char c in currentSaveFileName)
			{
				num = num * 1000 + c;
			}
			int seed = num;
			Logger.CreateLogSource("Market.Tormad").LogInfo((object)(seed + "????!?!?!?!??!"));
			rnd = new Random(seed);
		}
	}

	public static void updateItems()
	{
		new ModBase().ApplyConfig();
	}

	public static void GetItems()
	{
		Items = MarketSaveManager.LoadMarketItems() ?? new Dictionary<string, ItemData>();
		if (Items.Count == 0)
		{
			Items.Add("Airhorn", new ItemData
			{
				BaseValue = ItemInfo.Airhorn,
				Modifier = 100
			});
			Items.Add("Hive", new ItemData
			{
				BaseValue = ItemInfo.Hive,
				Modifier = 100
			});
			Items.Add("Apparatus", new ItemData
			{
				BaseValue = ItemInfo.Apparatus,
				Modifier = 100
			});
			Items.Add("Big bolt", new ItemData
			{
				BaseValue = ItemInfo.Bigbolt,
				Modifier = 100
			});
			Items.Add("Bottles", new ItemData
			{
				BaseValue = ItemInfo.Bottles,
				Modifier = 100
			});
			Items.Add("Bell", new ItemData
			{
				BaseValue = ItemInfo.Bell,
				Modifier = 100
			});
			Items.Add("Candy", new ItemData
			{
				BaseValue = ItemInfo.Candy,
				Modifier = 100
			});
			Items.Add("Cash register", new ItemData
			{
				BaseValue = ItemInfo.Cashregister,
				Modifier = 100
			});
			Items.Add("Chemical jug", new ItemData
			{
				BaseValue = ItemInfo.Chemicaljug,
				Modifier = 100
			});
			Items.Add("Clown horn", new ItemData
			{
				BaseValue = ItemInfo.Clownhorn,
				Modifier = 100
			});
			Items.Add("Coffee mug", new ItemData
			{
				BaseValue = ItemInfo.Coffeemug,
				Modifier = 100
			});
			Items.Add("Comedy", new ItemData
			{
				BaseValue = ItemInfo.Comedy,
				Modifier = 100
			});
			Items.Add("Cookie mold", new ItemData
			{
				BaseValue = ItemInfo.Cookiemold,
				Modifier = 100
			});
			Items.Add("DIY-Flashbang", new ItemData
			{
				BaseValue = ItemInfo.DIYFlashbang,
				Modifier = 100
			});
			Items.Add("Double-barrel", new ItemData
			{
				BaseValue = ItemInfo.Doublebarrel,
				Modifier = 100
			});
			Items.Add("Dust pan", new ItemData
			{
				BaseValue = ItemInfo.Dustpan,
				Modifier = 100
			});
			Items.Add("Egg beater", new ItemData
			{
				BaseValue = ItemInfo.Eggbeater,
				Modifier = 100
			});
			Items.Add("Fancy lamp", new ItemData
			{
				BaseValue = ItemInfo.Fancylamp,
				Modifier = 100
			});
			Items.Add("Flask", new ItemData
			{
				BaseValue = ItemInfo.Flask,
				Modifier = 100
			});
			Items.Add("Gift", new ItemData
			{
				BaseValue = ItemInfo.Gift,
				Modifier = 100
			});
			Items.Add("Gold bar", new ItemData
			{
				BaseValue = ItemInfo.Goldbar,
				Modifier = 100
			});
			Items.Add("Golden cup", new ItemData
			{
				BaseValue = ItemInfo.Goldencup,
				Modifier = 100
			});
			Items.Add("Hair brush", new ItemData
			{
				BaseValue = ItemInfo.Hairbrush,
				Modifier = 100
			});
			Items.Add("Hairdryer", new ItemData
			{
				BaseValue = ItemInfo.Hairdryer,
				Modifier = 100
			});
			Items.Add("Jar of pickles", new ItemData
			{
				BaseValue = ItemInfo.Jarofpickles,
				Modifier = 100
			});
			Items.Add("Large axle", new ItemData
			{
				BaseValue = ItemInfo.Largeaxle,
				Modifier = 100
			});
			Items.Add("Laser pointer", new ItemData
			{
				BaseValue = ItemInfo.Laserpointer,
				Modifier = 100
			});
			Items.Add("Magic 7 ball", new ItemData
			{
				BaseValue = ItemInfo.Magic7ball,
				Modifier = 100
			});
			Items.Add("Magnifying glass", new ItemData
			{
				BaseValue = ItemInfo.Magnifyingglass,
				Modifier = 100
			});
			Items.Add("Old phone", new ItemData
			{
				BaseValue = ItemInfo.Oldphone,
				Modifier = 100
			});
			Items.Add("Painting", new ItemData
			{
				BaseValue = ItemInfo.Painting,
				Modifier = 100
			});
			Items.Add("Perfume bottle", new ItemData
			{
				BaseValue = ItemInfo.Perfumebottle,
				Modifier = 100
			});
			Items.Add("Pill bottle", new ItemData
			{
				BaseValue = ItemInfo.Pillbottle,
				Modifier = 100
			});
			Items.Add("Plastic fish", new ItemData
			{
				BaseValue = ItemInfo.Plasticfish,
				Modifier = 100
			});
			Items.Add("Player Body", new ItemData
			{
				BaseValue = ItemInfo.PlayerBody,
				Modifier = 100
			});
			Items.Add("Red soda", new ItemData
			{
				BaseValue = ItemInfo.Redsoda,
				Modifier = 100
			});
			Items.Add("Remote", new ItemData
			{
				BaseValue = ItemInfo.Remote,
				Modifier = 100
			});
			Items.Add("Ring", new ItemData
			{
				BaseValue = ItemInfo.Ring,
				Modifier = 100
			});
			Items.Add("Robot", new ItemData
			{
				BaseValue = ItemInfo.Robot,
				Modifier = 100
			});
			Items.Add("Rubber Ducky", new ItemData
			{
				BaseValue = ItemInfo.RubberDucky,
				Modifier = 100
			});
			Items.Add("Steering wheel", new ItemData
			{
				BaseValue = ItemInfo.Steeringwheel,
				Modifier = 100
			});
			Items.Add("Stop sign", new ItemData
			{
				BaseValue = ItemInfo.Stopsign,
				Modifier = 100
			});
			Items.Add("Metal sheet", new ItemData
			{
				BaseValue = ItemInfo.Metalsheet,
				Modifier = 100
			});
			Items.Add("Tea kettle", new ItemData
			{
				BaseValue = ItemInfo.Teakettle,
				Modifier = 100
			});
			Items.Add("Teeth", new ItemData
			{
				BaseValue = ItemInfo.Teeth,
				Modifier = 100
			});
			Items.Add("Toothpaste", new ItemData
			{
				BaseValue = ItemInfo.Toothpaste,
				Modifier = 100
			});
			Items.Add("Toy cube", new ItemData
			{
				BaseValue = ItemInfo.Toycube,
				Modifier = 100
			});
			Items.Add("Tragedy", new ItemData
			{
				BaseValue = ItemInfo.Tragedy,
				Modifier = 100
			});
			Items.Add("V-type engine", new ItemData
			{
				BaseValue = ItemInfo.Vtypeengine,
				Modifier = 100
			});
			Items.Add("Whoopie-Cushion", new ItemData
			{
				BaseValue = ItemInfo.WhoopieCushion,
				Modifier = 100
			});
			Items.Add("Yield sign", new ItemData
			{
				BaseValue = ItemInfo.Yieldsign,
				Modifier = 100
			});
			Logger.CreateLogSource("Market.Tormad").LogInfo((object)"!Created new items!");
		}
	}

	public static int GetCurrentMarketValue(ItemData itemData)
	{
		GetItems();
		return (int)((double)itemData.BaseValue * ((double)itemData.Modifier / 100.0));
	}

	public static int GetCurrentMarketValueViaString(string itemName)
	{
		GetItems();
		Logger.CreateLogSource("Market.Tormad").LogInfo((object)"!!!!!!!!!!!!!!!!!!!!!!!!The test mod working!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
		if (Items.ContainsKey(itemName))
		{
			ItemData itemData = Items[itemName];
			double num = (double)itemData.BaseValue * ((double)itemData.Modifier / 100.0);
			Logger.CreateLogSource("Market.Tormad").LogInfo((object)("!!!!!!!!!!!!!!!!!!!!!!!!Value of " + itemName + " is " + num + " - Modifier " + itemData.Modifier));
			return (int)num;
		}
		Logger.CreateLogSource("Market.Tormad").LogInfo((object)("!!!!!!!!!!!!!!!!!!!!!!!! " + itemName + " is not listed"));
		return 0;
	}

	public static void UpdateDaily(int dayCount)
	{
		Initialize();
		GetItems();
		foreach (string item in Items.Keys.ToList())
		{
			ItemData value = Items[item];
			int num = value.Modifier;
			for (int i = 0; i < dayCount; i++)
			{
				num += rnd.Next(MinimumDecrease, MaximumIncrease);
				num = Mathf.Clamp(num, MinimumModifier, MaximumModifier);
				Logger.CreateLogSource("Market.Tormad").LogInfo((object)("Day " + (i + 1) + ": " + value.ToString() + " - Modifier " + num));
			}
			value.Modifier = num;
			Items[item] = value;
			MarketSaveManager.SaveMarketItems();
		}
		ModBase.UpdateKeywords();
		Logger.CreateLogSource("Market.Tormad").LogInfo((object)"!!!!!!!!!!!!!!!!!!!!!!!! LISTENHERE");
	}

	public static string GetFormattedMarketPrices()
	{
		GetItems();
		string text = "======================\n   MARKET PRICES\n======================\n\n";
		string text2 = "Item       | Modifier | Market Price\n------------------------------------\n";
		string text3 = "";
		foreach (KeyValuePair<string, ItemData> item in Items)
		{
			int currentMarketValue = GetCurrentMarketValue(item.Value);
			text3 = text3 + item.Key.PadRight(15) + "| " + item.Value.Modifier + "%".PadLeft(8) + " | " + currentMarketValue.ToString().PadLeft(12) + "\n";
		}
		return text + text2 + text3 + "\nNote: Prices are updated daily.";
	}

	public static void UpdateSellItems(string itemName)
	{
		GetItems();
		Logger.CreateLogSource("Market.Tormad").LogInfo((object)"!Tried to sell");
		if (Items.ContainsKey(itemName))
		{
			ItemData itemData = Items[itemName];
			itemData.Modifier += rnd.Next(-10, -5);
			ModBase.UpdateKeywords();
			Logger.CreateLogSource("Market.Tormad").LogInfo((object)("!" + itemName + " is listed"));
			MarketSaveManager.SaveMarketItems();
		}
		Logger.CreateLogSource("Market.Tormad").LogInfo((object)("!" + itemName + " is not listed"));
	}
}
public static class MarketSaveManager
{
	private static string itemsKey = "Market_Items";

	private static string daysKey = "Market_Days";

	public static void SaveMarketItems()
	{
		if ((Object)(object)GameNetworkManager.Instance == (Object)null || GameNetworkManager.Instance.currentSaveFileName == null)
		{
			new Dictionary<string, Market.ItemData>();
		}
		else
		{
			ES3.Save<Dictionary<string, Market.ItemData>>("Market_Items", Market.Items, GameNetworkManager.Instance.currentSaveFileName);
		}
	}

	public static Dictionary<string, Market.ItemData> LoadMarketItems()
	{
		if ((Object)(object)GameNetworkManager.Instance == (Object)null || GameNetworkManager.Instance.currentSaveFileName == null)
		{
			return new Dictionary<string, Market.ItemData>();
		}
		if (ES3.KeyExists(itemsKey, GameNetworkManager.Instance.currentSaveFileName))
		{
			return ES3.Load<Dictionary<string, Market.ItemData>>(itemsKey, GameNetworkManager.Instance.currentSaveFileName);
		}
		return new Dictionary<string, Market.ItemData>();
	}

	public static void SaveDays()
	{
		if (!((Object)(object)GameNetworkManager.Instance == (Object)null) && GameNetworkManager.Instance.currentSaveFileName != null)
		{
			ES3.Save<int>("Market_Days", DayChangeTracker.dayCount, GameNetworkManager.Instance.currentSaveFileName);
		}
	}

	public static int LoadDays()
	{
		if ((Object)(object)GameNetworkManager.Instance == (Object)null || GameNetworkManager.Instance.currentSaveFileName == null)
		{
			return 1;
		}
		if (ES3.KeyExists("Market_Days", GameNetworkManager.Instance.currentSaveFileName))
		{
			return ES3.Load<int>("Market_Days", GameNetworkManager.Instance.currentSaveFileName);
		}
		ES3.Save<int>("Market_Days", 1, GameNetworkManager.Instance.currentSaveFileName);
		return 1;
	}

	public static int LoadOldDays()
	{
		if ((Object)(object)GameNetworkManager.Instance == (Object)null || GameNetworkManager.Instance.currentSaveFileName == null)
		{
			return 0;
		}
		if (ES3.KeyExists("Market_Days", GameNetworkManager.Instance.currentSaveFileName))
		{
			if (ES3.Load<int>("Market_Days", GameNetworkManager.Instance.currentSaveFileName) == 1)
			{
				return 0;
			}
			return ES3.Load<int>("Market_Days", GameNetworkManager.Instance.currentSaveFileName);
		}
		return 0;
	}
}
public static class DayChangeTracker
{
	public static bool DayChangedFlag = true;

	public static float startTime = Time.realtimeSinceStartup;

	public static int dayCount = MarketSaveManager.LoadDays();

	public static int oldDayCount = MarketSaveManager.LoadOldDays();
}
namespace MarketMod
{
	[BepInPlugin("Market.Tormad", "Market Mod", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ModBase : BaseUnityPlugin
	{
		private const string modGUID = "Market.Tormad";

		private const string modName = "Market Mod";

		private const string modVersion = "1.1.0";

		private readonly Harmony harmony = new Harmony("Market.Tormad");

		private static ModBase Instance;

		internal ManualLogSource mls;

		private ConfigEntry<int> MiniumDecrease;

		private ConfigEntry<int> MaximumIncrease;

		private ConfigEntry<int> MinimumModifier;

		private ConfigEntry<int> MaximumModifier;

		private ConfigEntry<int> Airhorn;

		private ConfigEntry<int> Hive;

		private ConfigEntry<int> Apparatus;

		private ConfigEntry<int> Bigbolt;

		private ConfigEntry<int> Bottles;

		private ConfigEntry<int> Bell;

		private ConfigEntry<int> Candy;

		private ConfigEntry<int> Cashregister;

		private ConfigEntry<int> Chemicaljug;

		private ConfigEntry<int> Clownhorn;

		private ConfigEntry<int> Coffeemug;

		private ConfigEntry<int> Comedy;

		private ConfigEntry<int> Cookiemold;

		private ConfigEntry<int> DIYFlashbang;

		private ConfigEntry<int> Doublebarrel;

		private ConfigEntry<int> Dustpan;

		private ConfigEntry<int> Eggbeater;

		private ConfigEntry<int> Fancylamp;

		private ConfigEntry<int> Flask;

		private ConfigEntry<int> Gift;

		private ConfigEntry<int> Goldbar;

		private ConfigEntry<int> Goldencup;

		private ConfigEntry<int> Hairbrush;

		private ConfigEntry<int> Hairdryer;

		private ConfigEntry<int> Jarofpickles;

		private ConfigEntry<int> Largeaxle;

		private ConfigEntry<int> Laserpointer;

		private ConfigEntry<int> Magic7ball;

		private ConfigEntry<int> Magnifyingglass;

		private ConfigEntry<int> Oldphone;

		private ConfigEntry<int> Painting;

		private ConfigEntry<int> Perfumebottle;

		private ConfigEntry<int> Pillbottle;

		private ConfigEntry<int> Plasticfish;

		private ConfigEntry<int> PlayerBody;

		private ConfigEntry<int> Redsoda;

		private ConfigEntry<int> Remote;

		private ConfigEntry<int> Ring;

		private ConfigEntry<int> Robot;

		private ConfigEntry<int> RubberDucky;

		private ConfigEntry<int> Steeringwheel;

		private ConfigEntry<int> Stopsign;

		private ConfigEntry<int> Metalsheet;

		private ConfigEntry<int> Teakettle;

		private ConfigEntry<int> Teeth;

		private ConfigEntry<int> Toothpaste;

		private ConfigEntry<int> Toycube;

		private ConfigEntry<int> Tragedy;

		private ConfigEntry<int> Vtypeengine;

		private ConfigEntry<int> WhoopieCushion;

		private ConfigEntry<int> Yieldsign;

		private void Awake()
		{
			//IL_0cfd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d07: Expected O, but got Unknown
			//IL_0d0e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d18: Expected O, but got Unknown
			//IL_0d1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d29: Expected O, but got Unknown
			//IL_0d30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3a: Expected O, but got Unknown
			//IL_0d41: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d4b: Expected O, but got Unknown
			//IL_0d52: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d5c: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Market.Tormad");
			MiniumDecrease = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Minimum Decrease", -10, "The minuim the price can decrease a day");
			MaximumIncrease = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Maximum Increase", 16, "The maximum the price can increase a day");
			MinimumModifier = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Minimum Modifier", 20, "The minimum the modifier can reach");
			MaximumModifier = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Maximum Modifier", 200, "The maximum the modifier can reach");
			Airhorn = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Airhorn", 62, "");
			Hive = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Hive", 110, "");
			Apparatus = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Apparatus", 110, "");
			Bigbolt = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Big bolt", 26, "");
			Bottles = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Bottles", 50, "");
			Bell = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Bell", 64, "");
			Candy = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Candy", 21, "");
			Cashregister = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Cash register", 120, "");
			Chemicaljug = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Chemical jug", 58, "");
			Clownhorn = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Clown horn", 62, (ConfigDescription)null);
			Coffeemug = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Coffee mug", 46, "");
			Comedy = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Comedy", 40, "");
			Cookiemold = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Cookie mold", 26, "");
			DIYFlashbang = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "DIY-Flashbang", 19, "");
			Doublebarrel = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Double-barrel", 0, "");
			Dustpan = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Dust pan", 22, "");
			Eggbeater = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Egg beater", 28, "");
			Fancylamp = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Fancy lamp", 94, "");
			Flask = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Flask", 30, "");
			Gift = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Gift", 20, "");
			Goldbar = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Gold bar", 156, "");
			Goldencup = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Golden cup", 60, "");
			Hairbrush = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Hair brush", 22, "");
			Hairdryer = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Hairdryer", 80, "");
			Jarofpickles = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Jar of pickles", 46, "");
			Largeaxle = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Large axle", 46, "");
			Laserpointer = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Laser pointer", 66, "");
			Magic7ball = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Magic 7 ball", 54, "");
			Magnifyingglass = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Magnifying glass", 52, "");
			Oldphone = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Old phone", 56, "");
			Painting = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Painting", 92, "");
			Perfumebottle = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Perfume bottle", 76, "");
			Pillbottle = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Pill bottle", 28, "");
			Plasticfish = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Plastic fish", 34, "");
			PlayerBody = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Player Body", 21, "");
			Redsoda = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Red soda", 54, "");
			Remote = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Remote", 34, "");
			Ring = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Ring", 66, "");
			Robot = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Robot", 72, "");
			RubberDucky = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Rubber Ducky", 51, "");
			Steeringwheel = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Steering wheel", 24, "");
			Stopsign = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Stop sign", 36, "");
			Metalsheet = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Metal sheet", 16, "");
			Teakettle = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Tea kettle", 44, "");
			Teeth = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Teeth", 72, "");
			Toothpaste = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Toothpaste", 31, "");
			Toycube = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Toy cube", 34, "");
			Tragedy = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Tragedy", 40, "");
			Vtypeengine = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "V-type engine", 38, "");
			WhoopieCushion = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Whoopie-Cushion", 13, "");
			Yieldsign = ((BaseUnityPlugin)this).Config.Bind<int>("Items", "Yield sign", 27, "");
			MiniumDecrease.SettingChanged += OnConfigChanged;
			MaximumIncrease.SettingChanged += OnConfigChanged;
			MinimumModifier.SettingChanged += OnConfigChanged;
			MaximumModifier.SettingChanged += OnConfigChanged;
			Airhorn.SettingChanged += OnConfigChanged;
			Hive.SettingChanged += OnConfigChanged;
			Apparatus.SettingChanged += OnConfigChanged;
			Bigbolt.SettingChanged += OnConfigChanged;
			Bottles.SettingChanged += OnConfigChanged;
			Bell.SettingChanged += OnConfigChanged;
			Candy.SettingChanged += OnConfigChanged;
			Cashregister.SettingChanged += OnConfigChanged;
			Chemicaljug.SettingChanged += OnConfigChanged;
			Clownhorn.SettingChanged += OnConfigChanged;
			Coffeemug.SettingChanged += OnConfigChanged;
			Comedy.SettingChanged += OnConfigChanged;
			Cookiemold.SettingChanged += OnConfigChanged;
			DIYFlashbang.SettingChanged += OnConfigChanged;
			Doublebarrel.SettingChanged += OnConfigChanged;
			Dustpan.SettingChanged += OnConfigChanged;
			Eggbeater.SettingChanged += OnConfigChanged;
			Fancylamp.SettingChanged += OnConfigChanged;
			Flask.SettingChanged += OnConfigChanged;
			Gift.SettingChanged += OnConfigChanged;
			Goldbar.SettingChanged += OnConfigChanged;
			Goldencup.SettingChanged += OnConfigChanged;
			Hairbrush.SettingChanged += OnConfigChanged;
			Hairdryer.SettingChanged += OnConfigChanged;
			Jarofpickles.SettingChanged += OnConfigChanged;
			Largeaxle.SettingChanged += OnConfigChanged;
			Laserpointer.SettingChanged += OnConfigChanged;
			Magic7ball.SettingChanged += OnConfigChanged;
			Magnifyingglass.SettingChanged += OnConfigChanged;
			Oldphone.SettingChanged += OnConfigChanged;
			Painting.SettingChanged += OnConfigChanged;
			Perfumebottle.SettingChanged += OnConfigChanged;
			Pillbottle.SettingChanged += OnConfigChanged;
			Plasticfish.SettingChanged += OnConfigChanged;
			PlayerBody.SettingChanged += OnConfigChanged;
			Redsoda.SettingChanged += OnConfigChanged;
			Remote.SettingChanged += OnConfigChanged;
			Ring.SettingChanged += OnConfigChanged;
			Robot.SettingChanged += OnConfigChanged;
			RubberDucky.SettingChanged += OnConfigChanged;
			Steeringwheel.SettingChanged += OnConfigChanged;
			Stopsign.SettingChanged += OnConfigChanged;
			Metalsheet.SettingChanged += OnConfigChanged;
			Teakettle.SettingChanged += OnConfigChanged;
			Teeth.SettingChanged += OnConfigChanged;
			Toothpaste.SettingChanged += OnConfigChanged;
			Toycube.SettingChanged += OnConfigChanged;
			Tragedy.SettingChanged += OnConfigChanged;
			Vtypeengine.SettingChanged += OnConfigChanged;
			WhoopieCushion.SettingChanged += OnConfigChanged;
			Yieldsign.SettingChanged += OnConfigChanged;
			Market.Initialize();
			harmony.PatchAll(typeof(ModBase));
			harmony.PatchAll(typeof(PricesPatch));
			harmony.PatchAll(typeof(DayCaller));
			harmony.PatchAll(typeof(PricesUpdater));
			harmony.PatchAll(typeof(SellItemUpdater));
			harmony.PatchAll(typeof(Startpatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Test Plugin is loaded!");
			Events.TerminalAwake += new TerminalEventHandler(TerminalIsAwake);
			Events.TerminalStarted += new TerminalEventHandler(TerminalIsStarted);
			Events.TerminalParsedSentence += new TerminalParseSentenceEventHandler(TextSubmitted);
			Events.TerminalBeginUsing += new TerminalEventHandler(OnBeginUsing);
			Events.TerminalExited += new TerminalEventHandler(OnTerminalExit);
			Events.TerminalTextChanged += new TerminalTextChangedEventHandler(OnTerminalTextChanged);
			string formattedMarketPrices = Market.GetFormattedMarketPrices();
			TerminalApi.AddCommand("market", formattedMarketPrices + "\n", "show", true);
			ApplyConfig();
		}

		public void ApplyConfig()
		{
			Market.MinimumDecrease = MiniumDecrease.Value;
			Market.MaximumIncrease = MaximumIncrease.Value;
			Market.MinimumModifier = MinimumModifier.Value;
			Market.MaximumModifier = MaximumModifier.Value;
			Market.ItemInfo.Airhorn = Airhorn.Value;
			Market.ItemInfo.Hive = Hive.Value;
			Market.ItemInfo.Apparatus = Apparatus.Value;
			Market.ItemInfo.Bigbolt = Bigbolt.Value;
			Market.ItemInfo.Bottles = Bottles.Value;
			Market.ItemInfo.Bell = Bell.Value;
			Market.ItemInfo.Candy = Candy.Value;
			Market.ItemInfo.Cashregister = Cashregister.Value;
			Market.ItemInfo.Chemicaljug = Chemicaljug.Value;
			Market.ItemInfo.Clownhorn = Clownhorn.Value;
			Market.ItemInfo.Coffeemug = Coffeemug.Value;
			Market.ItemInfo.Comedy = Comedy.Value;
			Market.ItemInfo.Cookiemold = Cookiemold.Value;
			Market.ItemInfo.DIYFlashbang = DIYFlashbang.Value;
			Market.ItemInfo.Doublebarrel = Doublebarrel.Value;
			Market.ItemInfo.Dustpan = Dustpan.Value;
			Market.ItemInfo.Eggbeater = Eggbeater.Value;
			Market.ItemInfo.Fancylamp = Fancylamp.Value;
			Market.ItemInfo.Flask = Flask.Value;
			Market.ItemInfo.Gift = Gift.Value;
			Market.ItemInfo.Goldbar = Goldbar.Value;
			Market.ItemInfo.Goldencup = Goldencup.Value;
			Market.ItemInfo.Hairbrush = Hairbrush.Value;
			Market.ItemInfo.Hairdryer = Hairdryer.Value;
			Market.ItemInfo.Jarofpickles = Jarofpickles.Value;
			Market.ItemInfo.Largeaxle = Largeaxle.Value;
			Market.ItemInfo.Laserpointer = Laserpointer.Value;
			Market.ItemInfo.Magic7ball = Magic7ball.Value;
			Market.ItemInfo.Magnifyingglass = Magnifyingglass.Value;
			Market.ItemInfo.Oldphone = Oldphone.Value;
			Market.ItemInfo.Painting = Painting.Value;
			Market.ItemInfo.Perfumebottle = Perfumebottle.Value;
			Market.ItemInfo.Pillbottle = Pillbottle.Value;
			Market.ItemInfo.Plasticfish = Plasticfish.Value;
			Market.ItemInfo.PlayerBody = PlayerBody.Value;
			Market.ItemInfo.Redsoda = Redsoda.Value;
			Market.ItemInfo.Remote = Remote.Value;
			Market.ItemInfo.Ring = Ring.Value;
			Market.ItemInfo.Robot = Robot.Value;
			Market.ItemInfo.RubberDucky = RubberDucky.Value;
			Market.ItemInfo.Steeringwheel = Steeringwheel.Value;
			Market.ItemInfo.Stopsign = Stopsign.Value;
			Market.ItemInfo.Metalsheet = Metalsheet.Value;
			Market.ItemInfo.Teakettle = Teakettle.Value;
			Market.ItemInfo.Teeth = Teeth.Value;
			Market.ItemInfo.Toothpaste = Toothpaste.Value;
			Market.ItemInfo.Toycube = Toycube.Value;
			Market.ItemInfo.Tragedy = Tragedy.Value;
			Market.ItemInfo.Vtypeengine = Vtypeengine.Value;
			Market.ItemInfo.WhoopieCushion = WhoopieCushion.Value;
			Market.ItemInfo.Yieldsign = Yieldsign.Value;
		}

		public static void UpdateKeywords()
		{
			string formattedMarketPrices = Market.GetFormattedMarketPrices();
			TerminalApi.UpdateKeywordCompatibleNoun("show", "market", TerminalApi.CreateTerminalNode(formattedMarketPrices + "\n", true, ""));
		}

		private void OnTerminalTextChanged(object sender, TerminalTextChangedEventArgs e)
		{
			string terminalInput = TerminalApi.GetTerminalInput();
			((BaseUnityPlugin)this).Logger.LogMessage((object)terminalInput);
			if (terminalInput.ToLower() == "marekt" || terminalInput.ToLower() == "markit" || terminalInput.ToLower() == "mraket" || terminalInput.ToLower() == "makret" || terminalInput.ToLower() == "markt")
			{
				TerminalApi.SetTerminalInput("market");
			}
		}

		private void OnTerminalExit(object sender, TerminalEventArgs e)
		{
			((BaseUnityPlugin)this).Logger.LogMessage((object)"Terminal Exited");
		}

		private void TerminalIsAwake(object sender, TerminalEventArgs e)
		{
			((BaseUnityPlugin)this).Logger.LogMessage((object)"Terminal is awake");
			UpdateKeywords();
		}

		private void TerminalIsStarted(object sender, TerminalEventArgs e)
		{
			((BaseUnityPlugin)this).Logger.LogMessage((object)"Terminal is started");
			ApplyConfig();
			UpdateKeywords();
		}

		private void TextSubmitted(object sender, TerminalParseSentenceEventArgs e)
		{
			((BaseUnityPlugin)this).Logger.LogMessage((object)$"Text submitted: {e.SubmittedText} Node Returned: {e.ReturnedNode}");
		}

		private void OnBeginUsing(object sender, TerminalEventArgs e)
		{
			((BaseUnityPlugin)this).Logger.LogMessage((object)"Player has just started using the terminal");
		}

		private void OnConfigChanged(object sender, EventArgs e)
		{
			ApplyConfig();
		}
	}
}
namespace MarketMod.Patches
{
	[HarmonyPatch(typeof(TimeOfDay), "OnDayChanged")]
	public class DayCaller
	{
		[HarmonyPostfix]
		private static void PostfixLoadShipGrabbableItems()
		{
			DayChangeTracker.DayChangedFlag = true;
			DayChangeTracker.dayCount++;
			Logger.CreateLogSource("Market.Tormad").LogInfo((object)"! NEW DAY BABY");
		}
	}
	[HarmonyPatch(typeof(GrabbableObject), "Update")]
	internal class PricesUpdater
	{
		[HarmonyPrefix]
		private static void preUpdate(GrabbableObject __instance)
		{
			if (DayChangeTracker.DayChangedFlag && Time.realtimeSinceStartup < DayChangeTracker.startTime + 3f)
			{
				__instance.SetScrapValue(1);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB), "Update")]
	internal class Startpatch
	{
		[HarmonyPostfix]
		private static void preUpdate()
		{
			if (DayChangeTracker.dayCount != DayChangeTracker.oldDayCount)
			{
				DayChangeTracker.oldDayCount++;
				Market.UpdateDaily(DayChangeTracker.oldDayCount);
				Logger.CreateLogSource("Market.Tormad").LogInfo((object)"!Updated prices");
				ModBase.UpdateKeywords();
				MarketSaveManager.SaveDays();
				DayChangeTracker.DayChangedFlag = true;
				DayChangeTracker.startTime = Time.realtimeSinceStartup;
			}
		}
	}
	[HarmonyPatch(typeof(DepositItemsDesk), "SellItemsOnServer")]
	internal class SellItemUpdater
	{
		[HarmonyPostfix]
		private static void postSellItemsOnServer(DepositItemsDesk __instance)
		{
			if (DayChangeTracker.DayChangedFlag)
			{
				for (int i = 0; i < __instance.itemsOnCounter.Count; i++)
				{
					Market.UpdateSellItems(__instance.itemsOnCounter[i].itemProperties.itemName);
					Logger.CreateLogSource("Market.Tormad").LogInfo((object)"!!!!!!!!!!!!!!!!!!!!!!!!__ SOLD ITEM!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
				}
			}
		}
	}
	[HarmonyPatch(typeof(GrabbableObject), "SetScrapValue")]
	internal class PricesPatch
	{
		[HarmonyPrefix]
		private static void prefixSetScrapValue(GrabbableObject __instance, ref int setValueTo)
		{
			if (!((Object)(object)__instance.itemProperties != (Object)null))
			{
				return;
			}
			int currentMarketValueViaString = Market.GetCurrentMarketValueViaString(__instance.itemProperties.itemName);
			if (currentMarketValueViaString != setValueTo)
			{
				if (currentMarketValueViaString != 0)
				{
					setValueTo = currentMarketValueViaString;
				}
			}
			else
			{
				DayChangeTracker.DayChangedFlag = false;
			}
		}
	}
}