Decompiled source of BloodyMerchant v1.0.9

BloodyMerchant.dll

Decompiled 5 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.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Bloodstone.API;
using Bloody.Core;
using Bloody.Core.API.v1;
using Bloody.Core.GameData.v1;
using Bloody.Core.Helper.v1;
using Bloody.Core.Methods;
using Bloody.Core.Models.v1;
using Bloody.Core.Models.v1.Base;
using Bloody.Core.Patch.Server;
using BloodyMerchant.DB;
using BloodyMerchant.DB.Models;
using BloodyMerchant.Exceptions;
using BloodyMerchant.Systems;
using BloodyWallet.API;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Network;
using ProjectM.Shared;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using VampireCommandFramework;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("BloodyMerchant")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Create VRising NPC merchant")]
[assembly: AssemblyFileVersion("1.0.9.0")]
[assembly: AssemblyInformationalVersion("1.0.9+1.Branch.master.Sha.5590b05d554639cc038d25547da573614ed01f34")]
[assembly: AssemblyProduct("BloodyMerchant")]
[assembly: AssemblyTitle("BloodyMerchant")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.9.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsUnmanagedAttribute : Attribute
	{
	}
}
namespace BloodyMerchant
{
	public static class ECSExtensions
	{
		private static EntityManager GetEntityManager()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return Plugin.World.EntityManager;
		}

		public unsafe static void Write<T>(this Entity entity, T componentData) where T : struct
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			byte[] array = StructureToByteArray(componentData);
			int num = Marshal.SizeOf<T>();
			fixed (byte* ptr = array)
			{
				EntityManager entityManager = GetEntityManager();
				((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num);
			}
		}

		public static byte[] StructureToByteArray<T>(T structure) where T : struct
		{
			int num = Marshal.SizeOf(structure);
			byte[] array = new byte[num];
			IntPtr intPtr = Marshal.AllocHGlobal(num);
			Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true);
			Marshal.Copy(intPtr, array, 0, num);
			Marshal.FreeHGlobal(intPtr);
			return array;
		}

		public unsafe static T Read<T>(this Entity entity) where T : struct
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = GetEntityManager();
			return Marshal.PtrToStructure<T>(new IntPtr(((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex)));
		}

		public static DynamicBuffer<T> ReadBuffer<T>(this Entity entity) where T : struct
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = GetEntityManager();
			return ((EntityManager)(ref entityManager)).GetBuffer<T>(entity, false);
		}

		public static bool Has<T>(this Entity entity)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = GetEntityManager();
			return ((EntityManager)(ref entityManager)).HasComponent(entity, val);
		}

		public static string LookupName(this PrefabGUID prefabGuid)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			PrefabCollectionSystem existingSystemManaged = VWorld.Server.GetExistingSystemManaged<PrefabCollectionSystem>();
			object obj;
			if (!existingSystemManaged.PrefabGuidToNameDictionary.ContainsKey(prefabGuid))
			{
				obj = "GUID Not Found";
			}
			else
			{
				string text = existingSystemManaged.PrefabGuidToNameDictionary[prefabGuid];
				PrefabGUID val = prefabGuid;
				obj = text + " " + ((object)(PrefabGUID)(ref val)).ToString();
			}
			return obj.ToString();
		}

		public static void Add<T>(this Entity entity)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = GetEntityManager();
			((EntityManager)(ref entityManager)).AddComponent(entity, val);
		}

		public static void Remove<T>(this Entity entity)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = GetEntityManager();
			((EntityManager)(ref entityManager)).RemoveComponent(entity, val);
		}

		public static bool Exists(this Entity entity)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (entity.Index > 0)
			{
				EntityManager entityManager = GetEntityManager();
				return ((EntityManager)(ref entityManager)).Exists(entity);
			}
			return false;
		}
	}
	[BepInPlugin("BloodyMerchant", "BloodyMerchant", "1.0.9")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin, IRunOnInitialized
	{
		public static ManualLogSource Logger;

		private Harmony _harmony;

		public static World World;

		public static SystemsCore SystemsCore;

		public static ConfigEntry<bool> WalletSystem;

		public override void Load()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			Logger = ((BasePlugin)this).Log;
			_harmony = new Harmony("BloodyMerchant");
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			EventsHandlerSystem.OnInitialize += new OnGameDataInitializedEventHandler(GameDataOnInitialize);
			EventsHandlerSystem.OnDestroy += new OnGameDataDestroyedEventHandler(GameDataOnDestroy);
			CommandRegistry.RegisterAll();
			InitConfigServer();
			Database.Initialize();
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("BloodyMerchant");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
		}

		private void InitConfigServer()
		{
			WalletSystem = ((BasePlugin)this).Config.Bind<bool>("Wallet", "enabled", false, "Activate system for buy with virtual currency through BloodyWallet ( https://thunderstore.io/c/v-rising/p/Trodi/BloodyWallet/ )");
		}

		public override bool Unload()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			((BasePlugin)this).Config.Clear();
			CommandRegistry.UnregisterAssembly();
			_harmony.UnpatchSelf();
			EventsHandlerSystem.OnDestroy -= new OnGameDataDestroyedEventHandler(GameDataOnDestroy);
			EventsHandlerSystem.OnInitialize -= new OnGameDataInitializedEventHandler(GameDataOnInitialize);
			EventsHandlerSystem.OnDeath -= new DeathEventHandler(DeathEventSystem.OnDeath);
			return true;
		}

		private static void GameDataOnInitialize(World world)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			SystemsCore = Core.SystemsCore;
			EventsHandlerSystem.OnTraderPurchase += new TraderPurchaseEventHandler(AutorefillSystem.OnTraderPurchase);
			EventsHandlerSystem.OnDeath += new DeathEventHandler(DeathEventSystem.OnDeath);
			if (WalletSystem.Value)
			{
				VirtualBuySystem.MakeSpecialCurrenciesSoulbound();
				EventsHandlerSystem.OnPlayerBuffed += new PlayerBuffedEventHandler(VirtualBuySystem.HandleOnPlayerBuffed);
				EventsHandlerSystem.OnPlayerBuffRemoved += new PlayerBuffRemovedEventHandler(VirtualBuySystem.HandleOnPlayerBuffRemoved);
			}
			Logger.LogInfo((object)"GameDataOnInitialize BloodyMerchant");
		}

		private static void GameDataOnDestroy()
		{
			Logger.LogDebug((object)"GameDataOnDestroy");
		}

		public void OnGameInitialized()
		{
			World = VWorld.Server;
			Logger.LogDebug((object)"OnGameInitialized");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BloodyMerchant";

		public const string PLUGIN_NAME = "BloodyMerchant";

		public const string PLUGIN_VERSION = "1.0.9";
	}
}
namespace BloodyMerchant.Systems
{
	internal class AutorefillSystem
	{
		public static void OnTraderPurchase(NativeArray<Entity> entities)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			Singleton val = QueryComponents.GetEntitiesByComponentTypes<Singleton>((EntityQueryOptions)16, false)[0].Read<Singleton>();
			Enumerator<Entity> enumerator = entities.GetEnumerator();
			Entity val3 = default(Entity);
			while (enumerator.MoveNext())
			{
				TraderPurchaseEvent val2 = enumerator.Current.Read<TraderPurchaseEvent>();
				NetworkIdLookupMap networkIdLookupRW = ((Singleton)(ref val)).GetNetworkIdLookupRW();
				((NetworkIdLookupMap)(ref networkIdLookupRW)).TryGetValue(val2.Trader, ref val3);
				if (!val3.Has<NameableInteractable>())
				{
					continue;
				}
				NameableInteractable val4 = val3.Read<NameableInteractable>();
				string name = ((FixedString64Bytes)(ref val4.Name)).Value;
				foreach (MerchantModel item in Database.Merchants.Where((MerchantModel x) => x.name == name).ToList())
				{
					item.Refill(val3, val2);
				}
			}
		}
	}
	public class DeathEventSystem
	{
		public static void OnDeath(DeathEventListenerSystem sender, NativeArray<DeathEvent> deathEvents)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<DeathEvent> enumerator = deathEvents.GetEnumerator();
			while (enumerator.MoveNext())
			{
				DeathEvent current = enumerator.Current;
				if (!current.Died.Has<TradeCost>())
				{
					break;
				}
				if (!current.Died.Has<NameableInteractable>())
				{
					continue;
				}
				NameableInteractable val = current.Died.Read<NameableInteractable>();
				string name = ((FixedString64Bytes)(ref val.Name)).Value;
				foreach (MerchantModel item in Database.Merchants.Where((MerchantModel x) => x.name == name).ToList())
				{
					if (item.merchantEntity.Exists())
					{
						item.CleanIconMerchant(current.Killer);
					}
				}
			}
		}
	}
	public static class Il2cppService
	{
		private static Type GetType<T>()
		{
			return Il2CppType.Of<T>();
		}

		public unsafe static T GetComponentDataAOT<T>(this EntityManager entityManager, Entity entity) where T : unmanaged
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			TypeIndex typeIndex = TypeManager.GetTypeIndex(GetType<T>());
			T* componentDataRawRW = (T*)((EntityManager)(ref entityManager)).GetComponentDataRawRW(entity, typeIndex);
			return *componentDataRawRW;
		}

		public static NativeArray<Entity> GetEntitiesByComponentTypes<T1>(bool includeAll = false)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			EntityQueryOptions options = (EntityQueryOptions)(includeAll ? 195 : 0);
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1]
			{
				new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0)
			});
			val.Options = options;
			EntityQueryDesc val2 = val;
			EntityManager entityManager = VWorld.Server.EntityManager;
			EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val2 });
			return ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
		}

		public static NativeArray<Entity> GetEntitiesByComponentTypes<T1, T2>(bool includeAll = false)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			EntityQueryOptions options = (EntityQueryOptions)(includeAll ? 195 : 0);
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[2]
			{
				new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0),
				new ComponentType(Il2CppType.Of<T2>(), (AccessMode)0)
			});
			val.Options = options;
			EntityQueryDesc val2 = val;
			EntityManager entityManager = VWorld.Server.EntityManager;
			EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val2 });
			return ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
		}

		public static NativeArray<Entity> GetEntitiesByComponentTypes<T1, T2, T3>(bool includeAll = false)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			EntityQueryOptions options = (EntityQueryOptions)(includeAll ? 195 : 0);
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[3]
			{
				new ComponentType(Il2CppType.Of<T1>(), (AccessMode)0),
				new ComponentType(Il2CppType.Of<T2>(), (AccessMode)0),
				new ComponentType(Il2CppType.Of<T3>(), (AccessMode)0)
			});
			val.Options = options;
			EntityQueryDesc val2 = val;
			EntityManager entityManager = VWorld.Server.EntityManager;
			EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)new EntityQueryDesc[1] { val2 });
			return ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
		}
	}
	internal class VirtualBuySystem
	{
		private static bool withoutSpace;

		internal static void HandleOnPlayerBuffed(UserModel player, Entity buffEntity, PrefabGUID prefabGuid)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			if (!(prefabGuid == Prefabs.AB_Interact_Trade))
			{
				return;
			}
			Entity entity = buffEntity.Read<SpellTarget>().Target._Entity;
			if (!entity.Exists())
			{
				return;
			}
			try
			{
				if (!entity.Has<NameableInteractable>())
				{
					return;
				}
				NameableInteractable nameableInteractable = entity.Read<NameableInteractable>();
				if (Database.Merchants.Where((MerchantModel x) => ((FixedString64Bytes)(ref nameableInteractable.Name)).Value == x.name).FirstOrDefault() == null)
				{
					return;
				}
				if (InventoryUtilities.GetFreeSlotsCount(Plugin.SystemsCore.EntityManager, player.Character.Entity) == 0)
				{
					BuffSystem.Unbuff(player.Character.Entity, prefabGuid);
					UserModelMethods.SendSystemMessage(player, FontColorChatSystem.Red("You must have inventory space to interact with this trader!"));
					withoutSpace = true;
					return;
				}
				withoutSpace = false;
				int num = default(int);
				if (WalletAPI.GetTotalTokensForUser(player.CharacterName, ref num))
				{
					Entity val = default(Entity);
					UserModelMethods.TryGiveItem(player, new PrefabGUID(WalletAPI.GetPrefabGUID()), num, ref val);
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)ex.Message);
			}
		}

		internal static void HandleOnPlayerBuffRemoved(UserModel player, Entity buffEntity, PrefabGUID prefabGuid)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			if (!(prefabGuid == Prefabs.AB_Interact_Trade))
			{
				return;
			}
			Entity entity = buffEntity.Read<SpellTarget>().Target._Entity;
			if (!entity.Exists())
			{
				return;
			}
			try
			{
				if (!entity.Has<NameableInteractable>() || withoutSpace)
				{
					return;
				}
				NameableInteractable nameableInteractable = entity.Read<NameableInteractable>();
				int num = default(int);
				if (Database.Merchants.Where(delegate(MerchantModel x)
				{
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					string value = ((FixedString64Bytes)(ref nameableInteractable.Name)).Value;
					FixedString64Bytes val = new FixedString64Bytes(x.name);
					return value == ((FixedString64Bytes)(ref val)).Value;
				}).FirstOrDefault() == null || !WalletAPI.GetTotalTokensForUser(player.CharacterName, ref num))
				{
					return;
				}
				string text2 = default(string);
				if (searchTotalPrefabsInInventory(player, new PrefabGUID(WalletAPI.GetPrefabGUID()), out var total))
				{
					int num2 = num - total;
					if (getPrefabFromInventory(player, new PrefabGUID(WalletAPI.GetPrefabGUID()), num - num2))
					{
						string text = default(string);
						if (!WalletAPI.RemoveToken(num2, "BloodyMerchant", ((EntityModel)player).Entity, ((EntityModel)player).Entity, ref text))
						{
							UserModelMethods.SendSystemMessage(player, FontColorChatSystem.Red(text ?? ""));
						}
					}
					else
					{
						UserModelMethods.SendSystemMessage(player, FontColorChatSystem.Red("Error when trying to extract items from inventory"));
					}
				}
				else if (WalletAPI.RemoveToken(num, "BloodyMerchant", ((EntityModel)player).Entity, ((EntityModel)player).Entity, ref text2))
				{
					UserModelMethods.SendSystemMessage(player, text2);
				}
				else
				{
					UserModelMethods.SendSystemMessage(player, FontColorChatSystem.Red(text2 ?? ""));
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)ex.Message);
			}
		}

		internal static void MakeSpecialCurrenciesSoulbound()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			Entity entity = Plugin.SystemsCore.PrefabCollectionSystem._PrefabGuidToEntityMap[new PrefabGUID(WalletAPI.GetPrefabGUID())];
			ItemData val = entity.Read<ItemData>();
			val.MaxAmount = 4000;
			ref ItemCategory itemCategory = ref val.ItemCategory;
			itemCategory = (ItemCategory)((ulong)itemCategory | 0x100uL);
			entity.Write<ItemData>(val);
			NativeParallelHashMap<PrefabGUID, ItemData> itemHashLookupMap = Plugin.SystemsCore.GameDataSystem.ItemHashLookupMap;
			itemHashLookupMap[new PrefabGUID(WalletAPI.GetPrefabGUID())] = val;
		}

		public static bool searchTotalPrefabsInInventory(UserModel player, PrefabGUID prefabCurrencyGUID, out int total)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			total = 0;
			try
			{
				Entity entity = player.Character.Entity;
				total = InventoryUtilities.GetItemAmount(Plugin.SystemsCore.EntityManager, entity, prefabCurrencyGUID, default(Nullable_Unboxed<int>));
				if (total >= 0)
				{
					return true;
				}
				return false;
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(7, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logger.LogError(val);
				return false;
			}
		}

		public static bool getPrefabFromInventory(UserModel player, PrefabGUID prefabGUID, int quantity)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			try
			{
				ItemModel prefabById = GameData.Items.GetPrefabById(prefabGUID);
				Entity entity = player.Character.Entity;
				if (InventoryUtilitiesServer.TryRemoveItem(Plugin.SystemsCore.EntityManager, entity, ((EntityModel)prefabById).PrefabGUID, quantity))
				{
					return true;
				}
				return false;
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(6, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logger.LogError(val);
				return false;
			}
		}
	}
}
namespace BloodyMerchant.Exceptions
{
	internal class MerchantDontEnableException : Exception
	{
		public MerchantDontEnableException()
		{
		}

		public MerchantDontEnableException(string message)
			: base(message)
		{
		}

		public MerchantDontEnableException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		protected MerchantDontEnableException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	internal class MerchantDontExistException : Exception
	{
		public MerchantDontExistException()
		{
		}

		public MerchantDontExistException(string message)
			: base(message)
		{
		}

		public MerchantDontExistException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		protected MerchantDontExistException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	internal class MerchantEnableException : Exception
	{
		public MerchantEnableException()
		{
		}

		public MerchantEnableException(string message)
			: base(message)
		{
		}

		public MerchantEnableException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		protected MerchantEnableException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	internal class MerchantExistException : Exception
	{
		public MerchantExistException()
		{
		}

		public MerchantExistException(string message)
			: base(message)
		{
		}

		public MerchantExistException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		protected MerchantExistException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	internal class ProductDontExistException : Exception
	{
		public ProductDontExistException()
		{
		}

		public ProductDontExistException(string message)
			: base(message)
		{
		}

		public ProductDontExistException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		protected ProductDontExistException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
	internal class ProductExistException : Exception
	{
		public ProductExistException()
		{
		}

		public ProductExistException(string message)
			: base(message)
		{
		}

		public ProductExistException(string message, Exception innerException)
			: base(message, innerException)
		{
		}

		protected ProductExistException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}
	}
}
namespace BloodyMerchant.DB
{
	internal class Database
	{
		public static readonly string ConfigPath = Path.Combine(Paths.ConfigPath, "BloodyMerchant");

		public static string MerchantListFile = Path.Combine(ConfigPath, "merchants.json");

		public static List<MerchantModel> Merchants { get; set; } = new List<MerchantModel>();


		public static List<int> ValidMerchantIds { get; set; } = new List<int>
		{
			194933933, 233171451, 281572043, -1594911649, -1168705805, -375258845, -208499374, -1810631919, -1292194494, 1631713257,
			345283594, -1990875761, 1687896942, -915182578, 739223277
		};


		public static void Initialize()
		{
			createDatabaseFiles();
			loadDatabase();
		}

		public static bool saveDatabase()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			try
			{
				string contents = JsonSerializer.Serialize(Merchants, new JsonSerializerOptions
				{
					WriteIndented = true
				});
				File.WriteAllText(MerchantListFile, contents);
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(17, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Save Database: OK");
				}
				logger.LogDebug(val);
				return true;
			}
			catch (Exception ex)
			{
				ManualLogSource logger2 = Plugin.Logger;
				bool flag2 = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(20, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Error SaveDatabase: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logger2.LogError(val2);
				return false;
			}
		}

		public static bool loadDatabase()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			try
			{
				Merchants = JsonSerializer.Deserialize<List<MerchantModel>>(File.ReadAllText(MerchantListFile));
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(17, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Load Database: OK");
				}
				logger.LogDebug(val);
				return true;
			}
			catch (Exception ex)
			{
				ManualLogSource logger2 = Plugin.Logger;
				bool flag2 = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(20, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Error LoadDatabase: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logger2.LogError(val2);
				return false;
			}
		}

		public static bool createDatabaseFiles()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			if (!Directory.Exists(ConfigPath))
			{
				Directory.CreateDirectory(ConfigPath);
			}
			if (!File.Exists(MerchantListFile))
			{
				File.WriteAllText(MerchantListFile, "[]");
			}
			ManualLogSource logger = Plugin.Logger;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(19, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Create Database: OK");
			}
			logger.LogDebug(val);
			return true;
		}

		public static bool GetMerchant(string MerchantName, out MerchantModel merchant)
		{
			merchant = Merchants.Where((MerchantModel x) => x.name == MerchantName).FirstOrDefault();
			if (merchant == null)
			{
				return false;
			}
			return true;
		}

		public static bool AddMerchant(string MerchantName, int prefabGUIDOfMerchant, bool immortal, bool canMove, bool autoRespawn)
		{
			if (GetMerchant(MerchantName, out var merchant))
			{
				throw new MerchantExistException();
			}
			merchant = new MerchantModel();
			merchant.name = MerchantName;
			merchant.PrefabGUID = prefabGUIDOfMerchant;
			merchant.config.Immortal = immortal;
			merchant.config.CanMove = canMove;
			merchant.config.Autorepawn = autoRespawn;
			Merchants.Add(merchant);
			saveDatabase();
			return true;
		}

		public static bool RemoveMerchant(string MerchantName)
		{
			if (GetMerchant(MerchantName, out var merchant))
			{
				if (merchant.config.IsEnabled)
				{
					throw new MerchantEnableException();
				}
				Merchants.Remove(merchant);
				saveDatabase();
				return true;
			}
			throw new MerchantDontExistException();
		}
	}
}
namespace BloodyMerchant.DB.Models
{
	internal class ConfigMerchantModel
	{
		public bool IsEnabled { get; set; }

		public float x { get; set; }

		public float z { get; set; }

		public bool Immortal { get; set; }

		public bool CanMove { get; set; }

		public bool Autorepawn { get; set; }
	}
	public class ItemModel
	{
		public int OutputItem { get; set; }

		public int OutputAmount { get; set; }

		public int InputItem { get; set; }

		public int InputAmount { get; set; }

		public int StockAmount { get; set; }

		public bool Autorefill { get; set; }

		public ItemModel(int outputItem, int outputAmount, int inputItem, int inputAmount, int stockAmount, bool autorefill)
		{
			OutputItem = outputItem;
			OutputAmount = outputAmount;
			InputItem = inputItem;
			InputAmount = inputAmount;
			StockAmount = stockAmount;
			Autorefill = autorefill;
		}
	}
	internal class MerchantModel
	{
		private Entity icontEntity;

		public string name { get; set; } = string.Empty;


		public int PrefabGUID { get; set; }

		public List<ItemModel> items { get; set; } = new List<ItemModel>();


		public Entity merchantEntity { get; set; }

		public ConfigMerchantModel config { get; set; } = new ConfigMerchantModel();


		public List<TraderItem> GetTraderItems()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			List<TraderItem> list = new List<TraderItem>();
			foreach (ItemModel item2 in items)
			{
				TraderItem item = new TraderItem(new PrefabGUID(item2.OutputItem), item2.OutputAmount, new PrefabGUID(item2.InputItem), item2.InputAmount, item2.StockAmount);
				list.Add(item);
			}
			return list;
		}

		public bool GetProduct(int itemPrefabID, out ItemModel item)
		{
			item = items.Where((ItemModel x) => x.OutputItem == itemPrefabID).FirstOrDefault();
			if (item == null)
			{
				return false;
			}
			return true;
		}

		public bool Clean()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			items.Clear();
			Database.saveDatabase();
			if (GetEntity(name))
			{
				Addinventory(merchantEntity);
			}
			return true;
		}

		public bool AddProduct(int ItemPrefabID, int CurrencyfabID, int Stack, int Price, int Amount, bool Autorefill)
		{
			if (!GetProduct(ItemPrefabID, out var item))
			{
				item = new ItemModel(ItemPrefabID, Stack, CurrencyfabID, Price, Amount, Autorefill);
				items.Add(item);
				Database.saveDatabase();
				AddRealtimeObjet(item);
				return true;
			}
			throw new ProductExistException();
		}

		public bool RemoveProduct(int ItemPrefabID)
		{
			if (GetProduct(ItemPrefabID, out var item))
			{
				items.Remove(item);
				Database.saveDatabase();
				RemoveRealtimeObjet(item);
				return true;
			}
			throw new ProductDontExistException();
		}

		public bool SpawnWithLocation(Entity sender, float3 pos)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			if (!config.IsEnabled)
			{
				SpawnSystem.SpawnUnitWithCallback(sender, new PrefabGUID(PrefabGUID), new float2(pos.x, pos.z), -1f, (Action<Entity>)delegate(Entity e)
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_000f: Unknown result type (might be due to invalid IL or missing references)
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0073: Unknown result type (might be due to invalid IL or missing references)
					//IL_0079: Unknown result type (might be due to invalid IL or missing references)
					merchantEntity = e;
					config.z = pos.z;
					config.x = pos.x;
					config.IsEnabled = true;
					ModifyMerchant(sender, e);
					CoroutineHandler.StartFrameCoroutine((Action)delegate
					{
						//IL_000c: Unknown result type (might be due to invalid IL or missing references)
						Addinventory(e);
					}, 3, 1);
				});
				_ = Plugin.SystemsCore.EntityManager;
				ActionScheduler.RunActionOnceAfterDelay((Action)delegate
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_002b: Unknown result type (might be due to invalid IL or missing references)
					SpawnSystem.SpawnUnitWithCallback(sender, Prefabs.MapIcon_POI_Discover_Merchant, new float2(config.x, config.z), -1f, (Action<Entity>)delegate(Entity e)
					{
						//IL_0006: Unknown result type (might be due to invalid IL or missing references)
						//IL_0007: Unknown result type (might be due to invalid IL or missing references)
						//IL_000c: Unknown result type (might be due to invalid IL or missing references)
						//IL_0012: Unknown result type (might be due to invalid IL or missing references)
						//IL_0018: Unknown result type (might be due to invalid IL or missing references)
						//IL_0019: Unknown result type (might be due to invalid IL or missing references)
						//IL_001e: Unknown result type (might be due to invalid IL or missing references)
						//IL_0027: Unknown result type (might be due to invalid IL or missing references)
						//IL_002c: Unknown result type (might be due to invalid IL or missing references)
						//IL_0031: Unknown result type (might be due to invalid IL or missing references)
						//IL_003e: Unknown result type (might be due to invalid IL or missing references)
						//IL_0043: Unknown result type (might be due to invalid IL or missing references)
						//IL_0048: Unknown result type (might be due to invalid IL or missing references)
						//IL_004d: Unknown result type (might be due to invalid IL or missing references)
						//IL_004e: Unknown result type (might be due to invalid IL or missing references)
						//IL_0054: Unknown result type (might be due to invalid IL or missing references)
						//IL_005a: Unknown result type (might be due to invalid IL or missing references)
						//IL_005b: Unknown result type (might be due to invalid IL or missing references)
						//IL_0060: Unknown result type (might be due to invalid IL or missing references)
						//IL_0078: Unknown result type (might be due to invalid IL or missing references)
						//IL_007d: Unknown result type (might be due to invalid IL or missing references)
						//IL_0082: Unknown result type (might be due to invalid IL or missing references)
						//IL_0083: Unknown result type (might be due to invalid IL or missing references)
						icontEntity = e;
						e.Add<MapIconData>();
						e.Add<MapIconTargetEntity>();
						MapIconTargetEntity componentData = e.Read<MapIconTargetEntity>();
						componentData.TargetEntity = NetworkedEntity.ServerEntity(merchantEntity);
						componentData.TargetNetworkId = merchantEntity.Read<NetworkId>();
						e.Write<MapIconTargetEntity>(componentData);
						e.Add<NameableInteractable>();
						NameableInteractable componentData2 = e.Read<NameableInteractable>();
						componentData2.Name = new FixedString64Bytes(name + "_icon");
						e.Write<NameableInteractable>(componentData2);
					});
				}, 3.0);
				return true;
			}
			throw new MerchantEnableException();
		}

		public void ModifyMerchant(Entity user, Entity merchant)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			bool flag2 = default(bool);
			if (config.Immortal)
			{
				bool flag = MakeNPCImmortal(user, merchant);
				ManualLogSource logger = Plugin.Logger;
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(14, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("NPC immortal: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(flag);
				}
				logger.LogDebug(val);
			}
			if (!config.CanMove)
			{
				MakeNPCDontMove(user, merchant);
				ManualLogSource logger2 = Plugin.Logger;
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(13, 0, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("NPC Dont Move");
				}
				logger2.LogDebug(val);
			}
			RenameMerchant(merchant, name);
		}

		public void Addinventory(Entity merchant)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = Plugin.SystemsCore.EntityManager;
			_ = Plugin.SystemsCore.UnitSpawnerUpdateSystem;
			List<TraderItem> traderItems = GetTraderItems();
			DynamicBuffer<TradeOutput> buffer = ((EntityManager)(ref entityManager)).GetBuffer<TradeOutput>(merchant, false);
			DynamicBuffer<TraderEntry> buffer2 = ((EntityManager)(ref entityManager)).GetBuffer<TraderEntry>(merchant, false);
			DynamicBuffer<TradeCost> buffer3 = ((EntityManager)(ref entityManager)).GetBuffer<TradeCost>(merchant, false);
			buffer.Clear();
			buffer2.Clear();
			buffer3.Clear();
			int num = 0;
			foreach (TraderItem item in traderItems)
			{
				if (num > 32)
				{
					break;
				}
				buffer.Add(new TradeOutput
				{
					Amount = (ushort)item.OutputAmount,
					Item = item.OutputItem
				});
				buffer3.Add(new TradeCost
				{
					Amount = (ushort)item.InputAmount,
					Item = item.InputItem
				});
				buffer2.Add(new TraderEntry
				{
					RechargeInterval = 10f,
					CostCount = 1,
					CostStartIndex = (byte)num,
					FullRechargeTime = 60f,
					OutputCount = 1,
					OutputStartIndex = (byte)num,
					StockAmount = (ushort)item.StockAmount
				});
				num++;
			}
		}

		public void CreateIcon(Entity sender)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			_ = Plugin.SystemsCore.EntityManager;
			_ = Plugin.SystemsCore.UnitSpawnerUpdateSystem;
			icontEntity.Add<MapIconData>();
			icontEntity.Add<MapIconTargetEntity>();
			MapIconTargetEntity componentData = icontEntity.Read<MapIconTargetEntity>();
			componentData.TargetEntity = NetworkedEntity.ServerEntity(merchantEntity);
			componentData.TargetNetworkId = merchantEntity.Read<NetworkId>();
			icontEntity.Write<MapIconTargetEntity>(componentData);
			icontEntity.Add<NameableInteractable>();
			NameableInteractable componentData2 = icontEntity.Read<NameableInteractable>();
			componentData2.Name = new FixedString64Bytes(name + "_icon");
			icontEntity.Write<NameableInteractable>(componentData2);
		}

		internal bool AddRealtimeObjet(ItemModel item)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			if (GetEntity(name))
			{
				DynamicBuffer<TradeOutput> val = merchantEntity.ReadBuffer<TradeOutput>();
				DynamicBuffer<TraderEntry> val2 = merchantEntity.ReadBuffer<TraderEntry>();
				DynamicBuffer<TradeCost> val3 = merchantEntity.ReadBuffer<TradeCost>();
				int length = val3.Length;
				val.Add(new TradeOutput
				{
					Amount = (ushort)item.OutputAmount,
					Item = new PrefabGUID(item.OutputItem)
				});
				val3.Add(new TradeCost
				{
					Amount = (ushort)item.InputAmount,
					Item = new PrefabGUID(item.InputItem)
				});
				val2.Add(new TraderEntry
				{
					RechargeInterval = 10f,
					CostCount = 1,
					CostStartIndex = (byte)length,
					FullRechargeTime = 60f,
					OutputCount = 1,
					OutputStartIndex = (byte)length,
					StockAmount = (ushort)item.StockAmount
				});
				return true;
			}
			return false;
		}

		internal bool RemoveRealtimeObjet(ItemModel item)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (GetEntity(name))
			{
				Addinventory(merchantEntity);
				return true;
			}
			return false;
		}

		public void Refill(Entity merchant, TraderPurchaseEvent _event)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			DynamicBuffer<TraderEntry> val = merchant.ReadBuffer<TraderEntry>();
			DynamicBuffer<TradeCost> val2 = merchant.ReadBuffer<TradeCost>();
			DynamicBuffer<TradeOutput> val3 = merchant.ReadBuffer<TradeOutput>();
			for (int i = 0; i < val.Length; i++)
			{
				TraderEntry val4 = val[i];
				if (val[i].StockAmount == 1 && _event.ItemIndex == val4.OutputStartIndex)
				{
					PrefabGUID _outputItem = val3[i].Item;
					PrefabGUID _inputItem = val2[i].Item;
					ItemModel itemModel = items.Where((ItemModel x) => new PrefabGUID(x.InputItem) == _inputItem && new PrefabGUID(x.OutputItem) == _outputItem).FirstOrDefault();
					if (itemModel != null && itemModel.Autorefill)
					{
						val4.StockAmount = (ushort)(itemModel.StockAmount + 1);
						val[i] = val4;
					}
				}
			}
		}

		private void RenameMerchant(Entity merchant, string nameMerchant)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource logger = Plugin.Logger;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(12, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("NPC Add Name");
			}
			logger.LogDebug(val);
			if (!merchant.Has<NameableInteractable>())
			{
				merchant.Add<NameableInteractable>();
			}
			NameableInteractable componentData = merchant.Read<NameableInteractable>();
			componentData.Name = new FixedString64Bytes(nameMerchant);
			merchant.Write<NameableInteractable>(componentData);
		}

		public bool GetEntity(string nameMerchant)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			NativeArray<Entity> entitiesByComponentTypes = QueryComponents.GetEntitiesByComponentTypes<NameableInteractable, TradeCost>((EntityQueryOptions)2, false);
			Enumerator<Entity> enumerator = entitiesByComponentTypes.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				NameableInteractable val = current.Read<NameableInteractable>();
				if (((FixedString64Bytes)(ref val.Name)).Value == nameMerchant)
				{
					merchantEntity = current;
					entitiesByComponentTypes.Dispose();
					return true;
				}
			}
			entitiesByComponentTypes.Dispose();
			return false;
		}

		private bool GetIcon(string nameMerchant)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			NativeArray<Entity> entitiesByComponentTypes = QueryComponents.GetEntitiesByComponentTypes<NameableInteractable, MapIconData>((EntityQueryOptions)0, true);
			ManualLogSource logger = Plugin.Logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(12, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Encontrados ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(entitiesByComponentTypes.Length);
			}
			logger.LogInfo(val);
			Enumerator<Entity> enumerator = entitiesByComponentTypes.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				NameableInteractable val2 = current.Read<NameableInteractable>();
				if (((FixedString64Bytes)(ref val2.Name)).Value == nameMerchant + "_icon")
				{
					ManualLogSource logger2 = Plugin.Logger;
					val = new BepInExInfoLogInterpolatedStringHandler(16, 0, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Icono Encontrado");
					}
					logger2.LogInfo(val);
					icontEntity = current;
					entitiesByComponentTypes.Dispose();
					return true;
				}
			}
			entitiesByComponentTypes.Dispose();
			return false;
		}

		public bool MakeNPCDontMove(Entity user, Entity merchant)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			PrefabGUID buff_BloodQuality_T01_OLD = Prefabs.Buff_BloodQuality_T01_OLD;
			DebugEventsSystem existingSystemManaged = VWorld.Server.GetExistingSystemManaged<DebugEventsSystem>();
			ApplyBuffDebugEvent val = new ApplyBuffDebugEvent
			{
				BuffPrefabGUID = buff_BloodQuality_T01_OLD
			};
			FromCharacter val2 = new FromCharacter
			{
				User = user,
				Character = merchant
			};
			existingSystemManaged.ApplyBuff(val2, val);
			Entity entity = default(Entity);
			if (BuffUtility.TryGetBuff(Plugin.World.EntityManager, merchant, PrefabIdentifier.op_Implicit(buff_BloodQuality_T01_OLD), ref entity))
			{
				if (!entity.Has<BuffModificationFlagData>())
				{
					entity.Add<BuffModificationFlagData>();
				}
				BuffModificationFlagData componentData = entity.Read<BuffModificationFlagData>();
				componentData.ModificationTypes = 16L;
				entity.Write<BuffModificationFlagData>(componentData);
				return true;
			}
			return false;
		}

		public bool MakeNPCImmortal(Entity user, Entity merchant)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			PrefabGUID buff_Manticore_ImmaterialHomePos = Prefabs.Buff_Manticore_ImmaterialHomePos;
			DebugEventsSystem existingSystemManaged = VWorld.Server.GetExistingSystemManaged<DebugEventsSystem>();
			ApplyBuffDebugEvent val = new ApplyBuffDebugEvent
			{
				BuffPrefabGUID = buff_Manticore_ImmaterialHomePos
			};
			FromCharacter val2 = new FromCharacter
			{
				User = user,
				Character = merchant
			};
			existingSystemManaged.ApplyBuff(val2, val);
			Entity entity = default(Entity);
			if (BuffUtility.TryGetBuff(Plugin.World.EntityManager, merchant, PrefabIdentifier.op_Implicit(buff_Manticore_ImmaterialHomePos), ref entity))
			{
				entity.Add<Buff_Persists_Through_Death>();
				if (entity.Has<LifeTime>())
				{
					LifeTime componentData = entity.Read<LifeTime>();
					componentData.Duration = -1f;
					componentData.EndAction = (LifeTimeEndAction)0;
					entity.Write<LifeTime>(componentData);
				}
				if (entity.Has<RemoveBuffOnGameplayEvent>())
				{
					entity.Remove<RemoveBuffOnGameplayEvent>();
				}
				if (entity.Has<RemoveBuffOnGameplayEventEntry>())
				{
					entity.Remove<RemoveBuffOnGameplayEventEntry>();
				}
				return true;
			}
			return false;
		}

		public bool MakeNPCMortal(Entity user, Entity merchant)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			PrefabGUID buff_Manticore_ImmaterialHomePos = Prefabs.Buff_Manticore_ImmaterialHomePos;
			Entity val = default(Entity);
			if (BuffUtility.TryGetBuff(VWorld.Server.EntityManager, merchant, PrefabIdentifier.op_Implicit(buff_Manticore_ImmaterialHomePos), ref val))
			{
				DestroyUtility.Destroy(VWorld.Server.EntityManager, val, (DestroyDebugReason)13, (string)null, 0);
				return true;
			}
			return false;
		}

		public bool KillMerchant(Entity user)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (GetEntity(name))
			{
				CleanIconMerchant(user);
				config.IsEnabled = false;
				StatChangeUtility.KillOrDestroyEntity(Plugin.World.EntityManager, merchantEntity, user, user, 0.0, (StatChangeReason)0, true);
				return true;
			}
			ManualLogSource logger = Plugin.Logger;
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(28, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Entity of merchant not found");
			}
			logger.LogDebug(val);
			throw new MerchantDontExistException();
		}

		public bool CleanIconMerchant(Entity user)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val;
			if (!icontEntity.Exists() && !GetIcon(name))
			{
				ManualLogSource logger = Plugin.Logger;
				val = new BepInExInfoLogInterpolatedStringHandler(21, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Entity icon not found");
				}
				logger.LogInfo(val);
				return true;
			}
			icontEntity.Remove<MapIconData>();
			icontEntity.Remove<MapIconTargetEntity>();
			icontEntity.Remove<NameableInteractable>();
			StatChangeUtility.KillOrDestroyEntity(Plugin.World.EntityManager, icontEntity, user, user, 0.0, (StatChangeReason)0, true);
			ManualLogSource logger2 = Plugin.Logger;
			val = new BepInExInfoLogInterpolatedStringHandler(18, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Entity icon remove");
			}
			logger2.LogInfo(val);
			return true;
		}
	}
	public struct TraderItem
	{
		public PrefabGUID OutputItem { get; set; }

		public int OutputAmount { get; set; }

		public PrefabGUID InputItem { get; set; }

		public int InputAmount { get; set; }

		public int StockAmount { get; set; }

		public TraderItem(PrefabGUID outputItem, int outputAmount, PrefabGUID inputItem, int inputAmount, int stockAmount)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			OutputItem = outputItem;
			OutputAmount = outputAmount;
			InputItem = inputItem;
			InputAmount = inputAmount;
			StockAmount = stockAmount;
		}
	}
}
namespace BloodyMerchant.Commands
{
	[CommandGroup("bm config", null)]
	internal class ConfigCommand
	{
		[Command("show", null, "<NameOfMerchant>", "Show config of merchant", null, true)]
		public void ShowConfigMerchant(ChatCommandContext ctx, string merchantName)
		{
			try
			{
				if (Database.GetMerchant(merchantName, out var merchant))
				{
					ctx.Reply("Merchant '" + merchantName + "' config:");
					ctx.Reply("----------------------------------------------");
					ctx.Reply($"Immortal: '{merchant.config.Immortal}'");
					ctx.Reply($"Move: '{merchant.config.CanMove}'");
					ctx.Reply($"Autorespawn '{merchant.config.Autorepawn}' config:");
				}
			}
			catch (MerchantExistException)
			{
				throw ctx.Error("Merchant with name '" + merchantName + "' exist.");
			}
			catch (Exception ex2)
			{
				throw ctx.Error("Error: " + ex2.Message);
			}
		}

