Decompiled source of BloodyShop v1.0.2
BloodyShop.dll
Decompiled 5 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.Json; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using Bloodstone.API; using Bloodstone.Hooks; using Bloody.Core; using Bloody.Core.API.v1; using Bloody.Core.GameData.v1; using Bloody.Core.Helper.v1; using Bloody.Core.Methods; using Bloody.Core.Models.v1; using Bloody.Core.Models.v1.Base; using BloodyShop.AutoAnnouncer; using BloodyShop.AutoAnnouncer.Timers; using BloodyShop.Client; using BloodyShop.Client.DB; 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.Properties; using BloodyShop.Server; using BloodyShop.Server.Commands; using BloodyShop.Server.Core; using BloodyShop.Server.DB; using BloodyShop.Server.Systems; using BloodyShop.Utils; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using NAudio.Wave; using ProjectM; using ProjectM.Network; using Stunlock.Core; using Unity.Collections; using Unity.Collections.LowLevel.Unsafe; using Unity.Entities; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; using UniverseLib; using UniverseLib.Config; using UniverseLib.UI; using UniverseLib.UI.Models; using UniverseLib.UI.Panels; using UniverseLib.UI.Widgets; using VampireCommandFramework; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] [assembly: AssemblyCompany("BloodyShop")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Mod to create a store in VRising")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2+2.Branch.master.Sha.2917e4bd2350f4f3c048624b2484c208fd589ea5")] [assembly: AssemblyProduct("BloodyShop")] [assembly: AssemblyTitle("BloodyShop")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] namespace BloodyShop { public class BloodyShop { public static readonly string ConfigPath = Path.Combine(Paths.ConfigPath, "BloodyShop"); public static void serverInitMod(Harmony _harmony) { ServerMod.CreateFilesConfig(); CommandRegistry.RegisterCommandType(typeof(ShopCommands)); } public static void clientInitMod(Harmony _harmony) { UIManager.Initialize(); KeyBinds.Initialize(); KeyBinds.OnKeyPressed += KeyBindPressed.OnKeyPressedOpenPanel; } public static void onServerGameInitialized() { ServerMod.SetConfigMod(); } public static void onClientGameInitialized() { } public static void serverUnloadMod() { } public static void clientUnloadMod() { KeyBinds.OnKeyPressed -= KeyBindPressed.OnKeyPressedOpenPanel; } public static void onServerGameDataOnInitialize() { ServerMod.LoadConfigToDB(); ServerMod.LoadCurrenciesToDB(); } public static void onClientGameDataOnInitialize() { ClientMod.ClientEvents_OnGameDataInitialized(); } } [BepInPlugin("BloodyShop", "BloodyShop", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [Reloadable] public class Plugin : BasePlugin, IRunOnInitialized { internal static Plugin Instance; internal static string Name = "BloodyShop"; internal static string Guid = "BloodyShop"; internal static string Version = "1.0.2"; public static Logger 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 SystemsCore SystemsCore; 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown if (VWorld.IsServer) { Instance = this; Logger = new Logger(((BasePlugin)this).Log); _harmony = new Harmony("BloodyShop"); EventsHandlerSystem.OnInitialize += new OnGameDataInitializedEventHandler(GameDataOnInitialize); EventsHandlerSystem.OnDestroy += new OnGameDataDestroyedEventHandler(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() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown if (VWorld.IsServer) { ((BasePlugin)this).Config.Clear(); BloodyShop.serverUnloadMod(); CommandRegistry.UnregisterAssembly(); } else { BloodyShop.clientUnloadMod(); } _harmony.UnpatchSelf(); EventsHandlerSystem.OnDestroy -= new OnGameDataDestroyedEventHandler(GameDataOnDestroy); EventsHandlerSystem.OnInitialize -= new OnGameDataInitializedEventHandler(GameDataOnInitialize); return true; } private static void GameDataOnInitialize(World world) { SystemsCore = Core.SystemsCore; if (VWorld.IsServer) { BloodyShop.onServerGameDataOnInitialize(); return; } try { BloodyShop.onClientGameDataOnInitialize(); } catch (Exception ex) { Logger.LogError("Error GameDataOnInitialize " + ex.Message); } } 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"); } 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 = "1.0.2"; } } 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_0002: 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_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) 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.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() { if (!LoadDataFromFiles.loadProductList()) { Plugin.Logger.LogError("Error loading ProductList"); } } public static void LoadCurrenciesToDB() { if (!LoadDataFromFiles.loadCurrencies()) { Plugin.Logger.LogError("Error loading CurrenciesList"); } } 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; } } } } namespace BloodyShop.Server.Systems { internal class UserUI { private static Dictionary<string, User> _users = new Dictionary<string, User>(); public static void RegisterUserWithUI(User user) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) _users.TryAdd(((object)(FixedString64Bytes)(ref user.CharacterName)).ToString(), user); } public static Dictionary<string, User> GetUsersWithUI() { return _users; } } } namespace BloodyShop.Server.DB { public class ConfigDB { 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"; } internal class LoadDataFromFiles { public static bool loadProductList() { try { return ItemsDB.setProductList(JsonSerializer.Deserialize<List<ItemShopModel>>(File.ReadAllText(ServerMod.ProductListFile))); } catch (Exception ex) { Plugin.Logger.LogError("Error: " + ex.Message); return false; } } public static bool loadCurrencies() { try { return ShareDB.setCurrencyList(JsonSerializer.Deserialize<List<CurrencyModel>>(File.ReadAllText(ServerMod.CurrencyListFile))); } catch (Exception ex) { Plugin.Logger.LogError("Error: " + ex.Message); return false; } } } internal class SaveDataToFiles { public static bool saveProductList() { try { string contents = JsonSerializer.Serialize(ItemsDB.getProductListForSaveJSON()); File.WriteAllText(ServerMod.ProductListFile, contents); return true; } catch (Exception ex) { Plugin.Logger.LogError("Error: " + ex.Message); return false; } } public static bool saveCurrenciesList() { try { string contents = JsonSerializer.Serialize(ShareDB.getCurrencyList()); File.WriteAllText(ServerMod.CurrencyListFile, contents); return true; } catch (Exception ex) { Plugin.Logger.LogError("Error: " + ex.Message); return false; } } } } namespace BloodyShop.Server.Core { public class InventorySystem { public static bool searchPrefabsInInventory(string characterName, PrefabGUID prefabCurrencyGUID, out int total) { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0041: 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_004a: Unknown result type (might be due to invalid IL or missing references) total = 0; try { Entity entity = GameData.Users.GetUserByCharacterName(characterName).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) { Plugin.Logger.LogError("Error: " + ex.Message); return false; } } public static bool verifyHaveSuficientPrefabsInInventory(string characterName, PrefabGUID prefabCurrencyGUID, int quantity = 1) { //IL_0001: 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) { Plugin.Logger.LogError("Error: " + ex.Message); return false; } } public static bool getPrefabFromInventory(string characterName, PrefabGUID prefabGUID, int quantity) { //IL_0013: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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); Plugin.Server.GetExistingSystemManaged<GameDataSystem>(); InventoryBuffer val = default(InventoryBuffer); for (int i = 0; i < inventorySize; i++) { if (!InventoryUtilities.TryGetItemAtSlot(Plugin.Server.EntityManager, entity, i, ref val)) { continue; } ItemModel prefabById2 = GameData.Items.GetPrefabById(val.ItemType); if (prefabById2 != null && prefabById2.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) { Plugin.Logger.LogError("Error " + ex.Message); return false; } } public static bool AdditemToInventory(string characterName, PrefabGUID prefabGUID, int quantity) { //IL_0011: 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) try { UserModel userByCharacterName = GameData.Users.GetUserByCharacterName(characterName); Entity val = default(Entity); for (int i = 0; i < quantity; i++) { if (!UserModelMethods.TryGiveItem(userByCharacterName, prefabGUID, 1, ref val)) { UserModelMethods.DropItemNearby(userByCharacterName, prefabGUID, 1); } } return true; } catch (Exception ex) { Plugin.Logger.LogError("Error " + ex.Message); 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) PrefabGUID val = default(PrefabGUID); ((PrefabGUID)(ref val))..ctor(item); if (GameData.Items.GetPrefabById(val) == 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")); foreach (KeyValuePair<string, User> item2 in UserUI.GetUsersWithUI()) { User value = item2.Value; if (value.IsConnected) { _ = value.IsAdmin; } } } [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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00cf: 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.")); foreach (KeyValuePair<string, User> item in UserUI.GetUsersWithUI()) { User value = item.Value; if (value.IsConnected) { _ = value.IsAdmin; } } } catch (Exception ex) { Plugin.Logger.LogError("Error: " + ex.Message); 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) try { Plugin.Logger.LogInfo($"Estamos añadiendo un buff o no? {isBuff}"); if (!isBuff) { PrefabGUID val = default(PrefabGUID); ((PrefabGUID)(ref val))..ctor(item); if (GameData.Items.GetPrefabById(val) == 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()}"))); } foreach (KeyValuePair<string, User> item2 in UserUI.GetUsersWithUI()) { _ = item2.Value.IsConnected; } } catch (Exception ex) { Plugin.Logger.LogError(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_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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_015a: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) 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)(FixedString64Bytes)(ref user.CharacterName)).ToString(), ((EntityModel)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)(FixedString64Bytes)(ref user.CharacterName)).ToString(), ((EntityModel)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, true); } else { user = ctx.Event.User; if (!InventorySystem.AdditemToInventory(((object)(FixedString64Bytes)(ref user.CharacterName)).ToString(), new PrefabGUID(itemShopModel.PrefabGUID), num2)) { Logger logger = Plugin.Logger; DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(58, 4); defaultInterpolatedStringHandler.AppendLiteral("Error buying an item User: "); user = ctx.Event.User; defaultInterpolatedStringHandler.AppendFormatted(((object)(FixedString64Bytes)(ref user.CharacterName)).ToString()); defaultInterpolatedStringHandler.AppendLiteral(" Item: "); defaultInterpolatedStringHandler.AppendFormatted(itemShopModel.PrefabName); defaultInterpolatedStringHandler.AppendLiteral(" Quantity: "); defaultInterpolatedStringHandler.AppendFormatted(quantity); defaultInterpolatedStringHandler.AppendLiteral(" TotalPrice: "); defaultInterpolatedStringHandler.AppendFormatted(num); logger.LogError(defaultInterpolatedStringHandler.ToStringAndClear()); 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)) { Logger logger2 = Plugin.Logger; DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(59, 4); defaultInterpolatedStringHandler.AppendLiteral("Error ModifyStockByCommand: "); user = ctx.Event.User; defaultInterpolatedStringHandler.AppendFormatted(((object)(FixedString64Bytes)(ref user.CharacterName)).ToString()); defaultInterpolatedStringHandler.AppendLiteral(" Item: "); defaultInterpolatedStringHandler.AppendFormatted(itemShopModel.PrefabName); defaultInterpolatedStringHandler.AppendLiteral(" Quantity: "); defaultInterpolatedStringHandler.AppendFormatted(quantity); defaultInterpolatedStringHandler.AppendLiteral(" TotalPrice: "); defaultInterpolatedStringHandler.AppendFormatted(num); logger2.LogError(defaultInterpolatedStringHandler.ToStringAndClear()); return; } SaveDataToFiles.saveProductList(); LoadDataFromFiles.loadProductList(); foreach (KeyValuePair<string, User> item in UserUI.GetUsersWithUI()) { _ = item.Value.IsConnected; } 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) { Plugin.Logger.LogError("Error: " + ex.Message); 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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.")); foreach (KeyValuePair<string, User> item in UserUI.GetUsersWithUI()) { _ = item.Value.IsConnected; } if (ConfigDB.AnnounceAddRemovePublic) { ServerChatUtils.SendSystemMessageToAllClients(VWorld.Server.EntityManager, FontColorChat.Yellow("Item " + FontColorChat.White(itemShopModel.PrefabName ?? "") + " removed successful.")); } } catch (Exception ex) { Plugin.Logger.LogError("Error: " + ex.Message); 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_000b: 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")); UserUI.GetUsersWithUI(); } [Command("close", null, "", "Close store", null, true)] public static void CloseShop(ChatCommandContext ctx) { //IL_000b: 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")); UserUI.GetUsersWithUI(); } [Command("reload", null, "", "Reload products and currencies files from server", null, true)] public static void ReloadShop(ChatCommandContext ctx) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) LoadDataFromFiles.loadProductList(); LoadDataFromFiles.loadCurrencies(); ctx.Reply(FontColorChat.Yellow(" " + FontColorChat.White(" " + ConfigDB.StoreName + " ") + " Configuration has been reloaded successfully")); foreach (KeyValuePair<string, User> item in UserUI.GetUsersWithUI()) { _ = item.Value.IsConnected; } } } } 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) { resourceMan = new ResourceManager("BloodyShop.Properties.Resources", typeof(Resources).Assembly); } 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 => (byte[])ResourceManager.GetObject("close", resourceCulture); internal static UnmanagedMemoryStream coin => ResourceManager.GetStream("coin", resourceCulture); internal static byte[] config => (byte[])ResourceManager.GetObject("config", resourceCulture); internal static byte[] elixir => (byte[])ResourceManager.GetObject("elixir", resourceCulture); internal static UnmanagedMemoryStream floop2_x => ResourceManager.GetStream("floop2_x", resourceCulture); internal static byte[] open => (byte[])ResourceManager.GetObject("open", resourceCulture); internal static byte[] shop_close => (byte[])ResourceManager.GetObject("shop_close", resourceCulture); internal static byte[] shop_open => (byte[])ResourceManager.GetObject("shop_open", resourceCulture); internal Resources() { } } } namespace BloodyShop.DB { public class ItemsDB { public static List<(string name, string type, PrefabModel model)> _normalizedItemNameCache = new List<(string, string, PrefabModel)>(); public static List<(string name, int GUID, string type, PrefabModel model)> _normalizedItemShopNameCache = new List<(string, int, string, PrefabModel)>(); private static string _lastQueryAdd; private static List<PrefabModel> _lastResultAdd; public static List<PrefabModel> ProductList { get; set; } = new List<PrefabModel>(); public static void generateCacheItems() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0031: 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_0082: 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_00c8: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) Enumerator<PrefabGUID, Entity> enumerator = Plugin.SystemsCore.PrefabCollectionSystem._PrefabGuidToEntityMap.GetEnumerator(); while (enumerator.MoveNext()) { KeyValue<PrefabGUID, Entity> current = enumerator.Current; ItemModel val = GameData.Items.FromEntity(current.Value); if (val == null || val == null || val.Name == null || !(((val != null) ? val.Name : null) != "") || val == null) { continue; } _ = val.ItemType; object obj; ItemType itemType; if (val == null) { obj = null; } else { itemType = val.ItemType; obj = ((object)(ItemType)(ref itemType)).ToString(); } if (!((string?)obj != "")) { continue; } PrefabModel prefabModel = new PrefabModel(); prefabModel.PrefabName = ((val != null) ? val.Name : null); object prefabType; if (val == null) { prefabType = null; } else { itemType = val.ItemType; prefabType = ((object)(ItemType)(ref itemType)).ToString(); } prefabModel.PrefabType = (string)prefabType; int? obj2; if (val == null) { obj2 = null; } else { PrefabGUID? prefabGUID = ((EntityModel)val).Internals.PrefabGUID; if (!prefabGUID.HasValue) { obj2 = null; } else { PrefabGUID valueOrDefault = prefabGUID.GetValueOrDefault(); obj2 = ((PrefabGUID)(ref valueOrDefault)).GuidHash; } } int? num = obj2; prefabModel.PrefabGUID = num.GetValueOrDefault(); object prefabIcon; if (val == null) { prefabIcon = null; } else { ManagedItemData managedItemData = val.ManagedCore.ManagedItemData; prefabIcon = ((managedItemData != null) ? managedItemData.Icon : null); } prefabModel.PrefabIcon = (Sprite)prefabIcon; object prefabIcon2; if (val == null) { prefabIcon2 = null; } else { ManagedItemData managedItemData2 = val.ManagedCore.ManagedItemData; prefabIcon2 = ((managedItemData2 != null) ? managedItemData2.Icon : null); } prefabModel.PrefabIcon = (Sprite)prefabIcon2; _normalizedItemNameCache.Add((prefabModel.PrefabName.ToString().ToLower(), prefabModel.PrefabType.ToString().ToLower(), prefabModel)); } } public static bool setProductList(List<ItemShopModel> list) { //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) ProductList = new List<PrefabModel>(); _normalizedItemShopNameCache = new List<(string, int, string, PrefabModel)>(); foreach (ItemShopModel item in list) { if (item.isBuff) { PrefabModel prefabModel = new PrefabModel(); prefabModel.PrefabName = item?.name; prefabModel.PrefabType = "buff"; prefabModel.PrefabGUID = item.id; Sprite prefabIcon = SpritesUtil.LoadPNGTOSprite(Resources.elixir); prefabModel.PrefabIcon = prefabIcon; prefabModel.PrefabPrice = item.price; prefabModel.PrefabStock = item.stock; prefabModel.PrefabStack = item.stack; prefabModel.currency = item.currency; prefabModel.isBuff = item.isBuff; ProductList.Add(prefabModel); _normalizedItemShopNameCache.Add((prefabModel.PrefabName.ToString().ToLower(), prefabModel.PrefabGUID, prefabModel.PrefabType.ToString().ToLower(), prefabModel)); continue; } ItemModel prefabById = GameData.Items.GetPrefabById(new PrefabGUID(item.id)); PrefabModel prefabModel2 = new PrefabModel(); prefabModel2.PrefabName = item?.name; object prefabType; if (prefabById == null) { prefabType = null; } else { ItemType itemType = prefabById.ItemType; prefabType = ((object)(ItemType)(ref itemType)).ToString(); } prefabModel2.PrefabType = (string)prefabType; int? obj; if (prefabById == null) { obj = null; } else { PrefabGUID? prefabGUID = ((EntityModel)prefabById).Internals.PrefabGUID; if (!prefabGUID.HasValue) { obj = null; } else { PrefabGUID valueOrDefault = prefabGUID.GetValueOrDefault(); obj = ((PrefabGUID)(ref valueOrDefault)).GuidHash; } } int? num = obj; prefabModel2.PrefabGUID = num.GetValueOrDefault(); object prefabIcon2; if (prefabById == null) { prefabIcon2 = null; } else { ManagedItemData managedItemData = prefabById.ManagedCore.ManagedItemData; prefabIcon2 = ((managedItemData != null) ? managedItemData.Icon : null); } prefabModel2.PrefabIcon = (Sprite)prefabIcon2; prefabModel2.PrefabPrice = item.price; prefabModel2.PrefabStock = item.stock; prefabModel2.PrefabStack = item.stack; prefabModel2.currency = item.currency; prefabModel2.isBuff = item.isBuff; ProductList.Add(prefabModel2); _normalizedItemShopNameCache.Add((prefabModel2.PrefabName.ToString().ToLower(), prefabModel2.PrefabGUID, prefabModel2.PrefabType.ToString().ToLower(), prefabModel2)); } return true; } public static List<PrefabModel> searchItemByNameForAdd(string text) { if (text == "") { return new List<PrefabModel>(); } if (string.Equals(text, _lastQueryAdd)) { return _lastResultAdd; } _lastQueryAdd = text; List<PrefabModel> list = new List<PrefabModel>(); foreach (var (text2, _, item) in _normalizedItemNameCache) { if (text2.Contains(text)) { list.Add(item); } } _lastResultAdd = (from x in list orderby x.PrefabType, x.PrefabName select x).ToList(); return _lastResultAdd; } public static List<PrefabModel> searchItemByNameForShop(string text) { List<PrefabModel> list = new List<PrefabModel>(); foreach (var item in _normalizedItemShopNameCache) { if (item.name.Contains(text)) { list.Add(item.model); } } return list; } public static int searchIndexForProduct(int GUID, int stack, CurrencyModel currency) { int num = 1; foreach (PrefabModel product in ProductList) { if (product.PrefabGUID == GUID && product.PrefabStack == stack && product.currency == currency.guid) { return num; } num++; } return -1; } public static List<ItemShopModel> getProductListForSaveJSON() { List<ItemShopModel> list = new List<ItemShopModel>(); foreach (PrefabModel product in ProductList) { ItemShopModel itemShopModel = new ItemShopModel(); itemShopModel.id = product.PrefabGUID; itemShopModel.name = product.PrefabName; itemShopModel.stock = product.PrefabStock; itemShopModel.stack = product.PrefabStack; itemShopModel.currency = product.currency; itemShopModel.price = product.PrefabPrice; itemShopModel.isBuff = product.isBuff; list.Add(itemShopModel); } return list; } public static bool addProductList(int item, int price, int stock, string name, int currency, int stack = 1, bool isBuff = false) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) if (isBuff) { PrefabModel prefabModel = new PrefabModel(); prefabModel.PrefabName = name; prefabModel.PrefabType = "buff"; prefabModel.PrefabGUID = item; Sprite prefabIcon = SpritesUtil.LoadPNGTOSprite(Resources.elixir); prefabModel.PrefabIcon = prefabIcon; prefabModel.PrefabPrice = price; prefabModel.PrefabStock = stock; prefabModel.PrefabStack = stack; prefabModel.currency = currency; prefabModel.isBuff = true; ProductList.Add(prefabModel); _normalizedItemShopNameCache.Add((prefabModel.PrefabName.ToString().ToLower(), prefabModel.PrefabGUID, prefabModel.PrefabType.ToString().ToLower(), prefabModel)); return true; } ItemModel prefabById = GameData.Items.GetPrefabById(new PrefabGUID(item)); if (prefabById == null) { return false; } PrefabModel prefabModel2 = new PrefabModel(); prefabModel2.PrefabName = name; object prefabType; if (prefabById == null) { prefabType = null; } else { ItemType itemType = prefabById.ItemType; prefabType = ((object)(ItemType)(ref itemType)).ToString(); } prefabModel2.PrefabType = (string)prefabType; int? obj; if (prefabById == null) { obj = null; } else { PrefabGUID? prefabGUID = ((EntityModel)prefabById).Internals.PrefabGUID; if (!prefabGUID.HasValue) { obj = null; } else { PrefabGUID valueOrDefault = prefabGUID.GetValueOrDefault(); obj = ((PrefabGUID)(ref valueOrDefault)).GuidHash; } } int? num = obj; prefabModel2.PrefabGUID = num.GetValueOrDefault(); object prefabIcon2; if (prefabById == null) { prefabIcon2 = null; } else { ManagedItemData managedItemData = prefabById.ManagedCore.ManagedItemData; prefabIcon2 = ((managedItemData != null) ? managedItemData.Icon : null); } prefabModel2.PrefabIcon = (Sprite)prefabIcon2; prefabModel2.PrefabPrice = price; prefabModel2.PrefabStock = stock; prefabModel2.PrefabStack = stack; prefabModel2.currency = currency; prefabModel2.isBuff = isBuff; ProductList.Add(prefabModel2); _normalizedItemShopNameCache.Add((prefabModel2.PrefabName.ToString().ToLower(), prefabModel2.PrefabGUID, prefabModel2.PrefabType.ToString().ToLower(), prefabModel2)); return true; } public static bool RemoveItemByCommand(int index) { try { ProductList.RemoveAt(index - 1); _normalizedItemShopNameCache.RemoveAt(index - 1); return true; } catch (Exception ex) { Plugin.Logger.LogError("Error: " + ex.Message); return false; } } public static bool SearchItemByCommand(int index, out PrefabModel itemShopModel) { try { if (ProductList.Count >= index) { itemShopModel = ProductList[index - 1]; return true; } itemShopModel = null; return false; } catch (Exception ex) { Plugin.Logger.LogError("Error: " + ex.Message); itemShopModel = null; return false; } } public static bool SearchProductListAndRemoveItemByCommmand(int index, out PrefabModel itemShopModel) { try { if (ProductList.Count >= index) { itemShopModel = ProductList[index - 1]; if (RemoveItemByCommand(index)) { return true; } itemShopModel = null; return false; } itemShopModel = null; return false; } catch (Exception ex) { Plugin.Logger.LogError("Error: " + ex.Message); itemShopModel = null; return false; } } public static bool ModifyStockByCommand(int index, int amount) { try { if (ProductList.Count < index) { return false; } PrefabModel prefabModel = ProductList[index - 1]; int prefabStock = prefabModel.PrefabStock; if (prefabStock < 0) { return true; } prefabModel.PrefabStock = prefabStock - amount; if (prefabModel.PrefabStock == 0) { RemoveItemByCommand(index); } else { ProductList[index - 1] = prefabModel; _normalizedItemShopNameCache[index - 1] = (prefabModel.PrefabName.ToString().ToLower(), prefabModel.PrefabGUID, prefabModel.PrefabType.ToString().ToLower(), prefabModel); } return true; } catch (Exception ex) { Plugin.Logger.LogError("Error: " + ex.Message + " " + ex.Source); return false; } } public static bool SearchProductListAndRemoveItem(int itemGUID, out PrefabModel itemShopModel) { itemShopModel = null; int num = 0; foreach (var item in _normalizedItemShopNameCache) { if (item.GUID == itemGUID) { _normalizedItemShopNameCache.Remove(item); ProductList.Remove(item.model); itemShopModel = item.model; break; } num++; } if (itemShopModel == null) { return false; } return true; } public static bool SearchProductList(int itemGUID, out PrefabModel itemShopModel) { itemShopModel = null; int num = 0; foreach (var item in _normalizedItemShopNameCache) { if (item.GUID == itemGUID) { _normalizedItemShopNameCache.Remove(item); ProductList.Remove(item.model); itemShopModel = item.model; break; } num++; } if (itemShopModel == null) { return false; } return true; } public static bool SearchProductsWithCurrencyByCommand(CurrencyModel currencyModel, out int itemShopModel) { itemShopModel = 0; foreach (PrefabModel product in ProductList) { if (product.currency == currencyModel.guid) { itemShopModel++; } } if (itemShopModel == 0) { return false; } return true; } public static List<string> GetProductListMessage() { List<string> list = new List<string>(); int num = 1; string text = ""; foreach (PrefabModel product in ProductList) { CurrencyModel currency = ShareDB.getCurrency(product.currency); if (currency != null) { string text2 = ""; if (product.PrefabStock <= 0) { text2 = "Infinite"; text = "1x " + product.PrefabName; } else { text2 = product.PrefabStock.ToString(); text = product.PrefabStack + "x " + product.PrefabName; } list.Add(FontColorChat.White("[") + FontColorChat.Yellow(num.ToString()) + FontColorChat.White("]") + " " + FontColorChat.Yellow(text) + " " + $"{FontColorChat.Red("Price:")} {FontColorChat.Yellow(product.PrefabPrice.ToString())} {FontColorChat.White(currency.name ?? "")} " + FontColorChat.Red("Stock:") + " " + FontColorChat.Yellow(text2) + " units"); num++; } } return list; } } public class ShareDB { public static List<CurrencyModel> currenciesList = new List<CurrencyModel>(); public static List<CurrencyModel> getCurrencyList() { return currenciesList; } public static CurrencyModel getCurrency(int guid) { return currenciesList.FirstOrDefault((CurrencyModel currency) => currency.guid == guid); } public static CurrencyModel getCurrencyByName(string name) { return currenciesList.FirstOrDefault((CurrencyModel currency) => currency.name == name); } public static bool setCurrencyList(List<CurrencyModel> currencies) { currenciesList = currencies; return true; } public static bool addCurrencyList(string name, int guid, bool drop) { CurrencyModel currencyModel = new CurrencyModel(); int id = getCurrencyList().Last().id + 1; currencyModel.name = name; currencyModel.guid = guid; currencyModel.id = id; currencyModel.drop = drop; currenciesList.Add(currencyModel); return true; } public static List<string> GetCurrencyListMessage() { List<string> list = new List<string>(); foreach (CurrencyModel currencies in currenciesList) { list.Add(FontColorChat.White("[") + FontColorChat.Yellow(currencies.id.ToString()) + FontColorChat.White("]") + " " + FontColorChat.Yellow(currencies.name) + " "); } return list; } public static bool SearchCurrencyByCommand(int index, out CurrencyModel currencyModel) { currencyModel = currenciesList.FirstOrDefault((CurrencyModel currency) => currency.id == index); if (currencyModel == null) { return false; } return true; } public static bool RemoveCurrencyyByCommand(int index) { try { currenciesList.RemoveAll((CurrencyModel currency) => currency.id == index); return true; } catch (Exception ex) { Plugin.Logger.LogError("Error: " + ex.Message); return false; } } public static List<CurrencyModel> searchCurrencyByNameForShop(string text) { List<CurrencyModel> list = new List<CurrencyModel>(); foreach (CurrencyModel currencies in currenciesList) { if (currencies.name.Contains(text)) { list.Add(currencies); } } return list; } public static int searchIdForCurrency(int GUID) { foreach (CurrencyModel currencies in currenciesList) { if (currencies.guid == GUID) { return currencies.id; } } return -1; } } } namespace BloodyShop.DB.Models { [Serializable] public class CurrencyModel { public int id { get; set; } public string name { get; set; } public int guid { get; set; } public bool drop { get; set; } = true; } public class ItemShopModel { public int id { get; set; } public string name { get; set; } public int price { get; set; } public int stock { get; set; } public int stack { get; set; } public int currency { get; set; } public bool isBuff { get; set; } } public class PrefabModel { public string PrefabName { get; set; } public int PrefabPrice { get; set; } public int PrefabStock { get; set; } public int PrefabStack { get; set; } public string PrefabType { get; set; } public int PrefabGUID { get; set; } public Sprite PrefabIcon { get; set; } public ItemModel itemModel { get; set; } public int currency { get; set; } public bool isBuff { get; set; } public bool CheckStockAvailability(int numberofItemsBuy) { if (PrefabStock < 0) { return true; } if (PrefabStock >= numberofItemsBuy) { return true; } return false; } } } namespace BloodyShop.AutoAnnouncer { public class AutoUIFunction { public static void OnTimedAutoUI() { } } } namespace BloodyShop.AutoAnnouncer.Timers { public class AutoLoadUiTimer { private bool _enabled; private bool _isRunning; private DateTime _lastRunTime; private TimeSpan _delay; private Action<World> _action; private Func<object, TimeSpan> _delayAction; public void Start(Action<World> action, TimeSpan delay) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown _delay = delay; _lastRunTime = DateTime.UtcNow - delay; _action = action; _enabled = true; GameFrame.OnUpdate += new GameFrameUpdateEventHandler(GameFrame_OnUpdate); } public void Start(Action<World> action, Func<object, TimeSpan> delayAction) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown _delayAction = delayAction; _delay = _delayAction(1); _lastRunTime = DateTime.UtcNow; _action = action; _enabled = true; GameFrame.OnUpdate += new GameFrameUpdateEventHandler(GameFrame_OnUpdate); } private void GameFrame_OnUpdate() { Update(World.DefaultGameObjectInjectionWorld); } private void Update(World world) { if (!_enabled || _isRunning || _lastRunTime + _delay >= DateTime.UtcNow) { return; } _isRunning = true; try { _action(world); } catch (Exception ex) { Plugin.Logger.LogError(ex); } finally { int num = 30; if (_delayAction != null) { _delay = _delayAction(num); } _lastRunTime = DateTime.UtcNow; _isRunning = false; } } public void Stop() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown GameFrame.OnUpdate -= new GameFrameUpdateEventHandler(GameFrame_OnUpdate); _enabled = false; } public void Dispose() { if (_enabled) { Stop(); } } } } namespace BloodyShop.Client { public class ClientMod { private static AutoLoadUiTimer _autoLoadUiTimer; public static bool UIInit { get; set; } public static void ClientEvents_OnGameDataInitialized() { UIInit = false; _autoLoadUiTimer = new AutoLoadUiTimer(); StartAutoUI(); } public static void ClientEvents_OnClientUserConnected() { } public static void ClientEvents_OnClientUserDisconnected() { UIInit = false; UIManager.DestroyAllPanels(); } private static void StartAutoUI() { _autoLoadUiTimer.Start(delegate { AutoUIFunction.OnTimedAutoUI(); }, delegate(object input) { if (!(input is int)) { Plugin.Logger.LogError("Starting UI timer delay function parameter is not a valid integer"); return TimeSpan.MaxValue; } _ = (int)input; return TimeSpan.FromSeconds(30.0); }); } public static void StopAutoUI() { _autoLoadUiTimer?.Stop(); } } public class KeyBindPressed { public static bool UIActive = true; internal static void OnKeyPressedOpenPanel(KeyBindFunction keybindFunction) { if (keybindFunction == KeyBindFunction.ToggleShopUI) { if (ClientMod.UIInit) { if (UIActive) { UIActive = false; UIManager.HideAllPanels(); } else { UIActive = true; UIManager.ShowMenuPanel(); } } return; } throw new ArgumentOutOfRangeException("keybindFunction", keybindFunction, null); } } } namespace BloodyShop.Client.Utils { internal class Sound { private static MemoryStream ms; private static WaveStream ws; public static void Play(UnmanagedMemoryStream sound) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (Plugin.Sounds.Value) { ms = new MemoryStream(UseStreamDotReadMethod(sound)); ws = (WaveStream)new WaveFileReader((Stream)ms); WaveOutEvent val = new WaveOutEvent { Volume = 0.2f }; val.Init((IWaveProvider)(object)ws); val.Play(); } } private static byte[] UseStreamDotReadMethod(Stream stream) { List<byte> list = new List<byte>(); byte[] array = new byte[32]; int count; while ((count = stream.Read(array, 0, array.Length)) > 0) { list.AddRange(array.Take(count)); } return list.ToArray(); } } internal class SpritesUtil { public static Sprite LoadPNGTOSprite(byte[] file) { //IL_0000: 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_0035: Unknown result type (might be due to invalid IL or missing references) new Sprite(); Texture2D val = LoadPNGToTexture(file); return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f), 100f); } private static Texture2D LoadPNGToTexture(byte[] file) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2); if (ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(file))) { return val; } return null; } } } namespace BloodyShop.Client.UI { internal class UIManager { public static UIBase UiBase { get; private set; } public static ShopPanel ShopPanel { get; private set; } public static PanelConfig panelCOnfig { get; private set; } public static MenuPanel MenuPanel { get; private set; } public static AdminMenuPanel AdminMenuPanel { get; private set; } public static int SizeOfProdutcs { get; set; } internal static void Initialize() { //IL_0002: 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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) UniverseLibConfig val = default(UniverseLibConfig); val.Disable_EventSystem_Override = false; val.Force_Unlock_Mouse = false; val.Allow_UI_Selection_Outside_UIBase = true; val.Unhollowed_Modules_Folder = Path.Combine(Paths.BepInExRootPath, "interop"); UniverseLibConfig val2 = val; Universe.Init(3f, (Action)OnInitialized, (Action<string, LogType>)LogHandler, val2); } private static void OnInitialized() { UiBase = UniversalUI.RegisterUI(((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds).ToString(), (Action)UiUpdate); } public static void CreateAllPanels() { CreateMenuPanel(); CreateShopPanel(); CreatePanelCOnfigPanel(); } public static void showAllPanels() { ShowMenuPanel(); ShowShopPanel(); ShowPanelConfigPanel(); } public static void HideAllPanels() { HideMenuPanel(); HideShopPanel(); HidePanelConfigPanel(); } public static void DestroyAllPanels() { HideMenuPanel(); HideShopPanel(); HidePanelConfigPanel(); } public static void CreateMenuPanel() { if (ClientDB.IsAdmin) { AdminMenuPanel = new AdminMenuPanel(UiBase); ((UIModel)AdminMenuPanel).SetActive(true); } else { MenuPanel = new MenuPanel(UiBase); ((UIModel)MenuPanel).SetActive(true); } } public static void ShowMenuPanel() { if (ClientDB.IsAdmin) { ((UIModel)AdminMenuPanel).SetActive(true); } else { ((UIModel)MenuPanel).SetActive(true); } } public static void HideMenuPanel() { if (ClientDB.IsAdmin) { ((UIModel)AdminMenuPanel).SetActive(false); } else { ((UIModel)MenuPanel).SetActive(false); } } public static void DestroyMenuPanel() { if (ClientDB.IsAdmin) { ((UIModel)AdminMenuPanel).Destroy(); } else { ((UIModel)MenuPanel).Destroy(); } } public static void CreateShopPanel() { ShopPanel = new ShopPanel(UiBase); ((UIModel)ShopPanel).SetActive(false); } public static void ShowShopPanel() { if (ClientDB.shopOpen) { ((UIModel)ShopPanel).SetActive(true); } } public static void HideShopPanel() { ((UIModel)ShopPanel).SetActive(false); } public static void DestroyShopPanel() { ((UIModel)ShopPanel).Destroy(); } public static void CreatePanelCOnfigPanel() { if (ClientDB.IsAdmin) { panelCOnfig = new PanelConfig(UiBase); ((UIModel)panelCOnfig).SetActive(false); } } public static void ShowPanelConfigPanel() { if (ClientDB.IsAdmin) { ((UIModel)panelCOnfig).SetActive(true); } } public static void HidePanelConfigPanel() { if (ClientDB.IsAdmin) { ((UIModel)panelCOnfig).SetActive(false); } } public static void DestroyPanelConfigPanel() { if (ClientDB.IsAdmin) { ((UIModel)panelCOnfig).Destroy(); } } public static void RefreshDataPanel() { ShopPanel.RefreshData(); if (ClientDB.IsAdmin) { panelCOnfig.GetActivePanel().RefreshData(); panelCOnfig.GetCurrencyPanel().RefreshData(); } } public static void RefreshDataAddPanel() { panelCOnfig.GetActivePanel().RefreshData(); panelCOnfig.GetCurrencyPanel().RefreshData(); } private static void UiUpdate() { } private static void LogHandler(string message, LogType type) { } } } namespace BloodyShop.Client.UI.Panels.User { public class MenuPanel : PanelBase { public enum VerticalAnchor { Top, Bottom } public static VerticalAnchor NavbarAnchor = VerticalAnchor.Top; private static readonly Vector2 NAVBAR_DIMENSIONS = new Vector2(1020f, 35f); private int iconWH = 45; public static MenuPanel Instance { get; private set; } public override string Name => "Bloody Shop Menu"; public override int MinWidth => 70; public override int MinHeight => 50; public override Vector2 DefaultAnchorMin => new Vector2(0.5f, 1f); public override Vector2 DefaultAnchorMax => new Vector2(0.5f, 1f); public override Vector2 DefaultPosition => new Vector2((float)(-(((PanelBase)this).MinWidth / 2)), (float)Screen.height); public override bool CanDragAndResize => false; public static RectTransform NavBarRect { get; private set; } public GameObject NavbarTabButtonHolder { get; private set; } public ButtonRef closeBtn { get; private set; } public ButtonRef shopBtn { get; private set; } public ButtonRef adminBtn { get; private set; } public Text stateTXT { get; private set; } public bool active { get; private set; } public MenuPanel(UIBase owner) : base(owner) { Instance = this; } protected override void ConstructPanelContent() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) active = true; ((Graphic)((PanelBase)this).TitleBar.GetComponent<Image>()).color = new Color(1f, 1f, 1f, 0f); ((Graphic)((UIModel)this).UIRoot.GetComponent<Image>()).color = new Color(233f, 237f, 240f, 0.2f); GameObject val = UIFactory.CreateUIObject("MainNavbar", ((UIModel)this).UIRoot, default(Vector2)); UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(val, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)5, (int?)4, (int?)4, (int?)4, (int?)4, (TextAnchor?)(TextAnchor)4); NavBarRect = val.GetComponent<RectTransform>(); NavBarRect.pivot = new Vector2(0.5f, 1f); SetNavBarAnchor(); shopBtn = UIFactory.CreateButton(val, "ShopButton", "", (Color?)new Color(1f, 1f, 1f, 1f)); GameObject gameObject = ((Component)shopBtn.Component).gameObject; int? num = iconWH; int? num2 = iconWH; int? num3 = iconWH; int? num4 = iconWH; UIFactory.SetLayoutElement(gameObject, num, num2, (int?)0, (int?)0, num3, num4, (bool?)null); configShopButtonPanel(); } public static void SetNavBarAnchor() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00be: 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) switch (NavbarAnchor) { case VerticalAnchor.Top: NavBarRect.anchorMin = new Vector2(0.5f, 1f); NavBarRect.anchorMax = new Vector2(0.5f, 1f); NavBarRect.anchoredPosition = new Vector2(NavBarRect.anchoredPosition.x, 0f); NavBarRect.sizeDelta = NAVBAR_DIMENSIONS; break; case VerticalAnchor.Bottom: NavBarRect.anchorMin = new Vector2(0.5f, 0f); NavBarRect.anchorMax = new Vector2(0.5f, 0f); NavBarRect.anchoredPosition = new Vector2(NavBarRect.anchoredPosition.x, 35f); NavBarRect.sizeDelta = NAVBAR_DIMENSIONS; break; } } public void closeShop() { configShopButtonPanel(); } public void openShop() { configShopButtonPanel(); } private static void OpenShopPanel() { UIManager.ShowShopPanel(); } private void configShopButtonPanel() { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (!ClientDB.shopOpen) { Sprite sprite = SpritesUtil.LoadPNGTOSprite(Resources.shop_close); Image component = shopBtn.GameObject.GetComponent<Image>(); component.sprite = sprite; ((Graphic)component).color = new Color(1f, 1f, 1f, 1f); ButtonRef obj = shopBtn; obj.OnClick = (Action)Delegate.Remove(obj.OnClick, new Action(OpenShopPanel)); } else { Sprite sprite2 = SpritesUtil.LoadPNGTOSprite(Resources.shop_open); Image component2 = shopBtn.GameObject.GetComponent<Image>(); component2.sprite = sprite2; ((Graphic)component2).color = new Color(1f, 1f, 1f, 1f); ButtonRef obj2 = shopBtn; obj2.OnClick = (Action)Delegate.Combine(obj2.OnClick, new Action(OpenShopPanel)); } } } public class ShopPanel : PanelBase { public GameObject NavbarHead; public GameObject NavbarFoot; public Dropdown MouseInspectDropdown; public GameObject ContentHolder; public GameObject ContentProduct; public GameObject ContentPagination; public RectTransform ContentRect; public Text alertTXT; public GameObject contentScroll; public InputFieldRef searchInputTXT; public List<GameObject> productsListLayers = new List<GameObject>(); public int CurrentDisplayedIndex; public List<PrefabModel> items; public static List<(int index, InputFieldRef input)> _quantityArrayCache = new List<(int, InputFieldRef)>(); public static List<(int index, int input)> _stackArrayCache = new List<(int, int)>(); private static int limit = 10; private static int page = 0; private static int total = 0; private static int skip = 0; public static string textSearch = ""; private List<(int index, CurrencyModel currency)> _currenciesArrayCache = new List<(int, CurrencyModel)>(); public static ShopPanel Instance { get; private set; } public override string Name => ClientDB.shopName; public override bool CanDragAndResize => true; public override int MinWidth => 680; public override int MinHeight => 535; public override Vector2 DefaultAnchorMin => new Vector2(0.5f, 1f); public override Vector2 DefaultAnchorMax => new Vector2(0.5f, 1f); public override Vector2 DefaultPosition => new Vector2((float)(-(((PanelBase)this).MinWidth / 2)), (float)(((PanelBase)this).MinWidth / 2)); public static float CurrentPanelWidth { get { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Rect rect = ((PanelBase)Instance).Rect.rect; return ((Rect)(ref rect)).width; } } public static float CurrentPanelHeight { get { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Rect rect = ((PanelBase)Instance).Rect.rect; return ((Rect)(ref rect)).height; } } public static RectTransform ImageIconRect { get; private set; } public CurrencyModel currency { get; private set; } public ShopPanel(UIBase owner) : base(owner) { Instance = this; } public override void Update() { } public override void OnFinishResize() { ((PanelBase)this).OnFinishResize(); } protected override void ConstructPanelContent() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_0538: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_0636: Expected O, but got Unknown //IL_0650: Unknown result type (might be due to invalid IL or missing references) //IL_0656: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) textSearch = ""; page = 0; ButtonRef val = UIFactory.CreateButton(((Component)((PanelBase)this).TitleBar.transform.Find("CloseHolder")).gameObject.gameObject, "RefreshBtn", "Refresh", (Color?)null); RuntimeHelper.SetColorBlock((Selectable)(object)val.Component, (Color?)new Color(0.12156863f, 0.38039216f, 47f / 85f), (Color?)new Color(12f / 85f, 0.44313726f, 0.6392157f), (Color?)new Color(0.16078432f, 0.5019608f, 37f / 51f), (Color?)null); GameObject gameObject = ((Component)val.Component).gameObject; int? num = 25; int? num2 = ((PanelBase)this).MinWidth / 2; int? num3 = num; int? num4 = ((PanelBase)this).MinWidth / 2; int? num5 = 25; UIFactory.SetLayoutElement(gameObject, num2, num3, (int?)null, (int?)null, num4, num5, (bool?)null); ((Component)val.Component).transform.SetSiblingIndex(((Component)val.Component).transform.GetSiblingIndex() - 1); val.OnClick = (Action)Delegate.Combine(val.OnClick, new Action(RefreshAction)); GameObject val2 = UIFactory.CreateHorizontalGroup(((PanelBase)this).ContentRoot.gameObject, "HeaderItem", true, true, true, true, 4, default(Vector4), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)null); num5 = 0; num4 = 60; num = 60; int? num6 = 0; UIFactory.SetLayoutElement(val2, (int?)null, num4, num6, num5, (int?)null, num, (bool?)null); searchInputTXT = UIFactory.CreateInputField(val2, "SearchInput", "Search Text"); GameObject gameObject2 = searchInputTXT.GameObject; int? num7 = ((PanelBase)this).MinWidth - 100; int? num8 = 60; num6 = 0; num = 60; UIFactory.SetLayoutElement(gameObject2, num7, num8, (int?)9999, num6, (int?)(((PanelBase)this).MinWidth - 100), num, (bool?)null); searchInputTXT.OnValueChanged += SearchActionText; ButtonRef obj = UIFactory.CreateButton(val2, "saveBtn-", "Search", (Color?)new Color(0.20392157f, 0.28627452f, 0.36862746f)); GameObject gameObject3 = ((Component)obj.Component).gameObject; int? num9 = 80; int? num10 = 60; num = 0; num6 = 60; UIFactory.SetLayoutElement(gameObject3, num9, num10, (int?)0, num, (int?)80, num6, (bool?)null); obj.OnClick = (Action)Delegate.Combine(obj.OnClick, new Action(SearchAction)); GameObject contentRoot = ((PanelBase)this).ContentRoot; bool? flag = true; bool? flag2 = true; bool? flag3 = true; bool? flag4 = true; int? num11 = 4; num6 = 5; num = 5; UIFactory.SetLayoutGroup<VerticalLayoutGroup>(contentRoot, flag, flag2, flag3, flag4, num11, (int?)null, (int?)null, num6, num, (TextAnchor?)null); GameObject val3 = UIFactory.CreateHorizontalGroup(((PanelBase)this).ContentRoot.gameObject, "HeaderItem", true, true, true, true, 4, default(Vector4), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)null); GameObject gameObject4 = ((Component)UIFactory.CreateLabel(val3, "itemAvalTxt", "Stock", (TextAnchor)3, default(Color), true, 14)).gameObject; int? num12 = 50; int? num13 = 60; num = 0; num6 = 60; UIFactory.SetLayoutElement(gameObject4, num12, num13, (int?)0, num, (int?)50, num6, (bool?)null); GameObject gameObject5 = ((Component)UIFactory.CreateLabel(val3, "itemNameTxt", "Name", (TextAnchor)3, default(Color), true, 14)).gameObject; int? num14 = 60; int? num15 = 60; num6 = 0; num = 60; UIFactory.SetLayoutElement(gameObject5, num14, num15, (int?)0, num6, (int?)60, num, (bool?)null); GameObject obj2 = UIFactory.CreateUIObject("IconItem", val3, default(Vector2)); int? num16 = 210; int? num17 = 60; num = 0; num6 = 60; UIFactory.SetLayoutElement(obj2, num16, num17, (int?)0, num, (int?)210, num6, (bool?)null); GameObject gameObject6 = ((Component)UIFactory.CreateLabel(val3, "itemPriceTxt", "Price", (TextAnchor)3, default(Color), true, 14)).gameObject; int? num18 = 100; int? num19 = 60; num6 = 0; num = 60; UIFactory.SetLayoutElement(gameObject6, num18, num19, (int?)0, num6, (int?)100, num, (bool?)null); GameObject gameObject7 = ((Component)UIFactory.CreateLabel(val3, "itemAvalTxt", "Quantity", (TextAnchor)3, default(Color), true, 14)).gameObject; int? num20 = 50; int? num21 = 60; num = 0; num6 = 60; UIFactory.SetLayoutElement(gameObject7, num20, num21, (int?)0, num, (int?)50, num6, (bool?)null); GameObject obj3 = UIFactory.CreateUIObject("BuyItem", val3, default(Vector2)); int? num22 = 110; int? num23 = 60; num6 = 0; num = 60; UIFactory.SetLayoutElement(obj3, num22, num23, (int?)0, num6, (int?)110, num, (bool?)null); num = 0; num6 = 60; num4 = 60; num5 = 0; UIFactory.SetLayoutElement(val3, (int?)null, num6, num5, num, (int?)null, num4, (bool?)null); contentScroll = new GameObject(); AutoSliderScrollbar val4 = default(AutoSliderScrollbar); UIFactory.CreateScrollView(((PanelBase)this).ContentRoot.gameObject, "scrollView", ref contentScroll, ref val4, default(Color)); RuntimeHelper.SetColorBlock((Selectable)(object)val4.Slider, (Color?)new Color(0.83137256f, 0.6745098f, 0.050980393f), (Color?)new Color(0.95686275f, 0.8156863f, 21f / 85f), (Color?)new Color(0.96862745f, 44f / 51f, 37f / 85f), (Color?)null); CreateListProductsLayout(); ((UIModel)this).SetActive(true); } public void CreateListProductsLayout() { //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_05bb: Unknown result type (might be due to invalid IL or missing references) //IL_05c1: Unknown result type (might be due to invalid IL or missing references) items = ItemsDB.searchItemByNameForShop(textSearch); total = items.Count; productsListLayers = new List<GameObject>(); skip = page * limit; if (total > 0 && skip >= total) { page--; if (page < 0) { page = 0; } skip = page * limit; } int num = skip + 1; _quantityArrayCache = new List<(int, InputFieldRef)>(); _stackArrayCache = new List<(int, int)>(); _currenciesArrayCache = new List<(int, CurrencyModel)>(); foreach (PrefabModel item in items.Skip(skip).Take(limit)) { currency = ShareDB.getCurrency(item.currency); if (currency != null) { GameObject val = UIFactory.CreateHorizontalGroup(contentScroll, "ContentItem-" + num, true, true, true, true, 4, default(Vector4), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)null); string text = ""; text = ((item.PrefabStock > 0) ? item.PrefabStock.ToString() : "-"); GameObject gameObject = ((Component)UIFactory.CreateLabel(val, "itemAvalTxt-" + num, text ?? "", (TextAnchor)4, default(Color), true, 14)).gameObject; int? num2 = 50; int? num3 = 60; int? num4 = 0; int? num5 = 60; UIFactory.SetLayoutElement(gameObject, num2, num3, (int?)0, num4, (int?)50, num5, (bool?)null); GameObject obj = UIFactory.CreateUIObject("IconItem-" + num, val, default(Vector2)); obj.AddComponent<Image>().sprite = item.PrefabIcon; int? num6 = 60; int? num7 = 60; num5 = 0; num4 = 60; UIFactory.SetLayoutElement(obj, num6, num7, (int?)0, num5, (int?)60, num4, (bool?)null); GameObject gameObject2 = ((Component)UIFactory.CreateLabel(val, "itemNameTxt-" + num, $"{item.PrefabStack}x {item.PrefabName}", (TextAnchor)3, default(Color), true, 14)).gameObject; int? num8 = 230; int? num9 = 60; num4 = 0; num5 = 60; UIFactory.SetLayoutElement(gameObject2, num8, num9, (int?)0, num4, (int?)230, num5, (bool?)null); GameObject gameObject3 = ((Component)UIFactory.CreateLabel(val, "itemPriceTxt-" + num, $"{item.PrefabPrice}x {currency.name}", (TextAnchor)3, default(Color), true, 14)).gameObject; int? num10 = 100; int? num11 = 60; num5 = 0; num4 = 60; UIFactory.SetLayoutElement(gameObject3, num10, num11, (int?)0, num5, (int?)100, num4, (bool?)null); _currenciesArrayCache.Add((num, currency)); InputFieldRef val2 = UIFactory.CreateInputField(val, "quantityNew|" + num, "Quantity"); GameObject gameObject4 = val2.GameObject; int? num12 = 40; int? num13 = 60; num4 = 0; num5 = 60; UIFactory.SetLayoutElement(gameObject4, num12, num13, (int?)0, num4, (int?)40, num5, (bool?)null); val2.Component.contentType = (ContentType)2; val2.Text = "1"; val2.Text.PadLeft(2); _quantityArrayCache.Add((num, val2)); _stackArrayCache.Add((num, item.PrefabStack)); ButtonRef obj2 = UIFactory.CreateButton(val, "buyItemBtn-" + num, "BUY", (Color?)new Color(0.83137256f, 0.6745098f, 0.050980393f)); GameObject gameObject5 = ((Component)obj2.Component).gameObject; int? num14 = 100; int? num15 = 60; num5 = 0; num4 = 60; UIFactory.SetLayoutElement(gameObject5, num14, num15, (int?)0, num5, (int?)100, num4, (bool?)null); obj2.OnClick = (Action)Delegate.Combine(obj2.OnClick, new Action(BuyAction)); num4 = 0; num5 = 60; int? num16 = 60; int? num17 = 0; UIFactory.SetLayoutElement(val, (int?)null, num5, num17, num4, (int?)null, num16, (bool?)null); productsListLayers.Add(val); GameObject val3 = UIFactory.CreateHorizontalGroup(contentScroll, "Separator-" + num, true, true, true, true, 4, default(Vector4), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)null); GameObject gameObject6 = ((Component)UIFactory.CreateLabel(val3, "FakeTextt-" + num, "", (TextAnchor)4, default(Color), true, 14)).gameObject; int? num18 = ((PanelBase)this).MinWidth; int? num19 = 2; num17 = 0; num16 = 2; UIFactory.SetLayoutElement(gameObject6, num18, num19, (int?)9999, num17, (int?)((PanelBase)this).MinWidth, num16, (bool?)null); productsListLayers.Add(val3); num++; } } createPagination(); } private void createPagination() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0091: 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_00a8: 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) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) decimal num = Math.Ceiling((decimal)(total / limit)); GameObject contentRoot = ((PanelBase)this).ContentRoot; bool? flag = true; bool? flag2 = true; bool? flag3 = true; bool? flag4 = true; int? num2 = 4; int? num3 = 5; int? num4 = 5; UIFactory.SetLayoutGroup<VerticalLayoutGroup>(contentRoot, flag, flag2, flag3, flag4, num2, (int?)null, (int?)null, num3, num4, (TextAnchor?)null); ContentPagination = new GameObject(); ContentPagination = UIFactory.CreateHorizontalGroup(((PanelBase)this).ContentRoot.gameObject, "PaginationGroup", true, true, true, true, 4, default(Vector4), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)null); GameObject gameObject = ((Component)UIFactory.CreateLabel(ContentPagination, "footerText", $"Products: {total} Pages: {num + 1m}", (TextAnchor)3, default(Color), true, 14)).gameObject; int? num5 = 50; int? num6 = 30; num4 = 0; num3 = 30; UIFactory.SetLayoutElement(gameObject, num5, num6, (int?)0, num4, (int?)50, num3, (bool?)null); if (items.Count > limit) { int num7 = page + 1; if (page - 1 >= 0) { ButtonRef obj = UIFactory.CreateButton(ContentPagination, "previousBtn", $"<- Page {num7 - 1}", (Color?)null); RuntimeHelper.SetColorBlockAuto((Selectable)(object)obj.Component, new Color(0.09019608f, 0.64705884f, 0.5372549f)); GameObject gameObject2 = ((Component)obj.Component).gameObject; int? num8 = 150; int? num9 = 30; num3 = 0; num4 = 30; UIFactory.SetLayoutElement(gameObject2, num8, num9, (int?)0, num3, (int?)150, num4, (bool?)null); obj.OnClick = (Action)Delegate.Combine(obj.OnClick, new Action(changePage)); } if ((decimal)(page + 1) <= num) { ButtonRef obj2 = UIFactory.CreateButton(ContentPagination, "nextBtn", $"Page {num7 + 1} ->", (Color?)null); RuntimeHelper.SetColorBlockAuto((Selectable)(object)obj2.Component, new Color(0.09019608f, 0.64705884f, 0.5372549f)); GameObject gameObject3 = ((Component)obj2.Component).gameObject; int? num10 = 150; int? num11 = 30; num4 = 0; num3 = 30; UIFactory.SetLayoutElement(gameObject3, num10, num11, (int?)0, num4, (int?)150, num3, (bool?)null); obj2.OnClick = (Action)Delegate.Combine(obj2.OnClick, new Action(changePage)); } } } private void SearchActionText(string str) { textSearch = str.ToLower(); page = 0; RefreshData(); CreateListProductsLayout(); } private void SearchAction() { textSearch = searchInputTXT.Text.ToLower(); page = 0; RefreshData(); CreateListProductsLayout(); } private void RefreshAction() { UIManager.RefreshDataPanel(); } public void RefreshData() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) foreach (GameObject productsListLayer in productsListLayers) { Object.Destroy((Object)(object)productsListLayer, 0f); } productsListLayers = new List<GameObject>(); UIFactory.CreateHorizontalGroup(contentScroll, "ContentItem", true, true, true, true, 4, default(Vector4), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)null); Object.Destroy((Object)(object)ContentPagination, 0f); } private void BuyAction() { Sound.Play(Resources.cash_register_x); string s = ((Object)EventSystem.current.currentSelectedGameObject).name.Replace("buyItemBtn-", ""); PrefabModel prefabModel = items[int.Parse(s) - 1]; serachQuantityInput(int.Parse(s)); s = ItemsDB.searchIndexForProduct(stack: serachStackInput(int.Parse(s)), currency: serachCurrencyInput(int.Parse(s)), GUID: prefabModel.PrefabGUID).ToString(); if (s != "-1") { RefreshAction(); } } private string serachQuantityInput(int indexSearch) { foreach (var (num, val) in _quantityArrayCache) { if (num == indexSearch) { if (val.Text == "") { return "0"; } return val.Text; } } return "0"; } private int serachStackInput(int indexSearch) { foreach (var (num, num2) in _stackArrayCache) { if (num == indexSearch) { if (num2 == 0) { return 1; } return num2; } } return 1; } private CurrencyModel serachCurrencyInput(int indexSearch) { foreach (var (num, result) in _currenciesArrayCache) { if (num == indexSearch) { return result; } } return null; } private void changePage() { if (((Object)EventSystem.current.currentSelectedGameObject).name == "nextBtn") { page++; } else { page--; } RefreshData(); CreateListProductsLayout(); } } } namespace BloodyShop.Client.UI.Panels.Admin { public class AddCurrencyPanel : UIModel { public GameObject NavbarHolder; public GameObject ContentHolder; public GameObject ContentProduct; public RectTransform ContentRect; public Text alertTXT; public GameObject contentScroll; public Dropdown dropdownCurrency; public Dropdown dropdownitem; public ButtonRef OpenCloseStoreBtn; public List<GameObject> currencyListLayers = new List<GameObject>(); public List<PrefabModel> currencyModel = new List<PrefabModel>(); public int CurrentDisplayedIndex; public static bool active = false; private InputFieldRef searchInputTXT; private static int limit = 10; private static GameObject uiRoot; private List<Dropdown> currencyDropArray = new List<Dropdown>(); public PanelConfig Parent { get; } public static AddCurrencyPanel Instance { get; private set; } public static int MinWidth => 680; public override GameObject UIRoot => uiRoot; public AddCurrencyPanel(PanelConfig parent) { Parent = parent; } public override void ConstructUI(GameObject content) { //IL_000e: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Expected O, but got Unknown //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) active = true; uiRoot = UIFactory.CreateUIObject("ConfigPanel", content, default(Vector2)); GameObject val = UIFactory.CreateHorizontalGroup(uiRoot, "HeaderItem", true, true, true, true, 4, default(Vector4), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)null); int? num = 0; int? num2 = 60; int? num3 = 60; int? num4 = 0; UIFactory.SetLayoutElement(val, (int?)null, num2, num4, num, (int?)null, num3, (bool?)null); searchInputTXT = UIFactory.CreateInputField(val, "SearchInput", "Search Text"); GameObject gameObject = searchInputTXT.GameObject; int? num5 = MinWidth - 100; int? num6 = 60; num4 = 0; num3 = 60; UIFactory.SetLayoutElement(gameObject, num5, num6, (int?)9999, num4, (int?)(MinWidth - 100), num3, (bool?)null); searchInputTXT.OnValueChanged += SearchActionText; ButtonRef obj = UIFactory.CreateButton(val, "saveBtn-", "Search", (Color?)new Color(0.20392157f, 0.28627452f, 0.36862746f)); GameObject gameObject2 = ((Component)obj.Component).gameObject; int? num7 = 80; int? num8 = 60; num3 = 0; num4 = 60; UIFactory.SetLayoutElement(gameObject2, num7, num8, (int?)0, num3, (int?)80, num4, (bool?)null); obj.OnClick = (Action)Delegate.Combine(obj.OnClick, new Action(SearchAction)); GameObject obj2 = uiRoot; bool? flag = true; bool? flag2 = true; bool? flag3 = true; bool? flag4 = true; int? num9 = 4; num4 = 5; num3 = 5; UIFactory.SetLayoutGroup<VerticalLayoutGroup>(obj2, flag, flag2, flag3, flag4, num9, (int?)null, (int?)null, num4, num3, (TextAnchor?)null); GameObject val2 = UIFactory.CreateHorizontalGroup(uiRoot, "HeaderItem", true, true, true, true, 4, default(Vector4), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)null); GameObject obj3 = UIFactory.CreateUIObject("IconItem", val2, default(Vector2)); int? num10 = 60; int? num11 = 60; num3 = 0; num4 = 60; UIFactory.SetLayoutElement(obj3, num10, num11, (int?)0, num3, (int?)60, num4, (bool?)null); Text obj4 = UIFactory.CreateLabel(val2, "itemNameTxt", "Name", (TextAnchor)3, default(Color), true, 14); GameObject gameObject3 = ((Component)obj4).gameObject; int? num12 = 310; int? num13 = 60; num4 =