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

FREE BuildTools : 1.5.37 1.5.37

Нет прав для скачивания
C#:
// #define TESTING
#define EDITING_MODE
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Libraries;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using Rust;
using UnityEngine;
using UnityEngine.Networking;
using Debug = UnityEngine.Debug;
using Global = Rust.Global;
using Time = UnityEngine.Time;
using Utility = Oxide.Core.Utility;
using Oxide.Plugins.BuildToolsExtensionMethods;
#if TESTING
using System.Diagnostics;
#endif
namespace Oxide.Plugins {
    [Info("Build Tools", "Mevent", "1.5.37")]
    public class BuildTools : RustPlugin {
#region Fields
        [PluginReference]
        private Plugin ImageLibrary = null, NoEscape = null, DefendableHomes = null, Clans = null, Friends = null, PersonalVaultDoor = null, Notify = null, UINotify = null, LangAPI = null;
        private const bool LangRu = false;
        private static BuildTools _instance;
        private enum Types {
            None = 0, Remove = 5, Down = 6, Wood = 1, Stone = 2, Metal = 3, TopTier = 4
        }
        private const string Layer = "UI.BuildTools", CrosshairLayer = "UI.BuildTools.Sight", CupboardLayer = "UI.BuildTools.Cupboard", CMD_Main_Console = "UI_Builder", PERM_EDIT = "BuildTools.edit", PermFree = "buildtools.free", HammerShortname = "hammer", ToolGunShortname = "toolgun", BuldingPlannerShortname = "building.planner";
        private Dictionary<string, string> _shortPrefabNamesToItem = new Dictionary<string, string>();
        private bool _needImageLibrary, _enabledImageLibrary;
        private Dictionary<int, Mode> _modeByType = new Dictionary<int, Mode>();
        private readonly Dictionary<uint, string> colors = new Dictionary<uint, string>() {
            [1]
            = "0.38 0.56 0.74 1.0", [2] = "0.45 0.71 0.34 1.0", [3] = "0.57 0.29 0.83 1.0", [4] = "0.42 0.17 0.11 1.0", [5] = "0.82 0.46 0.13 1.0", [6] = "0.87 0.87 0.87 1.0", [7] = "0.20 0.20 0.18 1.0", [8] = "0.40 0.33 0.27 1.0", [9] = "0.20 0.22 0.34 1.0", [10] = "0.24 0.35 0.20 1.0", [11] = "0.73 0.30 0.18 1.0", [12] = "0.78 0.53 0.39 1.0", [13] = "0.84 0.66 0.22 1.0", [14] = "0.34 0.33 0.31 1.0", [15] = "0.21 0.34 0.37 1.0", [16] = "0.66 0.61 0.56 1.0"
        }
        ;
        private const uint _useRandomColor = 23435621;
#endregion
#region Config
        private static Configuration _config;
        private class Configuration {
            [JsonProperty(PropertyName = LangRu ? "Разрешение для использования плагина (прим: buildtools.use)" : "Permission to use plugin (ex: buildtools.use)")]
            public string Permission = string.Empty;
            [JsonProperty(PropertyName = LangRu ? "Команды для удаления" : "Remove Commands")]
            public string[] RemoveCommands = {
                "remove"
            }
            ;
            [JsonProperty(PropertyName = LangRu ? "Команды для улучшения" : "Upgrade Commands")]
            public string[] UpgradeCommands = {
                "up", "building.upgrade"
            }
            ;
            [JsonProperty(PropertyName = LangRu ? "Команды для понижения" : "Downgrade Commands")]
            public string[] DowngradeCommands = {
                "down", "down.grade", "downgrade"
            }
            ;
            [JsonProperty(PropertyName = LangRu ? "Команды настроек" : "Settings Commands")]
            public string[] SettingsCommands = {
                "bskin", "buildingskin", "bsettings"
            }
            ;
            [JsonProperty(PropertyName = LangRu ? "Работать с Notify?" : "Work with Notify?")]
            public bool UseNotify = true;
            [JsonProperty(PropertyName = LangRu ? "Работать с PersonalVaultDoor?" : "Work with PersonalVaultDoor?")]
            public bool UsePersonalVaultDoor = true;
            [JsonProperty(PropertyName = LangRu ? "Включить работу с LangAPI?" : "Work with LangAPI?")]
            public bool UseLangAPI = true;
            [JsonProperty(PropertyName = LangRu ? "Использовать действия по удару молотком по объекту?" : "Use hammer hit actions on entity?")]
            public bool UseHammer = true;
            [JsonProperty(PropertyName = LangRu ? "Переключение между режимами с помощью щелчка колёсика мыши?" : "Switching between modes with a middle click?")]
            public bool SwitchModesMiddleClick = false;
            [JsonProperty(PropertyName = LangRu ? "Настройки режимов" : "Setting Modes", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<Mode> Modes = new List<Mode> {
                new Mode {
                    Enabled = true, Type = Types.Remove, Icon = "assets/icons/clear.png", Permission = string.Empty, UseSkins = false, Skins = new List<SkinConf>()
                }
                , new Mode {
                    Enabled = true, Type = Types.Wood, Icon = "assets/icons/level_wood.png", Permission = string.Empty, UseSkins = true, Skins = new List<SkinConf> {
                        new SkinConf {
                            Enabled = true, LangKey = "SkinLegacy Wood", Permission = string.Empty, Skin = 10232
                        }
                        , new SkinConf {
                            Enabled = true, LangKey = "SkinGingerbread", Permission = string.Empty, Skin = 2
                        }
                    }
                }
                , new Mode {
                    Enabled = true, Type = Types.Stone, Icon = "assets/icons/level_stone.png", Permission = string.Empty, UseSkins = true, Skins = new List<SkinConf> {
                        new SkinConf {
                            Enabled = true, LangKey = "SkinAdobe", Permission = string.Empty, Skin = 10220
                        }
                        , new SkinConf {
                            Enabled = true, LangKey = "SkinBrick", Permission = string.Empty, Skin = 10223
                        }
                        , new SkinConf {
                            Enabled = true, LangKey = "SkinBrutalist", Permission = string.Empty, Skin = 10225
                        }
                    }
                }
                , new Mode {
                    Enabled = true, Type = Types.Metal, Icon = "assets/icons/level_metal.png", Permission = string.Empty, UseSkins = true, Skins = new List<SkinConf> {
                        new SkinConf {
                            Enabled = true, LangKey = "SkinContainer", Permission = string.Empty, Skin = 10221, UseColors = true
                        }
                    }
                }
                , new Mode {
                    Enabled = true, Type = Types.TopTier, Icon = "assets/icons/level_top.png", Permission = string.Empty, UseSkins = false, Skins = new List<SkinConf>(),
                }
                , new Mode {
                    Enabled = true, Type = Types.Down, Icon = "assets/icons/demolish.png", Permission = string.Empty, UseSkins = false, Skins = new List<SkinConf>(),
                }
            }
            ;
            [JsonProperty(PropertyName = LangRu ? "Настройки улучшения" : "Upgrade Settings")]
            public UpgradeSettings Upgrade = new UpgradeSettings {
                PermissionToAll = "buildtools.all", ActionTime = 30, Cooldown = 0, VipCooldown = new Dictionary<string, int> {
                    ["buildtools.vip"]
                    = 0, ["buildtools.premium"] = 0
                }
                , AfterWipe = 0, VipAfterWipe = new Dictionary<string, int> {
                    ["buildtools.vip"]
                    = 0, ["buildtools.premium"] = 0
                }
                , AmountPerTick = 5, NotifyRequiredResources = false, ShiftAttackToUpgradeAll = false, UpdateSkinsOnRightClick = true, UpgradeBuildingOnBuilt = true
            }
            ;
            [JsonProperty(PropertyName = LangRu ? "Настройки удаления" : "Remove Settings")]
            public RemoveSettings Remove = new RemoveSettings {
                PermissionToAll = "buildtools.all", ActionTime = 30, Cooldown = 0, VipCooldown = new Dictionary<string, int> {
                    ["buildtools.vip"]
                    = 0, ["buildtools.premium"] = 0
                }
                , AfterWipe = 0, VipAfterWipe = new Dictionary<string, int> {
                    ["buildtools.vip"]
                    = 0, ["buildtools.premium"] = 0
                }
                , Condition = new ConditionSettings {
                    Default = true, Percent = false, PercentValue = 0
                }
                , ReturnItem = true, ReturnPercent = 100, ReturnPercents = new Dictionary<string, float> {
                    ["buildtools.vip"]
                    = 100, ["buildtools.premium"] = 100
                }
                , CanFriends = true, CanClan = true, CanTeams = true, RemoveByCupboard = false, RemoveItemsContainer = false, BlockedList = new Dictionary<string, List<IgnoredBlock>> {
                    ["shortname 1"]
                    = new List<IgnoredBlock> {
                        new IgnoredBlock {
                            Skins = new List<string> {
                                "*"
                            }
                            , CanRemove = false, ReturnItem = false, ReturnPercent = 100
                        }
                    }
                    , ["shortname 2"] = new List<IgnoredBlock> {
                        new IgnoredBlock {
                            Skins = new List<string> {
                                "*"
                            }
                            , CanRemove = false, ReturnItem = false, ReturnPercent = 100
                        }
                    }
                    , ["shortname 3"] = new List<IgnoredBlock> {
                        new IgnoredBlock {
                            Skins = new List<string> {
                                "*"
                            }
                            , CanRemove = false, ReturnItem = false, ReturnPercent = 100
                        }
                    }
                    ,
                }
                , BlockCooldown = new ActionCooldown {
                    Default = 36000, Permissions = new Dictionary<string, float> {
                        ["buildtools.vip"]
                        = 34000, ["buildtools.premium"] = 32000
                    }
                }
                , AmountPerTick = 5, ShiftAttackToRemoveAll = false, Vision = new RemoveSettings.VisionRemoval {
                    Enabled = false, Permission = "buildtools.vision", Distance = 5f, Crosshair = new CrosshairSettings {
                        Enabled = false, Size = 30f, Thickness = 4f, Color = IColor.Create("#FFFFFF"), DisplayType = "Overlay"
                    }
                }
            }
            ;
            [JsonProperty(PropertyName = LangRu ? "Настройки понижения" : "Downgrade Settings")]
            public DowngradeSettings Downgrade = new DowngradeSettings {
                PermissionToAll = "buildtools.all", ActionTime = 30, Cooldown = 0, VipCooldown = new Dictionary<string, int> {
                    ["buildtools.vip"]
                    = 0, ["buildtools.premium"] = 0
                }
                , AfterWipe = 0, VipAfterWipe = new Dictionary<string, int> {
                    ["buildtools.vip"]
                    = 0, ["buildtools.premium"] = 0
                }
                , CanFriends = true, CanClan = true, CanTeams = true, BlockedList = new Dictionary<string, List<string>> {
                    ["shortname 1"]
                    = new List<string> {
                        "*"
                    }
                    , ["shortname 2"] = new List<string> {
                        "*"
                    }
                    , ["shortname 3"] = new List<string> {
                        "*"
                    }
                }
                , AmountPerTick = 5, ShiftAttackToDowngradeAll = false, CanDowngradeToTwigs = false
            }
            ;
            [JsonProperty(PropertyName = LangRu ? "Настройки блокировки" : "Block Settings")]
            public BlockSettings Block = new BlockSettings {
                UseNoEscape = true, UseClans = true, UseFriends = true, UseCupboard = true, NeedCupboard = false
            }
            ;
            [JsonProperty(PropertyName = LangRu ? "Настройки UI" : "UI Settings")]
            public InterfaceSettings UI = new InterfaceSettings {
                DisplayType = "Overlay", Color1 = IColor.Create("#4B68FF"), Color2 = IColor.Create("#2C2C2C"), Color3 = IColor.Create("#B64040"), OffsetY = 0, OffsetX = 0, ProgressTitleTextSize = 12, ProgressTitleTextColor = IColor.Create("#FFFFFF", 60), SettingsBackgroundColor = IColor.Create("#0E0E10"), SettingsHeaderColor = IColor.Create("#161617"), SettingsImageBackgroundColor = IColor.Create("#161617"), SettingsSelectedColor = IColor.Create("#4B68FF"), SettingsNotSelectedColor = IColor.Create("#242425"), SettingsTextColor = IColor.Create("#FFFFFF"), PanelBackground = new ImageSettings {
                    AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "50 50", OffsetMax = "200 80", Sprite = string.Empty, Material = string.Empty, Image = string.Empty, Color = IColor.Create("#2C2C2C")
                }
                , PanelCancelButton = new ButtonSettings {
                    AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "5 5", OffsetMax = "25 25", Align = TextAnchor.MiddleCenter, IsBold = false, FontSize = 14, Color = IColor.Create("#FFFFFF"), ButtonColor = IColor.Create("#000000", 00), Sprite = string.Empty, Material = string.Empty, Image = string.Empty, ImageColor = IColor.Create("#FFFFFF")
                }
                , PanelSettingsBackground = new ImageSettings {
                    AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "15 50", OffsetMax = "45 80", Sprite = string.Empty, Material = string.Empty, Image = string.Empty, Color = IColor.Create("#2C2C2C")
                }
                , PanelSettingsIcon = new ImageSettings {
                    AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "5 5", OffsetMax = "-5 -5", Sprite = "assets/icons/gear.png", Material = string.Empty, Image = string.Empty, Color = IColor.Create("#FFFFFF")
                }
                , Skins = new InterfaceSettings.SkinsUI {
                    TabUpIndent = 15, TabHeight = 20, TabWidth = 80, TabMargin = 5, ImageLeftIndent = -22.5f, ImageUpIndent = 60, ImageHeight = 190, ImageWidth = 190, ModeUpIndent = 60, ModeHeight = 40, ModeWidth = 130, ModeMargin = 15, SkinButtonLeftIndent = -167.5f, SettingsModalBackground = new ImageSettings {
                        AnchorMin = "0 0", AnchorMax = "1 1", OffsetMin = "-210 -167.5", OffsetMax = "210 167.5", Sprite = string.Empty, Material = string.Empty, Image = string.Empty, Color = IColor.Create("#0E0E10")
                    }
                    , SelectColorButton = new ButtonSettings {
                        AnchorMin = "0.5 1", AnchorMax = "0.5 1", OffsetMin = "-22.5 -280", OffsetMax = "167.5 -255", FontSize = 14, IsBold = true, Align = TextAnchor.MiddleCenter, Color = IColor.Create("#FFFFFF"), ButtonColor = IColor.Create("#FF4B4B"), Sprite = string.Empty, Material = string.Empty, Image = string.Empty, ImageColor = IColor.Create("#FFFFFF")
                    }
                }
                , SelectItemImage = "https://i.ibb.co/pJF7XJN/search.png",
            }
            ;
            [JsonProperty(PropertyName = LangRu ? "Настройки активного предмета" : "Active Item Settings")]
            public ActiveItemConf ActiveItem = new ActiveItemConf {
                Enabled = false, Items = new Dictionary<string, ActiveItemConf.ActiveItem> {
                    [HammerShortname]
                    = new ActiveItemConf.ActiveItem {
                        Enabled = true, DefaultMode = Types.Remove, IgnoredSkins = new List<ulong> {
                            1196009619u
                        }
                        , SaveSelectedMode = false
                    }
                    , [ToolGunShortname] = new ActiveItemConf.ActiveItem {
                        Enabled = true, DefaultMode = Types.Remove, IgnoredSkins = new List<ulong>(), SaveSelectedMode = false
                    }
                    , ["building.planner"] = new ActiveItemConf.ActiveItem {
                        Enabled = true, DefaultMode = Types.Stone, IgnoredSkins = new List<ulong> {
                            1195976254u
                        }
                        , SaveSelectedMode = false
                    }
                }
            }
            ;
            [JsonProperty(PropertyName = LangRu ? "Настройки биндов" : "Binds Settings", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public BindsConf Binds = new BindsConf {
                Enabled = false, Buttons = new Dictionary<BUTTON, KeyActionConf> {
                    [BUTTON.RELOAD]
                    = new KeyActionConf {
                        Enabled = false, Action = KeyAction.OpenOrChangeMode, TargetMode = Types.Remove, RequiredItems = new List<string> {
                            "hammer", "toolgun"
                        }
                    }
                    , [BUTTON.USE] = new KeyActionConf {
                        Enabled = false, Action = KeyAction.OpenOrChangeMode, TargetMode = Types.Stone, RequiredItems = new List<string> {
                            "hammer", "toolgun", "building.planner"
                        }
                    }
                    , [BUTTON.FIRE_THIRD] = new KeyActionConf {
                        Enabled = false, Action = KeyAction.ChangeModeToNext, TargetMode = Types.None, RequiredItems = new List<string> {
                            "hammer", "toolgun", "building.planner"
                        }
                    }
                    ,
                }
            }
            ;
            public VersionNumber Version;
        }
        private class BindsConf {
            [JsonProperty(PropertyName = LangRu ? "Включено" : "Enabled")]
            public bool Enabled;
            [JsonProperty(PropertyName = LangRu ? "Кнопки" : "Buttons", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<BUTTON, KeyActionConf> Buttons = new Dictionary<BUTTON, KeyActionConf>();
        }
        private class KeyActionConf {
            [JsonProperty(PropertyName = LangRu ? "Включено" : "Enabled")]
            public bool Enabled;
            [JsonProperty(PropertyName = LangRu ? "Действие" : "Action")]
            [JsonConverter(typeof(StringEnumConverter))]
            public KeyAction Action;
            [JsonProperty(PropertyName = LangRu ? "Режим" : "Mode")]
            [JsonConverter(typeof(StringEnumConverter))]
            public Types TargetMode;
            [JsonProperty(PropertyName = LangRu ? "Требуемый предмет в руке" : "Required items in hand", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public List<string> RequiredItems = new List<string>();
        }
        private enum KeyAction {
            OpenOrChangeMode, ChangeModeToNext,
        }
        private class CrosshairSettings {
            [JsonProperty(PropertyName = LangRu ? "Включено" : "Enabled")]
            public bool Enabled;
            [JsonProperty(PropertyName = LangRu ? "Размер" : "Size")]
            public float Size;
            [JsonProperty(PropertyName = LangRu ? "Толщина" : "Thickness")]
            public float Thickness;
            [JsonProperty(PropertyName = LangRu ? "Цвет" : "Color")]
            public IColor Color;
            [JsonProperty(PropertyName = LangRu ? "Тип отображения (Overlay/Hud)" : "Display type (Overlay/Hud)")]
            public string DisplayType;
        }
        private class ActiveItemConf {
            [JsonProperty(PropertyName = LangRu ? "Включено" : "Enabled")]
            public bool Enabled;
            [JsonProperty(PropertyName = LangRu ? "Предметы" : "Items", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, ActiveItem> Items;
            public class ActiveItem {
                [JsonProperty(PropertyName = LangRu ? "Включено" : "Enabled")]
                public bool Enabled;
                [JsonProperty(PropertyName = LangRu ? "Режим по умолчанию" : "Default Mode")]
                [JsonConverter(typeof(StringEnumConverter))]
                public Types DefaultMode;
                [JsonProperty(PropertyName = LangRu ? "Игнорируемые скины" : "Ignored Skins", ObjectCreationHandling = ObjectCreationHandling.Replace)]
                public List<ulong> IgnoredSkins = new List<ulong>();
                [JsonProperty(PropertyName = LangRu ? "Сохранять выделенный режим при закрытии?" : "Save the selected mode when closing?")]
                public bool SaveSelectedMode;
                [JsonIgnore]
                private Mode _mode;
                public Mode GetMode(BasePlayer player, string item) {
#if TESTING
                    Debug.Log($"[ActiveItem.GetMode] player={player.UserIDString}, item={item}");
#endif
                    if (SaveSelectedMode) {
                        var selectedMode = PlayerData.GetOrLoad(player.UserIDString)?.GetSelectedMode(item);
                        if (selectedMode != null) {
#if TESTING
                            Debug.Log($"[ActiveItem.GetMode] SaveSelectedMode.return: {selectedMode.Type}");
#endif
                            return selectedMode;
                        }
                    }
#if TESTING
                    Debug.Log($"[ActiveItem.GetMode] return default");
#endif
                    return _mode;
                }
                public void SetMode(Mode mode) {
                    _mode = mode;
                }
            }
            public void Init() {
                foreach (var item in Items.Values) item.SetMode(_instance.GetModeByType(item.DefaultMode));
            }
        }
        private class ActionCooldown {
            [JsonProperty(PropertyName = LangRu ? "По умолчанию" : "Default")]
            public float Default;
            [JsonProperty(PropertyName = LangRu ? "Разрешения" : "Permissions", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, float> Permissions;
            public float GetCooldown(BasePlayer player) {
                var result = Default;
                foreach (var check in Permissions.Where(check => player.IPlayer.HasPermission(check.Key) && result < check.Value)) result = check.Value;
                return result;
            }
        }
        private class InterfaceSettings {
            [JsonProperty(PropertyName = LangRu ? "Тип отображения (Overlay/Hud)" : "Display type (Overlay/Hud)")]
            public string DisplayType;
            [JsonProperty(PropertyName = LangRu ? "Цвет 1" : "Color 1")]
            public IColor Color1;
            [JsonProperty(PropertyName = LangRu ? "Цвет 2" : "Color 2")]
            public IColor Color2;
            [JsonProperty(PropertyName = LangRu ? "Цвет 3" : "Color 3")]
            public IColor Color3;
            [JsonProperty(PropertyName = LangRu ? "Сдвиг Y" : "Offset Y")]
            public float OffsetY;
            [JsonProperty(PropertyName = LangRu ? "Сдвиг X" : "Offset X")]
            public float OffsetX;
            [JsonProperty(PropertyName = LangRu ? "Размер текста заголовка прогресса" : "Progress Title Text Size")]
            public int ProgressTitleTextSize;
            [JsonProperty(PropertyName = LangRu ? "Цвет текста заголовка прогресса" : "Progress Title Text Color")]
            public IColor ProgressTitleTextColor;
            [JsonProperty(PropertyName = LangRu ? "Цвет фона настроек" : "Settings Background Color")]
            public IColor SettingsBackgroundColor;
            [JsonProperty(PropertyName = LangRu ? "Цвет заголовка настроек" : "Settings Header Color")]
            public IColor SettingsHeaderColor;
            [JsonProperty(PropertyName = LangRu ? "Цвет фона изображения настроек" : "Settings Image Background Color")]
            public IColor SettingsImageBackgroundColor;
            [JsonProperty(PropertyName = LangRu ? "Цвет выбранного в настройках" : "Settings Selected Color")]
            public IColor SettingsSelectedColor;
            [JsonProperty(PropertyName = LangRu ? "Цвет не выбранного в настройках" : "Settings Not Selected Color")]
            public IColor SettingsNotSelectedColor;
            [JsonProperty(PropertyName = LangRu ? "Цвет текста настроек" : "Settings Text Color")]
            public IColor SettingsTextColor;
            [JsonProperty(PropertyName = LangRu ? "Панель фна" : "Panel Background")]
            public ImageSettings PanelBackground;
            [JsonProperty(PropertyName = LangRu ? "Панель кнопки отмены" : "Panel Cancel Button")]
            public ButtonSettings PanelCancelButton;
            [JsonProperty(PropertyName = LangRu ? "Панель фона кнопки настроек" : "Panel Settings Background")]
            public ImageSettings PanelSettingsBackground;
            [JsonProperty(PropertyName = LangRu ? "Панель иконки кнопки настроек" : "Panel Settings Icon")]
            public ImageSettings PanelSettingsIcon;
            [JsonProperty(PropertyName = LangRu ? "Скины" : "Skins")]
            public SkinsUI Skins;
            [JsonProperty(PropertyName = LangRu ? "Изображение иконки выбора предмета" : "Select Item Image")]
            public string SelectItemImage;
            public class SkinsUI {
                [JsonProperty(PropertyName = LangRu ? "Отступ для вкладки сверху" : "Tab Up Indent")]
                public float TabUpIndent;
                [JsonProperty(PropertyName = LangRu ? "Высота вкладки" : "Tab Height")]
                public float TabHeight;
                [JsonProperty(PropertyName = LangRu ? "Ширина вкладки" : "Tab Width")]
                public float TabWidth;
                [JsonProperty(PropertyName = LangRu ? "Отступ между вкладками" : "Tab Margin")]
                public float TabMargin;
                [JsonProperty(PropertyName = LangRu ? "Отступ слева для изображения" : "Image Left Indent")]
                public float ImageLeftIndent;
                [JsonProperty(PropertyName = LangRu ? "Отступ сверху для изображения" : "Image Up Indent")]
                public float ImageUpIndent;
                [JsonProperty(PropertyName = LangRu ? "Высота изображения" : "Image Height")]
                public float ImageHeight;
                [JsonProperty(PropertyName = LangRu ? "Ширина изображения" : "Image Width")]
                public float ImageWidth;
                [JsonProperty(PropertyName = LangRu ? "Отступ сверху для режима" : "Mode Up Indent")]
                public float ModeUpIndent;
                [JsonProperty(PropertyName = LangRu ? "Высота режима" : "Mode Height")]
                public float ModeHeight;
                [JsonProperty(PropertyName = LangRu ? "Ширина режима" : "Mode Width")]
                public float ModeWidth;
                [JsonProperty(PropertyName = LangRu ? "Отступ между режимами" : "Mode Margin")]
                public float ModeMargin;
                [JsonProperty(PropertyName = LangRu ? "Отступ слева для кнопки скина" : "Skin Button Left Indent")]
                public float SkinButtonLeftIndent;
                [JsonProperty(PropertyName = LangRu ? "Фон модального окна настроек" : "Settings Modal Background")]
                public ImageSettings SettingsModalBackground;
                [JsonProperty(PropertyName = LangRu ? "Цвет кнопки выбора" : "Select Color Button")]
                public ButtonSettings SelectColorButton;
            }
        }
#region Configuration.UI
        private class ImageSettings : InterfacePosition {
            [JsonProperty(PropertyName = LangRu ? "Спрайт" : "Sprite")]
            public string Sprite;
            [JsonProperty(PropertyName = LangRu ? "Материал" : "Material")]
            public string Material;
            [JsonProperty(PropertyName = LangRu ? "Изображение" : "Image")]
            public string Image;
            [JsonProperty(PropertyName = LangRu ? "Цвет" : "Color")]
            public IColor Color;
            private ICuiComponent GetImage() {
                if (!string.IsNullOrEmpty(Image)) {
                    var rawImage = new CuiRawImageComponent {
                        Png = _instance.GetImage(Image), Color = Color.Get
                    }
                    ;
                    if (!string.IsNullOrEmpty(Sprite)) rawImage.Sprite = Sprite;
                    if (!string.IsNullOrEmpty(Material)) rawImage.Material = Material;
                    return rawImage;
                }
                var image = new CuiImageComponent {
                    Color = Color.Get
                }
                ;
                if (!string.IsNullOrEmpty(Sprite)) image.Sprite = Sprite;
                if (!string.IsNullOrEmpty(Material)) image.Material = Material;
                return image;
            }
            public CuiElement GetImage(string parent, string name = null, string destroyUI = null) {
                if (string.IsNullOrEmpty(name)) name = CuiHelper.GetGuid();
                return new CuiElement {
                    Name = name, Parent = parent, DestroyUi = destroyUI, Components = {
                        GetImage(), GetPosition()
                    }
                }
                ;
            }
        }
        private class ButtonSettings : TextSettings {
            [JsonProperty(PropertyName = LangRu ? "Цвет кнопки" : "Button Color")]
            public IColor ButtonColor;
            [JsonProperty(PropertyName = LangRu ? "Спрайт" : "Sprite")]
            public string Sprite;
            [JsonProperty(PropertyName = LangRu ? "Материал" : "Material")]
            public string Material;
            [JsonProperty(PropertyName = LangRu ? "Изображение" : "Image")]
            public string Image;
            [JsonProperty(PropertyName = LangRu ? "Цвет изображения" : "Image Color")]
            public IColor ImageColor;
            public List<CuiElement> Get(string msg, string cmd, string parent, string name = null, string destroyUI = null, string close = null) {
                if (string.IsNullOrEmpty(name)) name = CuiHelper.GetGuid();
                var list = new List<CuiElement>();
                var btn = new CuiButtonComponent {
                    Color = ButtonColor.Get
                }
                ;
                if (!string.IsNullOrEmpty(cmd)) btn.Command = cmd;
                if (!string.IsNullOrEmpty(close)) btn.Close = close;
                if (!string.IsNullOrEmpty(Sprite)) btn.Sprite = Sprite;
                if (!string.IsNullOrEmpty(Material)) btn.Material = Material;
                if (!string.IsNullOrEmpty(Image)) {
                    list.Add(new CuiElement() {
                        Name = name, Parent = parent, DestroyUi = destroyUI, Components = {
                            new CuiRawImageComponent {
                                Png = _instance.GetImage(Image), Color = ImageColor.Get
                            }
                            , GetPosition()
                        }
                    }
                    );
                    list.Add(new CuiElement() {
                        Parent = name, Components = {
                            btn, new CuiRectTransformComponent()
                        }
                    }
                    );
                }
                else {
                    list.Add(new CuiElement {
                        Name = name, Parent = parent, DestroyUi = destroyUI, Components = {
                            btn, GetPosition()
                        }
                    }
                    );
                }
                if (!string.IsNullOrEmpty(msg)) {
                    list.Add(new CuiElement {
                        Parent = name, Components = {
                            GetTextComponent(msg), new CuiRectTransformComponent()
                        }
                    }
                    );
                }
                return list;
            }
        }
        private class TextSettings : InterfacePosition {
            [JsonProperty(PropertyName = LangRu ? "Размер шрифта" : "Font Size")]
            public int FontSize;
            [JsonProperty(PropertyName = LangRu ? "Жирный?" : "Is Bold?")]
            public bool IsBold;
            [JsonProperty(PropertyName = LangRu ? "Выравнивание" : "Align")]
            [JsonConverter(typeof(StringEnumConverter))]
            public TextAnchor Align;
            [JsonProperty(PropertyName = LangRu ? "Цвет" : "Color")]
            public IColor Color;
            public CuiTextComponent GetTextComponent(string msg) {
                return new CuiTextComponent {
                    Text = msg, FontSize = FontSize, Font = IsBold ? "robotocondensed-bold.ttf" : "robotocondensed-regular.ttf", Align = Align, Color = Color.Get
                }
                ;
            }
            public CuiElement GetText(string msg, string parent, string name = null, string destroyUI = null) {
                if (string.IsNullOrEmpty(name)) name = CuiHelper.GetGuid();
                return new CuiElement {
                    Name = name, Parent = parent, DestroyUi = destroyUI, Components = {
                        GetTextComponent(msg), GetPosition()
                    }
                }
                ;
            }
        }
        private class InterfacePosition {
            public string AnchorMin;
            public string AnchorMax;
            public string OffsetMin;
            public string OffsetMax;
            public CuiRectTransformComponent GetPosition() {
                return new CuiRectTransformComponent {
                    AnchorMin = AnchorMin, AnchorMax = AnchorMax, OffsetMin = OffsetMin, OffsetMax = OffsetMax
                }
                ;
            }
        }
        public class IColor {
            [JsonProperty(PropertyName = LangRu ? "Непрозрачность (0 - 100)" : "Opacity (0 - 100)", NullValueHandling = NullValueHandling.Include)]
            public float Alpha;
            [JsonProperty(PropertyName = "HEX", NullValueHandling = NullValueHandling.Include)]
            public string Hex;
            public static IColor Create(string hex, float alpha = 100) {
                return new IColor {
                    Hex = hex, Alpha = alpha
                }
                ;
            }
            [JsonIgnore]
            private string _color;
            [JsonIgnore]
            public string Get {
                get {
                    if (string.IsNullOrEmpty(_color)) UpdateColor();
                    return _color;
                }
            }
            public void UpdateColor() {
                _color = GetColor();
            }
            private string GetColor() {
                if (string.IsNullOrEmpty(Hex)) Hex = "#FFFFFF";
                var str = Hex.Trim('#');
                if (str.Length != 6) throw new Exception(Hex);
                var r = byte.Parse(str.Substring(0, 2), NumberStyles.HexNumber);
                var g = byte.Parse(str.Substring(2, 2), NumberStyles.HexNumber);
                var b = byte.Parse(str.Substring(4, 2), NumberStyles.HexNumber);
                return $"{(double) r / 255} {(double) g / 255} {(double) b / 255} {Alpha / 100}";
            }
        }
#endregion
        private class ConditionSettings {
            [JsonProperty(PropertyName = LangRu ? "По умолчанию (из игры)" : "Default (from game)")]
            public bool Default;
            [JsonProperty(PropertyName = LangRu ? "Использовать процент?" : "Use percent?")]
            public bool Percent;
            [JsonProperty(PropertyName = LangRu ? "Процент (значение)" : "Percent (value)")]
            public float PercentValue;
        }
        private class BlockSettings {
            [JsonProperty(PropertyName = LangRu ? "Работать с NoEscape?" : "Work with NoEscape?")]
            public bool UseNoEscape;
            [JsonProperty(PropertyName = LangRu ? "Работать с Clans? (участники клана смогут удалять/улучшать)" : "Work with Clans? (clan members will be able to delete/upgrade)")]
            public bool UseClans;
            [JsonProperty(PropertyName = LangRu ? "Работать с Friends? (друзья смогут удалять/улучшать)" : "Work with Friends? (friends will be able to delete/upgrade)")]
            public bool UseFriends;
            [JsonProperty(PropertyName = LangRu ? "Могут ли те, кто имеет доступ к шкафу, удалять/улучшать?" : "Can those authorized in the cupboard delete/upgrade?")]
            public bool UseCupboard;
            [JsonProperty(PropertyName = LangRu ? "Требуется ли шкаф для улучшения/удаления?" : "Is an upgrade/remove cupboard required?")]
            public bool NeedCupboard;
        }
        private abstract class TotalSettings {
            [JsonProperty(PropertyName = LangRu ? "Разрешения на изменение всех объектов (/command all)" : "Permission to modify all entities (/command all) ")]
            public string PermissionToAll;
            [JsonProperty(PropertyName = LangRu ? "Время действия" : "Time of action")]
            public int ActionTime;
            [JsonProperty(PropertyName = LangRu ? "Задержка (по умолчанию | 0 - отключить)" : "Cooldown (default | 0 - disable)")]
            public int Cooldown;
            [JsonProperty(PropertyName = LangRu ? "Задержки" : "Cooldowns", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, int> VipCooldown;
            [JsonProperty(PropertyName = LangRu ? "Блокировка после вайпа (по умолчанию | 0 - отключить)" : "Block After Wipe (default | 0 - disable)")]
            public int AfterWipe;
            [JsonProperty(PropertyName = LangRu ? "Блокировки после вайпа" : "Block After Wipe", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, int> VipAfterWipe;
            public int GetCooldown(BasePlayer player) {
                return (from check in VipCooldown where player.IPlayer.HasPermission(check.Key) select check.Value).Prepend(Cooldown).Min();
            }
            public int GetWipeCooldown(BasePlayer player) {
                return (from check in VipAfterWipe where player.IPlayer.HasPermission(check.Key) select check.Value).Prepend(AfterWipe).Min();
            }
            public bool HasAllPermission(BasePlayer player) {
                return string.IsNullOrWhiteSpace(PermissionToAll) || _instance.permission.UserHasPermission(player.UserIDString, PermissionToAll);
            }
        }
        private class UpgradeSettings : TotalSettings {
            [JsonProperty(PropertyName = LangRu ? "Количество улучшаемых сущностей за такт" : "Amount of upgrade entities per tick")]
            public int AmountPerTick;
            [JsonProperty(PropertyName = LangRu ? "Уведомлять игрока о необходимых ресурсах для улучшения здания, когда у него недостаточно ресурсов" : "Notify the player of the required resources for upgrading a building when they do not have enough resources")]
            public bool NotifyRequiredResources;
            [JsonProperty(PropertyName = LangRu ? "Нажмите Shift + Attack для upgrade all" : "Press Shift + Attack to Upgrade All")]
            public bool ShiftAttackToUpgradeAll;
            [JsonProperty(PropertyName = LangRu ? "Обновлять скины зданий при внутриигровом улучшении?" : "Updating building skins on right-click upgrade?")]
            public bool UpdateSkinsOnRightClick;
            [JsonProperty(PropertyName = LangRu ? "Настройки скинов" : "Skins Settings")]
            public SkinsInfo Skins = new SkinsInfo {
                Enabled = true, Icon = "assets/icons/gear.png", Images = new Dictionary<ulong, string> {
                    [10220]
                    = "https://i.ibb.co/GRjNqrq/ty1gZVS.png", [10221] = "https://i.ibb.co/N1ZtZ1h/CSTnZ9V.png", [10223] = "https://i.ibb.co/6yv2gCp/SGB52rr.png", [10225] = "https://i.ibb.co/HgjXDCp/512fx512fdpx2x.png", [10232] = "https://i.ibb.co/zWcN5wR/512fx512f.png", [2] = "https://i.ibb.co/ZSjMHJt/gingerbread.png"
                }
            }
            ;
            [JsonProperty(PropertyName = LangRu ? "Улучшать здания во время их строительства?" : "Upgrade buildings while they are being built?")]
            public bool UpgradeBuildingOnBuilt = true;
        }
        private class SkinsInfo {
            [JsonProperty(PropertyName = LangRu ? "Включено" : "Enabled")]
            public bool Enabled;
            [JsonProperty(PropertyName = LangRu ? "Иконка (assets/url)" : "Icon (assets/url)")]
            public string Icon;
            [JsonProperty(PropertyName = LangRu ? "Изображения для скинов" : "Image for skins", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<ulong, string> Images = new Dictionary<ulong, string>();
        }
        private class SkinConf {
            [JsonProperty(PropertyName = LangRu ? "Включено" : "Enabled")]
            public bool Enabled;
            [JsonProperty(PropertyName = LangRu ? "Ключ lang" : "Lang Key")]
            public string LangKey;
            [JsonProperty(PropertyName = LangRu ? "Разрешение" : "Permission")]
            public string Permission;
            [JsonProperty(PropertyName = LangRu ? "Скин" : "Skin")]
            public ulong Skin;
            [JsonProperty(PropertyName = LangRu ? "Использовать цвета?" : "Enable colors?")]
            public bool UseColors;
        }
        private class RemoveSettings : TotalSettings {
            [JsonProperty(PropertyName = LangRu ? "Заблокированные предметы для удаления (предмет – настройки)" : "Blocked items to remove (prefab – settings)", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, List<IgnoredBlock>> BlockedList;
            [JsonProperty(PropertyName = LangRu ? "Возвращать предмет" : "Return Item")]
            public bool ReturnItem;
            [JsonProperty(PropertyName = LangRu ? "Процент возвращаемого предмета" : "Returnable Item Percentage")]
            public float ReturnPercent;
            [JsonProperty(PropertyName = LangRu ? "Проценты возвращаемых предметов (разрешение – процент)" : "Percentages of returnable items (permission – percent)", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, float> ReturnPercents = new Dictionary<string, float>();
            [JsonProperty(PropertyName = LangRu ? "Могут ли друзья удалять? (Friends)" : "Can friends remove? (Friends)")]
            public bool CanFriends;
            [JsonProperty(PropertyName = LangRu ? "Могут ли члены клана удалять? (Clans)" : "Can clanmates remove? (Clans)")]
            public bool CanClan;
            [JsonProperty(PropertyName = LangRu ? "Могут ли товарищи по команде удалять?" : "Can teammates remove?")]
            public bool CanTeams;
            [JsonProperty(PropertyName = LangRu ? "Удаление по шкафу? (только авторизованные в шкафе могут удалять)" : "Remove by cupboard? (those who are authorized in the cupboard can remove)")]
            public bool RemoveByCupboard;
            [JsonProperty(PropertyName = LangRu ? "Удалять контейнер, в котором находятся предметы" : "Remove container with items?")]
            public bool RemoveItemsContainer;
            [JsonProperty(PropertyName = LangRu ? "Настройка состояния" : "Condition Settings")]
            public ConditionSettings Condition;
            [JsonProperty(PropertyName = LangRu ? "Настройки задержки после спавна объекта" : "Block Cooldown After Spawn Settings")]
            public ActionCooldown BlockCooldown;
            [JsonProperty(PropertyName = LangRu ? "Количество удаляемых объектов за такт" : "Amount of remove entities per tick")]
            public int AmountPerTick;
            [JsonProperty(PropertyName = LangRu ? "Нажмите Shift + Attack для remove all" : "Press Shift + Attack to Remove All")]
            public bool ShiftAttackToRemoveAll;
            [JsonProperty(PropertyName = LangRu ? "Настройки зрительного удаления" : "Vision Removal")]
            public VisionRemoval Vision;
            public class VisionRemoval {
                [JsonProperty(PropertyName = LangRu ? "Включено" : "Enabled")]
                public bool Enabled;
                [JsonProperty(PropertyName = LangRu ? "Разрешение" : "Permission")]
                public string Permission;
                [JsonProperty(PropertyName = LangRu ? "Дистанция" : "Distance")]
                public float Distance;
                [JsonProperty(PropertyName = LangRu ? "Прицел" : "Crosshair")]
                public CrosshairSettings Crosshair;
            }
            public float GetReturnPercent(BasePlayer player) {
                var result = ReturnPercent;
                foreach (var returnPercent in ReturnPercents) if (_instance?.permission?.UserHasPermission(returnPercent.Key, player.UserIDString) == true && returnPercent.Value > result) result = returnPercent.Value;
                return result;
            }
            [JsonIgnore]
            private Dictionary<string, Dictionary<string, IgnoredBlock>> _ignoredBlocks;
            public void Init() {
                _ignoredBlocks = new Dictionary<string, Dictionary<string, IgnoredBlock>>();
                foreach (var block in BlockedList) {
                    _ignoredBlocks[block.Key] = new Dictionary<string, IgnoredBlock>();
                    foreach (var ignoredBlock in block.Value) {
                        foreach (var ignoredSkin in ignoredBlock.Skins) {
                            IgnoredBlock check;
                            if (!_ignoredBlocks[block.Key].TryGetValue(ignoredSkin, out check)) {
                                _ignoredBlocks[block.Key].Add(ignoredSkin, ignoredBlock);
                            }
                        }
                    }
                }
            }
            public IgnoredBlock GetIgnoredBlock(BaseEntity entity) {
                Dictionary<string, IgnoredBlock> dictionary;
                if (!_ignoredBlocks.TryGetValue(entity.name, out dictionary)) return null;
                IgnoredBlock block;
                return dictionary.TryGetValue(entity.skinID.ToString(), out block) ? block : dictionary.TryGetValue("*", out block) ? block : null;
            }
        }
        private class DowngradeSettings : TotalSettings {
            [JsonProperty(PropertyName = LangRu ? "Заблокированные предметы для понижения уровня (prefab – скины, при '*' - все скины)" : "Blocked items to downgrade (prefab – skins, but '*' - all skins)", ObjectCreationHandling = ObjectCreationHandling.Replace)]
            public Dictionary<string, List<string>> BlockedList;
            [JsonProperty(PropertyName = LangRu ? "Могут л
// ... [Code preview truncated due to length. Full source in attached file] ...

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