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

FREE zEcoLootUI : 1.1.17 1.1.17

Нет прав для скачивания
C#:
using Newtonsoft.Json;
using Oxide.Core;
using Oxide.Core.Libraries;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Oxide.Plugins {
    [Info("zEcoLootUI", "https://topplugin.ru / https://discord.com/invite/5DPTsRmd3G", "1.1.17")]
    class zEcoLootUI : RustPlugin {
        string perm = "zecolootui.edit";
        private Dictionary<string, string> containerNames = new Dictionary<string, string>() {
            ["crate_basic"]
            = "Маленький деревянный ящик", ["crate_elite"] = "Элитный ящик", ["crate_mine"] = "Ящик из пещер", ["crate_tools"] = "Ящик с инструментами", ["crate_normal"] = "Зеленый военный ящик", ["crate_normal_2"] = "Обычный деревянный ящик", ["crate_normal_2_food"] = "Ящик с едой", ["crate_normal_2_medical"] = "Ящик с медециной", ["crate_underwater_advanced"] = "Большой подводный ящик", ["crate_underwater_basic"] = "Малый подводный ящик", ["foodbox"] = "Корзинка с едой", ["loot_barrel_1"] = "Синяя бочка у дорог", ["loot_barrel_2"] = "Ржавая бочка у дорог", ["loot-barrel-1"] = "Ржавая бочка на РТ", ["loot-barrel-2"] = "Синяя бочка на РТ", ["minecart"] = "Тележка с углем", ["bradley_crate"] = "Бредли ящик", ["oil_barrel"] = "Нефтяная бочка", ["heli_crate"] = "Вертолетный ящик", ["codelockedhackablecrate"] = "Ящик с электронным замком", ["supply_drop"] = "Аир дроп", ["trash-pile-1"] = "Корзинка с припасами", ["vehicle_parts"] = "Ящик с частями", ["codelockedhackablecrate_oilrig"] = "Ящик с электронным замком с Нефтевышки", ["presentdrop"] = "Новогодний дроп", ["dm ammo"] = "DM AMMO", ["dm c4"] = "DM C4", ["dm construction tools"] = "DM CONSTRUCTION TOOLS", ["dm food"] = "DM FOOD", ["dm res"] = "DM RES", ["dm tier1 lootbox"] = "DM TIER1 LOOTBOX", ["dm tier2 lootbox"] = "DM TIER2 LOOTBOX", ["dm tier3 lootbox"] = "DM TIER3 LOOTBOX", ["loot_component_test"] = "LOOT_COMPONENT_TEST", ["roadsign1"] = "ROADSIGN 1", ["roadsign2"] = "ROADSIGN 2", ["roadsign3"] = "ROADSIGN 3", ["roadsign4"] = "ROADSIGN 4", ["roadsign5"] = "ROADSIGN 5", ["roadsign6"] = "ROADSIGN 6", ["roadsign7"] = "ROADSIGN 7", ["roadsign8"] = "ROADSIGN 8", ["roadsign9"] = "ROADSIGN 9", ["giftbox_loot"] = "GIFTBOX_LOOT", ["diesel_barrel_world"] = "DIESEL_BARREL_WORLD", ["visualshelvestest"] = "VISUALSHELVESTEST"
        }
        ;
        List<string> prefabcontaner = new List<string>() {
            "assets/bundled/prefabs/radtown/crate_basic.prefab", "assets/bundled/prefabs/radtown/crate_elite.prefab", "assets/bundled/prefabs/radtown/crate_mine.prefab", "assets/bundled/prefabs/radtown/crate_tools.prefab", "assets/bundled/prefabs/radtown/crate_normal.prefab", "assets/bundled/prefabs/radtown/crate_normal_2.prefab", "assets/bundled/prefabs/radtown/crate_normal_2_food.prefab", "assets/bundled/prefabs/radtown/crate_normal_2_medical.prefab", "assets/bundled/prefabs/radtown/crate_underwater_advanced.prefab", "assets/bundled/prefabs/radtown/crate_underwater_basic.prefab", "assets/bundled/prefabs/radtown/foodbox.prefab", "assets/bundled/prefabs/radtown/loot_barrel_1.prefab", "assets/bundled/prefabs/radtown/loot_barrel_2.prefab", "assets/bundled/prefabs/autospawn/resource/loot/loot-barrel-1.prefab", "assets/bundled/prefabs/autospawn/resource/loot/loot-barrel-2.prefab", "assets/bundled/prefabs/radtown/minecart.prefab", "assets/prefabs/npc/m2bradley/bradley_crate.prefab", "assets/bundled/prefabs/radtown/oil_barrel.prefab", "assets/prefabs/npc/patrol helicopter/heli_crate.prefab", "assets/prefabs/deployable/chinooklockedcrate/codelockedhackablecrate.prefab", "assets/prefabs/misc/supply drop/supply_drop.prefab", "assets/bundled/prefabs/autospawn/resource/loot/trash-pile-1.prefab", "assets/bundled/prefabs/radtown/vehicle_parts.prefab", "assets/prefabs/deployable/chinooklockedcrate/codelockedhackablecrate_oilrig.prefab", "assets/prefabs/misc/xmas/sleigh/presentdrop.prefab", "assets/bundled/prefabs/radtown/dmloot/dm ammo.prefab", "assets/bundled/prefabs/radtown/dmloot/dm c4.prefab", "assets/bundled/prefabs/radtown/dmloot/dm construction tools.prefab", "assets/bundled/prefabs/radtown/dmloot/dm res.prefab", "assets/bundled/prefabs/radtown/dmloot/dm food.prefab", "assets/bundled/prefabs/radtown/dmloot/dm tier1 lootbox.prefab", "assets/bundled/prefabs/radtown/dmloot/dm tier2 lootbox.prefab", "assets/bundled/prefabs/radtown/dmloot/dm tier3 lootbox.prefab", "assets/bundled/prefabs/radtown/loot_component_test.prefab", "assets/content/props/roadsigns/roadsign1.prefab", "assets/content/props/roadsigns/roadsign2.prefab", "assets/content/props/roadsigns/roadsign3.prefab", "assets/content/props/roadsigns/roadsign4.prefab", "assets/content/props/roadsigns/roadsign5.prefab", "assets/content/props/roadsigns/roadsign6.prefab", "assets/content/props/roadsigns/roadsign7.prefab", "assets/content/props/roadsigns/roadsign8.prefab", "assets/content/props/roadsigns/roadsign9.prefab", "assets/prefabs/misc/xmas/giftbox/giftbox_loot.prefab", "assets/prefabs/resource/diesel barrel/diesel_barrel_world.prefab", "assets/scripts/entity/misc/visualstoragecontainer/visualshelvestest.prefab"
        }
        ;
        PluginConfig config;
        public class PluginConfig {
            [JsonProperty("Настройка контейнеров")]
            public Dictionary<string, LootSetting> crateSetting;
        }
        public class LootSetting {
            [JsonProperty("Рандомить количество слотов в ящике? (false - будет браться максимум)")]
            public bool RandomItemAmount;
            [JsonProperty("Максимум слотов")]
            public int MaxItemInCrate;
            [JsonProperty("Минимум слотов")]
            public int MinItemInCrate;
            [JsonProperty("Удалять ящик если не был залутан до конца?")]
            public bool DeleteCrate;
            [JsonProperty("Интервал удаления ящика (минуты)")]
            public int DeleteTimer;
        }
        Dictionary<string, LootSetting> ConfigSetup() {
            Dictionary<string, LootSetting> setting = new Dictionary<string, LootSetting>();
            foreach (var value in containerNames.Values) {
                setting.Add(value, new LootSetting() {
                    RandomItemAmount = false, MaxItemInCrate = 4, MinItemInCrate = 4, DeleteCrate = true, DeleteTimer = 5
                }
                );
            }
            return setting;
        }
        protected override void LoadDefaultConfig() {
            config = new PluginConfig() {
                crateSetting = ConfigSetup()
            }
            ;
        }
        protected override void LoadConfig() {
            base.LoadConfig();
            config = Config.ReadObject<PluginConfig>();
            foreach (KeyValuePair<string, string> value in containerNames.Where(x => !config.crateSetting.ContainsKey(x.Value))) {
                PrintWarning($"Added New crate {value.Value}");
                config.crateSetting.Add(value.Value, new LootSetting() {
                    RandomItemAmount = false, MaxItemInCrate = 4, MinItemInCrate = 4, DeleteCrate = true, DeleteTimer = 5
                }
                );
            }
            SaveConfig();
        }
        protected override void SaveConfig() => Config.WriteObject(config);
        bool init = false;
        void OnServerInitialized() {
            version = $"{this.Version.Major}_{this.Version.Minor}_{this.Version.Patch}";
            ChekNewItem();
            GetDefaultLoot();
            RestoreBase();
            LootTimer();
            permission.RegisterPermission(perm, this);
            PrintWarning($"Registered permission {perm}");
            init = true;
            var containers = BaseNetworkable.serverEntities.OfType<LootContainer>();
            foreach(var container in containers) {
                ServerMgr.Instance.StartCoroutine(FillContaner(container));
            }
        }
        string version = $"";
        private Dictionary<BasePlayer, bool> visionImage = new Dictionary<BasePlayer, bool>();
        void RestoreBase() {
            foreach (var prefab in containerNames) {
                List<ItemSetting> itemlist = Interface.Oxide.DataFileSystem.ReadObject<List<ItemSetting>>($"zEcoLootUI/{prefab.Value}");
                foreach (var loot in itemlist) {
                    if (loot.version == $"{this.Version.Major}_{this.Version.Minor}_{this.Version.Patch}") continue;
                    loot.version = version;
                    Item it = ItemManager.CreateByName(loot.shortname);
                    if (it.hasCondition && (loot.Condition == 0f || loot.Condition > 100f)) {
                        var fraction = UnityEngine.Random.Range(it.info.condition.foundCondition.fractionMin, it.info.condition.foundCondition.fractionMax);
                        var condition = fraction * 100f;
                        loot.Condition = condition;
                    }
                    loot.HasCondition = it.hasCondition;
                }
                Interface.Oxide.DataFileSystem.WriteObject($"zEcoLootUI/{prefab.Value}", itemlist);
            }
        }
        void Unload() {
            foreach (var pl in BasePlayer.activePlayerList) {
                CuiHelper.DestroyUi(pl, "zEcoLootUI.Main.UI");
            }
        }
        void OnHammerHit(BasePlayer player, HitInfo info) {
            if (!player.IsAdmin && !permission.UserHasPermission(player.UserIDString, perm)) return;
            if (!(info.HitEntity is LootContainer)) return;
            CuiHelper.DestroyUi(player, "zEcoLootUI.Main.UI");
            var container = new CuiElementContainer();
            container.Add(new CuiElement() {
                Parent = "Overlay", Name = "zEcoLootUI.Main.UI", Components = {
                    new CuiButtonComponent {
                        Close = "zEcoLootUI.Main.UI", Color = "0 0 0 0.8", Sprite = "assets/content/ui/ui.background.transparent.radial.psd", Material = "assets/content/ui/uibackgroundblur.mat"
                    }
                    , new CuiNeedsCursorComponent {
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0 0", AnchorMax = "1 1",
                    }
                }
            }
            );
            container.Add(new CuiElement() {
                Parent = "zEcoLootUI.Main.UI", Name = $"zEcoLootUI.Main.UI.text", Components = {
                    new CuiTextComponent {
                        Text = $"Редактируется:\n{(containerNames.ContainsKey(info.HitEntity.ShortPrefabName) ? containerNames[info.HitEntity.ShortPrefabName] : info.HitEntity.ShortPrefabName)}", Align = TextAnchor.MiddleCenter, FontSize = 22
                    }
                    , new CuiOutlineComponent {
                        Color = "0 0 0 1", Distance = "-1 1"
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = $"0.5 0.9", AnchorMax = $"0.5 0.9", OffsetMin = $"-250 -64", OffsetMax = $"250 80",
                    }
                }
            }
            );
            CuiHelper.AddUi(player, container);
            DrawPanel(player, info.HitEntity.ShortPrefabName);
        }
        void DrawPanel(BasePlayer player, string prefab) {
            if (coroutine != null) ServerMgr.Instance.StopCoroutine(coroutine);
            var container = new CuiElementContainer();
            CuiHelper.DestroyUi(player, "zEcoLootUI.Main.UI.BG");
            container.Add(new CuiElement() {
                Parent = "zEcoLootUI.Main.UI", Name = "zEcoLootUI.Main.UI.BG", Components = {
                    new CuiImageComponent {
                        Color = "0 0 0 0.0"
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0 0", AnchorMax = "1 1",
                    }
                }
            }
            );
            CuiHelper.AddUi(player, container);
            DrawCrateitem(player, prefab);
        }
        void DrawCrateitem(BasePlayer player, string prefab, int page = 0) {
            ServerMgr.Instance.StartCoroutine(DrawCrateItem(player, prefab, page));
        }
        Coroutine coroutine;
        [PluginReference]
        Plugin ImageLibrary;
        [ConsoleCommand("AddSlot")]
        void AddSlot(ConsoleSystem.Arg arg) {
            var player = arg.Player();
            var prefab = string.Join(" ", arg.Args.Skip(1));
            var type = arg.Args[0];
            if (type == "min") {
                config.crateSetting[containerNames[prefab]].MinItemInCrate++;
                if (config.crateSetting[containerNames[prefab]].MaxItemInCrate < config.crateSetting[containerNames[prefab]].MinItemInCrate) config.crateSetting[containerNames[prefab]].MaxItemInCrate = config.crateSetting[containerNames[prefab]].MinItemInCrate;
                Config.WriteObject(config);
            }
            else if (type == "max") {
                config.crateSetting[containerNames[prefab]].MaxItemInCrate++;
                Config.WriteObject(config);
            }
            CuiHelper.DestroyUi(player, type == "min" ? $"zEcoLootUI.Main.UI.BG.Slot.MinText" : $"zEcoLootUI.Main.UI.BG.Slot.MaxText");
            var container = new CuiElementContainer();
            container.Add(new CuiElement() {
                Parent = "zEcoLootUI.Main.UI.BG", Name = type == "min" ? $"zEcoLootUI.Main.UI.BG.Slot.MinText" : $"zEcoLootUI.Main.UI.BG.Slot.MaxText", Components = {
                    new CuiTextComponent {
                        Text = type == "min" ? $"{config.crateSetting[containerNames[prefab]].MinItemInCrate}" : $"{config.crateSetting[containerNames[prefab]].MaxItemInCrate}", Align = TextAnchor.MiddleCenter, FontSize = 22
                    }
                    , new CuiOutlineComponent {
                        Color = "0 0 0 1", Distance = "-1 1"
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = type == "min" ? $"0.15 0.98" : "0.15 0.935", AnchorMax =type == "min" ? $"0.15 0.98" : "0.15 0.935", OffsetMin = $"-30 -15", OffsetMax = $"30 15",
                    }
                }
            }
            );
            CuiHelper.AddUi(player, container);
        }
        [ConsoleCommand("RemSlot")]
        void RemSlot(ConsoleSystem.Arg arg) {
            var player = arg.Player();
            var prefab = string.Join(" ", arg.Args.Skip(1));
            var type = arg.Args[0];
            if (type == "min") {
                config.crateSetting[containerNames[prefab]].MinItemInCrate--;
                if (config.crateSetting[containerNames[prefab]].MinItemInCrate < 1) config.crateSetting[containerNames[prefab]].MinItemInCrate = 1;
                Config.WriteObject(config);
            }
            else if (type == "max") {
                config.crateSetting[containerNames[prefab]].MaxItemInCrate--;
                if (config.crateSetting[containerNames[prefab]].MaxItemInCrate < 1) config.crateSetting[containerNames[prefab]].MaxItemInCrate = 1;
                if (config.crateSetting[containerNames[prefab]].MinItemInCrate > config.crateSetting[containerNames[prefab]].MaxItemInCrate) config.crateSetting[containerNames[prefab]].MinItemInCrate = config.crateSetting[containerNames[prefab]].MaxItemInCrate;
            }
            CuiHelper.DestroyUi(player, type == "min" ? $"zEcoLootUI.Main.UI.BG.Slot.MinText" : $"zEcoLootUI.Main.UI.BG.Slot.MaxText");
            var container = new CuiElementContainer();
            container.Add(new CuiElement() {
                Parent = "zEcoLootUI.Main.UI.BG", Name = type == "min" ? $"zEcoLootUI.Main.UI.BG.Slot.MinText" : $"zEcoLootUI.Main.UI.BG.Slot.MaxText", Components = {
                    new CuiTextComponent {
                        Text = type == "min" ? $"{config.crateSetting[containerNames[prefab]].MinItemInCrate}" : $"{config.crateSetting[containerNames[prefab]].MaxItemInCrate}", Align = TextAnchor.MiddleCenter, FontSize = 22
                    }
                    , new CuiOutlineComponent {
                        Color = "0 0 0 1", Distance = "-1 1"
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = type == "min" ? $"0.15 0.98" : "0.15 0.935", AnchorMax = type == "min" ? $"0.15 0.98" : "0.15 0.935", OffsetMin = $"-30 -15", OffsetMax = $"30 15",
                    }
                }
            }
            );
            CuiHelper.AddUi(player, container);
        }
        IEnumerator DrawCrateItem(BasePlayer player, string prefab, int page = 0) {
            CuiHelper.DestroyUi(player, "zEcoLootUI.Main.UI.BG");
            if (!visionImage.ContainsKey(player)) visionImage.Add(player, false);
            List<ItemSetting> itemlist = Interface.Oxide.DataFileSystem.ReadObject<List<ItemSetting>>($"zEcoLootUI/{containerNames[prefab]}");
            var container = new CuiElementContainer();
            container.Add(new CuiElement() {
                Parent = "zEcoLootUI.Main.UI", Name = "zEcoLootUI.Main.UI.BG", Components = {
                    new CuiImageComponent {
                        Color = "0 0 0 0.0"
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0 0", AnchorMax = "1 1",
                    }
                }
            }
            );
            container.Add(new CuiButton() {
                Button = {
                    Command = $"AddSlot min {prefab}", Color = "0 1 0 0.3"
                }
                , Text = {
                    Text = "+Slot", Align = TextAnchor.MiddleCenter
                }
                , RectTransform = {
                    AnchorMin = "0.1 0.98", AnchorMax = "0.1 0.98", OffsetMin = "-30 -15", OffsetMax = "30 15"
                }
            }
            , "zEcoLootUI.Main.UI.BG", "AddSlot");
            container.Add(new CuiElement() {
                Parent = "zEcoLootUI.Main.UI.BG", Name = $"zEcoLootUI.Main.UI.BG.Slot.MinText", Components = {
                    new CuiTextComponent {
                        Text = $"{config.crateSetting[containerNames[prefab]].MinItemInCrate}", Align = TextAnchor.MiddleCenter, FontSize = 22
                    }
                    , new CuiOutlineComponent {
                        Color = "0 0 0 1", Distance = "-1 1"
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = $"0.15 0.98", AnchorMax = $"0.15 0.98", OffsetMin = $"-30 -15", OffsetMax = $"30 15",
                    }
                }
            }
            );
            container.Add(new CuiElement() {
                Parent = "zEcoLootUI.Main.UI.BG", Name = $"zEcoLootUI.Main.UI.BG.Slot", Components = {
                    new CuiTextComponent {
                        Text = $"MIN: ", Align = TextAnchor.MiddleCenter, FontSize = 22
                    }
                    , new CuiOutlineComponent {
                        Color = "0 0 0 1", Distance = "-1 1"
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = $"0.05 0.98", AnchorMax = $"0.05 0.98", OffsetMin = $"-30 -15", OffsetMax = $"30 15",
                    }
                }
            }
            );
            container.Add(new CuiButton() {
                Button = {
                    Command = $"RemSlot min {prefab}", Color = "0 1 0 0.3"
                }
                , Text = {
                    Text = "-Slot", Align = TextAnchor.MiddleCenter
                }
                , RectTransform = {
                    AnchorMin = "0.2 0.98", AnchorMax = "0.2 0.98", OffsetMin = "-30 -15", OffsetMax = "30 15"
                }
            }
            , "zEcoLootUI.Main.UI.BG", "RemSlot");
            //////////////////////////////////////////////////////////////////////////////////////////////
            ///
            container.Add(new CuiButton() {
                Button = {
                    Command = $"AddSlot max {prefab}", Color = "0 1 0 0.3"
                }
                , Text = {
                    Text = "+Slot", Align = TextAnchor.MiddleCenter
                }
                , RectTransform = {
                    AnchorMin = "0.1 0.935", AnchorMax = "0.1 0.935", OffsetMin = "-30 -15", OffsetMax = "30 15"
                }
            }
            , "zEcoLootUI.Main.UI.BG", "AddSlot");
            container.Add(new CuiElement() {
                Parent = "zEcoLootUI.Main.UI.BG", Name = $"zEcoLootUI.Main.UI.BG.Slot.MaxText", Components = {
                    new CuiTextComponent {
                        Text = $"{config.crateSetting[containerNames[prefab]].MaxItemInCrate}", Align = TextAnchor.MiddleCenter, FontSize = 22
                    }
                    , new CuiOutlineComponent {
                        Color = "0 0 0 1", Distance = "-1 1"
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = $"0.15 0.935", AnchorMax = $"0.15 0.935", OffsetMin = $"-30 -15", OffsetMax = $"30 15",
                    }
                }
            }
            );
            container.Add(new CuiElement() {
                Parent = "zEcoLootUI.Main.UI.BG", Name = $"zEcoLootUI.Main.UI.BG.Slot", Components = {
                    new CuiTextComponent {
                        Text = $"MAX: ", Align = TextAnchor.MiddleCenter, FontSize = 22
                    }
                    , new CuiOutlineComponent {
                        Color = "0 0 0 1", Distance = "-1 1"
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = $"0.05 0.935", AnchorMax = $"0.05 0.935", OffsetMin = $"-30 -15", OffsetMax = $"30 15",
                    }
                }
            }
            );
            container.Add(new CuiButton() {
                Button = {
                    Command = $"RemSlot max {prefab}", Color = "0 1 0 0.3"
                }
                , Text = {
                    Text = "-Slot", Align = TextAnchor.MiddleCenter
                }
                , RectTransform = {
                    AnchorMin = "0.2 0.935", AnchorMax = "0.2 0.935", OffsetMin = "-30 -15", OffsetMax = "30 15"
                }
            }
            , "zEcoLootUI.Main.UI.BG", "RemSlot");
            //////////////////////////////////////////////////////////////////////////////////
            container.Add(new CuiButton() {
                Button = {
                    Command = $"Add {prefab}", Color = "0 1 0 0.3"
                }
                , Text = {
                    Text = "ДОБАВИТЬ", Align = TextAnchor.MiddleCenter
                }
                , RectTransform = {
                    AnchorMin = "0.4 0.05", AnchorMax = "0.4 0.05", OffsetMin = "-60 -15", OffsetMax = "60 15"
                }
            }
            , "zEcoLootUI.Main.UI.BG", "AddBtn");
            container.Add(new CuiButton() {
                Button = {
                    Command = $"hidelootimage {prefab}", Color = "1 1 1 0.3"
                }
                , Text = {
                    Text = visionImage.ContainsKey(player) ? visionImage[player] ? "Показать картинки" : "Скрыть картинки" : "Скрыть картинки", Align = TextAnchor.MiddleCenter
                }
                , RectTransform = {
                    AnchorMin = "0.5 0.05", AnchorMax = "0.5 0.05", OffsetMin = "-60 -20", OffsetMax = "40 20"
                }
            }
            , "zEcoLootUI.Main.UI.BG", "HideImageBtn");
            container.Add(new CuiButton() {
                Button = {
                    Command = $"AddInv {prefab}", Color = "1 1 1 0.2"
                }
                , Text = {
                    Text = "ДОБАВИТЬ ИЗ ИНВЕТАРЯ", Align = TextAnchor.MiddleCenter
                }
                , RectTransform = {
                    AnchorMin = "0.6 0.05", AnchorMax = "0.6 0.05", OffsetMin = "-80 -15", OffsetMax = "80 15"
                }
            }
            , "zEcoLootUI.Main.UI.BG", "AddBtn");
            CuiHelper.AddUi(player, container);
            var starthorisontal = 0.05f;
            var startvertical = 0.8f;
            var horisontal = starthorisontal;
            var vertical = startvertical;
            var widthBtn = 32;
            var hightBtn = 32;
            int count = 0;
            int i = page == 0 ? 0 : page * 60;
            foreach (var item in itemlist.Skip(page * 60).Take(60)) {
                var itemContainer = new CuiElementContainer();
                if (!visionImage[player]) {
                    itemContainer.Add(new CuiElement() {
                        Parent = "zEcoLootUI.Main.UI.BG", Name = $"zEcoLootUI.Main.UI.BG.{i}", Components = {
                            new CuiRawImageComponent {
                                Png = GetItemImage(item.shortname, item.skin)
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = $"{horisontal} {vertical}", AnchorMax = $"{horisontal} {vertical}", OffsetMin = $"-{widthBtn} -{hightBtn}", OffsetMax = $"{widthBtn} {hightBtn}",
                            }
                        }
                    }
                    );
                }
                else {
                    itemContainer.Add(new CuiElement() {
                        Parent = "zEcoLootUI.Main.UI.BG", Name = $"zEcoLootUI.Main.UI.BG.{i}", Components = {
                            new CuiImageComponent {
                                Color = "1 1 1 0.1"
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = $"{horisontal} {vertical}", AnchorMax = $"{horisontal} {vertical}", OffsetMin = $"-{widthBtn} -{hightBtn}", OffsetMax = $"{widthBtn} {hightBtn}",
                            }
                        }
                    }
                    );
                }
                itemContainer.Add(new CuiElement() {
                    Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Delete", Components = {
                        new CuiButtonComponent {
                            Color = "1 0 0 0.4", Command = $"Delete {page} {i} {prefab}"
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "1 1", AnchorMax = "1 1", OffsetMin = "-20 -16", OffsetMax = "0 0"
                        }
                    }
                }
                );
                itemContainer.Add(new CuiElement() {
                    Parent = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Delete", Name = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Delete.Txt", Components = {
                        new CuiTextComponent {
                            Text = "Del", Align = TextAnchor.MiddleCenter, FontSize = 12
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 0", AnchorMax = "1 1"
                        }
                    }
                }
                );
                if (item.IsBp) itemContainer.Add(new CuiElement() {
                    Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.IsBP", Components = {
                        //new CuiRawImageComponent{Png = GetItemImage("blueprintbase") },
                        new CuiRawImageComponent {
                            Sprite ="assets/icons/blueprint.png"
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = "0 -20", OffsetMax = "20 0"
                        }
                    }
                }
                );
                else {
                    if (item.HasCondition) {
                        itemContainer.Add(new CuiElement() {
                            Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.condition.BG", Components = {
                                new CuiImageComponent {
                                    Color = "1 1 1 0.5"
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "1 1", OffsetMax = "5 62"
                                }
                            }
                        }
                        );
                        var cond = 62 * item.Condition / 100f;
                        itemContainer.Add(new CuiElement() {
                            Parent = $"zEcoLootUI.Main.UI.BG.{i}.condition.BG", Name = $"zEcoLootUI.Main.UI.BG.{i}.condition", Components = {
                                new CuiImageComponent {
                                    Color = "0 0.5 0 1"
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "0 0", OffsetMax = $"4 {cond}"
                                }
                            }
                        }
                        );
                        itemContainer.Add(new CuiElement() {
                            Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Condition", Components = {
                                new CuiButtonComponent {
                                    Color = "1 1 1 0.3", Command = $"condition {page} {i} {prefab}"
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = "1 -11", OffsetMax = "25 -1"
                                }
                            }
                        }
                        );
                        itemContainer.Add(new CuiElement() {
                            Parent = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Condition", Name = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Condition.Txt", Components = {
                                new CuiTextComponent {
                                    Text = "cond", Align = TextAnchor.MiddleCenter, FontSize = 9, Color = "1 1 1 1"
                                }
                                , new CuiRectTransformComponent {
                                    AnchorMin = "0 0", AnchorMax = "1 1"
                                }
                            }
                        }
                        );
                    }
                }
                itemContainer.Add(new CuiElement() {
                    Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.text", Components = {
                        new CuiTextComponent {
                            Text = string.IsNullOrEmpty(item.custonname) ? ItemManager.CreateByName(item.shortname).info.displayName.english : item.custonname, Align = TextAnchor.MiddleCenter
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"-{widthBtn+5} -40", OffsetMax = $"{widthBtn+5} -5",
                        }
                    }
                }
                );
                itemContainer.Add(new CuiButton() {
                    Button = {
                        Command = $"BPChange {page} {i} {prefab}", Color = "1 1 1 0.3"
                    }
                    , Text = {
                        Text = "BP", Align = TextAnchor.MiddleCenter, FontSize = 8
                    }
                    , RectTransform = {
                        AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 41", OffsetMax = $"66 50",
                    }
                }
                , $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMinBP.{i}");
                itemContainer.Add(new CuiElement() {
                    Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.textmin", Components = {
                        new CuiTextComponent {
                            Text = $"min - {item.minamount}" , Align = TextAnchor.MiddleRight, FontSize = 9
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"-{widthBtn+10} 15", OffsetMax = $"{widthBtn+10} 35",
                        }
                    }
                }
                );
                itemContainer.Add(new CuiButton() {
                    Button = {
                        Command = $"editfeil {page} {i} minminus {prefab}", Color = "1 1 1 0.3"
                    }
                    , Text = {
                        Text = "edit", Align = TextAnchor.MiddleCenter, FontSize = 8
                    }
                    , RectTransform = {
                        AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 21", OffsetMax = $"66 30",
                    }
                }
                , $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMinMinus.{i}");
                itemContainer.Add(new CuiElement() {
                    Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.textmax", Components = {
                        new CuiTextComponent {
                            Text = $"max - {item.maxamount}" , Align = TextAnchor.MiddleRight, FontSize = 9
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"-{widthBtn+10} 5", OffsetMax = $"{widthBtn+10} 25",
                        }
                    }
                }
                );
                itemContainer.Add(new CuiButton() {
                    Button = {
                        Command = $"editfeil {page} {i} maxminus {prefab}", Color = "1 1 1 0.3"
                    }
                    , Text = {
                        Text = "edit", Align = TextAnchor.MiddleCenter, FontSize = 8
                    }
                    , RectTransform = {
                        AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 10", OffsetMax = $"66 19",
                    }
                }
                , $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMaxMinus.{i}");
                itemContainer.Add(new CuiElement() {
                    Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.textchance", Components = {
                        new CuiTextComponent {
                            Text = $"chance - {item.chansedrop}%" , Align = TextAnchor.MiddleRight, FontSize = 9
                        }
                        , new CuiRectTransformComponent {
                            AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"-{widthBtn+10} -10", OffsetMax = $"{widthBtn+10} 15",
                        }
                    }
                }
                );
                itemContainer.Add(new CuiButton() {
                    Button = {
                        Command = $"editfeil {page} {i} chanceminus {prefab}", Color = "1 1 1 0.3"
                    }
                    , Text = {
                        Text = "edit", Align = TextAnchor.MiddleCenter, FontSize = 8
                    }
                    , RectTransform = {
                        AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 -1", OffsetMax = $"66 8",
                    }
                }
                , $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMaxChanceMinus.{i}");
                horisontal += 0.08f;
                if (horisontal > 0.95) {
                    horisontal = starthorisontal;
                    vertical -= 0.15f;
                }
                count++;
                i++;
                CuiHelper.DestroyUi(player, $"zEcoLootUI.Main.UI.BG.{i}");
                CuiHelper.AddUi(player, itemContainer);
                yield return null;
            }
            if (count == 0 && page > 0) {
                page--;
                if (coroutine != null) ServerMgr.Instance.StopCoroutine(coroutine);
                DrawCrateitem(player, prefab, page);
                yield break;
            }
            if (page > 0) {
                var continerBack = new CuiElementContainer();
                continerBack.Add(new CuiButton() {
                    Button = {
                        Command = $"pages {prefab} {page - 1}", Color = "1 1 1 0.5"
                    }
                    , Text = {
                        Text = "Назад", Align = TextAnchor.MiddleCenter
                    }
                    , RectTransform = {
                        AnchorMin = "0.02 0.02", AnchorMax = "0.02 0.02", OffsetMax = "60 30"
                    }
                }
                , "zEcoLootUI.Main.UI.BG", "ButtonBack");
                CuiHelper.AddUi(player, continerBack);
            }
            if (count == 60) {
                var continerNext = new CuiElementContainer();
                continerNext.Add(new CuiButton() {
                    Button = {
                        Command = $"pages {prefab} {page + 1}", Color = "1 1 1 0.5"
                    }
                    , Text = {
                        Text = "Далее", Align = TextAnchor.MiddleCenter
                    }
                    , RectTransform = {
                        AnchorMin = "0.98 0.02", AnchorMax = "0.98 0.02", OffsetMin = "-60 0", OffsetMax = "0 30"
                    }
                }
                , "zEcoLootUI.Main.UI.BG", "ButtonNext");
                CuiHelper.AddUi(player, continerNext);
            }
        }
        void RedrawItem(BasePlayer player, ItemSetting item, int i, string prefab, int page) {
            CuiHelper.DestroyUi(player, "zEcoLootUI.Main.UI.Adding.BG");
            CuiHelper.DestroyUi(player, $"zEcoLootUI.Main.UI.BG.{i}.textmin");
            CuiHelper.DestroyUi(player, $"zEcoLootUI.Main.UI.BG.{i}.IsBP");
            CuiHelper.DestroyUi(player, $"zEcoLootUI.Main.UI.BG.{i}.textmax");
            CuiHelper.DestroyUi(player, $"zEcoLootUI.Main.UI.BG.{i}.condition.BG");
            CuiHelper.DestroyUi(player, $"zEcoLootUI.Main.UI.BG.{i}.Btn_Condition");
            CuiHelper.DestroyUi(player, $"ButtonMinMinus.{i}");
            CuiHelper.DestroyUi(player, $"ButtonMaxMinus.{i}");
            CuiHelper.DestroyUi(player, $"zEcoLootUI.Main.UI.BG.{i}.textchance");
            CuiHelper.DestroyUi(player, $"ButtonMaxChancePlus.{i}");
            CuiHelper.DestroyUi(player, $"ButtonMaxChanceMinus.{i}");
            CuiHelper.DestroyUi(player, $"ButtonMinBP.{i}");
            var container = new CuiElementContainer();
            if (item.IsBp) container.Add(new CuiElement() {
                Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.IsBP", Components = {
                    new CuiRawImageComponent {
                        Png = GetItemImage("blueprintbase")
                    }
                    , new CuiRectTransformComponent {
                        AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = "0 -20", OffsetMax = "20 0"
                    }
                }
            }
            );
            else {
                if (item.HasCondition) {
                    container.Add(new CuiElement() {
                        Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.condition.BG", Components = {
                            new CuiImageComponent {
                                Color = "1 1 1 0.5"
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "1 1", OffsetMax = "5 62"
                            }
                        }
                    }
                    );
                    var cond = 62 * item.Condition / 100f;
                    container.Add(new CuiElement() {
                        Parent = $"zEcoLootUI.Main.UI.BG.{i}.condition.BG", Name = $"zEcoLootUI.Main.UI.BG.{i}.condition", Components = {
                            new CuiImageComponent {
                                Color = "0 0.5 0 1"
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "0 0", OffsetMax = $"4 {cond}"
                            }
                        }
                    }
                    );
                    container.Add(new CuiElement() {
                        Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Condition", Components = {
                            new CuiButtonComponent {
                                Color = "1 1 1 0.3", Command = $"condition {page} {i} {prefab}"
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = "1 -11", OffsetMax = "25 -1"
                            }
                        }
                    }
                    );
                    container.Add(new CuiElement() {
                        Parent = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Condition", Name = $"zEcoLootUI.Main.UI.BG.{i}.Btn_Condition.Txt", Components = {
                            new CuiTextComponent {
                                Text = "cond", Align = TextAnchor.MiddleCenter, FontSize = 9, Color = "1 1 1 1"
                            }
                            , new CuiRectTransformComponent {
                                AnchorMin = "0 0", AnchorMax = "1 1"
                            }
                        }
                    }
                    );
                }
            }
            container.Add(new CuiButton() {
                Button = {
                    Command = $"BPChange {page} {i} {prefab}", Color = "1 1 1 0.3"
                }
                , Text = {
                    Text = "BP", Align = TextAnchor.MiddleCenter, FontSize = 8
                }
                , RectTransform = {
                    AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 41", OffsetMax = $"66 50",
                }
            }
            , $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMinBP.{i}");
            container.Add(new CuiElement() {
                Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.textmin", Components = {
                    new CuiTextComponent {
                        Text = $"min - {item.minamount}" , Align = TextAnchor.MiddleRight, FontSize = 9
                    }
                    ,  //new CuiOutlineComponent{Color = "0 0 0 1", Distance = "-1 1"},
                    new CuiRectTransformComponent {
                        AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"-42 15", OffsetMax = $"42 35",
                    }
                }
            }
            );
            container.Add(new CuiButton() {
                Button = {
                    Command = $"editfeil {page} {i} minminus {prefab}", Color = "1 1 1 0.3"
                }
                , Text = {
                    Text = "edit", Align = TextAnchor.MiddleCenter, FontSize = 8
                }
                , RectTransform = {
                    AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 21", OffsetMax = $"66 30",
                }
            }
            , $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMinMinus.{i}");
            container.Add(new CuiElement() {
                Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.textmax", Components = {
                    new CuiTextComponent {
                        Text = $"max - {item.maxamount}" , Align = TextAnchor.MiddleRight, FontSize = 9
                    }
                    ,  //new CuiOutlineComponent{Color = "0 0 0 1", Distance = "-1 1"},
                    new CuiRectTransformComponent {
                        AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"-42 5", OffsetMax = $"42 25",
                    }
                }
            }
            );
            container.Add(new CuiButton() {
                Button = {
                    Command = $"editfeil {page} {i} maxminus {prefab}", Color = "1 1 1 0.3"
                }
                , Text = {
                    Text = "edit", Align = TextAnchor.MiddleCenter, FontSize = 8
                }
                , RectTransform = {
                    AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 10", OffsetMax = $"66 19",
                }
            }
            , $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMaxMinus.{i}");
            container.Add(new CuiElement() {
                Parent = $"zEcoLootUI.Main.UI.BG.{i}", Name = $"zEcoLootUI.Main.UI.BG.{i}.textchance", Components = {
                    new CuiTextComponent {
                        Text = $"chance - {item.chansedrop}%" , Align = TextAnchor.MiddleRight, FontSize = 9
                    }
                    ,  //new CuiOutlineComponent{Color = "0 0 0 1", Distance = "-1 1"},
                    new CuiRectTransformComponent {
                        AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"-{32+10} -10", OffsetMax = $"{32+10} 15",
                    }
                }
            }
            );
            container.Add(new CuiButton() {
                Button = {
                    Command = $"editfeil {page} {i} chanceminus {prefab}", Color = "1 1 1 0.3"
                }
                , Text = {
                    Text = "edit", Align = TextAnchor.MiddleCenter, FontSize = 8
                }
                , RectTransform = {
                    AnchorMin = $"0.5 0", AnchorMax = $"0.5 0", OffsetMin = $"45 -1", OffsetMax = $"66 8",
                }
            }
            , $"zEcoLootUI.Main.UI.BG.{i}", $"ButtonMaxChanceMinus.{i}");
            CuiHelper.AddUi(player, container);
        }
        [ConsoleCommand("hidelootimage")]
        void HideImage(ConsoleSystem.Arg arg) {
            var player = arg.Player();
            string prefab = string.Join(" ", arg.Args);
            if (visionImage.ContainsKey(player)) visionImage[player] = !visionImage[player];
            else visionImage.Add(player, false);
            DrawPanel(player, prefab);
        }
        [ConsoleCommand("chanceminus")]
        void chanceminus(ConsoleSystem.Arg arg) {
            var player = arg.Player();
            string prefab = string.Join(" ", arg.Args.Skip(2));
            prefab = prefab.Remove(prefab.LastIndexOf(' '));
            List<ItemSetting> itemlist = Interface.Oxide.DataFileSystem.ReadObject<List<ItemSetting>>($"zEcoLootUI/{containerNames[prefab]}");
            var page = arg.GetInt(0);
            var index = arg.GetInt(1);
            int amount = 0;
            if (!int.Try
// ... [Code preview truncated due to length. Full source in attached file] ...

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

Другие ресурсы пользователя 15FPS

Сверху