Decompiled source of Retailier v1.3.2

spdx_Retailier.dll

Decompiled 4 months 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;
using Il2CppSystem.Collections.Generic;
using Rewired.Utils;
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+1da5f46f49e17b33f161e4a1ebd8e7dbac8f794f")]
[assembly: AssemblyProduct("spdx_Retailier")]
[assembly: AssemblyTitle("spdx_Retailier")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Retailier;

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

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

	public const string PLUGIN_VERSION = "1.3.2";

	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\": {\"Copies\": \"Hamburger\"}}, \"BungeoPpangWhole\": {\"destroyWhenAllConsumed\": true, \"retailItem\": {\"Copies\": \"Donut\"}}, \"Eclair\": {\"destroyWhenAllConsumed\": true, \"retailItem\": {\"Copies\": \"Donut\"}}, \"FairyBread\": {\"destroyWhenAllConsumed\": true}, \"Gimbap\": {\"destroyWhenAllConsumed\": true, \"retailItem\": {\"Copies\": \"Hamburger\"}}, \"KabuliBurger\": {\"destroyWhenAllConsumed\": true}, \"PocketWatch\": {\"isClock\": true, \"readingEnabled\": true, \"readingSource\": \"time\"}, \"Razor\": {\"fpsItemOffset\": [\"Vector3\", \"34\", \"-35\", \"-145\"]}, \"ReubenSandwich\": {\"destroyWhenAllConsumed\": true}, \"TikaToast\": {\"destroyWhenAllConsumed\": true, \"retailItem\": {\"Copies\": \"Donut\"}}, \"TinnedFood\": {\"retailItem\": {\"Copies\": \"Donut\"}, \"value\": [\"Vector2\", \"2\", \"4\"]}, \"WashingUpLiquid\": {\"value\": [\"Vector2\", \"5\", \"10\"]}, \"YorkiePie\": {\"destroyWhenAllConsumed\": true, \"retailItem\": {\"Copies\": \"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.3.2\"]}}";
			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.3.2")
				{
					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.3.2");
						((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_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Expected O, but got Unknown
			List<KeyValuePair<string[], object>> interactables = Retailier.interactables;
			Il2CppArrayBase<RetailItemPreset> source = Resources.FindObjectsOfTypeAll<RetailItemPreset>();
			foreach (KeyValuePair<string[], object> item in interactables)
			{
				InteractablePreset interactable = Utils.GetInteractable(item.Key[0], suppress: false);
				Type propertyType = ((object)interactable).GetType().GetProperty(item.Key[1]).PropertyType;
				if (propertyType.BaseType == typeof(Enum))
				{
					Utils.SetInteractableProp(interactable, item.Key[1], Enum.Parse(propertyType, item.Value.ToString()), suppress: false);
				}
				else if (propertyType == typeof(RetailItemPreset))
				{
					Dictionary<string, object> dictionary = item.Value as Dictionary<string, object>;
					RetailItemPreset val = null;
					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 = item.Key[0];
						val.itemPreset = interactable;
						interactable.retailItem = val;
					}
					else
					{
						val = interactable.retailItem;
					}
					if (dictionary.Count <= 0)
					{
						continue;
					}
					foreach (KeyValuePair<string, object> item2 in dictionary)
					{
						Utils.SetRetailItemProp(val, item2.Key, item2.Value);
					}
				}
				else
				{
					Utils.SetInteractableProp(interactable, item.Key[1], item.Value, suppress: false);
				}
			}
			ManualLogSource log = PluginController<Plugin, IPluginBindings>.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(30, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("spdx.Retailier");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": InteractablePresets patched!");
			}
			log.LogInfo(val2);
		}
	}

	[HarmonyPatch(typeof(Toolbox), "LoadAll")]
	internal class AddMenuItems
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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 (!ExtensionMethods.IsNullOrDestroyed((Object)(object)interactable))
					{
						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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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;
			string text = default(string);
			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);
					float num = (interactable.value.y - interactable.value.x) / 4f * Toolbox.Instance.GetPsuedoRandomNumberContained(-0.5f, 0.5f, ((NewGameLocation)val.address).district.seed, ref text);
					if (!ExtensionMethods.IsNullOrDestroyed((Object)(object)interactable))
					{
						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 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_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Expected O, but got Unknown
		Enumerator<InteractablePreset> enumerator = presetList.GetEnumerator();
		while (enumerator.MoveNext())
		{
			InteractablePreset current = enumerator.Current;
			if (((SoCustomComparison)current).GetPresetName() == name)
			{
				return current;
			}
		}
		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_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Expected O, but got Unknown
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Expected O, but got Unknown
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Expected O, but got Unknown
		bool flag = default(bool);
		if (!ExtensionMethods.IsNullOrDestroyed((Object)(object)preset))
		{
			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(35, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Preset passed is null or destroyed.");
			}
			log3.LogError(val);
		}
	}

	public static void SetRetailItemProp(RetailItemPreset preset, string prop, object value, bool suppress = true)
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Expected O, but got Unknown
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Expected O, but got Unknown
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Expected O, but got Unknown
		bool flag = default(bool);
		if (!ExtensionMethods.IsNullOrDestroyed((Object)(object)preset))
		{
			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(35, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Preset passed is null or destroyed.");
			}
			log3.LogError(val);
		}
	}

	public static object ConvertJSONElement(JsonElement element)
	{
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: 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:
			if (element.GetType() == typeof(int))
			{
				result = element.GetInt32();
			}
			else if (element.GetType() == typeof(float))
			{
				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;
	}
}