		[Command("immortal", null, "<NameOfMerchant> <true/false>", "Set config immortal of merchant", null, true)]
		public void InmortalMerchant(ChatCommandContext ctx, string merchantName, bool value)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Database.GetMerchant(merchantName, out var merchant))
				{
					merchant.config.Immortal = value;
					if (value)
					{
						merchant.MakeNPCImmortal(ctx.Event.SenderUserEntity, merchant.merchantEntity);
					}
					else
					{
						merchant.MakeNPCMortal(ctx.Event.SenderUserEntity, merchant.merchantEntity);
					}
					Database.saveDatabase();
					ctx.Reply($"Merchant '{merchantName}' immortal {value}");
					return;
				}
				throw new MerchantDontExistException();
			}
			catch (MerchantDontExistException)
			{
				throw ctx.Error("Merchant with name '" + merchantName + "' does not exist.");
			}
			catch (Exception ex2)
			{
				throw ctx.Error("Error: " + ex2.Message);
			}
		}

		[Command("move", null, "<NameOfMerchant> <true/false>", "Set config move of merchant", null, true)]
		public void MoveMerchant(ChatCommandContext ctx, string merchantName, bool value)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			try
			{
				if (Database.GetMerchant(merchantName, out var merchant))
				{
					merchant.config.CanMove = value;
					bool flag = default(bool);
					if (value)
					{
						merchant.merchantEntity.Add<MoveEntity>();
						ManualLogSource logger = Plugin.Logger;
						BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(12, 0, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("NPC Add Move");
						}
						logger.LogDebug(val);
					}
					else
					{
						merchant.merchantEntity.Remove<MoveEntity>();
						ManualLogSource logger2 = Plugin.Logger;
						BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(15, 0, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("NPC Remove Move");
						}
						logger2.LogDebug(val);
					}
					Database.saveDatabase();
					ctx.Reply($"Merchant '{merchantName}' move {value}");
					return;
				}
				throw new MerchantDontExistException();
			}
			catch (MerchantDontExistException)
			{
				throw ctx.Error("Merchant with name '" + merchantName + "' does not exist.");
			}
			catch (Exception ex2)
			{
				throw ctx.Error("Error: " + ex2.Message);
			}
		}

		[Command("enabled", null, "<NameOfMerchant> <true/false>", "Enable merchant", null, true)]
		public void EnableMerchant(ChatCommandContext ctx, string merchantName, bool value)
		{
			try
			{
				if (Database.GetMerchant(merchantName, out var merchant))
				{
					merchant.config.IsEnabled = value;
					Database.saveDatabase();
					ctx.Reply($"Merchant '{merchantName}' enabled {value}");
					return;
				}
				throw new MerchantDontExistException();
			}
			catch (MerchantDontExistException)
			{
				throw ctx.Error("Merchant with name '" + merchantName + "' does not exist.");
			}
			catch (Exception ex2)
			{
				throw ctx.Error("Error: " + ex2.Message);
			}
		}

		[Command("autorespawn", null, "<NameOfMerchant> <true/false>", "Autorespawn of merchant", null, true)]
		public void AutorespawnMerchant(ChatCommandContext ctx, string merchantName, bool value)
		{
			try
			{
				if (Database.GetMerchant(merchantName, out var merchant))
				{
					merchant.config.Autorepawn = value;
					Database.saveDatabase();
					ctx.Reply($"Merchant '{merchantName}' autorespawn {value}");
					return;
				}
				throw new MerchantDontExistException();
			}
			catch (MerchantDontExistException)
			{
				throw ctx.Error("Merchant with name '" + merchantName + "' does not exist.");
			}
			catch (Exception ex2)
			{
				throw ctx.Error("Error: " + ex2.Message);
			}
		}
	}
	[CommandGroup("bm", null)]
	internal class MerchantCommand
	{
		[Command("list", null, "", "List of merchant", null, true)]
		public void ListMerchant(ChatCommandContext ctx)
		{
			List<MerchantModel> list = Database.Merchants.ToList();
			if (list.Count == 0)
			{
				throw ctx.Error("There are no merchants created");
			}
			ctx.Reply("Merchant List");
			ctx.Reply("----------------------------");
			ctx.Reply("--");
			foreach (MerchantModel item in list)
			{
				ctx.Reply("Merchant " + item.name);
				ctx.Reply("--");
			}
			ctx.Reply("----------------------------");
		}

		[Command("create", null, "<NameOfMerchant> [PrefabGUIDOfMerchant] [Immortal] [Move] [Autorespawn]", "Create a merchant", null, true)]
		public void CreateMerchant(ChatCommandContext ctx, string merchantName, int prefabGUIDOfMerchant = -1810631919, bool immortal = false, bool canMove = true, bool autorespawn = true)
		{
			try
			{
				if (Database.ValidMerchantIds.Where((int x) => x == prefabGUIDOfMerchant).ToList().Count <= 0)
				{
					throw ctx.Error("PrefabGUIDOfMerchant not valid");
				}
				if (Database.AddMerchant(merchantName, prefabGUIDOfMerchant, immortal, canMove, autorespawn))
				{
					ctx.Reply("Merchant '" + merchantName + "' created successfully");
				}
			}
			catch (MerchantExistException)
			{
				throw ctx.Error("Merchant with name '" + merchantName + "' exist.");
			}
			catch (Exception ex2)
			{
				throw ctx.Error("Error: " + ex2.Message);
			}
		}

		[Command("remove", null, "<NameOfMerchant>", "Remove a merchant", null, true)]
		public void RemoveMerchant(ChatCommandContext ctx, string merchantName)
		{
			try
			{
				if (Database.RemoveMerchant(merchantName))
				{
					ctx.Reply("Merchant '" + merchantName + "' remove successfully");
				}
			}
			catch (MerchantDontExistException)
			{
				throw ctx.Error("Merchant with name '" + merchantName + "' does not exist.");
			}
			catch (MerchantEnableException)
			{
				throw ctx.Error("The merchant is in the world, you must kill the merchant with the command .merchant kill " + merchantName);
			}
			catch (Exception ex3)
			{
				throw ctx.Error("Error: " + ex3.Message);
			}
		}

		[Command("spawn", null, "<NameOfMerchant>", "Spawn a merchant in your location", null, true)]
		public void Spawn(ChatCommandContext ctx, string merchantName)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (Database.GetMerchant(merchantName, out var merchant))
			{
				Entity senderUserEntity = ctx.Event.SenderUserEntity;
				EntityManager entityManager = VWorld.Server.EntityManager;
				LocalToWorld componentData = ((EntityManager)(ref entityManager)).GetComponentData<LocalToWorld>(senderUserEntity);
				float3 position = ((LocalToWorld)(ref componentData)).Position;
				merchant.SpawnWithLocation(senderUserEntity, position);
				ctx.Reply("Merchant '" + merchantName + "' has spawned correctly");
				return;
			}
			throw new MerchantDontExistException();
		}

		[Command("kill", null, "<NameOfMerchant>", "Kill a merchant", null, true)]
		public void Kill(ChatCommandContext ctx, string merchantName)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Database.GetMerchant(merchantName, out var merchant))
				{
					Entity senderUserEntity = ctx.Event.SenderUserEntity;
					merchant.KillMerchant(senderUserEntity);
					ctx.Reply("Merchant '" + merchantName + "' has killed correctly");
					return;
				}
				throw new MerchantDontExistException();
			}
			catch (MerchantDontExistException)
			{
				throw ctx.Error("Merchant with name '" + merchantName + "' does not exist.");
			}
			catch (MerchantDontEnableException)
			{
				throw ctx.Error("Merchant with name '" + merchantName + "' does not exist in world.");
			}
			catch (Exception ex3)
			{
				throw ctx.Error("Error: " + ex3.Message);
			}
		}

		[Command("cleanicons", null, "", "Clean all icons.", null, true)]
		public void CleanIcons(ChatCommandContext ctx, string merchantName)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			NativeArray<Entity> entitiesByComponentTypes = QueryComponents.GetEntitiesByComponentTypes<NameableInteractable, MapIconData>((EntityQueryOptions)2, false);
			Enumerator<Entity> enumerator = entitiesByComponentTypes.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				NameableInteractable val = current.Read<NameableInteractable>();
				if (((FixedString64Bytes)(ref val.Name)).Value.Contains("_icon"))
				{
					StatChangeUtility.KillOrDestroyEntity(Plugin.World.EntityManager, current, ctx.Event.SenderUserEntity, ctx.Event.SenderUserEntity, 0.0, (StatChangeReason)0, true);
				}
			}
			entitiesByComponentTypes.Dispose();
			ctx.Reply("All icons have been deleted, if you had any active merchants in the world you should recreate them if you want them to have an icon.");
		}
	}
	[CommandGroup("bm product", null)]
	internal class ProductsCommand
	{
		[Command("list", null, "", "List product of merchant", null, true)]
		public void ListMerchant(ChatCommandContext ctx, string merchantName)
		{
			try
			{
				if (Database.GetMerchant(merchantName, out var merchant))
				{
					ctx.Reply(merchant.name + " Products List");
					ctx.Reply("----------------------------");
					ctx.Reply("--");
					foreach (ItemModel item in merchant.items)
					{
						ctx.Reply($"Currency {item.InputItem}");
						ctx.Reply($"Item {item.OutputItem}");
						ctx.Reply($"Price {item.InputAmount}");
						ctx.Reply($"Stack {item.OutputAmount}");
						ctx.Reply($"Stock {item.StockAmount}");
						ctx.Reply("--");
					}
					ctx.Reply("----------------------------");
					return;
				}
				throw new MerchantDontExistException();
			}
			catch (MerchantDontExistException)
			{
				throw ctx.Error("Merchant with name '" + merchantName + "' does not exist.");
			}
			catch (ProductExistException)
			{
				throw ctx.Error("This product configuration already exists at merchant '" + merchantName + "'");
			}
			catch (Exception ex3)
			{
				throw ctx.Error("Error: " + ex3.Message);
			}
		}

		[Command("clean", null, "<NameOfMerchant>", "Clean all products to a merchant", null, true)]
		public void CleanProducts(ChatCommandContext ctx, string merchantName)
		{
			try
			{
				if (Database.GetMerchant(merchantName, out var merchant))
				{
					merchant.Clean();
					ctx.Reply("Product successfully added to merchant '" + merchantName + "'");
					return;
				}
				throw new MerchantDontExistException();
			}
			catch (MerchantDontExistException)
			{
				throw ctx.Error("Merchant with name '" + merchantName + "' does not exist.");
			}
			catch (ProductExistException)
			{
				throw ctx.Error("This product configuration already exists at merchant '" + merchantName + "'");
			}
			catch (Exception ex3)
			{
				throw ctx.Error("Error: " + ex3.Message);
			}
		}

		[Command("add", null, "<NameOfMerchant> <ItemPrefabID> <CurrencyfabID> <Stack> <Price> <Stock> [Autorefill true/false]", "Add a product to a merchant", null, true)]
		public void CreateProduct(ChatCommandContext ctx, string merchantName, int ItemPrefabID, int CurrencyfabID, int Stack, int Price, int Stock, bool Autorefill = false)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Database.GetMerchant(merchantName, out var merchant))
				{
					if (merchant.items.Count >= 33)
					{
						throw ctx.Error("Maximum products reached. The maximum number of items you can add to a merchant is 33.");
					}
					merchant.AddProduct(ItemPrefabID, CurrencyfabID, Stack, Price, Stock, Autorefill);
					if (merchant.config.IsEnabled)
					{
						merchant.ModifyMerchant(ctx.Event.SenderUserEntity, merchant.merchantEntity);
					}
					ctx.Reply("Product successfully added to merchant '" + merchantName + "'");
					return;
				}
				throw new MerchantDontExistException();
			}
			catch (MerchantDontExistException)
			{
				throw ctx.Error("Merchant with name '" + merchantName + "' does not exist.");
			}
			catch (ProductExistException)
			{
				throw ctx.Error("This product configuration already exists at merchant '" + merchantName + "'");
			}
			catch (Exception ex3)
			{
				throw ctx.Error("Error: " + ex3.Message);
			}
		}

		[Command("remove", null, "<NameOfMerchant> <ItemPrefabID>", "Remove a product to a merchant", null, true)]
		public void RemoveProduct(ChatCommandContext ctx, string merchantName, int ItemPrefabID)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Database.GetMerchant(merchantName, out var merchant))
				{
					merchant.RemoveProduct(ItemPrefabID);
					if (merchant.config.IsEnabled)
					{
						merchant.ModifyMerchant(ctx.Event.SenderUserEntity, merchant.merchantEntity);
					}
					ctx.Reply("Merchant '" + merchantName + "''s product has been successfully removed");
					return;
				}
				throw new MerchantDontExistException();
			}
			catch (MerchantDontExistException)
			{
				throw ctx.Error("Merchant with name '" + merchantName + "' does not exist.");
			}
			catch (ProductDontExistException)
			{
				throw ctx.Error("This product does not exist at merchant '" + merchantName + "'");
			}
			catch (Exception ex3)
			{
				throw ctx.Error("Error: " + ex3.Message);
			}
		}
	}
}