Decompiled source of Retailier v1.4.0

spdx_Retailier.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.Json;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using SOD.Common;
using SOD.Common.BepInEx;
using SOD.Common.ConfigBindings;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("spdx_Retailier")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5f58d8cf673b866c6015649853f6e2f947ad9362")]
[assembly: AssemblyProduct("spdx_Retailier")]
[assembly: AssemblyTitle("spdx_Retailier")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Retailier;

[BepInPlugin("spdx.Retailier", "[SPDX] Retailier", "1.4.0")]
public class Retailier : BasePlugin
{
	public const string PLUGIN_GUID = "spdx.Retailier";

	public const string PLUGIN_NAME = "[SPDX] Retailier";

	public const string PLUGIN_VERSION = "1.4.0";

	public static string PLUGIN_PATH = Lib.SaveGame.GetSavestoreDirectoryPath(Assembly.GetExecutingAssembly());

	public static string PLUGIN_PATH_MENUS = PLUGIN_PATH + "\\menus\\";

	public static string PLUGIN_PATH_INTERACTABLES = PLUGIN_PATH + "\\interactables\\";

	public static string PLUGIN_PATH_FURNITURE = PLUGIN_PATH + "\\furniture\\";

	public static Dictionary<string, string[]> menus = SetupMenusDict(PLUGIN_PATH_MENUS);

	public static List<KeyValuePair<string[], object>> interactables = SetupInteractables(PLUGIN_PATH_INTERACTABLES);

	public override void Load()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Expected O, but got Unknown
		if (!Directory.Exists(PLUGIN_PATH))
		{
			Directory.CreateDirectory(PLUGIN_PATH);
		}
		Harmony val = new Harmony("spdx.Retailier");
		ManualLogSource log = ((BasePlugin)this).Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(7, 0, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Loaded!");
		}
		log.LogInfo(val2);
		val.PatchAll();
	}

	public static List<KeyValuePair<string[], object>> SetupInteractables(string path)
	{
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Expected O, but got Unknown
		if (!Directory.Exists(path))
		{
			Directory.CreateDirectory(path);
		}
		if (!File.Exists(path + "\\_base.json"))
		{
			string contents = "{\"BanhMi\":{\"destroyWhenAllConsumed\":true,\"retailItem\":\"Hamburger\"},\"BungeoPpangWhole\":{\"destroyWhenAllConsumed\":true,\"retailItem\":\"Donut\"},\"Cigar\":{\"consumableAmount\":5,\"destroyWhenAllConsumed\":true,\"fpsItem\":\"food_medicine\",\"fpsItemOffset\":[\"Vector3\",\"50\",\"500\",\"25\"],\"fpsItemRotation\":[\"Vector3\",\"210\",\"120\",\"0\"],\"retailItem\":{\"alertness\":0.25,\"hygiene\":-0.05,\"numb\":0.15}},\"Cigarettes\":{\"consumableAmount\":10,\"fpsItem\":\"food_medicine\",\"fpsItemOffset\":[\"Vector3\",\"-50\",\"250\",\"-50\"],\"fpsItemRotation\":[\"Vector3\",\"160\",\"-30\",\"110\"],\"retailItem\":{\"alertness\":0.15,\"hygiene\":-0.05,\"numb\":0.1}},\"Eclair\":{\"destroyWhenAllConsumed\":true,\"retailItem\":\"Donut\"},\"FairyBread\":{\"destroyWhenAllConsumed\":true},\"Gimbap\":{\"destroyWhenAllConsumed\":true,\"retailItem\":\"Hamburger\"},\"KabuliBurger\":{\"destroyWhenAllConsumed\":true},\"PocketWatch\":{\"isClock\":true,\"readingEnabled\":true,\"readingSource\":\"time\"},\"Razor\":{\"fpsItemOffset\":[\"Vector3\",\"34\",\"-35\",\"-145\"]},\"ReubenSandwich\":{\"destroyWhenAllConsumed\":true},\"SoapBar\":{\"consumableAmount\":16,\"fpsItem\":\"item_application\",\"fpsItemOffset\":[\"Vector3\",\"100\",\"300\",\"-80\"],\"fpsItemRotation\":[\"Vector3\",\"0\",\"180\",\"-80\"],\"retailItem\":{\"hygiene\":0.2,\"wet\":0.1}},\"TikaToast\":{\"destroyWhenAllConsumed\":true,\"retailItem\":\"Donut\"},\"TinnedFood\":{\"retailItem\":\"Donut\",\"value\":[\"Vector2\",\"2\",\"4\"]},\"WashingUpLiquid\":{\"value\":[\"Vector2\",\"5\",\"10\"]},\"YorkiePie\":{\"destroyWhenAllConsumed\":true,\"retailItem\":\"Donut\"}}";
			File.WriteAllText(path + "\\_base.json", contents);
			ManualLogSource log = PluginController<Plugin, IPluginBindings>.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(41, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("spdx.Retailier");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Created default interactable table at ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(path);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("!");
			}
			log.LogInfo(val);
		}
		return SetupPropertyList(path);
	}

	public static List<KeyValuePair<string[], object>> SetupPropertyList(string path)
	{
		List<KeyValuePair<string[], object>> list = new List<KeyValuePair<string[], object>>();
		string[] files = Directory.GetFiles(path, "*.json");
		Array.Sort(files);
		string[] array = files;
		foreach (string path2 in array)
		{
			string json = File.ReadAllText(path2);
			Dictionary<string, Dictionary<string, JsonElement>> dictionary = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, JsonElement>>>(json);
			foreach (KeyValuePair<string, Dictionary<string, JsonElement>> item in dictionary)
			{
				object obj = null;
				foreach (KeyValuePair<string, JsonElement> item2 in item.Value)
				{
					if (item2.Value.ValueKind == JsonValueKind.Object)
					{
						Dictionary<string, object> dictionary2 = new Dictionary<string, object>();
						foreach (KeyValuePair<string, JsonElement> item3 in item2.Value.Deserialize<Dictionary<string, JsonElement>>())
						{
							dictionary2.Add(item3.Key, Utils.ConvertJSONElement(item3.Value));
						}
						obj = dictionary2;
					}
					else
					{
						obj = Utils.ConvertJSONElement(item2.Value);
					}
					list.Add(new KeyValuePair<string[], object>(new string[2] { item.Key, item2.Key }, obj));
				}
			}
		}
		return list;
	}

	public static Dictionary<string, string[]> SetupMenusDict(string path)
	{
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Expected O, but got Unknown
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Expected O, but got Unknown
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Expected O, but got Unknown
		Dictionary<string, string[]> dictionary = new Dictionary<string, string[]>();
		if (!Directory.Exists(path))
		{
			Directory.CreateDirectory(path);
		}
		bool flag = default(bool);
		if (!File.Exists(path + "\\_base.json"))
		{
			string contents = "{\"Aliases\": {\"Bar\": [\"AmericanBar\"], \"ChineseEatery\": [\"Chinese\"], \"FastFood\": [\"AmericanDiner\"], \"HardwareStore\": [\"Hardware\"]}, \"Combines\": {\"Supermarket\": [\"SupermarketFruit\", \"SupermarketMagazines\", \"SupermarketShelf\"]}, \"Menus\": {\"AmericanBar\": [\"FishNChipsInBox\", \"MushyPeas\", \"YorkiePie\", \"TikaToast\"], \"AmericanDiner\": [\"ReubenSandwich\", \"PoutineInBox\"], \"Ballroom\": [\"Eclair\", \"Crepe\"], \"BlackmarketTrader\": [\"PropGun\", \"Diamond\", \"JadeNecklace\", \"ClawOfTheFathomsFirstEdition\", \"ChateauDArc1868\"], \"Chemist\": [\"Glasses\", \"ToiletBrush\", \"WashingUpLiquid\"], \"Chinese\": [\"Fishlafel\", \"KabuliBurger\", \"BanhMi\", \"BungeoPpangWhole\", \"Gimbap\", \"BreathMints\"], \"Hardware\": [\"PhotoChemicals\", \"FilmCanister\", \"Plunger\", \"MugEmpty\", \"PaintBucket\", \"PaintTube\", \"PaintBrush\", \"Pallette\", \"CleanPlate\", \"CleaningSpray\", \"PowerDrill\", \"PackingTape\", \"DuctTape\", \"Wool\", \"Thread\", \"KnittingNeedle\", \"JerryCan\", \"OilCan\", \"Bleach\", \"WashingUpLiquid\"], \"PawnShop\": [\"JadeNecklace\", \"WristWatch\", \"PocketWatch\", \"FilmCanister\", \"Katana\", \"TradingCard\", \"BaseballCap\"], \"SupermarketFruit\": [\"MegaMite\", \"Ketchup\", \"Mustard\", \"Vinegar\", \"Salt\", \"Pepper\", \"TinnedFood\", \"FairyBread\", \"PickapepperSauce\"], \"SupermarketMagazines\": [\"PackingTape\", \"Pencil\", \"Sharpener\", \"Eraser\", \"VideoTape\"], \"SupermarketShelf\": [\"Toothbrush\", \"Sponge\", \"Comb\", \"Camera\", \"FilmCanister\", \"MugEmpty\", \"Teacup\", \"WristWatch\", \"Battery\", \"Battery9V\", \"WhiteDice\", \"RedDice\", \"Bleach\", \"WashingUpLiquid\"]}, \"Meta\": {\"Override\": [\"False\"], \"Version\": [\"1.4.0\"]}}";
			File.WriteAllText(path + "\\_base.json", contents);
			ManualLogSource log = PluginController<Plugin, IPluginBindings>.Log;
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("spdx.Retailier");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Created default menu table at ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(path);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("!");
			}
			log.LogInfo(val);
		}
		string[] files = Directory.GetFiles(path, "*.json");
		Array.Sort(files);
		string[] array = files;
		foreach (string path2 in array)
		{
			string json = File.ReadAllText(path2);
			Dictionary<string, Dictionary<string, string[]>> dictionary2 = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string[]>>>(json);
			bool flag2 = false;
			try
			{
				if (dictionary2["Meta"]["Version"][0] != "1.4.0")
				{
					ManualLogSource log2 = PluginController<Plugin, IPluginBindings>.Log;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(48, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("spdx.Retailier");
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": Version mismatch! Plugin is ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.4.0");
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", JSON version is ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(dictionary2["Meta"]["Version"][0]);
					}
					log2.LogWarning(val2);
				}
				flag2 = bool.Parse(dictionary2["Meta"]["Override"][0]);
			}
			catch
			{
				ManualLogSource log3 = PluginController<Plugin, IPluginBindings>.Log;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(18, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("spdx.Retailier");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": No metadata in ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Path.GetFileName(path2));
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("!");
				}
				log3.LogWarning(val2);
			}
			foreach (KeyValuePair<string, string[]> item in dictionary2["Menus"])
			{
				if (!dictionary.TryGetValue(item.Key, out var _))
				{
					dictionary.Add(item.Key, item.Value);
				}
				else if (flag2)
				{
					dictionary[item.Key] = item.Value;
				}
			}
			foreach (KeyValuePair<string, string[]> item2 in dictionary2["Combines"])
			{
				List<string> list = new List<string>();
				string[] value2 = item2.Value;
				foreach (string key in value2)
				{
					list.AddRange(dictionary2["Menus"][key]);
				}
				if (dictionary.TryGetValue(item2.Key, out var value3))
				{
					if (flag2)
					{
						value3 = list.ToArray();
					}
					else
					{
						value3.Concat(list);
					}
				}
				else
				{
					dictionary.Add(item2.Key, list.ToArray());
				}
			}
			foreach (KeyValuePair<string, string[]> item3 in dictionary2["Aliases"])
			{
				if (flag2 && dictionary.TryGetValue(item3.Key, out var _))
				{
					dictionary.Remove(item3.Key);
				}
				string[] value5 = item3.Value;
				foreach (string key2 in value5)
				{
					dictionary.Add(item3.Key, dictionary2["Menus"][key2]);
				}
			}
		}
		return dictionary;
	}
}
public class Patches
{
	[HarmonyPatch(typeof(Toolbox), "LoadAll")]
	internal class PatchInteractableProps
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Expected O, but got Unknown
			List<KeyValuePair<string[], object>> interactables = Retailier.interactables;
			Il2CppArrayBase<RetailItemPreset> source = Resources.FindObjectsOfTypeAll<RetailItemPreset>();
			Il2CppArrayBase<FirstPersonItem> source2 = Resources.FindObjectsOfTypeAll<FirstPersonItem>();
			foreach (KeyValuePair<string[], object> interactable in interactables)
			{
				InteractablePreset interactable2 = Utils.GetInteractable(interactable.Key[0], suppress: false);
				Type propertyType = ((object)interactable2).GetType().GetProperty(interactable.Key[1]).PropertyType;
				if (propertyType.BaseType == typeof(Enum))
				{
					Utils.SetInteractableProp(interactable2, interactable.Key[1], Enum.Parse(propertyType, interactable.Value.ToString()), suppress: false);
				}
				else if (propertyType == typeof(RetailItemPreset))
				{
					RetailItemPreset val = null;
					if (interactable.Value is string)
					{
						val = Object.Instantiate<RetailItemPreset>(((IEnumerable<RetailItemPreset>)source).Where((RetailItemPreset item) => ((Object)item).name == (string)interactable.Value).FirstOrDefault());
						((Object)val).name = (string)interactable.Value;
					}
					else
					{
						Dictionary<string, object> dictionary = interactable.Value as Dictionary<string, object>;
						if (dictionary.TryGetValue("Copies", out var retailItemToCopy))
						{
							val = Object.Instantiate<RetailItemPreset>(((IEnumerable<RetailItemPreset>)source).Where((RetailItemPreset item) => ((Object)item).name == (string)retailItemToCopy).FirstOrDefault());
							dictionary.Remove("Copies");
							((Object)val).name = interactable.Key[0];
							val.itemPreset = interactable2;
						}
						else
						{
							val = interactable2.retailItem;
						}
						if (dictionary.Count > 0)
						{
							foreach (KeyValuePair<string, object> item in dictionary)
							{
								Utils.SetRetailItemProp(val, item.Key, item.Value, suppress: false);
							}
						}
					}
					Utils.SetInteractableProp(interactable2, interactable.Key[1], val, suppress: false);
				}
				else if (propertyType == typeof(FirstPersonItem))
				{
					FirstPersonItem val2 = null;
					if (interactable.Value is string)
					{
						val2 = ((IEnumerable<FirstPersonItem>)source2).Where((FirstPersonItem item) => ((Object)item).name == (string)interactable.Value).FirstOrDefault();
					}
					else
					{
						Dictionary<string, object> dictionary2 = interactable.Value as Dictionary<string, object>;
						if (dictionary2.TryGetValue("Copies", out var FPItemToCopy))
						{
							val2 = ((IEnumerable<FirstPersonItem>)source2).Where((FirstPersonItem item) => ((Object)item).name == (string)FPItemToCopy).FirstOrDefault();
							dictionary2.Remove("Copies");
						}
						else
						{
							val2 = interactable2.fpsItem;
						}
						if (dictionary2.Count > 0)
						{
							foreach (KeyValuePair<string, object> item2 in dictionary2)
							{
								Utils.SetFPItemProp(val2, item2.Key, item2.Value, suppress: false);
							}
						}
					}
					Utils.SetInteractableProp(interactable2, interactable.Key[1], val2, suppress: false);
				}
				else
				{
					Utils.SetInteractableProp(interactable2, interactable.Key[1], interactable.Value, suppress: false);
				}
			}
			ManualLogSource log = PluginController<Plugin, IPluginBindings>.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(30, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>("spdx.Retailier");
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": InteractablePresets patched!");
			}
			log.LogInfo(val3);
		}
	}

	[HarmonyPatch(typeof(Toolbox), "LoadAll")]
	internal class AddMenuItems
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			MenuPreset[] array = Il2CppArrayBase<MenuPreset>.op_Implicit(Resources.FindObjectsOfTypeAll<MenuPreset>());
			Dictionary<string, string[]> menus = Retailier.menus;
			MenuPreset[] array2 = array;
			foreach (MenuPreset val in array2)
			{
				if (!menus.TryGetValue(((SoCustomComparison)val).GetPresetName(), out var value))
				{
					continue;
				}
				string[] array3 = value;
				foreach (string name in array3)
				{
					InteractablePreset interactable = Utils.GetInteractable(name);
					if ((SoCustomComparison)(object)interactable != (SoCustomComparison)null)
					{
						Utils.AddToMenu(val, interactable);
					}
				}
			}
			ManualLogSource log = PluginController<Plugin, IPluginBindings>.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("spdx.Retailier");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": MenuPresets patched!");
			}
			log.LogInfo(val2);
		}
	}

	[HarmonyPatch(typeof(CityConstructor), "Finalized")]
	internal class SetupCompanies
	{
		[HarmonyPrefix]
		public static void Prefix()
		{
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, string[]> menus = Retailier.menus;
			Company[] array = Il2CppArrayBase<Company>.op_Implicit(CityData.Instance.companyDirectory.ToArray());
			Company[] array2 = array;
			int num3 = default(int);
			foreach (Company val in array2)
			{
				if (!menus.TryGetValue(((SoCustomComparison)val.preset).presetName, out var value))
				{
					continue;
				}
				string[] array3 = value;
				foreach (string name in array3)
				{
					InteractablePreset interactable = Utils.GetInteractable(name, suppress: false);
					string seed = ((NewGameLocation)val.address).district.seed;
					float num = (interactable.value.y - interactable.value.x) / 4f * Toolbox.Instance.GetPsuedoRandomNumberContained(-0.5f, 0.5f, ref seed);
					if ((SoCustomComparison)(object)interactable != (SoCustomComparison)null)
					{
						int num2 = Mathf.RoundToInt(Mathf.Lerp(interactable.value.x, interactable.value.y, (float)((NewGameLocation)val.address).building.cityTile.landValue / 4f) + num);
						if (val.prices.TryGetValue(interactable, ref num3))
						{
							num3 = num2;
						}
						else
						{
							val.prices.Add(interactable, num2);
						}
					}
				}
			}
			ManualLogSource log = PluginController<Plugin, IPluginBindings>.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("spdx.Retailier");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": Companies patched!");
			}
			log.LogInfo(val2);
		}
	}

	public const bool suppressErrors = false;
}
public class Utils
{
	public static void AddToMenu(MenuPreset menu, InteractablePreset interactable, bool suppress = true)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Expected O, but got Unknown
		if (!menu.itemsSold.Contains(interactable))
		{
			menu.itemsSold.Add(interactable);
		}
		else if (!suppress)
		{
			ManualLogSource log = PluginController<Plugin, IPluginBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(26, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Key '");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((SoCustomComparison)interactable).GetPresetName());
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' already exists in ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((SoCustomComparison)menu).GetPresetName());
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
			}
			log.LogError(val);
		}
	}

	public static void AddToMenu(MenuPreset menu, InteractablePreset[] interactables, bool suppress = true)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Expected O, but got Unknown
		bool flag = default(bool);
		foreach (InteractablePreset val in interactables)
		{
			if (!menu.itemsSold.Contains(val))
			{
				menu.itemsSold.Add(val);
			}
			else if (!suppress)
			{
				ManualLogSource log = PluginController<Plugin, IPluginBindings>.Log;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(26, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Key '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((SoCustomComparison)val).GetPresetName());
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' already exists in ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((SoCustomComparison)menu).GetPresetName());
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(".");
				}
				log.LogError(val2);
			}
		}
	}

	public static InteractablePreset GetInteractable(string name, bool suppress = true)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		Dictionary<string, InteractablePreset> objectPresetDictionary = Toolbox.Instance.objectPresetDictionary;
		InteractablePreset result = default(InteractablePreset);
		if (objectPresetDictionary.TryGetValue(name, ref result))
		{
			return result;
		}
		if (!suppress)
		{
			ManualLogSource log = PluginController<Plugin, IPluginBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(38, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' does not exist in given dictionary.");
			}
			log.LogError(val);
		}
		return null;
	}

	public static InteractablePreset GetInteractable(List<InteractablePreset> presetList, string name, bool suppress = true)
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		foreach (InteractablePreset preset in presetList)
		{
			if (((SoCustomComparison)preset).GetPresetName() == name)
			{
				return preset;
			}
		}
		if (!suppress)
		{
			ManualLogSource log = PluginController<Plugin, IPluginBindings>.Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(32, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' does not exist in given list.");
			}
			log.LogError(val);
		}
		return null;
	}

	public static void SetInteractableProp(InteractablePreset preset, string prop, object value, bool suppress = true)
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Expected O, but got Unknown
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Expected O, but got Unknown
		bool flag = default(bool);
		if ((SoCustomComparison)(object)preset != (SoCustomComparison)null)
		{
			try
			{
				PropertyInfo property = ((object)preset).GetType().GetProperty(prop);
				property.SetValue(preset, value);
				return;
			}
			catch (Exception ex)
			{
				if (!suppress)
				{
					ManualLogSource log = PluginController<Plugin, IPluginBindings>.Log;
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(31, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to change ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((SoCustomComparison)preset).GetPresetName());
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(prop);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to value '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(value.ToString());
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
					}
					log.LogError(val);
					ManualLogSource log2 = PluginController<Plugin, IPluginBindings>.Log;
					val = new BepInExErrorLogInterpolatedStringHandler(0, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.ToString());
					}
					log2.LogError(val);
				}
				return;
			}
		}
		if (!suppress)
		{
			ManualLogSource log3 = PluginController<Plugin, IPluginBindings>.Log;
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(22, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Preset passed is null.");
			}
			log3.LogError(val);
		}
	}

	public static void SetRetailItemProp(RetailItemPreset preset, string prop, object value, bool suppress = true)
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Expected O, but got Unknown
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Expected O, but got Unknown
		bool flag = default(bool);
		if ((SoCustomComparison)(object)preset != (SoCustomComparison)null)
		{
			try
			{
				PropertyInfo property = ((object)preset).GetType().GetProperty(prop);
				property.SetValue(preset, value);
				return;
			}
			catch (Exception ex)
			{
				if (!suppress)
				{
					ManualLogSource log = PluginController<Plugin, IPluginBindings>.Log;
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(31, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to change ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((SoCustomComparison)preset).GetPresetName());
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(prop);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to value '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(value.ToString());
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
					}
					log.LogError(val);
					ManualLogSource log2 = PluginController<Plugin, IPluginBindings>.Log;
					val = new BepInExErrorLogInterpolatedStringHandler(0, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.ToString());
					}
					log2.LogError(val);
				}
				return;
			}
		}
		if (!suppress)
		{
			ManualLogSource log3 = PluginController<Plugin, IPluginBindings>.Log;
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(22, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Preset passed is null.");
			}
			log3.LogError(val);
		}
	}

	public static void SetFPItemProp(FirstPersonItem item, string prop, object value, bool suppress = true)
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Expected O, but got Unknown
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Expected O, but got Unknown
		bool flag = default(bool);
		if ((SoCustomComparison)(object)item != (SoCustomComparison)null)
		{
			try
			{
				PropertyInfo property = ((object)item).GetType().GetProperty(prop);
				property.SetValue(item, value);
				return;
			}
			catch (Exception ex)
			{
				if (!suppress)
				{
					ManualLogSource log = PluginController<Plugin, IPluginBindings>.Log;
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(31, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to change ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((SoCustomComparison)item).GetPresetName());
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(prop);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to value '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(value.ToString());
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
					}
					log.LogError(val);
					ManualLogSource log2 = PluginController<Plugin, IPluginBindings>.Log;
					val = new BepInExErrorLogInterpolatedStringHandler(0, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.ToString());
					}
					log2.LogError(val);
				}
				return;
			}
		}
		if (!suppress)
		{
			ManualLogSource log3 = PluginController<Plugin, IPluginBindings>.Log;
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(20, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Item passed is null.");
			}
			log3.LogError(val);
		}
	}

	public static object ConvertJSONElement(JsonElement element)
	{
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		object result = null;
		switch (element.ValueKind)
		{
		case JsonValueKind.True:
			result = true;
			break;
		case JsonValueKind.False:
			result = false;
			break;
		case JsonValueKind.String:
			result = element.ToString();
			break;
		case JsonValueKind.Number:
			result = (float)element.GetDouble();
			break;
		case JsonValueKind.Array:
		{
			List<string> list = element.Deserialize<List<string>>();
			string text = list[0].ToString().ToLower();
			string text2 = text;
			if (!(text2 == "vector2"))
			{
				if (text2 == "vector3")
				{
					result = (object)new Vector3(float.Parse(list[1]), float.Parse(list[2]), float.Parse(list[3]));
				}
			}
			else
			{
				result = (object)new Vector2(float.Parse(list[1]), float.Parse(list[2]));
			}
			break;
		}
		}
		return result;
	}
}