Иконка ресурса

FREE IQKits : 2.5.5 2.5.5

Нет прав для скачивания
C#:
using System.Collections.Generic;
using Newtonsoft.Json;
using UnityEngine;
using Object = System.Object;
using Oxide.Core.Plugins;
using System;
using System.Text;
using Pool = Facepunch.Pool;
using UnityEngine.UI;
using Oxide.Game.Rust.Cui;
using System.Linq;
using System.Collections;
using UnityEngine.Networking;
using Oxide.Core;
namespace Oxide.Plugins {
    [Info("IQKits", "Mercury", "2.5.5")]
    [Description("Лучшие наборы из всех,которые есть")]
    public class IQKits : RustPlugin {
        private void PresetRemove(BasePlayer player, String presetName) {
            if (!config.presetsItems.ContainsKey(presetName)) {
                SendChat(GetLang("CHAT_ALERT_REMOVE_PRESET_ERROR_NO_ITEMS", player.UserIDString), player);
                return;
            }
            config.presetsItems.Remove(presetName);
            SendChat(GetLang("CHAT_ALERT_REMOVE_PRESET_SUCCESS", player.UserIDString, presetName), player);
            SaveConfig();
        }
        private void RemoveKit(BasePlayer player, String categoryName, String presetName) {
            if (!config.categoryKits.TryGetValue(categoryName, out Configuration.CategoryInfo categoryInfo)) {
                SendChat(GetLang("CHAT_ADMIN_COMMAND_KIT_NO_CATEGORY", player.UserIDString), player);
                return;
            }
            if (String.IsNullOrWhiteSpace(presetName)) {
                config.categoryKits.Remove(categoryName);
                SendChat(GetLang("CHAT_ADMIN_COMMAND_KIT_CATEGORY_REMOVE", player.UserIDString, categoryName), player);
                return;
            }
            if (!categoryInfo.kitList.ContainsKey(presetName)) {
                SendChat(GetLang("CHAT_ADMIN_COMMAND_KIT_TRY_REMOVE_NO_PRESET_KIT", player.UserIDString, presetName), player);
                return;
            }
            if (config.categoryKits[categoryName].kitList.Count == 1) {
                config.categoryKits.Remove(categoryName);
                SendChat(GetLang("CHAT_ADMIN_COMMAND_KIT_CATEGORY_REMOVE", player.UserIDString, categoryName), player);
                return;
            }
            config.categoryKits[categoryName].kitList.Remove(presetName);
            SendChat(GetLang("CHAT_ADMIN_COMMAND_KIT_REMOVE_PRESET_IN_CATEGORY", player.UserIDString, presetName, categoryName), player);
        }
        private Boolean IsRank(BasePlayer player, String rankKey) {
            if (!IQRankSystem) return true;
            if (String.IsNullOrWhiteSpace(rankKey)) return true;
            return (Boolean)IQRankSystem?.Call("API_GET_AVAILABILITY_RANK_USER", player.userID.Get(), rankKey);
        }
        private Boolean TryGetKitInfo(BasePlayer player, String categoryKey, String kitName, out CategoryInfo.KitInfo kitValue) {
            kitValue = null;
            if (!config.presetsItems.ContainsKey(kitName)) return false;
            if (!config.categoryKits.TryGetValue(categoryKey, out Configuration.CategoryInfo categoryConfig) || !categoryConfig.kitList.ContainsKey(kitName)) return false;
            if (!repositoryKits.TryGetValue(player.UserIDString, out Dictionary<String, CategoryInfo> categoryInfo) || !categoryInfo.TryGetValue(categoryKey, out CategoryInfo categoryValue)) return true;
            categoryValue.playerKitsTaked.TryGetValue(kitName, out kitValue);
            return true;
        }
        private void DrawUI_InfoKit_Panel_InfoKit(BasePlayer player, Configuration.CategoryInfo categoryInfo, List<Configuration.ItemKits> presetItems, String categoryKey, String kitKey) {
            if (_interface == null) return;
            String Interface = InterfaceBuilder.GetInterface("UI_KIT_ITEM_PANEL_INFO_KIT");
            if (Interface == null) return;
            if (!categoryInfo.kitList.TryGetValue(kitKey, out Configuration.KitInfo kitInfo)) return;
            String getStatusKit = GetStatusAvaliable(player, categoryKey, kitKey);
            String statusKit = String.IsNullOrWhiteSpace(getStatusKit) ? GetLang("UI_KIT_AVALIABLE_OPEN", player.UserIDString) : getStatusKit;
            String descriptionKit = kitInfo.type switch {
                TypeKit.OnlyAmount => GetLang("UI_KIT_DESCRIPTION", player.UserIDString, "00:00:00", kitInfo.amount, presetItems.Count), TypeKit.CooldownAndAmount => GetLang("UI_KIT_DESCRIPTION", player.UserIDString, ConvertMinutesToTimeFormat(kitInfo.cooldown), kitInfo.amount, presetItems.Count), TypeKit.OnlyCooldown => GetLang("UI_KIT_DESCRIPTION", player.UserIDString, ConvertMinutesToTimeFormat(kitInfo.cooldown), GetLang("UI_KIT_DESCRIPTION_ONLY_COOLDOWN", player.UserIDString), presetItems.Count), _ => String.Empty
            }
            ;
            Interface = Interface.Replace("%NAME_KIT%", kitInfo.title.GetLanguageText(player));
            Interface = Interface.Replace("%KIT_ICON%", _imageUI.GetImage(kitInfo.iconKey));
            Interface = Interface.Replace("%DESCRIPTION_KIT%", descriptionKit);
            Interface = Interface.Replace("%AVALIABLE_STATUS_KIT%", statusKit);
            AddUI(player, Interface);
            return;
            String ConvertMinutesToTimeFormat(Int32 totalMinutes) {
                Int32 hours = totalMinutes / 60;
                Int32 minutes = totalMinutes % 60;
                return $"{hours:00}:{minutes:00}:{0:00}";
            }
        }
        private Int32 GetLeftAmountKit(BasePlayer player, String categoryKey, String kitName, Int32 configKitAmount) {
            return TryGetKitInfo(player, categoryKey, kitName, out CategoryInfo.KitInfo kitValue) ? configKitAmount - (kitValue?.amount ?? 0) <= 0 ? 0 : configKitAmount - (kitValue?.amount ?? 0) : configKitAmount;
        }
        private String GetRankName(String rankKey) {
            if (!IQRankSystem) return String.Empty;
            return (String)IQRankSystem?.Call("API_GET_RANK_NAME", rankKey);
        }
        private void DrawUI_InfoKit_Panel(BasePlayer player, String categoryKey, String kitKey) {
            if (!config.presetsItems.TryGetValue(kitKey, out List<Configuration.ItemKits> presetItems)) return;
            if (!config.categoryKits.TryGetValue(categoryKey, out Configuration.CategoryInfo categoryInfo)) return;
            if (_interface == null) return;
            String Interface = InterfaceBuilder.GetInterface("UI_KIT_ITEM_PANEL");
            if (Interface == null) return;
            AddUI(player, Interface);
            DrawUI_InfoKit_Panel_InfoKit(player, categoryInfo, presetItems, categoryKey, kitKey);
            DrawUI_InfoKit_Panel_ScrollBar(player, presetItems);
        }
        public class Configuration {
            [JsonProperty(LanguageEn ? "Auto kits settings on respawn" : "Настройка автоматических наборов при возрождении")]
            public AutoKitController autoKitController;
            public class ItemKits {
                [JsonProperty(LanguageEn ? "Item type: 0 - Physical item, 1 - Command" : "Тип предмета : 0 - Физический предмет, 1 - Команда")]
                public TypeKitItem typeItem;
                [JsonProperty(LanguageEn ? "Physical item settings" : "Настройка физического предмета")]
                public PhysicItem physicItem;
                [JsonProperty(LanguageEn ? "Command settings" : "Настройка команды")]
                public Command commandItem;
                public class PhysicItem {
                    [JsonProperty(LanguageEn ? "Container where the item will be placed [0 - Clothing, 1 - Belt, 2 - Main]" : "Контейнер в котором будет предмет [0 - Одежда, 1 - Пояс, 2 - Основной]")]
                    public ContainerItem containerItem;
                    [JsonProperty("Shortname")]
                    public String shortname;
                    [JsonProperty(LanguageEn ? "Quantity" : "Количество")]
                    public Int32 amount;
                    [JsonProperty("SkinID")]
                    public UInt64 skinID;
                    [JsonProperty(LanguageEn ? "Displayed name [Leave empty for in-game name]" : "Отображаемое имя [Оставьте пустым - тогда будет название из игры]")]
                    public String displayName;
                    [JsonProperty(LanguageEn ? "Container slot where the item will be placed" : "Слот контейнера в котором будет расположен предмет")]
                    public Int32 slotIndex;
                    [JsonProperty(LanguageEn ? "List of item contents" : "Список контента предмета")]
                    public List<ContentItem> contentsItem;
                    [JsonProperty(LanguageEn ? "List of armor modules/inserts for clothing items" : "Список модулей брони/вставок для предметов одежды")]
                    public List<String> armorModules;
                    [JsonProperty(LanguageEn ? "Note text content (for note items)" : "Текст записки (для предметов записки)")]
                    public String noteText;
                    public class ContentItem {
                        [JsonProperty(LanguageEn ? "Ammunition [true], other content [false]" : "Патроны [true], другой контент [false]")]
                        public Boolean ammoOrContent;
                        [JsonProperty("Shortname")]
                        public String shortname;
                        [JsonProperty(LanguageEn ? "Quantity" : "Количество")]
                        public Int32 amount;
                    }
                    public Item BuildItem() {
                        Item itemBuild = ItemManager.CreateByName(shortname, amount, skinID);
                        if (itemBuild == null) return null;
                        if(!String.IsNullOrWhiteSpace(displayName) && _.ItemIdCorrecteds.Contains(itemBuild.skin)) itemBuild.name = displayName;
                        // Устанавливаем текст для записок
                        if (!String.IsNullOrWhiteSpace(noteText) && shortname == "note") {
                            itemBuild.text = noteText;
                        }
                        // Добавляем модули брони для предметов одежды
                        if (armorModules != null && armorModules.Count > 0) {
                            foreach (String armorModule in armorModules) {
                                if (String.IsNullOrWhiteSpace(armorModule)) continue;
                                ItemDefinition armorModuleDef = ItemManager.FindItemDefinition(armorModule);
                                if (armorModuleDef == null) continue;
                                Item armorModuleItem = ItemManager.CreateByName(armorModule, 1);
                                if (armorModuleItem != null) {
                                    armorModuleItem.MoveToContainer(itemBuild.contents);
                                }
                            }
                        }
                        if (contentsItem == null || contentsItem.Count == 0) return itemBuild;
                        foreach (ContentItem contentItem in contentsItem) {
                            if (contentItem.ammoOrContent) {
                                BaseProjectile weapon = itemBuild.GetHeldEntity() as BaseProjectile;
                                if(!weapon) continue;
                                weapon.primaryMagazine.contents = contentItem.amount;
                                weapon.primaryMagazine.ammoType = ItemManager.FindItemDefinition(contentItem.shortname);
                            }
                            else {
                                Item itemContent = ItemManager.CreateByName(contentItem.shortname, contentItem.amount);
                                itemContent?.MoveToContainer(itemBuild.contents);
                            }
                        }
                        return itemBuild;
                    }
                }
                public class Command {
                    [JsonProperty(LanguageEn ? "Icon name from the folder [data/IQSystem/IQKits/Images]. Without file extension" : "Название иконки из папки [data/IQSystem/IQKits/Images]. Без расширения файла")]
                    public String iconKey;
                    [JsonProperty(LanguageEn ? "Console command [%USERID% - will be replaced with player's Steam64ID]" : "Консольная команда [%USERID% - заменится на Steam64ID игрока]")]
                    public String command;
                    public String BuildCommand(String userID) => command.Replace("%USERID%", userID);
                }
            }
            public class IQChatSetting {
                [JsonProperty(LanguageEn ? "IQChat: Custom prefix in chat" : "IQChat : Кастомный префикс в чате")]
                public String customPrefix;
                [JsonProperty(LanguageEn ? "IQChat: Custom chat avatar [SteamID] (If required)" : "IQChat : Кастомный аватар в чате [SteamID]")]
                public String customAvatar;
            }
            public class KitInfo {
                [JsonProperty(LanguageEn ? "Kit restriction type: 0 - Cooldown, 1 - Amount, 2 - Cooldown + Amount" : "Тип ограничения набора : 0 - Перезарядка, 1 - Количество, 2 - Перезарядка + Количество")]
                public TypeKit type;
                [JsonProperty(LanguageEn ? "Additional permissions required to access this kit (category permission has priority). Leave empty to ignore" : "Дополнительные разрешения для доступа к этому набору (разрешение категории главнее). Оставьте пустым - не учитывать")]
                public List<String> additionalPermissions = new List<String>();
                [JsonProperty(LanguageEn ? "Kit name" : "Название для набора")]
                public LanguageText title;
                [JsonProperty(LanguageEn ? "Icon name from the folder [data/IQSystem/IQKits/Images]. Without file extension" : "Название иконки из папки [data/IQSystem/IQKits/Images]. Без расширения файла")]
                public String iconKey;
                [JsonProperty(LanguageEn ? "Kit cooldown time in minutes [For types 0, 2]" : "Время перезарядки набора в минутах [Для типов 0, 2]")]
                public Int32 cooldown;
                [JsonProperty(LanguageEn ? "Number of available kits [For types 1, 2]" : "Количество доступных наборов [Для типов 1, 2]")]
                public Int32 amount;
                [JsonProperty(LanguageEn ? "How many minutes after a server wipe the kit becomes available" : "Через сколько минут разблокируется набор после вайпа сервера")]
                public Int32 unlockedAfterMinutes;
                [JsonProperty(LanguageEn ? "Can this kit be taken during a raid block? [true - yes/false - no]" : "Можно ли взять данный набор во время рейд-блока [true - да/false - нет]")]
                public Boolean takeIsRaidblock;
                public Double GetUnblockTime() => unlockedAfterMinutes > 0 ? (unlockedAfterMinutes - DateTime.UtcNow.Subtract(SaveRestore.SaveCreatedTime).TotalMinutes) * 60.0 : 0;
            }
            public class CategoryInfo {
                [JsonProperty(LanguageEn ? "Hide the category if the player does not have permissions for it [true], otherwise, it will be displayed to the player [false].\n\n\n\n\n\n\n\n\n" : "Скрыть категорию, если у игрока нет разрешений на нее [true], иначе она будет отображаться у игрока [false]")]
                public Boolean hideCategoryPermission;
                [JsonProperty(LanguageEn ? "Category name" : "Название категории")]
                public LanguageText title;
                [JsonProperty(LanguageEn ? "Category description" : "Описание категории")]
                public LanguageText description;
                [JsonProperty(LanguageEn ? "Icon name from the folder [data/IQSystem/IQKits/Images]. Without file extension" : "Название иконки из папки [data/IQSystem/IQKits/Images]. Без расширения файла")]
                public String iconKey;
                [JsonProperty(LanguageEn ? "Permission required to access this category and its kits [Leave empty to make it available to everyone]" : "Разрешение с которым будет доступна данная категория и наборы в ней [Оставьте пустым - будет доступен всем]")]
                public String permission;
                [JsonProperty(LanguageEn ? "IQRankSystem: Rank key required to access this kit [Leave empty to ignore]" : "IQRankSystem : Ключ ранга с которым будет доступен этот набор [Оставьте пустым - не будет учитываться]")]
                public String rankKey;
                [JsonProperty(LanguageEn ? "List of item presets for this category [Preset key (Must be unique within the category)] = Settings" : "Список пресетов с предметами для данной категории [Ключ из списка пресетов (Не должны повторяться в одной категории)] = Настройка")]
                public Dictionary<String, KitInfo> kitList = new Dictionary<String, KitInfo>();
            }
            public class LanguageText {
                [JsonProperty(LanguageEn ? "Text in Russian" : "Текст на русском")]
                public String russianText;
                [JsonProperty(LanguageEn ? "Text in English" : "Текст на английском")]
                public String englishText;
                public String GetLanguageText(BasePlayer player) => _.lang.GetLanguage(player.UserIDString).Equals("ru") ? russianText : englishText;
            }
            [JsonProperty(LanguageEn ? "IQChat Settings" : "Настройки IQChat")]
            public IQChatSetting iqchatSetting = new IQChatSetting();
            [JsonProperty(LanguageEn ? "Preset item settings [Unique preset name] = List of items" : "Настройка пресетов с предметами [Уникальное название пресета] = Список предметов")]
            public Dictionary<String, List<ItemKits>> presetsItems = new Dictionary<String, List<ItemKits>>();
            public static Configuration GetNewConfiguration() {
                return new Configuration {
                    iqchatSetting = new IQChatSetting {
                        customPrefix = "[<color=#5A9FDD>IQKits</color>]\n", customAvatar = "0"
                    }
                    , sortedPermissions = true, autoKitController = new AutoKitController {
                        useAutoKit = false, stripInventoryDefaultItems = false, settingAutoKits = new AutoKitController.AutoKits {
                            useRandomAutoKit = false, listAutoKits = new Dictionary<String, AutoKitController.AutoKits.AutoKit>() {
                                ["iqkits.default"]
                                = new AutoKitController.AutoKits.AutoKit {
                                    biomeType = BiomeType.None, itemPresetKey = "AUTO_KIT_DEFAULT",
                                }
                                , ["iqkits.vip"] = new AutoKitController.AutoKits.AutoKit {
                                    biomeType = BiomeType.None, itemPresetKey = "AUTO_KIT_VIP",
                                }
                                ,
                            }
                        }
                    }
                    , categoryKits = new Dictionary<String, CategoryInfo>() {
                        ["DEFAULT_CATEGORY"]
                        = new CategoryInfo {
                            title = new LanguageText {
                                russianText = "НАЧАЛЬНЫЙ", englishText = "STARTING",
                            }
                            , description = new LanguageText {
                                russianText = "Наборы для всех игроков", englishText = "Kits for all players"
                            }
                            , iconKey = "START_CATEGORY", permission = String.Empty, rankKey = String.Empty, hideCategoryPermission = false, kitList = new Dictionary<String, KitInfo>() {
                                ["START_PRESET_KIT"]
                                = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Стартовый", englishText = "Starting",
                                    }
                                    , iconKey = "START_ICON", cooldown = 30, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["TOOL_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Инструменты", englishText = "Tools",
                                    }
                                    , iconKey = "TOOL_ICON", cooldown = 30, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["MED_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Медицина", englishText = "Medicine",
                                    }
                                    , iconKey = "MED_ICON", cooldown = 10, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["FOOD_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Еда", englishText = "Food",
                                    }
                                    , iconKey = "FOOD_ICON", cooldown = 10, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["DIVER_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.CooldownAndAmount, title = new LanguageText {
                                        russianText = "ДАЙВЕР", englishText = "DIVER",
                                    }
                                    , iconKey = "DIVER_ICON", cooldown = 60, amount = 3, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["HOME_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyAmount, title = new LanguageText {
                                        russianText = "ДОМ", englishText = "HOME",
                                    }
                                    , iconKey = "HOME_ICON", cooldown = 0, amount = 1, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                ,
                            }
                        }
                        , ["VIP_CATEGORY"] = new CategoryInfo {
                            title = new LanguageText {
                                russianText = "VIP", englishText = "VIP",
                            }
                            , description = new LanguageText {
                                russianText = "Улучшенные наборы", englishText = "Enhanced kits"
                            }
                            , hideCategoryPermission = false, iconKey = "VIP_CATEGORY", rankKey = String.Empty, permission = String.Empty, kitList = new Dictionary<String, KitInfo>() {
                                ["VIP_START_PRESET_KIT"]
                                = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Стартовый", englishText = "Starting",
                                    }
                                    , iconKey = "VIP_START_ICON", cooldown = 120, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["VIP_MED_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Медицина", englishText = "Medicine",
                                    }
                                    , iconKey = "UPGRADE_MED_ICON", cooldown = 25, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["VIP_RESOURCE_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Ресурсы", englishText = "Resource",
                                    }
                                    , iconKey = "RESOURCE_ICON", cooldown = 60, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["VIP_COMPONENT_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Компоненты", englishText = "Components",
                                    }
                                    , iconKey = "COMPONENT_ICON", cooldown = 300, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["VIP_BOOM_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.CooldownAndAmount, title = new LanguageText {
                                        russianText = "Взрывчатка", englishText = "Explosives",
                                    }
                                    , iconKey = "BOOM_ICON", cooldown = 1440, amount = 5, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["VIP_ONLY_ONE_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyAmount, title = new LanguageText {
                                        russianText = "VIP", englishText = "VIP",
                                    }
                                    , iconKey = "PRIVILAGE_ICON", cooldown = 0, amount = 1, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                ,
                            }
                        }
                        , ["PREMIUM_CATEGORY"] = new CategoryInfo {
                            title = new LanguageText {
                                russianText = "PREMIUM", englishText = "PREMIUM",
                            }
                            , description = new LanguageText {
                                russianText = "Продвинутые наборы", englishText = "Advanced kits"
                            }
                            , hideCategoryPermission = false, iconKey = "PREMIUM_CATEGORY", permission = String.Empty, rankKey = String.Empty, kitList = new Dictionary<String, KitInfo>() {
                                ["PREMIUM_START_PRESET_KIT"]
                                = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Стартовый", englishText = "Starting",
                                    }
                                    , iconKey = "PREMIUM_START_ICON", cooldown = 120, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["PREMIUM_MED_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Медицина", englishText = "Medicine",
                                    }
                                    , iconKey = "UPGRADE_MED_ICON", cooldown = 25, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["PREMIUM_RESOURCE_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Ресурсы", englishText = "Resource",
                                    }
                                    , iconKey = "UPGRADE_RESOURCE_ICON", cooldown = 60, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["PREMIUM_COMPONENT_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Компоненты", englishText = "Components",
                                    }
                                    , iconKey = "UPGRADE_COMPONENT_ICON", cooldown = 300, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["PREMIUM_BOOM_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.CooldownAndAmount, title = new LanguageText {
                                        russianText = "Взрывчатка", englishText = "Explosives",
                                    }
                                    , iconKey = "UPGRADE_BOOM_ICON", cooldown = 1440, amount = 5, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["PREMIUM_ONLY_ONE_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyAmount, title = new LanguageText {
                                        russianText = "PREMIUM", englishText = "PREMIUM",
                                    }
                                    , iconKey = "PRIVILAGE_ICON", cooldown = 0, amount = 1, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                ,
                            }
                        }
                        , ["ELITE_CATEGORY"] = new CategoryInfo {
                            title = new LanguageText {
                                russianText = "ELITE", englishText = "ELITE",
                            }
                            , description = new LanguageText {
                                russianText = "Элитные наборы", englishText = "Elite kits"
                            }
                            , hideCategoryPermission = false, iconKey = "ELITE_CATEGORY", permission = String.Empty, rankKey = String.Empty, kitList = new Dictionary<String, KitInfo>() {
                                ["ELITE_START_PRESET_KIT"]
                                = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Стартовый", englishText = "Starting",
                                    }
                                    , iconKey = "ELITE_START_ICON", cooldown = 120, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["ELITE_MED_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Медицина", englishText = "Medicine",
                                    }
                                    , iconKey = "UPGRADE_MED_ICON", cooldown = 25, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["ELITE_RESOURCE_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Ресурсы", englishText = "Resource",
                                    }
                                    , iconKey = "ADVANCED_RESOURCE_ICON", cooldown = 60, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["ELITE_COMPONENT_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyCooldown, title = new LanguageText {
                                        russianText = "Компоненты", englishText = "Components",
                                    }
                                    , iconKey = "ADVANCED_COMPONENT_ICON", cooldown = 300, amount = 0, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["ELITE_BOOM_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.CooldownAndAmount, title = new LanguageText {
                                        russianText = "Взрывчатка", englishText = "Explosives",
                                    }
                                    , iconKey = "ADVANCED_BOOM_ICON", cooldown = 1440, amount = 5, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["ELITE_ONLY_ONE_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyAmount, title = new LanguageText {
                                        russianText = "ELITE", englishText = "ELITE",
                                    }
                                    , iconKey = "PRIVILAGE_ICON", cooldown = 0, amount = 1, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                ,
                            }
                        }
                        , ["BONUS_CATEGORY"] = new CategoryInfo {
                            title = new LanguageText {
                                russianText = "БОНУС", englishText = "BONUS",
                            }
                            , description = new LanguageText {
                                russianText = "Бонусные наборы", englishText = "Bonus kits"
                            }
                            , hideCategoryPermission = false, iconKey = "BONUS_CATEGORY", permission = String.Empty, rankKey = String.Empty, kitList = new Dictionary<String, KitInfo>() {
                                ["BONUS_ONE_PRESET_KIT"]
                                = new KitInfo {
                                    type = TypeKit.OnlyAmount, title = new LanguageText {
                                        russianText = "Подарок", englishText = "Present",
                                    }
                                    , iconKey = "BONUS_PRESENTS", cooldown = 0, amount = 1, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["BONUS_TWO_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyAmount, title = new LanguageText {
                                        russianText = "Комфорт", englishText = "Comfort",
                                    }
                                    , iconKey = "BONUS_PLUSHY", cooldown = 0, amount = 1, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                , ["BONUS_THREE_PRESET_KIT"] = new KitInfo {
                                    type = TypeKit.OnlyAmount, title = new LanguageText {
                                        russianText = "Карты", englishText = "Cards",
                                    }
                                    , iconKey = "BONUS_CARDS", cooldown = 0, amount = 1, unlockedAfterMinutes = 0, takeIsRaidblock = false,
                                }
                                ,
                            }
                        }
                        ,
                    }
                    , presetsItems = new Dictionary<String, List<ItemKits>>() {
                        ["START_PRESET_KIT"]
                        = new List<ItemKits>() {
                            new ItemKits() {
                                physicItem = new ItemKits.PhysicItem {
                                    containerItem = ContainerItem.containerMain, shortname = "rock", amount = 1, skinID = 0, displayName = "", slotIndex = 0, contentsItem = new List<ItemKits.PhysicItem.ContentItem>(), armorModules = new List<String>(), noteText = ""
                                }
                            }
                        }
                    }
                    ,
                }
                ;
            }
            [JsonProperty(LanguageEn ? "Kit category settings [Unique category name] = Settings" : "Настройка категорий с наборами [Уникальное название категории] = Настройка")]
            public Dictionary<String, CategoryInfo> categoryKits = new Dictionary<String, CategoryInfo>();
            [JsonProperty(LanguageEn ? "Sort categories in UI by permissions [if a player has access to a category, it will appear earlier in the list] [true - yes/false - no]" : "Сортировать категории в UI по разрешениям [если у игрока есть доступ к категории - она будет первее в списке] [true - да/false - нет]")]
            public Boolean sortedPermissions;
            public class AutoKitController {
                [JsonProperty(LanguageEn ? "Use automatic kits [true - yes/false - no]" : "Использовать автоматические наборов [true - да/false - нет]")]
                public Boolean useAutoKit;
                [JsonProperty(LanguageEn ? "Clear player's inventory on respawn [true - yes/false - no]" : "Очищать инвентарь игрока при возрождении [true - да/false - нет]")]
                public Boolean stripInventoryDefaultItems;
                [JsonProperty(LanguageEn ? "Automatic kits settings" : "Настройка автоматических наборов")]
                public AutoKits settingAutoKits;
                public class AutoKits {
                    [JsonProperty(LanguageEn ? "Use a random kit after respawn (if multiple are available) [true - yes/false - no]" : "Использовать случайный набор после возрождения (если доступно сразу несколько) [true - да/false - нет]")]
                    public Boolean useRandomAutoKit;
                    [JsonProperty(LanguageEn ? "List of automatic kits and their settings [Permission = Settings]" : "Список автоматических наборов и их настройка [Разрешение = Настройка]")]
                    public Dictionary<String, AutoKit> listAutoKits = new Dictionary<String, AutoKit>();
                    public class AutoKit {
                        [JsonProperty(LanguageEn ? "Biome type where this kit will be given [0 - Not dependent on biome, 1 - Arid, 2 - Temperate, 3 - Tundra, 4 - Arctic, 5 - Jungle]" : "Тип биома в котором будет выдаваться данный набор [0 - Не зависит от биома, 1 - Arid, 2 - Temperate, 3 - Tundra, 4 - Arctic, 5 - Jungle]")]
                        public BiomeType biomeType;
                        [JsonProperty(LanguageEn ? "Preset key from the list for item distribution" : "Ключ из списка пресетов для выдачи предметов")]
                        public String itemPresetKey;
                    }
                    public String GetAutoKitKey(BasePlayer player) {
                        List<String> avaliableKeys = Pool.Get<List<String>>();
                        foreach (KeyValuePair<String, AutoKit> listAutoKit in listAutoKits) {
                            if (_.permission.UserHasPermission(player.UserIDString, listAutoKit.Key)) {
                                if(listAutoKit.Value.biomeType == BiomeType.None) avaliableKeys.Add(listAutoKit.Value.itemPresetKey);
                                else if(listAutoKit.Value.biomeType == GetBiome(player)) avaliableKeys.Add(listAutoKit.Value.itemPresetKey);
                            }
                        }
                        try {
                            if (avaliableKeys.Count == 0) return String.Empty;
                            return useRandomAutoKit ? avaliableKeys.GetRandom() : avaliableKeys[0];
                        }
                        finally {
                            Pool.FreeUnmanaged(ref avaliableKeys);
                        }
                    }
                    private BiomeType GetBiome(BasePlayer player) {
                        if (TerrainMeta.BiomeMap.GetBiome(player.transform.position, 1) > 0.5) return BiomeType.Arid;
                        if (TerrainMeta.BiomeMap.GetBiome(player.transform.position, 2) > 0.5) return BiomeType.Temperate;
                        if (TerrainMeta.BiomeMap.GetBiome(player.transform.position, 4) > 0.5) return BiomeType.Tundra;
                        if (TerrainMeta.BiomeMap.GetBiome(player.transform.position, 8) > 0.5) return BiomeType.Arctic;
                        return TerrainMeta.BiomeMap.GetBiome(player.transform.position, 16) > 0.5 ? BiomeType.Jungle : BiomeType.None;
                    }
                }
            }
            [JsonProperty(LanguageEn ? "Internal: Auto kit biome settings version (used for migrations)" : "Внутреннее: Версия настроек биомов авто-наборов (используется для миграций)")]
            public Int32 autoKitBiomeSettingsVersion;
        }
        [ConsoleCommand("kit")]
        private void ConsoleCommandKit(ConsoleSystem.Arg arg) {
            BasePlayer player = arg.Player();
            if (!player) {
                if (!arg.HasArgs(1)) return;
                String action = arg.Args[0];
                switch (action) {
                    case "give" : {
                        if (!arg.HasArgs(3)) {
                            PrintWarning(LanguageEn ? "" : "Попытка выдать кит игроку - неуспешна, не полностью заполнены аргументы команды!");
                            return;
                        }
                        String nameOrID = arg.Args[1];
                        String presetName = arg.Args[2];
                        BasePlayer targetPlayer = BasePlayer.Find(nameOrID);
                        if (!targetPlayer) return;
                        MovedItemsInPreset(targetPlayer, presetName);
                        break;
                    }
                }
                return;
            }
            DrawUI_Kit_Overlay(player);
        }
        private void DrawUI_Kit_Panel(BasePlayer player, Int32 kitIndex, String indexName, Int32 page, String categoryName, KeyValuePair<String, Configuration.KitInfo> kitInfo) {
            if (_interface == null) return;
            String Interface = InterfaceBuilder.GetInterface("UI_KIT_PANEL");
            if (Interface == null) return;
            String getStatusKit = GetStatusAvaliable(player, categoryName, kitInfo.Key);
            String statusKit = getStatusKit;
            String panelImg = "UI_BLOCKED_PANEL_KIT";
            String commandKit = String.Empty;
            if (String.IsNullOrWhiteSpace(getStatusKit)) {
                panelImg = "UI_PANEL_KIT";
                statusKit = GetLang("UI_KIT_AVALIABLE_OPEN", player.UserIDString);
                commandKit = $"ui_kit_func take.kit {categoryName} {kitInfo.Key} {page}";
            }
            Interface = Interface.Replace("%CATEGORY_INDEX%", $"{categoryName}");
            Interface = Interface.Replace("%INDEX%", $"{indexName}");
            Interface = Interface.Replace("%OFFSET_MIN%", $"-101.729 {-64.037 - (kitIndex * 54)}");
            Interface = Interface.Replace("%OFFSET_MAX%", $"102.938 {-8.037 - (kitIndex * 54)}");
            Interface = Interface.Replace("%COMMAND_TAKE_KIT%", commandKit);
            Interface = Interface.Replace("%COMMAND_INFO_KIT%", $"ui_kit_func open.info.kit {categoryName} {kitInfo.Key}");
            Interface = Interface.Replace("%KIT_TITLE%", kitInfo.Value.title.GetLanguageText(player));
            Interface = Interface.Replace("%PANEL_KIT_PNG%", _imageUI.GetImage(panelImg));
            Interface = Interface.Replace("%IS_AVALIABLE_STATUS%", statusKit);
            Interface = Interface.Replace("%ICON_KIT%", _imageUI.GetImage(kitInfo.Value.iconKey));
            AddUI(player, Interface);
            if(kitInfo.Value.type is TypeKit.OnlyAmount or TypeKit.CooldownAndAmount) DrawUI_Kit_Panel_Amount(player, indexName, GetLeftAmountKit(player, categoryName, kitInfo.Key, kitInfo.Value.amount));
        }
        private static Configuration config = new Configuration();
        private static List<Configuration.ItemKits.PhysicItem.ContentItem> ParseContentInfo(Item item) {
            List<Configuration.ItemKits.PhysicItem.ContentItem> contentsItem = new();
            if (item.contents != null) {
                foreach (Item content in item.contents.itemList) {
                    Configuration.ItemKits.PhysicItem.ContentItem contentItem = new() {
                        ammoOrContent = false, shortname = content.info.shortname, amount = content.amount
                    }
                    ;
                    contentsItem.Add(contentItem);
                }
            }
            if (item.info.category != ItemCategory.Weapon) return contentsItem;
            BaseProjectile weapon = item.GetHeldEntity() as BaseProjectile;
            if (!weapon) return contentsItem;
            Configuration.ItemKits.PhysicItem.ContentItem ammoItem = new() {
                ammoOrContent = true, shortname = weapon.primaryMagazine.ammoType.shortname, amount = weapon.primaryMagazine.contents == 0 ? 1 : weapon.primaryMagazine.contents
            }
            ;
            contentsItem.Add(ammoItem);
            return contentsItem;
        }
        private static List<String> ParseArmorModules(Item item) {
            List<String> armorModules = new();
            if (item.contents != null) {
                foreach (Item content in item.contents.itemList) {
                    // Проверяем, является ли предмет модулем брони
                    if (content.info.category == ItemCategory.Attire && content.info.shortname.Contains("armorinsert")) {
                        armorModules.Add(content.info.shortname);
                    }
                }
            }
            return armorModules;
        }
        private static String ParseNoteText(Item item) {
            // Проверяем, является ли предмет запиской и есть ли у неё текст
            if (item.info.shortname == "note" && !String.IsNullOrWhiteSpace(item.text)) {
                return item.text;
            }
            return String.Empty;
        }
        private class ImageUI {
            private const String _path = "IQSystem/IQKits/Images/";
            private const String _printPath = "data/" + _path;
            private readonly Dictionary<String, ImageData> _images = new() {
                {
                    "UI_BLOCKED_PANEL_KIT", new ImageData()
                }
                , {
                    "UI_PANEL_KIT", new ImageData()
                }
                , {
                    "UI_CATEGORY_PANEL", new ImageData()
                }
                , {
                    "UI_EMPTY_CATEGORY", new ImageData()
                }
                , {
                    "UI_BLOCK_AMOUNT", new ImageData()
                }
                , {
                    "UI_PAGE_LEFT", new ImageData()
                }
                , {
                    "UI_PAGE_RIGHT", new ImageData()
                }
                , {
                    "UI_INFO_PANEL_NO_ITEMS", new ImageData()
                }
                , {
                    "UI_INFO_PANEL_ITEM_BACKGROUND", new ImageData()
                }
                , {
                    "UI_INFO_PANEL", new ImageData()
                }
                ,
            }
            ;
            private enum ImageStatus {
 
// ... [Code preview truncated due to length. Full source in attached file] ...

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху