Decompiled source of BloodyShop v0.9.92

BloodyShop.dll

Decompiled 6 months ago
#define DEBUG
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BloodShop_NAudio.Dmo;
using BloodShop_NAudio.FileFormats.Wav;
using BloodShop_NAudio.Utils;
using BloodShop_NAudio.Wave;
using BloodShop_UniverseLib;
using BloodShop_UniverseLib.Config;
using BloodShop_UniverseLib.Input;
using BloodShop_UniverseLib.Reflection;
using BloodShop_UniverseLib.Runtime;
using BloodShop_UniverseLib.Runtime.Il2Cpp;
using BloodShop_UniverseLib.UI;
using BloodShop_UniverseLib.UI.Models;
using BloodShop_UniverseLib.UI.ObjectPool;
using BloodShop_UniverseLib.UI.Panels;
using BloodShop_UniverseLib.UI.Widgets;
using BloodShop_UniverseLib.UI.Widgets.ScrollView;
using BloodShop_UniverseLib.Utility;
using BloodShop_VRising.GameData;
using BloodShop_VRising.GameData.Methods;
using BloodShop_VRising.GameData.Models;
using BloodShop_VRising.GameData.Models.Base;
using BloodShop_VRising.GameData.Models.Data;
using BloodShop_VRising.GameData.Models.Internals;
using BloodShop_VRising.GameData.Patch;
using BloodShop_VRising.GameData.Utils;
using Bloodstone.API;
using Bloodstone.Hooks;
using BloodyShop.AutoAnnouncer;
using BloodyShop.AutoAnnouncer.Timers;
using BloodyShop.Client;
using BloodyShop.Client.DB;
using BloodyShop.Client.Network;
using BloodyShop.Client.Patch;
using BloodyShop.Client.UI;
using BloodyShop.Client.UI.Panels.Admin;
using BloodyShop.Client.UI.Panels.User;
using BloodyShop.Client.Utils;
using BloodyShop.DB;
using BloodyShop.DB.Models;
using BloodyShop.Network.Messages;
using BloodyShop.Properties;
using BloodyShop.Server;
using BloodyShop.Server.Commands;
using BloodyShop.Server.Core;
using BloodyShop.Server.DB;
using BloodyShop.Server.DB.Model;
using BloodyShop.Server.Network;
using BloodyShop.Server.Patch;
using BloodyShop.Server.Systems;
using BloodyShop.Utils;
using HarmonyLib;
using Il2CppInterop.Common;
using Il2CppInterop.Common.Attributes;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppInterop.Runtime.Runtime;
using Il2CppSystem;
using Il2CppSystem.Collections;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Auth;
using ProjectM.Behaviours;
using ProjectM.CastleBuilding;
using ProjectM.CastleBuilding.Placement;
using ProjectM.Gameplay;
using ProjectM.Gameplay.Clan;
using ProjectM.Gameplay.Scripting;
using ProjectM.Hybrid;
using ProjectM.Network;
using ProjectM.Pathfinding;
using ProjectM.Physics;
using ProjectM.Portrait;
using ProjectM.Roofs;
using ProjectM.Scripting;
using ProjectM.Sequencer;
using ProjectM.Shared;
using ProjectM.Terrain;
using ProjectM.Tiles;
using ProjectM.UI;
using Stunlock.Core;
using Stunlock.Localization;
using Stunlock.Network;
using Stunlock.Sequencer;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Physics;
using Unity.Physics.Systems;
using Unity.Scenes;
using Unity.Transforms;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using VampireCommandFramework;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BloodyShop")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Mod to create a store in VRising")]
[assembly: AssemblyFileVersion("0.9.92.0")]
[assembly: AssemblyInformationalVersion("0.9.92")]
[assembly: AssemblyProduct("BloodyShop")]
[assembly: AssemblyTitle("BloodyShop")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.9.92.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BloodyShop
{
	public class BloodyShop
	{
		public static readonly string ConfigPath = Path.Combine(Paths.ConfigPath, "BloodyShop");

		public static void serverInitMod(Harmony _harmony)
		{
			_harmony.PatchAll(typeof(global::BloodyShop.Server.Patch.ServerEvents));
			global::BloodyShop.Server.Patch.ServerEvents.OnDeath += DropSystem.ServerEvents_OnDeath;
			global::BloodyShop.Server.Patch.ServerEvents.OnVampireDowned += DropSystem.ServerEvents_OnVampireDowned;
			ServerMod.CreateFilesConfig();
			CommandRegistry.RegisterCommandType(typeof(ShopCommands));
		}

		public static void clientInitMod(Harmony _harmony)
		{
			_harmony.PatchAll(typeof(global::BloodyShop.Client.Patch.ClientEvents));
			UIManager.Initialize();
			KeyBinds.Initialize();
			global::BloodyShop.Client.Patch.ClientEvents.OnClientConnected += ClientMod.ClientEvents_OnClientUserConnected;
			global::BloodyShop.Client.Patch.ClientEvents.OnClientDisconected += ClientMod.ClientEvents_OnClientUserDisconnected;
			KeyBinds.OnKeyPressed += KeyBindPressed.OnKeyPressedOpenPanel;
		}

		public static void onServerGameInitialized()
		{
			ServerMod.SetConfigMod();
		}

		public static void onClientGameInitialized()
		{
			NetworkMessages.RegisterMessage();
		}

		public static void serverUnloadMod()
		{
			global::BloodyShop.Server.Patch.ServerEvents.OnDeath -= DropSystem.ServerEvents_OnDeath;
		}

		public static void clientUnloadMod()
		{
			global::BloodyShop.Client.Patch.ClientEvents.OnClientConnected -= ClientMod.ClientEvents_OnClientUserConnected;
			global::BloodyShop.Client.Patch.ClientEvents.OnClientDisconected -= ClientMod.ClientEvents_OnClientUserDisconnected;
			KeyBinds.OnKeyPressed -= KeyBindPressed.OnKeyPressedOpenPanel;
		}

		public static void onServerGameDataOnInitialize()
		{
			NetworkMessages.RegisterMessage();
			ServerMod.LoadConfigToDB();
			ServerMod.LoadCurrenciesToDB();
			ServerMod.LoadUserCurrenciesPerDayToDB();
		}

		public static void onClientGameDataOnInitialize()
		{
			ClientMod.ClientEvents_OnGameDataInitialized();
		}
	}
	public static class ECSExtensions
	{
		public unsafe static void Write<T>(this Entity entity, T componentData) where T : struct
		{
			//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_0045: 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)
			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 = VWorld.Server.EntityManager;
				((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_0013: 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_001b: 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)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = VWorld.Server.EntityManager;
			void* componentDataRawRO = ((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex);
			return Marshal.PtrToStructure<T>(new IntPtr(componentDataRawRO));
		}

		public static DynamicBuffer<T> ReadBuffer<T>(this Entity entity) where T : struct
		{
			//IL_0006: 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_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_0017: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = VWorld.Server.EntityManager;
			return ((EntityManager)(ref entityManager)).GetBuffer<T>(entity);
		}

		public static void Add<T>(this Entity entity)
		{
			//IL_0013: 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_001b: 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)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = VWorld.Server.EntityManager;
			((EntityManager)(ref entityManager)).AddComponent(entity, val);
		}

		public static void Remove<T>(this Entity entity)
		{
			//IL_0013: 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_001b: 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)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = VWorld.Server.EntityManager;
			((EntityManager)(ref entityManager)).RemoveComponent(entity, val);
		}

		public static bool Has<T>(this Entity entity)
		{
			//IL_0013: 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_001b: 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)
			ComponentType val = default(ComponentType);
			((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
			EntityManager entityManager = VWorld.Server.EntityManager;
			return ((EntityManager)(ref entityManager)).HasComponent(entity, val);
		}

		public static void LogComponentTypes(this Entity entity)
		{
			//IL_0006: 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_000e: 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_0015: 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_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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = VWorld.Server.EntityManager;
			Enumerator<ComponentType> enumerator = ((EntityManager)(ref entityManager)).GetComponentTypes(entity, (Allocator)2).GetEnumerator();
			bool flag = default(bool);
			while (enumerator.MoveNext())
			{
				ComponentType current = enumerator.Current;
				ManualLogSource logger = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(0, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ComponentType>(current);
				}
				logger.LogInfo(val);
			}
			Plugin.Logger.LogInfo((object)"===");
		}

		public static void LogComponentTypes(this EntityQuery entityQuery)
		{
			//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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0040: 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_0078: Expected O, but got Unknown
			Il2CppStructArray<ComponentType> queryTypes = ((EntityQuery)(ref entityQuery)).GetQueryTypes();
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val;
			foreach (ComponentType item in (Il2CppArrayBase<ComponentType>)(object)queryTypes)
			{
				ManualLogSource logger = Plugin.Logger;
				val = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Query Component Type: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ComponentType>(item);
				}
				logger.LogInfo(val);
			}
			ManualLogSource logger2 = Plugin.Logger;
			val = new BepInExInfoLogInterpolatedStringHandler(3, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("===");
			}
			logger2.LogInfo(val);
		}

		public static string LookupName(this PrefabGUID prefabGuid)
		{
			//IL_0012: 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_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)
			PrefabCollectionSystem existingSystem = VWorld.Server.GetExistingSystem<PrefabCollectionSystem>();
			object obj;
			if (!((PrefabCollectionSystem_Base)existingSystem).PrefabGuidToNameDictionary.ContainsKey(prefabGuid))
			{
				obj = "GUID Not Found";
			}
			else
			{
				string text = ((PrefabCollectionSystem_Base)existingSystem).PrefabGuidToNameDictionary[prefabGuid];
				PrefabGUID val = prefabGuid;
				obj = text + " " + ((object)(PrefabGUID)(ref val)).ToString();
			}
			return obj.ToString();
		}
	}
	[BepInPlugin("BloodyShop", "BloodyShop", "0.9.92")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin, IRunOnInitialized
	{
		internal static Plugin Instance;

		internal static string Name = "BloodyShop";

		internal static string Guid = "BloodyShop";

		internal static string Version = "0.9.92";

		public static ManualLogSource Logger;

		private Harmony _harmony;

		public static ConfigEntry<bool> ShopEnabled;

		public static ConfigEntry<bool> AnnounceAddRemovePublic;

		public static ConfigEntry<bool> AnnounceBuyPublic;

		public static ConfigEntry<string> StoreName;

		public static ConfigEntry<bool> DropEnabled;

		public static ConfigEntry<int> DropNpcPercentage;

		public static ConfigEntry<int> IncrementPercentageDropEveryTenLevelsNpc;

		public static ConfigEntry<int> DropdNpcCurrenciesMin;

		public static ConfigEntry<int> DropNpcCurrenciesMax;

		public static ConfigEntry<int> MaxCurrenciesPerDayPerPlayerNpc;

		public static ConfigEntry<int> DropdVBloodPercentage;

		public static ConfigEntry<int> IncrementPercentageDropEveryTenLevelsVBlood;

		public static ConfigEntry<int> DropVBloodCurrenciesMin;

		public static ConfigEntry<int> DropVBloodCurrenciesMax;

		public static ConfigEntry<int> MaxCurrenciesPerDayPerPlayerVBlood;

		public static ConfigEntry<int> DropPvpPercentage;

		public static ConfigEntry<int> IncrementPercentageDropEveryTenLevelsPvp;

		public static ConfigEntry<int> DropPvpCurrenciesMin;

		public static ConfigEntry<int> DropPvpCurrenciesMax;

		public static ConfigEntry<int> MaxCurrenciesPerDayPerPlayerPvp;

		public static ConfigEntry<bool> Sounds;

		private static World _serverWorld;

		private static World _clientWorld;

		public static World Server
		{
			get
			{
				if (_serverWorld != null)
				{
					return _serverWorld;
				}
				_serverWorld = GetWorld("Server") ?? throw new Exception("There is no Server world (yet). Did you install a server mod on the client?");
				return _serverWorld;
			}
		}

		public static World Client
		{
			get
			{
				if (_clientWorld != null)
				{
					return _clientWorld;
				}
				_clientWorld = GetWorld("Client") ?? throw new Exception("There is no Client world (yet). Did you install a client mod on the server?");
				return _clientWorld;
			}
		}

		public static bool IsServer => Application.productName == "VRisingServer";

		public static bool IsClient => Application.productName == "VRisingClient";

		private static World GetWorld(string name)
		{
			Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
			while (enumerator.MoveNext())
			{
				World current = enumerator.Current;
				if (current.Name == name)
				{
					return current;
				}
			}
			return null;
		}

		public override void Load()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			Instance = this;
			Logger = ((BasePlugin)this).Log;
			_harmony = new Harmony("BloodyShop");
			GameData.OnInitialize += GameDataOnInitialize;
			GameData.OnDestroy += GameDataOnDestroy;
			if (VWorld.IsServer)
			{
				InitConfigServer();
				BloodyShop.serverInitMod(_harmony);
			}
			else
			{
				InitConfigClient();
				BloodyShop.clientInitMod(_harmony);
			}
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(21, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("BloodyShop is loaded!");
			}
			log.LogInfo(val);
		}

		public override bool Unload()
		{
			if (VWorld.IsServer)
			{
				((BasePlugin)this).Config.Clear();
				BloodyShop.serverUnloadMod();
				CommandRegistry.UnregisterAssembly();
			}
			else
			{
				BloodyShop.clientUnloadMod();
			}
			_harmony.UnpatchSelf();
			GameData.OnDestroy -= GameDataOnDestroy;
			GameData.OnInitialize -= GameDataOnInitialize;
			return true;
		}

		private static void GameDataOnInitialize(World world)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			if (VWorld.IsServer)
			{
				BloodyShop.onServerGameDataOnInitialize();
				return;
			}
			try
			{
				BloodyShop.onClientGameDataOnInitialize();
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(27, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error GameDataOnInitialize ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logger.LogError(val);
			}
		}

		private static void GameDataOnDestroy()
		{
		}

		private void InitConfigClient()
		{
			Sounds = ((BasePlugin)this).Config.Bind<bool>("Client", "enabled", true, "Enable Sounds");
		}

		private void InitConfigServer()
		{
			ShopEnabled = ((BasePlugin)this).Config.Bind<bool>("ConfigShop", "enabled", true, "Enable Shop");
			StoreName = ((BasePlugin)this).Config.Bind<string>("ConfigShop", "name", "Bloody Shop", "Store's name");
			AnnounceAddRemovePublic = ((BasePlugin)this).Config.Bind<bool>("ConfigShop", "announceAddRemovePublic", true, "Public announcement when an item is added or removed from the store");
			AnnounceBuyPublic = ((BasePlugin)this).Config.Bind<bool>("ConfigShop", "announceBuyPublic", true, "Public announcement when someone buys an item from the store");
			DropEnabled = ((BasePlugin)this).Config.Bind<bool>("DropSystem", "enabled", true, "Enable Drop System");
			DropNpcPercentage = ((BasePlugin)this).Config.Bind<int>("DropSystem", "minPercentageDropNpc", 5, "Percent chance that an NPC will drop the type of currency from the shop");
			IncrementPercentageDropEveryTenLevelsNpc = ((BasePlugin)this).Config.Bind<int>("DropSystem", "IncrementPercentageDropEveryTenLevelsNpc", 5, "Percentage increase for every rank of 10 levels of the NPC");
			DropdNpcCurrenciesMin = ((BasePlugin)this).Config.Bind<int>("DropSystem", "DropdNpcCurrenciesMin", 1, "Minimum currency an NPC can drop");
			DropNpcCurrenciesMax = ((BasePlugin)this).Config.Bind<int>("DropSystem", "DropNpcCurrenciesMax", 5, "Maximum currency an NPC can drop");
			MaxCurrenciesPerDayPerPlayerNpc = ((BasePlugin)this).Config.Bind<int>("DropSystem", "MaxCurrenciesPerDayPerPlayerNpc", 5, "Maximum number of currency that a user can get per day by NPC death");
			DropdVBloodPercentage = ((BasePlugin)this).Config.Bind<int>("DropSystem", "minPercentageDropVBlood", 20, "Percent chance that an VBlood will drop the type of currency from the shop");
			IncrementPercentageDropEveryTenLevelsVBlood = ((BasePlugin)this).Config.Bind<int>("DropSystem", "IncrementPercentageDropEveryTenLevelsVBlood", 5, "Percentage increase for every rank of 10 levels of the VBlood");
			DropVBloodCurrenciesMin = ((BasePlugin)this).Config.Bind<int>("DropSystem", "DropVBloodCurrenciesMin", 10, "Minimum currency an VBlood can drop");
			DropVBloodCurrenciesMax = ((BasePlugin)this).Config.Bind<int>("DropSystem", "DropVBloodCurrenciesMax", 20, "Maximum currency an VBlood can drop");
			MaxCurrenciesPerDayPerPlayerVBlood = ((BasePlugin)this).Config.Bind<int>("DropSystem", "MaxCurrenciesPerDayPerPlayerVBlood", 20, "Maximum number of currency that a user can get per day by VBlood death");
			DropPvpPercentage = ((BasePlugin)this).Config.Bind<int>("DropSystem", "minPercentageDropPvp", 100, "Percent chance that victory in a PVP duel will drop the type of currency in the store");
			IncrementPercentageDropEveryTenLevelsPvp = ((BasePlugin)this).Config.Bind<int>("DropSystem", "IncrementPercentageDropEveryTenLevelsPvp", 5, "Percentage increase for every rank of 10 levels of the Player killed in pvp duel");
			DropPvpCurrenciesMin = ((BasePlugin)this).Config.Bind<int>("DropSystem", "DropPvpCurrenciesMin", 15, "Minimum currency can drop victory in PVP");
			DropPvpCurrenciesMax = ((BasePlugin)this).Config.Bind<int>("DropSystem", "DropPvpCurrenciesMax", 20, "Maximum currency can drop victory in PVP");
			MaxCurrenciesPerDayPerPlayerPvp = ((BasePlugin)this).Config.Bind<int>("DropSystem", "MaxCurrenciesPerDayPerPlayerPvp", 20, "Maximum number of currency that a user can get per day by victory in PVP");
		}

		public void OnGameInitialized()
		{
			if (VWorld.IsServer)
			{
				BloodyShop.onServerGameInitialized();
			}
			else
			{
				BloodyShop.onClientGameInitialized();
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BloodyShop";

		public const string PLUGIN_NAME = "BloodyShop";

		public const string PLUGIN_VERSION = "0.9.92";
	}
}
namespace BloodyShop.Utils
{
	internal class FontColorChat
	{
		public static string Color(string hexColor, string text)
		{
			return $"<color={hexColor}>{text}</color>";
		}

		public static string Red(string text)
		{
			return Color("#E90000", text);
		}

		public static string Blue(string text)
		{
			return Color("#0000ff", text);
		}

		public static string Green(string text)
		{
			return Color("#7FE030", text);
		}

		public static string Yellow(string text)
		{
			return Color("#FBC01E", text);
		}

		public static string White(string text)
		{
			return Color("#FFFFFF", text);
		}
	}
	public static class RectTransformExtensions
	{
		public static Vector2 GetSize(this RectTransform source)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = source.rect;
			return ((Rect)(ref rect)).size;
		}

		public static float GetWidth(this RectTransform source)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = source.rect;
			return ((Rect)(ref rect)).size.x;
		}

		public static float GetHeight(this RectTransform source)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = source.rect;
			return ((Rect)(ref rect)).size.y;
		}

		public static void SetSize(this RectTransform source, RectTransform toCopy)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			source.SetSize(toCopy.GetSize());
		}

		public static void SetSize(this RectTransform source, Vector2 newSize)
		{
			//IL_0002: 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)
			source.SetSize(newSize.x, newSize.y);
		}

		public static void SetSize(this RectTransform source, float width, float height)
		{
			source.SetSizeWithCurrentAnchors((Axis)0, width);
			source.SetSizeWithCurrentAnchors((Axis)1, height);
		}

		public static void SetWidth(this RectTransform source, float width)
		{
			source.SetSizeWithCurrentAnchors((Axis)0, width);
		}

		public static void SetHeight(this RectTransform source, float height)
		{
			source.SetSizeWithCurrentAnchors((Axis)1, height);
		}
	}
}
namespace BloodyShop.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("BloodyShop.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static UnmanagedMemoryStream cash_register_x => ResourceManager.GetStream("cash_register_x", resourceCulture);

		internal static byte[] close
		{
			get
			{
				object @object = ResourceManager.GetObject("close", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static UnmanagedMemoryStream coin => ResourceManager.GetStream("coin", resourceCulture);

		internal static byte[] config
		{
			get
			{
				object @object = ResourceManager.GetObject("config", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] elixir
		{
			get
			{
				object @object = ResourceManager.GetObject("elixir", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static UnmanagedMemoryStream floop2_x => ResourceManager.GetStream("floop2_x", resourceCulture);

		internal static byte[] open
		{
			get
			{
				object @object = ResourceManager.GetObject("open", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] shop_close
		{
			get
			{
				object @object = ResourceManager.GetObject("shop_close", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] shop_open
		{
			get
			{
				object @object = ResourceManager.GetObject("shop_open", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace BloodyShop.Server
{
	public class ServerMod
	{
		public static ConfigEntry<bool> ShopEnabled;

		public static ConfigEntry<int> CurrencyGUID;

		public static readonly string ConfigPath = Path.Combine(Paths.ConfigPath, "BloodyShop");

		public static readonly string DropSystemPath = Path.Combine(ConfigPath, "DropSystem");

		public static string ProductListFile = Path.Combine(ConfigPath, "products_list.json");

		public static string CurrencyListFile = Path.Combine(ConfigPath, "currency_list.json");

		public static string UserCurrenciesPerDayFile = Path.Combine(ConfigPath, "user_currencies_per_day.json");

		public static void CreateFilesConfig()
		{
			if (!Directory.Exists(ConfigPath))
			{
				Directory.CreateDirectory(ConfigPath);
			}
			if (!File.Exists(ProductListFile))
			{
				File.WriteAllText(ProductListFile, "[]");
			}
			if (!File.Exists(CurrencyListFile))
			{
				File.WriteAllText(CurrencyListFile, "[{\"id\":1,\"name\":\"Silver Coin\",\"guid\":-949672483}]");
			}
			if (!Directory.Exists(DropSystemPath))
			{
				Directory.CreateDirectory(DropSystemPath);
			}
			if (!File.Exists(UserCurrenciesPerDayFile))
			{
				File.WriteAllText(UserCurrenciesPerDayFile, "");
			}
		}

		public static void LoadConfigToDB()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if (!LoadDataFromFiles.loadProductList())
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(25, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error loading ProductList");
				}
				logger.LogError(val);
			}
		}

		public static void LoadCurrenciesToDB()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if (!LoadDataFromFiles.loadCurrencies())
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(28, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error loading CurrenciesList");
				}
				logger.LogError(val);
			}
		}

		public static void LoadUserCurrenciesPerDayToDB()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if (!LoadDataFromFiles.loadUserCurrenciesPerDay())
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(38, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error loading loadUserCurrenciesPerDay");
				}
				logger.LogError(val);
			}
		}

		public static void SetConfigMod()
		{
			ConfigDB.ShopEnabled = Plugin.ShopEnabled.Value;
			ConfigDB.AnnounceAddRemovePublic = Plugin.AnnounceAddRemovePublic.Value;
			ConfigDB.AnnounceBuyPublic = Plugin.AnnounceBuyPublic.Value;
			string value = Plugin.StoreName.Value;
			if (value != string.Empty)
			{
				ConfigDB.StoreName = value;
			}
			ConfigDB.DropEnabled = Plugin.DropEnabled.Value;
			ConfigDB.DropNpcPercentage = Plugin.DropNpcPercentage.Value;
			ConfigDB.IncrementPercentageDropEveryTenLevelsNpc = Plugin.IncrementPercentageDropEveryTenLevelsNpc.Value;
			ConfigDB.DropdNpcCurrenciesMin = Plugin.DropdNpcCurrenciesMin.Value;
			ConfigDB.DropNpcCurrenciesMax = Plugin.DropNpcCurrenciesMax.Value;
			ConfigDB.MaxCurrenciesPerDayPerPlayerNpc = Plugin.MaxCurrenciesPerDayPerPlayerNpc.Value;
			ConfigDB.DropdVBloodPercentage = Plugin.DropdVBloodPercentage.Value;
			ConfigDB.IncrementPercentageDropEveryTenLevelsVBlood = Plugin.IncrementPercentageDropEveryTenLevelsVBlood.Value;
			ConfigDB.DropVBloodCurrenciesMin = Plugin.DropVBloodCurrenciesMin.Value;
			ConfigDB.DropVBloodCurrenciesMax = Plugin.DropVBloodCurrenciesMax.Value;
			ConfigDB.MaxCurrenciesPerDayPerPlayerVBlood = Plugin.MaxCurrenciesPerDayPerPlayerVBlood.Value;
			ConfigDB.DropPvpPercentage = Plugin.DropPvpPercentage.Value;
			ConfigDB.IncrementPercentageDropEveryTenLevelsPvp = Plugin.IncrementPercentageDropEveryTenLevelsPvp.Value;
			ConfigDB.DropPvpCurrenciesMin = Plugin.DropPvpCurrenciesMin.Value;
			ConfigDB.DropPvpCurrenciesMax = Plugin.DropPvpCurrenciesMax.Value;
			ConfigDB.MaxCurrenciesPerDayPerPlayerPvp = Plugin.MaxCurrenciesPerDayPerPlayerPvp.Value;
		}
	}
}
namespace BloodyShop.Server.Systems
{
	public class DropSystem
	{
		private static EntityManager em = VWorld.Server.EntityManager;

		private static Random rnd = new Random();

		private static PrefabGUID vBloodType = new PrefabGUID(1557174542);

		public static void ServerEvents_OnDeath(DeathEventListenerSystem sender, NativeArray<DeathEvent> deathEvents)
		{
			//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_0021: 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_0029: 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_0052: 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_0068: 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_006e: 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 (!ConfigDB.DropEnabled)
			{
				return;
			}
			Enumerator<DeathEvent> enumerator = deathEvents.GetEnumerator();
			while (enumerator.MoveNext())
			{
				DeathEvent current = enumerator.Current;
				if (((EntityManager)(ref em)).HasComponent<PlayerCharacter>(current.Killer) && ((EntityManager)(ref em)).HasComponent<Movement>(current.Died) && ((EntityManager)(ref em)).HasComponent<UnitLevel>(current.Died))
				{
					pveReward(current.Killer, current.Died);
				}
			}
		}

		public static void ServerEvents_OnVampireDowned(VampireDownedServerEventSystem sender, NativeArray<Entity> vampireDownedEntitys)
		{
			//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_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_0026: 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_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_0047: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0087: 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)
			if (!ConfigDB.DropEnabled)
			{
				return;
			}
			Enumerator<Entity> enumerator = vampireDownedEntitys.GetEnumerator();
			Entity val = default(Entity);
			Entity val2 = default(Entity);
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				VampireDownedServerEventSystem.TryFindRootOwner(current, 1, em, ref val);
				Entity source = ((EntityManager)(ref em)).GetComponentData<VampireDownedBuff>(current).Source;
				VampireDownedServerEventSystem.TryFindRootOwner(source, 1, em, ref val2);
				if (((EntityManager)(ref em)).HasComponent<PlayerCharacter>(val2) && ((EntityManager)(ref em)).HasComponent<PlayerCharacter>(val) && !((Entity)(ref val2)).Equals(val))
				{
					pvpReward(val2, val);
				}
			}
		}

		private static void pveReward(Entity killer, Entity died)
		{
			//IL_0006: 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_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_0028: 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_003a: 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_0040: 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_005e: 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)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if (!((EntityManager)(ref em)).HasComponent<Minion>(died))
			{
				PlayerCharacter componentData = ((EntityManager)(ref em)).GetComponentData<PlayerCharacter>(killer);
				UserModel userModelKiller = GameData.Users.FromEntity(componentData.UserEntity);
				UnitLevel componentData2 = ((EntityManager)(ref em)).GetComponentData<UnitLevel>(died);
				int level = componentData2.Level;
				bool flag;
				if (((EntityManager)(ref em)).HasComponent<BloodConsumeSource>(died))
				{
					BloodConsumeSource componentData3 = ((EntityManager)(ref em)).GetComponentData<BloodConsumeSource>(died);
					flag = ((PrefabGUID)(ref componentData3.UnitBloodType)).Equals(vBloodType);
				}
				else
				{
					flag = false;
				}
				if (flag)
				{
					rewardForVBlood(userModelKiller, level);
				}
				else
				{
					rewardForNPC(userModelKiller, level);
				}
			}
		}

		private static void pvpReward(Entity killer, Entity died)
		{
			//IL_0006: 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_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_0028: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			if (((EntityManager)(ref em)).HasComponent<Minion>(died))
			{
				return;
			}
			PlayerCharacter componentData = ((EntityManager)(ref em)).GetComponentData<PlayerCharacter>(killer);
			UserModel userModel = GameData.Users.FromEntity(componentData.UserEntity);
			List<CurrencyModel> list = (from currency in ShareDB.getCurrencyList()
				where currency.drop
				select currency).ToList();
			Random random = new Random();
			int index = random.Next(list.Count);
			PrefabGUID itemGuid = default(PrefabGUID);
			((PrefabGUID)(ref itemGuid))..ctor(list[index].guid);
			PlayerCharacter componentData2 = ((EntityManager)(ref em)).GetComponentData<PlayerCharacter>(died);
			UserModel userModel2 = GameData.Users.FromEntity(componentData.UserEntity);
			float level = userModel2.Character.Equipment.Level;
			int percentage = calculateDropPercentage((int)level, ConfigDB.DropPvpPercentage, ConfigDB.IncrementPercentageDropEveryTenLevelsPvp);
			if (!probabilityOeneratingReward(percentage))
			{
				return;
			}
			int num = rnd.Next(ConfigDB.DropPvpCurrenciesMin, ConfigDB.DropPvpCurrenciesMax);
			if (ConfigDB.searchUserCurrencyPerDay(userModel.CharacterName, out var userCurrenciesPerDayModel))
			{
				int num2 = userCurrenciesPerDayModel.AmountPvp + num;
				if (num2 <= ConfigDB.MaxCurrenciesPerDayPerPlayerPvp)
				{
					userCurrenciesPerDayModel.AmountPvp = num2;
					userModel.DropItemNearby(itemGuid, num);
					ConfigDB.addUserCurrenciesPerDayToList(userCurrenciesPerDayModel);
					SaveDataToFiles.saveUsersCurrenciesPerDay();
				}
				else if (userCurrenciesPerDayModel.AmountNpc < ConfigDB.MaxCurrenciesPerDayPerPlayerPvp)
				{
					num = ConfigDB.MaxCurrenciesPerDayPerPlayerPvp - userCurrenciesPerDayModel.AmountPvp;
					userCurrenciesPerDayModel.AmountPvp += num;
					userModel.DropItemNearby(itemGuid, num);
					ConfigDB.addUserCurrenciesPerDayToList(userCurrenciesPerDayModel);
					SaveDataToFiles.saveUsersCurrenciesPerDay();
				}
			}
		}

		private static void rewardForNPC(UserModel userModelKiller, int diedLevel)
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			List<CurrencyModel> list = (from currency in ShareDB.getCurrencyList()
				where currency.drop
				select currency).ToList();
			Random random = new Random();
			int index = random.Next(list.Count);
			PrefabGUID itemGuid = default(PrefabGUID);
			((PrefabGUID)(ref itemGuid))..ctor(list[index].guid);
			int percentage = calculateDropPercentage(diedLevel, ConfigDB.DropNpcPercentage, ConfigDB.IncrementPercentageDropEveryTenLevelsNpc);
			if (!probabilityOeneratingReward(percentage))
			{
				return;
			}
			int num = rnd.Next(ConfigDB.DropdNpcCurrenciesMin, ConfigDB.DropNpcCurrenciesMax);
			if (ConfigDB.searchUserCurrencyPerDay(userModelKiller.CharacterName, out var userCurrenciesPerDayModel))
			{
				int num2 = userCurrenciesPerDayModel.AmountNpc + num;
				if (num2 <= ConfigDB.MaxCurrenciesPerDayPerPlayerNpc)
				{
					userCurrenciesPerDayModel.AmountNpc = num2;
					userModelKiller.DropItemNearby(itemGuid, num);
					ConfigDB.addUserCurrenciesPerDayToList(userCurrenciesPerDayModel);
					SaveDataToFiles.saveUsersCurrenciesPerDay();
				}
				else if (userCurrenciesPerDayModel.AmountNpc < ConfigDB.MaxCurrenciesPerDayPerPlayerNpc)
				{
					num = ConfigDB.MaxCurrenciesPerDayPerPlayerNpc - userCurrenciesPerDayModel.AmountNpc;
					userCurrenciesPerDayModel.AmountNpc += num;
					userModelKiller.DropItemNearby(itemGuid, num);
					ConfigDB.addUserCurrenciesPerDayToList(userCurrenciesPerDayModel);
					SaveDataToFiles.saveUsersCurrenciesPerDay();
				}
			}
		}

		private static void rewardForVBlood(UserModel userModelKiller, int diedLevel)
		{
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			List<CurrencyModel> list = (from currency in ShareDB.getCurrencyList()
				where currency.drop
				select currency).ToList();
			Random random = new Random();
			int index = random.Next(list.Count);
			PrefabGUID itemGuid = default(PrefabGUID);
			((PrefabGUID)(ref itemGuid))..ctor(list[index].guid);
			int percentage = calculateDropPercentage(diedLevel, ConfigDB.DropdVBloodPercentage, ConfigDB.IncrementPercentageDropEveryTenLevelsVBlood);
			if (!probabilityOeneratingReward(percentage))
			{
				return;
			}
			int num = rnd.Next(ConfigDB.DropVBloodCurrenciesMin, ConfigDB.DropVBloodCurrenciesMax);
			if (ConfigDB.searchUserCurrencyPerDay(userModelKiller.CharacterName, out var userCurrenciesPerDayModel))
			{
				int num2 = userCurrenciesPerDayModel.AmountVBlood + num;
				if (num2 <= ConfigDB.MaxCurrenciesPerDayPerPlayerVBlood)
				{
					userCurrenciesPerDayModel.AmountVBlood = num2;
					userModelKiller.DropItemNearby(itemGuid, num);
					ConfigDB.addUserCurrenciesPerDayToList(userCurrenciesPerDayModel);
					SaveDataToFiles.saveUsersCurrenciesPerDay();
				}
				else if (userCurrenciesPerDayModel.AmountVBlood < ConfigDB.MaxCurrenciesPerDayPerPlayerVBlood)
				{
					num = ConfigDB.MaxCurrenciesPerDayPerPlayerVBlood - userCurrenciesPerDayModel.AmountVBlood;
					userCurrenciesPerDayModel.AmountVBlood += num;
					userModelKiller.DropItemNearby(itemGuid, num);
					ConfigDB.addUserCurrenciesPerDayToList(userCurrenciesPerDayModel);
					SaveDataToFiles.saveUsersCurrenciesPerDay();
				}
			}
		}

		private static int calculateDropPercentage(int level, int initialPercent, int incremental)
		{
			decimal d = level / 10;
			decimal num = Math.Ceiling(d);
			return decimal.ToInt32(num * (decimal)incremental) + initialPercent;
		}

		private static bool probabilityOeneratingReward(int percentage)
		{
			int num = rnd.Next(1, 100);
			if (num <= percentage)
			{
				return true;
			}
			return false;
		}
	}
	internal class UserUI
	{
		private static Dictionary<string, User> _users = new Dictionary<string, User>();

		public static void RegisterUserWithUI(User user)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			User? val = null;
			_users.TryAdd(((object)(FixedString64)(ref user.CharacterName)).ToString(), user);
		}

		public static Dictionary<string, User> GetUsersWithUI()
		{
			return _users;
		}
	}
}
namespace BloodyShop.Server.Patch
{
	public delegate void DeathEventHandler(DeathEventListenerSystem sender, NativeArray<DeathEvent> deathEvents);
	public delegate void VampireDownedHandler(VampireDownedServerEventSystem sender, NativeArray<Entity> deathEvents);
	[HarmonyPatch]
	public class ServerEvents
	{
		public static event DeathEventHandler OnDeath;

		public static event VampireDownedHandler OnVampireDowned;

		[HarmonyPatch(typeof(DeathEventListenerSystem), "OnUpdate")]
		[HarmonyPostfix]
		private static void DeathEventListenerSystemPatch_Postfix(DeathEventListenerSystem __instance)
		{
			//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_002d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				EntityQuery deathEventQuery = __instance._DeathEventQuery;
				NativeArray<DeathEvent> deathEvents = ((EntityQuery)(ref deathEventQuery)).ToComponentDataArray<DeathEvent>((Allocator)2);
				if (deathEvents.Length > 0)
				{
					ServerEvents.OnDeath?.Invoke(__instance, deathEvents);
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)ex);
			}
		}

		[HarmonyPatch(typeof(VampireDownedServerEventSystem), "OnUpdate")]
		[HarmonyPostfix]
		public static void VampireDownedServerEventSystem_Postfix(VampireDownedServerEventSystem __instance)
		{
			//IL_0002: 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_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)
			//IL_001c: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			_ = __instance.__OnUpdate_LambdaJob0_entityQuery;
			if (0 == 0)
			{
				EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
				EntityQuery _OnUpdate_LambdaJob0_entityQuery = __instance.__OnUpdate_LambdaJob0_entityQuery;
				NativeArray<Entity> deathEvents = ((EntityQuery)(ref _OnUpdate_LambdaJob0_entityQuery)).ToEntityArray((Allocator)2);
				if (deathEvents.Length > 0)
				{
					ServerEvents.OnVampireDowned?.Invoke(__instance, deathEvents);
				}
			}
		}
	}
}
namespace BloodyShop.Server.DB
{
	public class ConfigDB
	{
		public static List<(string name, DateTime date, UserCurrenciesPerDayModel model)> _normalizedUsersCurrenciesPerDay = new List<(string, DateTime, UserCurrenciesPerDayModel)>();

		public static bool ShopEnabled { get; set; } = true;


		public static bool AnnounceAddRemovePublic { get; set; } = true;


		public static bool AnnounceBuyPublic { get; set; } = true;


		public static string StoreName { get; set; } = "Bloody Shop";


		public static bool DropEnabled { get; set; } = true;


		public static int DropNpcPercentage { get; set; } = 0;


		public static int IncrementPercentageDropEveryTenLevelsNpc { get; set; } = 0;


		public static int DropdNpcCurrenciesMin { get; set; } = 0;


		public static int DropNpcCurrenciesMax { get; set; } = 0;


		public static int MaxCurrenciesPerDayPerPlayerNpc { get; set; } = 0;


		public static int DropdVBloodPercentage { get; set; } = 0;


		public static int IncrementPercentageDropEveryTenLevelsVBlood { get; set; } = 0;


		public static int DropVBloodCurrenciesMin { get; set; } = 0;


		public static int DropVBloodCurrenciesMax { get; set; } = 0;


		public static int MaxCurrenciesPerDayPerPlayerVBlood { get; set; } = 0;


		public static int DropPvpPercentage { get; set; } = 0;


		public static int IncrementPercentageDropEveryTenLevelsPvp { get; set; } = 0;


		public static int DropPvpCurrenciesMin { get; set; } = 0;


		public static int DropPvpCurrenciesMax { get; set; } = 0;


		public static int MaxCurrenciesPerDayPerPlayerPvp { get; set; } = 0;


		public static List<UserCurrenciesPerDayModel> UsersCurrenciesPerDay { get; set; } = new List<UserCurrenciesPerDayModel>();


		public static bool setUsersCurrenciesPerDay(List<UserCurrenciesPerDayModel> listUsersCurrenciesPerDay)
		{
			UsersCurrenciesPerDay = new List<UserCurrenciesPerDayModel>();
			foreach (UserCurrenciesPerDayModel item in listUsersCurrenciesPerDay)
			{
				DateTime dateTime = DateTime.Parse(item.date);
				if (!(dateTime != DateTime.Today))
				{
					_normalizedUsersCurrenciesPerDay.Add((item.CharacterName, dateTime, item));
					UsersCurrenciesPerDay.Add(item);
				}
			}
			return true;
		}

		public static void addUserCurrenciesPerDayToList(UserCurrenciesPerDayModel userCurrenciesPerDay)
		{
			foreach (var (text, item, userCurrenciesPerDayModel) in _normalizedUsersCurrenciesPerDay)
			{
				if (text == userCurrenciesPerDay.CharacterName)
				{
					UsersCurrenciesPerDay.Remove(userCurrenciesPerDayModel);
					_normalizedUsersCurrenciesPerDay.Remove((text, item, userCurrenciesPerDayModel));
					UsersCurrenciesPerDay.Add(userCurrenciesPerDay);
					_normalizedUsersCurrenciesPerDay.Add((userCurrenciesPerDay.CharacterName, DateTime.Parse(userCurrenciesPerDay.date), userCurrenciesPerDay));
					break;
				}
			}
		}

		public static bool searchUserCurrencyPerDay(string characterName, out UserCurrenciesPerDayModel userCurrenciesPerDayModel)
		{
			userCurrenciesPerDayModel = null;
			if (characterName == "")
			{
				return false;
			}
			DateTime today = DateTime.Today;
			string date = $"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day}";
			foreach (var (text, dateTime, userCurrenciesPerDayModel2) in _normalizedUsersCurrenciesPerDay)
			{
				if (text == characterName)
				{
					if (today == dateTime)
					{
						userCurrenciesPerDayModel = userCurrenciesPerDayModel2;
						break;
					}
					UsersCurrenciesPerDay.Remove(userCurrenciesPerDayModel2);
					_normalizedUsersCurrenciesPerDay.Remove((text, dateTime, userCurrenciesPerDayModel2));
					userCurrenciesPerDayModel = new UserCurrenciesPerDayModel
					{
						CharacterName = userCurrenciesPerDayModel2.CharacterName,
						date = date
					};
					UsersCurrenciesPerDay.Add(userCurrenciesPerDayModel2);
					_normalizedUsersCurrenciesPerDay.Add((characterName, today, userCurrenciesPerDayModel));
					break;
				}
			}
			if (userCurrenciesPerDayModel == null)
			{
				userCurrenciesPerDayModel = new UserCurrenciesPerDayModel
				{
					CharacterName = characterName,
					date = date
				};
				UsersCurrenciesPerDay.Add(userCurrenciesPerDayModel);
				_normalizedUsersCurrenciesPerDay.Add((characterName, today, userCurrenciesPerDayModel));
				return true;
			}
			return true;
		}
	}
	internal class LoadDataFromFiles
	{
		public static bool loadProductList()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			try
			{
				string json = File.ReadAllText(ServerMod.ProductListFile);
				List<ItemShopModel> productList = JsonSerializer.Deserialize<List<ItemShopModel>>(json);
				return ItemsDB.setProductList(productList);
			}
			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 loadCurrencies()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			try
			{
				string json = File.ReadAllText(ServerMod.CurrencyListFile);
				List<CurrencyModel> currencyList = JsonSerializer.Deserialize<List<CurrencyModel>>(json);
				return ShareDB.setCurrencyList(currencyList);
			}
			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 loadUserCurrenciesPerDay()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			try
			{
				string json = File.ReadAllText(ServerMod.UserCurrenciesPerDayFile);
				List<UserCurrenciesPerDayModel> usersCurrenciesPerDay = JsonSerializer.Deserialize<List<UserCurrenciesPerDayModel>>(json);
				return ConfigDB.setUsersCurrenciesPerDay(usersCurrenciesPerDay);
			}
			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;
			}
		}
	}
	internal class SaveDataToFiles
	{
		public static bool saveProductList()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			try
			{
				List<ItemShopModel> productListForSaveJSON = ItemsDB.getProductListForSaveJSON();
				string contents = JsonSerializer.Serialize(productListForSaveJSON);
				File.WriteAllText(ServerMod.ProductListFile, contents);
				return true;
			}
			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 saveCurrenciesList()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			try
			{
				List<CurrencyModel> currencyList = ShareDB.getCurrencyList();
				string contents = JsonSerializer.Serialize(currencyList);
				File.WriteAllText(ServerMod.CurrencyListFile, contents);
				return true;
			}
			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 saveUsersCurrenciesPerDay()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			try
			{
				List<UserCurrenciesPerDayModel> usersCurrenciesPerDay = ConfigDB.UsersCurrenciesPerDay;
				string contents = JsonSerializer.Serialize(usersCurrenciesPerDay);
				File.WriteAllText(ServerMod.UserCurrenciesPerDayFile, contents);
				return true;
			}
			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;
			}
		}
	}
}
namespace BloodyShop.Server.DB.Model
{
	public class UserCurrenciesPerDayModel
	{
		public string CharacterName { get; set; }

		public string date { get; set; }

		public int AmountNpc { get; set; } = 0;


		public int AmountVBlood { get; set; } = 0;


		public int AmountPvp { get; set; } = 0;

	}
}
namespace BloodyShop.Server.Core
{
	internal class BuffSystem
	{
		public const int NO_DURATION = 0;

		public const int DEFAULT_DURATION = -1;

		public const int RANDOM_POWER = -1;

		public static bool BuffPlayer(Entity character, Entity user, PrefabGUID buff, int duration = -1, bool persistsThroughDeath = false)
		{
			//IL_0001: 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_001d: 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_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_0030: 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_0038: 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_003e: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_0094: 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_00ba: 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)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			ClearExtraBuffs(character);
			DebugEventsSystem existingSystem = VWorld.Server.GetExistingSystem<DebugEventsSystem>();
			ApplyBuffDebugEvent val = default(ApplyBuffDebugEvent);
			val.BuffPrefabGUID = buff;
			ApplyBuffDebugEvent val2 = val;
			FromCharacter val3 = default(FromCharacter);
			val3.User = user;
			val3.Character = character;
			FromCharacter val4 = val3;
			Entity entity = default(Entity);
			if (!BuffUtility.TryGetBuff(VWorld.Server.EntityManager, character, buff, ref entity))
			{
				existingSystem.ApplyBuff(val4, val2);
				if (BuffUtility.TryGetBuff(VWorld.Server.EntityManager, character, buff, ref entity))
				{
					if (entity.Has<CreateGameplayEventsOnSpawn>())
					{
						entity.Remove<CreateGameplayEventsOnSpawn>();
					}
					if (entity.Has<GameplayEventListeners>())
					{
						entity.Remove<GameplayEventListeners>();
					}
					if (persistsThroughDeath)
					{
						entity.Add<Buff_Persists_Through_Death>();
						if (entity.Has<RemoveBuffOnGameplayEvent>())
						{
							entity.Remove<RemoveBuffOnGameplayEvent>();
						}
						if (entity.Has<RemoveBuffOnGameplayEventEntry>())
						{
							entity.Remove<RemoveBuffOnGameplayEventEntry>();
						}
					}
					if (duration > 0 && duration != -1)
					{
						if (entity.Has<LifeTime>())
						{
							LifeTime componentData = entity.Read<LifeTime>();
							componentData.Duration = duration;
							entity.Write<LifeTime>(componentData);
						}
					}
					else if (duration == 0)
					{
						if (entity.Has<LifeTime>())
						{
							LifeTime componentData2 = entity.Read<LifeTime>();
							componentData2.Duration = -1f;
							componentData2.EndAction = (LifeTimeEndAction)0;
							entity.Write<LifeTime>(componentData2);
						}
						if (entity.Has<RemoveBuffOnGameplayEvent>())
						{
							entity.Remove<RemoveBuffOnGameplayEvent>();
						}
						if (entity.Has<RemoveBuffOnGameplayEventEntry>())
						{
							entity.Remove<RemoveBuffOnGameplayEventEntry>();
						}
					}
					return true;
				}
				return false;
			}
			return false;
		}

		public static void ClearExtraBuffs(Entity player)
		{
			//IL_0006: 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_000f: 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_0015: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = VWorld.Server.EntityManager;
			DynamicBuffer<BuffBuffer> buffer = ((EntityManager)(ref entityManager)).GetBuffer<BuffBuffer>(player);
			List<string> list = new List<string> { "BloodBuff", "SetBonus", "EquipBuff", "Combat", "VBlood_Ability_Replace", "Shapeshift", "Interact", "AB_Consumable" };
			Enumerator<BuffBuffer> enumerator = buffer.GetEnumerator();
			while (enumerator.MoveNext())
			{
				BuffBuffer current = enumerator.Current;
				bool flag = true;
				foreach (string item in list)
				{
					if (current.PrefabGuid.LookupName().Contains(item))
					{
						flag = false;
						break;
					}
				}
				if (flag)
				{
					DestroyUtility.Destroy(VWorld.Server.EntityManager, current.Entity, (DestroyDebugReason)13, (string)null, 0);
				}
			}
			Equipment val = player.Read<Equipment>();
			EquipmentType val2 = default(EquipmentType);
			if (!((Equipment)(ref val)).IsEquipped(new PrefabGUID(1063517722), ref val2) && BuffUtility.HasBuff(VWorld.Server.EntityManager, player, new PrefabGUID(476186894)))
			{
				UnbuffCharacter(player, new PrefabGUID(476186894));
			}
		}

		public static void UnbuffCharacter(Entity Character, PrefabGUID buffGUID)
		{
			//IL_0006: 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_000c: 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)
			Entity val = default(Entity);
			if (BuffUtility.TryGetBuff(VWorld.Server.EntityManager, Character, buffGUID, ref val))
			{
				DestroyUtility.Destroy(VWorld.Server.EntityManager, val, (DestroyDebugReason)13, (string)null, 0);
			}
		}
	}
	public class InventorySystem
	{
		public static bool searchPrefabsInInventory(string characterName, PrefabGUID prefabCurrencyGUID, out int total)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//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_001f: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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)
			total = 0;
			try
			{
				UserModel userByCharacterName = GameData.Users.GetUserByCharacterName(characterName);
				Entity entity = userByCharacterName.Character.Entity;
				NativeArray<InventoryBuffer> val = default(NativeArray<InventoryBuffer>);
				InventoryUtilities.TryGetInventory(Plugin.Server.EntityManager, entity, ref val, 0);
				total = InventoryUtilities.GetItemAmount(Plugin.Server.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 val2 = new BepInExErrorLogInterpolatedStringHandler(7, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Error: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logger.LogError(val2);
				return false;
			}
		}

		public static bool verifyHaveSuficientPrefabsInInventory(string characterName, PrefabGUID prefabCurrencyGUID, int quantity = 1)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (searchPrefabsInInventory(characterName, prefabCurrencyGUID, out var total))
				{
					if (total >= quantity)
					{
						return true;
					}
					return false;
				}
				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(string characterName, PrefabGUID prefabGUID, int quantity)
		{
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			//IL_0015: 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_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_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_0074: 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_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				int num = quantity;
				UserModel userByCharacterName = GameData.Users.GetUserByCharacterName(characterName);
				ItemModel prefabById = GameData.Items.GetPrefabById(prefabGUID);
				Entity entity = userByCharacterName.Character.Entity;
				int inventorySize = InventoryUtilities.GetInventorySize(Plugin.Server.EntityManager, entity);
				GameDataSystem existingSystem = Plugin.Server.GetExistingSystem<GameDataSystem>();
				InventoryBuffer val = default(InventoryBuffer);
				for (int i = 0; i < inventorySize; i++)
				{
					if (!InventoryUtilities.TryGetItemAtSlot(Plugin.Server.EntityManager, entity, i, ref val))
					{
						continue;
					}
					ManagedItemData orDefault = existingSystem.ManagedDataRegistry.GetOrDefault<ManagedItemData>(val.ItemType, (ManagedItemData)null);
					if (orDefault != null && orDefault.PrefabName == prefabById.PrefabName)
					{
						if (val.Amount >= num)
						{
							InventoryUtilitiesServer.TryRemoveItemAtIndex(Plugin.Server.EntityManager, entity, val.ItemType, num, i, false);
							num = 0;
							break;
						}
						if (val.Amount < num)
						{
							InventoryUtilitiesServer.TryRemoveItemAtIndex(Plugin.Server.EntityManager, entity, val.ItemType, val.Amount, i, true);
							num -= val.Amount;
						}
						if (num == 0)
						{
							break;
						}
					}
				}
				if (num > 0)
				{
					AdditemToInventory(userByCharacterName.CharacterName, prefabGUID, quantity - num);
					return false;
				}
				return true;
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(6, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Error ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logger.LogError(val2);
				return false;
			}
		}

		public static bool AdditemToInventory(string characterName, PrefabGUID prefabGUID, int quantity)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0014: 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)
			try
			{
				UserModel userByCharacterName = GameData.Users.GetUserByCharacterName(characterName);
				for (int i = 0; i < quantity; i++)
				{
					if (!userByCharacterName.TryGiveItem(prefabGUID, 1, out var _))
					{
						userByCharacterName.DropItemNearby(prefabGUID, 1);
					}
				}
				return true;
			}
			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 BloodyShop.Server.Commands
{
	[CommandGroup("shop", null)]
	internal class ShopCommands
	{
		public static CurrencyModel currency { get; private set; }

		public static List<CurrencyModel> currencies { get; private set; }

		[Command("currency add", null, "\"<Name>\" <PrefabGuid>", "Add a currency to the store. To know the PrefabGuid of an item you must look for the item in the following URL <#4acc45><u>https://gaming.tools/v-rising/items</u></color>", null, true)]
		public static void AddCurrency(ChatCommandContext ctx, string name, int item, bool drop)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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)
			//IL_009c: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			PrefabGUID prefabGuid = default(PrefabGUID);
			((PrefabGUID)(ref prefabGuid))..ctor(item);
			ItemModel prefabById = GameData.Items.GetPrefabById(prefabGuid);
			if (prefabById == null)
			{
				throw ctx.Error("Invalid item type");
			}
			if (!ShareDB.addCurrencyList(name, item, drop))
			{
				throw ctx.Error("Invalid item type");
			}
			SaveDataToFiles.saveCurrenciesList();
			ctx.Reply(FontColorChat.Yellow("Added currency " + FontColorChat.White(name ?? "") + " to the store"));
			Dictionary<string, User> usersWithUI = UserUI.GetUsersWithUI();
			foreach (KeyValuePair<string, User> item2 in usersWithUI)
			{
				User value = item2.Value;
				if (value.IsConnected && value.IsAdmin)
				{
					ListSerializedMessage msg = ServerListMessageAction.createMsg();
					ServerListMessageAction.Send(value, msg);
				}
			}
		}

		[Command("currency list", null, "", "List of products available to buy in the store", null, true)]
		public static void ListCurrency(ChatCommandContext ctx)
		{
			if (!ConfigDB.ShopEnabled)
			{
				throw ctx.Error(FontColorChat.Yellow(FontColorChat.White(ConfigDB.StoreName ?? "") + " is closed"));
			}
			List<string> currencyListMessage = ShareDB.GetCurrencyListMessage();
			if (currencyListMessage.Count <= 0)
			{
				throw ctx.Error("No currency available in the store");
			}
			foreach (string item in currencyListMessage)
			{
				ctx.Reply(item);
			}
		}

		[Command("currency remove", "crm", "<NumberItem>", "Delete a currency from the store", null, true)]
		public static void RemoveCurrency(ChatCommandContext ctx, int index)
		{
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (ShareDB.currenciesList.Count == 1)
				{
					throw ctx.Error(FontColorChat.Yellow("Do not remove all currency from the store."));
				}
				if (!ShareDB.SearchCurrencyByCommand(index, out var currencyModel))
				{
					throw ctx.Error(FontColorChat.Yellow("Currency removed error."));
				}
				if (!ShareDB.RemoveCurrencyyByCommand(index))
				{
					throw ctx.Error(FontColorChat.Yellow("Item " + FontColorChat.White(currencyModel.name ?? "") + " removed error."));
				}
				SaveDataToFiles.saveCurrenciesList();
				LoadDataFromFiles.loadCurrencies();
				ctx.Reply(FontColorChat.Yellow("Currency " + FontColorChat.White(currencyModel.name ?? "") + " removed successful."));
				Dictionary<string, User> usersWithUI = UserUI.GetUsersWithUI();
				foreach (KeyValuePair<string, User> item in usersWithUI)
				{
					User value = item.Value;
					if (value.IsConnected && value.IsAdmin)
					{
						ListSerializedMessage msg = ServerListMessageAction.createMsg();
						ServerListMessageAction.Send(value, msg);
					}
				}
			}
			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);
				throw ctx.Error("Error: " + ex.Message);
			}
		}

		[Command("add", null, "\"<Name>\" <PrefabGuid> <Currency> <Price> <Stock> <Stack> <Buff|true/false>", "Add a product to the store. To know the PrefabGuid of an item you must look for the item in the following URL <#4acc45><u>https://gaming.tools/v-rising/items</u></color>", null, true)]
		public static void AddItem(ChatCommandContext ctx, string name, int item, int currencyId, int price, int stock, int stack = 1, bool isBuff = false)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Estamos añadiendo un buff o no? ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(isBuff);
				}
				logger.LogInfo(val);
				if (!isBuff)
				{
					PrefabGUID prefabGuid = default(PrefabGUID);
					((PrefabGUID)(ref prefabGuid))..ctor(item);
					ItemModel prefabById = GameData.Items.GetPrefabById(prefabGuid);
					if (prefabById == null)
					{
						throw ctx.Error("Invalid item type");
					}
				}
				currencies = ShareDB.getCurrencyList();
				currency = currencies.FirstOrDefault((CurrencyModel currency) => currency.id == currencyId);
				if (currency == null)
				{
					throw ctx.Error("Error loading currency type");
				}
				if (stock <= 0)
				{
					stock = -1;
				}
				if (!ItemsDB.addProductList(item, price, stock, name, currency.guid, stack, isBuff))
				{
					throw ctx.Error("Invalid item type");
				}
				SaveDataToFiles.saveProductList();
				ctx.Reply(FontColorChat.Yellow("Added item " + FontColorChat.White($"{stack}x {name} ({stock})") + " to the store with a price of " + FontColorChat.White($"{price} {currency?.name.ToString()}")));
				if (!ConfigDB.ShopEnabled)
				{
					return;
				}
				if (ConfigDB.AnnounceAddRemovePublic)
				{
					ServerChatUtils.SendSystemMessageToAllClients(VWorld.Server.EntityManager, FontColorChat.Yellow(FontColorChat.White($"{stack}x {name} ({stock})") + " have been added to the Store for " + FontColorChat.White($"{price} {currency?.name.ToString()}")));
				}
				Dictionary<string, User> usersWithUI = UserUI.GetUsersWithUI();
				foreach (KeyValuePair<string, User> item2 in usersWithUI)
				{
					User value = item2.Value;
					if (value.IsConnected)
					{
						ListSerializedMessage msg = ServerListMessageAction.createMsg();
						ServerListMessageAction.Send(value, msg);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)ex.Message);
				throw ctx.Error("Error saving the item in the store ");
			}
		}

		[Command("buy", null, "<NumberItem> <Quantity> ", "Buy an object from the shop", null, false)]
		public static void BuyItem(ChatCommandContext ctx, int indexPosition, int quantity)
		{
			//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d8: Expected O, but got Unknown
			//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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Expected O, but got Unknown
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Expected O, but got Unknown
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Unknown result type (might be due to invalid IL or missing references)
			bool flag = default(bool);
			try
			{
				Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity;
				if (!ConfigDB.ShopEnabled)
				{
					throw ctx.Error(FontColorChat.Yellow(FontColorChat.White(ConfigDB.StoreName ?? "") + " is closed"));
				}
				if (quantity <= 0)
				{
					throw ctx.Error("The minimum purchase quantity of a product is 1");
				}
				if (!ItemsDB.SearchItemByCommand(indexPosition, out var itemShopModel))
				{
					throw ctx.Error("This item is not available in the store");
				}
				currency = ShareDB.getCurrency(itemShopModel.currency);
				if (currency == null)
				{
					throw ctx.Error("Error loading currency type");
				}
				int num = itemShopModel.PrefabPrice * quantity;
				if (!itemShopModel.CheckStockAvailability(quantity))
				{
					throw ctx.Error("There is not enough stock of this item");
				}
				ItemModel prefabById = GameData.Items.GetPrefabById(new PrefabGUID(currency.guid));
				User user = ctx.Event.User;
				if (!InventorySystem.verifyHaveSuficientPrefabsInInventory(((object)(FixedString64)(ref user.CharacterName)).ToString(), prefabById.PrefabGUID, num))
				{
					throw ctx.Error("You need " + FontColorChat.White($"{num} {currency.name}") + " in your inventory for this purchase");
				}
				user = ctx.Event.User;
				if (!InventorySystem.getPrefabFromInventory(((object)(FixedString64)(ref user.CharacterName)).ToString(), prefabById.PrefabGUID, num))
				{
					throw ctx.Error("You need " + FontColorChat.White($"{num} {currency.name}") + " in your inventory for this purchase");
				}
				int num2 = itemShopModel.PrefabStack * quantity;
				if (itemShopModel.isBuff)
				{
					BuffSystem.BuffPlayer(senderCharacterEntity, ctx.Event.SenderUserEntity, new PrefabGUID(itemShopModel.PrefabGUID), 0, persistsThroughDeath: true);
				}
				else
				{
					user = ctx.Event.User;
					if (!InventorySystem.AdditemToInventory(((object)(FixedString64)(ref user.CharacterName)).ToString(), new PrefabGUID(itemShopModel.PrefabGUID), num2))
					{
						ManualLogSource logger = Plugin.Logger;
						BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(58, 4, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error buying an item User: ");
							BepInExErrorLogInterpolatedStringHandler obj = val;
							user = ctx.Event.User;
							((BepInExLogInterpolatedStringHandler)obj).AppendFormatted<string>(((object)(FixedString64)(ref user.CharacterName)).ToString());
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Item: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(itemShopModel.PrefabName);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Quantity: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(quantity);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" TotalPrice: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
						}
						logger.LogError(val);
						throw ctx.Error("An error has occurred when delivering the items, please contact an administrator");
					}
				}
				ctx.Reply(FontColorChat.Yellow("Transaction successful. You have purchased " + FontColorChat.White($"{quantity}x {itemShopModel.PrefabName}") + " for a total of  " + FontColorChat.White($"{num} {currency.name}")));
				if (!ItemsDB.ModifyStockByCommand(indexPosition, quantity))
				{
					ManualLogSource logger2 = Plugin.Logger;
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(59, 4, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error ModifyStockByCommand: ");
						BepInExErrorLogInterpolatedStringHandler obj2 = val;
						user = ctx.Event.User;
						((BepInExLogInterpolatedStringHandler)obj2).AppendFormatted<string>(((object)(FixedString64)(ref user.CharacterName)).ToString());
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Item: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(itemShopModel.PrefabName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Quantity: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(quantity);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" TotalPrice: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
					}
					logger2.LogError(val);
					return;
				}
				SaveDataToFiles.saveProductList();
				LoadDataFromFiles.loadProductList();
				Dictionary<string, User> usersWithUI = UserUI.GetUsersWithUI();
				foreach (KeyValuePair<string, User> item in usersWithUI)
				{
					User value = item.Value;
					if (value.IsConnected)
					{
						ListSerializedMessage msg = ServerListMessageAction.createMsg();
						ServerListMessageAction.Send(value, msg);
					}
				}
				if (ConfigDB.AnnounceBuyPublic)
				{
					ServerChatUtils.SendSystemMessageToAllClients(VWorld.Server.EntityManager, FontColorChat.Yellow($"{ctx.Event.User.CharacterName} has purchased {FontColorChat.White($"{num2}x {itemShopModel.PrefabName}")} for a total of  {FontColorChat.White($"{num} {currency.name}")}"));
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger3 = Plugin.Logger;
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(7, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logger3.LogError(val);
				throw ctx.Error("Error: " + ex.Message);
			}
		}

		[Command("remove", "rm", "<NumberItem>", "Delete a product from the store", null, true)]
		public static void removeItemFromShop(ChatCommandContext ctx, int index)
		{
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!ItemsDB.SearchItemByCommand(index, out var itemShopModel))
				{
					throw ctx.Error(FontColorChat.Yellow("Item removed error."));
				}
				if (!ItemsDB.RemoveItemByCommand(index))
				{
					throw ctx.Error(FontColorChat.Yellow("Item " + FontColorChat.White(itemShopModel.PrefabName ?? "") + " removed error."));
				}
				SaveDataToFiles.saveProductList();
				LoadDataFromFiles.loadProductList();
				ctx.Reply(FontColorChat.Yellow("Item " + FontColorChat.White(itemShopModel.PrefabName ?? "") + " removed successful."));
				Dictionary<string, User> usersWithUI = UserUI.GetUsersWithUI();
				foreach (KeyValuePair<string, User> item in usersWithUI)
				{
					User value = item.Value;
					if (value.IsConnected)
					{
						ListSerializedMessage msg = ServerListMessageAction.createMsg();
						ServerListMessageAction.Send(value, msg);
					}
				}
				if (ConfigDB.AnnounceAddRemovePublic)
				{
					ServerChatUtils.SendSystemMessageToAllClients(VWorld.Server.EntityManager, FontColorChat.Yellow("Item " + FontColorChat.White(itemShopModel.PrefabName ?? "") + " removed successful."));
				}
			}
			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);
				throw ctx.Error("Error: " + ex.Message);
			}
		}

		[Command("list", null, "", "List of products available to buy in the store", null, false)]
		public static void list(ChatCommandContext ctx)
		{
			if (!ConfigDB.ShopEnabled)
			{
				throw ctx.Error(FontColorChat.Yellow(FontColorChat.White(ConfigDB.StoreName ?? "") + " is closed"));
			}
			List<string> productListMessage = ItemsDB.GetProductListMessage();
			if (productListMessage.Count <= 0)
			{
				throw ctx.Error("No products available in the store");
			}
			foreach (string item in productListMessage)
			{
				ctx.Reply(item);
			}
			ctx.Reply(FontColorChat.Yellow("To buy an object you must have in your inventory the number of currency indicated by each product."));
			ctx.Reply(FontColorChat.Yellow("Use the chat command \"" + FontColorChat.White("shop buy <NumberItem> <Quantity> ") + "\""));
		}

		[Command("open", null, "", "Open store", null, true)]
		public static void OpenShop(ChatCommandContext ctx)
		{
			//IL_000d: 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_006b: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			ConfigDB.ShopEnabled = true;
			ServerChatUtils.SendSystemMessageToAllClients(VWorld.Server.EntityManager, FontColorChat.Yellow(" " + FontColorChat.White(" " + ConfigDB.StoreName + " ") + " just opened"));
			Dictionary<string, User> usersWithUI = UserUI.GetUsersWithUI();
			OpenSerializedMessage msg = new OpenSerializedMessage();
			foreach (KeyValuePair<string, User> item in usersWithUI)
			{
				User value = item.Value;
				if (value.IsConnected)
				{
					ServerOpenMessageAction.Send(value, msg);
				}
			}
		}

		[Command("close", null, "", "Close store", null, true)]
		public static void CloseShop(ChatCommandContext ctx)
		{
			//IL_000d: 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_006b: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			ConfigDB.ShopEnabled = false;
			ServerChatUtils.SendSystemMessageToAllClients(VWorld.Server.EntityManager, FontColorChat.Yellow(" " + FontColorChat.White(" " + ConfigDB.StoreName + " ") + " just closed"));
			Dictionary<string, User> usersWithUI = UserUI.GetUsersWithUI();
			CloseSerializedMessage msg = new CloseSerializedMessage();
			foreach (KeyValuePair<string, User> item in usersWithUI)
			{
				User value = item.Value;
				if (value.IsConnected)
				{
					ServerCloseMessageAction.Send(value, msg);
				}
			}
		}

		[Command("reload", null, "", "Reload products and currencies files from server", null, true)]
		public static void ReloadShop(ChatCommandContext ctx)
		{
			//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_0068: Unknown result type (might be due to invalid IL or missin