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

FREE ZealStatisticsReborn : 1.0.0 1.0.0

Нет прав для скачивания
C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Oxide.Core;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using Rust;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("ZealStatisticsReborn", "Kira", "1.0.0")]
    [Description("Interface for displaying player statistics")]
    public class ZealStatisticsReborn : RustPlugin
    {
        #region [Reference] / [Ссылки]

        [PluginReference] private Plugin ImageLibrary;

        #endregion

        #region [Vars] / [Переменные]

        private StoredData _dataBase = new StoredData();
        private ulong _lastDamagePlayer;
        private const string UILayerMain = "ZealStatisticsReborn_UI_Layer";
        private const string UILayerServer = "ZealStatisticsReborn_UI_LayerServer";
        private const string Sharp = "assets/content/ui/ui.background.tile.psd";
        private const string Blur = "assets/content/ui/uibackgroundblur.mat";
        private const string Radial = "assets/content/ui/ui.background.transparent.radial.psd";

        private class Filter
        {
            public string Name;
            public int Number;
        }

        private readonly List<Filter> _filters = new List<Filter>
        {
            new Filter
            {
                Name = "KILLS",
                Number = 0
            },
            new Filter
            {
                Name = "DEATHS",
                Number = 1
            },
            new Filter
            {
                Name = "ANIMAL_KILLS",
                Number = 2
            },
            new Filter
            {
                Name = "GATHER",
                Number = 3
            },
            new Filter
            {
                Name = "ENTITY_DESTROYING",
                Number = 4
            },
            new Filter
            {
                Name = "TIME_PLAYING",
                Number = 5
            },
        };

        #endregion 
 
        #region [Lang]

        protected override void LoadDefaultMessages()
        {
            var ru = new Dictionary<string, string>
            {
                ["KILL_NAME"] = "Убито игроков",
                ["DEATH_NAME"] = "Смертей от игроков",
                ["KILLANIMALS_NAME"] = "Убито животных",
                ["GATHERRESOURCES_NAME"] = "Добыто ресурсов",
                ["DESTROYINGOBJECTS_NAME"] = "Уничтожено объектов",
                ["PLAYEDTIME_NAME"] = "Наигранное время : ",
                ["General"] = "Общий счёт",
                ["Firearms"] = "Огнестрельное",
                ["Coldsteel"] = "Холодное",
                ["Bow"] = "Лук",
                ["Headshot"] = "В голову",
                ["Wounded"] = "Раненых",
                ["Sleeping"] = "Спящих",
                ["Bear"] = "Медведей",
                ["Boar"] = "Кабанов",
                ["Chicken"] = "Куриц",
                ["Stag"] = "Оленей",
                ["Horse"] = "Лошадей",
                ["Wolf"] = "Волков",
                ["Wood"] = "Дерева",
                ["Stones"] = "Камня",
                ["MetalOre"] = "Железа",
                ["SulfurOre"] = "Серы",
                ["Constructions"] = "Конструкций",
                ["Helicopter"] = "Вертолётов",
                ["BradleyApc"] = "Танков",
                ["AVATAR"] = "АВАТАР",
                ["NAME"] = "ИМЯ",
                ["KILLS"] = "УБИЙСТВ",
                ["DEATHS"] = "СМЕРТЕЙ",
                ["ANIMAL_KILLS"] = "УБИЙСТВ ЖИВОТНЫХ",
                ["GATHER"] = "ДОБЫТО РЕСУРСОВ",
                ["ENTITY_DESTROYING"] = "УНИЧТОЖЕНО ОБЪЕКТОВ",
                ["TIME_PLAYING"] = "НАИГРАННО ВРЕМЕНИ",
                ["GOTOP"] = "ПЕРЕЙТИ В ОБЩУЮ СТАТИСТИКУ\n▼",
                ["GOMAIN"] = "ПЕРЕЙТИ В ЛИЧНУЮ СТАТИСТИКУ\n▼",
                ["TOP"] = "ОБЩАЯ СТАТИСТИКА"
            };

            var en = new Dictionary<string, string>
            {
                ["KILL_NAME"] = "Killed players",
                ["DEATH_NAME"] = "Deaths for players",
                ["KILLANIMALS_NAME"] = "Killed animals",
                ["GATHERRESOURCES_NAME"] = "Gather resources",
                ["DESTROYINGOBJECTS_NAME"] = "Destroying objects",
                ["PLAYEDTIME_NAME"] = "Playing time : ",
                ["General"] = "General scores",
                ["Firearms"] = "Firearms",
                ["Coldsteel"] = "Coldsteel",
                ["Bow"] = "Bow",
                ["Headshot"] = "Headshot",
                ["Wounded"] = "Wounded",
                ["Sleeping"] = "Sleeping",
                ["Bear"] = "Bear",
                ["Boar"] = "Boar",
                ["Chicken"] = "Chicken",
                ["Stag"] = "Stag",
                ["Horse"] = "Horse",
                ["Wolf"] = "Wolf",
                ["Wood"] = "Wood",
                ["Stones"] = "Stones",
                ["MetalOre"] = "Metal",
                ["SulfurOre"] = "Sulfur",
                ["Constructions"] = "Constructions",
                ["Helicopter"] = "Helicopters",
                ["BradleyApc"] = "Tanks",
                ["AVATAR"] = "AVATAR",
                ["NAME"] = "NAME",
                ["KILLS"] = "KILLS",
                ["DEATHS"] = "DEATHS",
                ["ANIMAL_KILLS"] = "ANIMAL KILLS",
                ["GATHER"] = "GATHER RESOURCES",
                ["ENTITY_DESTROYING"] = "DESTROYING ENTITIES",
                ["TIME_PLAYING"] = "PLAYING TIME",
                ["GOTOP"] = "GO TO GENERAL STATISTICS\n▼",
                ["GOMAIN"] = "GO TO PERSONAL STATISTICS\n▼",
                ["TOP"] = "GENERAL STATISTICS"
            };
            lang.RegisterMessages(ru, this, "ru");
            lang.RegisterMessages(en, this);
        }

        #endregion
 
        #region [DrawUI] / [Отрисовка UI]

        private void DrawUI_MainStatistic(BasePlayer player, bool kills, bool killsAnimal, bool gather,
            bool objDestroying)
        {
            var ui = new CuiElementContainer
            {
                {
                    new CuiPanel
                    {
                        CursorEnabled = true,
                        Image =
                        {
                            Color = HexToRustFormat("#000000F9"),
                            Material = Blur,
                            Sprite = Radial
                        },
                        RectTransform =
                        {
                            AnchorMin = "0 0",
                            AnchorMax = "1 1"
                        }
                    },
                    "Overlay", UILayerMain
                },
                {
                    new CuiButton
                    {
                        Button =
                        {
                            Command = "zstats.close",
                            Color = "0 0 0 0"
                        },
                        Text =
                        {
                            Text = " "
                        },
                        RectTransform =
                        {
                            AnchorMin = "0 0",
                            AnchorMax = "1 1"
                        }
                    },
                    UILayerMain, "ButtonCloseGUI"
                },
                new CuiElement
                {
                    Name = $"{UILayerMain}_ServerName",
                    Parent = UILayerMain,
                    Components =
                    {
                        new CuiTextComponent
                        {
                            Align = TextAnchor.MiddleCenter,
                            Color = HexToRustFormat("#EAEAEAFF"),
                            FontSize = 40,
                            Text = ConVar.Server.hostname,
                            Font = "robotocondensed-regular.ttf"
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0 0.9213709",
                            AnchorMax = "1 1"
                        },
                        new CuiOutlineComponent
                        {
                            Color = HexToRustFormat("#000000AE"),
                            Distance = "0.5 0.5"
                        }
                    }
                },
                new CuiElement
                {
                    Name = $"{UILayerMain}_BGAvatar",
                    Parent = UILayerMain,
                    Components =
                    {
                        new CuiImageComponent
                        {
                            Color = HexToRustFormat("#FFFFFFA4")
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0.4360861 0.6925457",
                            AnchorMax = "0.5627829 0.9183521"
                        }
                    }
                },
                new CuiElement
                {
                    Name = $"{UILayerMain}_BGAvatar_Avatar",
                    Parent = $"{UILayerMain}_BGAvatar",
                    Components =
                    {
                        new CuiRawImageComponent
                        {
                            Png = (string) ImageLibrary.Call("GetImage", player.UserIDString)
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0.01 0.01",
                            AnchorMax = "0.988 0.989"
                        }
                    }
                },
                new CuiElement
                {
                    Name = $"{UILayerMain}_Avatar_Sprite",
                    Parent = $"{UILayerMain}_BGAvatar_Avatar",
                    Components =
                    {
                        new CuiImageComponent
                        {
                            Color = HexToRustFormat("#000000AA"),
                            Sprite = Radial
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0 0",
                            AnchorMax = "0.99 0.99"
                        }
                    }
                },
                new CuiElement
                {
                    Name = $"{UILayerMain}_Name",
                    Parent = UILayerMain,
                    Components =
                    {
                        new CuiTextComponent
                        {
                            Align = TextAnchor.MiddleCenter,
                            Color = "1 1 1 1",
                            FontSize = 23,
                            Text = player.displayName,
                            Font = "robotocondensed-regular.ttf"
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0.3212669 0.641129",
                            AnchorMax = "0.6804298 0.6875"
                        },
                        new CuiOutlineComponent
                        {
                            Color = HexToRustFormat("#000000AE"),
                            Distance = "0.5 0.5"
                        }
                    }
                },
                new CuiElement
                {
                    Name = $"{UILayerMain}_Name_Line",
                    Parent = UILayerMain,
                    Components =
                    {
                        new CuiImageComponent
                        {
                            Color = HexToRustFormat("#CBCBCBFF")
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0.3829193 0.6401247",
                            AnchorMax = "0.6193514 0.6411328"
                        }
                    }
                },
                new CuiElement
                {
                    Name = $"{UILayerMain}_SteamID",
                    Parent = UILayerMain,
                    Components =
                    {
                        new CuiTextComponent
                        {
                            Align = TextAnchor.MiddleCenter,
                            Color = "1 1 1 1",
                            FontSize = 14,
                            Text = player.UserIDString,
                            Font = "robotocondensed-regular.ttf"
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0.3212669 0.6088712",
                            AnchorMax = "0.6804298 0.6421358"
                        },
                        new CuiOutlineComponent
                        {
                            Color = HexToRustFormat("#000000AE"),
                            Distance = "0.5 0.5"
                        }
                    }
                },
                {
                    new CuiPanel
                    {
                        Image =
                        {
                            Color = "0 0 0 0"
                        },
                        RectTransform =
                        {
                            AnchorMin = "0.08177081 0.4453703",
                            AnchorMax = "0.9197907 0.5740741"
                        }
                    },
                    UILayerMain, $"{UILayerMain}_Layer_Statistics"
                },
                new CuiElement
                {
                    Name = $"{UILayerMain}_PlayedTimeValue",
                    Parent = UILayerMain,
                    Components =
                    {
                        new CuiTextComponent
                        {
                            Align = TextAnchor.MiddleCenter,
                            Color = HexToRustFormat("#CBCBCBFF"),
                            FontSize = 15,
                            Text =
                                $"{lang.GetMessage("PLAYEDTIME_NAME", this, player.UserIDString)}{Convert.ToInt32(TimeSpan.FromSeconds(_dataBase.PlayerDB[player.userID].ActiveTimeDB.Seconds).TotalHours)} H"
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0.3552083 0.5601852",
                            AnchorMax = "0.6453125 0.6064815"
                        },
                        new CuiOutlineComponent
                        {
                            Color = HexToRustFormat("#000000AE"),
                            Distance = "0.5 0.5"
                        }
                    }
                },
                {
                    new CuiButton
                    {
                        Button =
                        {
                            Command = "servertop",
                            Color = "0 0 0 0"
                        },
                        Text =
                        {
                            Align = TextAnchor.MiddleCenter,
                            Color = HexToRustFormat("#EAEAEAFF"),
                            FontSize = 18,
                            Text = lang.GetMessage("GOTOP", this, player.UserIDString)
                        },
                        RectTransform =
                        {
                            AnchorMin = "0.3665158 0.01108896",
                            AnchorMax = "0.6329185 0.08165347"
                        }
                    },
                    UILayerMain, "GoTop"
                }
            };


            CuiHelper.DestroyUi(player, UILayerMain);
            CuiHelper.DestroyUi(player, UILayerServer);
            CuiHelper.AddUi(player, ui);
            DrawUI_KillStat(player, false);
            DrawUI_DeathsStat(player);
            DrawUI_KillAnimalsStat(player, false);
            DrawUI_GatherResourcesStat(player, false);
            DrawUI_ObjectDestroyingStat(player, false);
        }

        private void DrawUI_ServerStatistic(BasePlayer player)
        {
            var ui = new CuiElementContainer
            {
                {
                    new CuiPanel
                    {
                        CursorEnabled = true,
                        Image =
                        {
                            Color = HexToRustFormat("#000000F9"),
                            Material = Blur, Sprite = Radial
                        },
                        RectTransform =
                        {
                            AnchorMin = "0 0",
                            AnchorMax = "1 1"
                        }
                    },
                    "Overlay", UILayerServer
                },
                {
                    new CuiButton
                    {
                        Button =
                        {
                            Command = "zstats.close",
                            Color = "0 0 0 0"
                        },
                        Text =
                        {
                            Text = " "
                        },
                        RectTransform =
                        {
                            AnchorMin = "0 0",
                            AnchorMax = "1 1"
                        }
                    },
                    UILayerServer, "ButtonCloseGUI"
                },
                new CuiElement
                {
                    Name = "ZagServerTOP",
                    Parent = UILayerServer,
                    Components =
                    {
                        new CuiTextComponent
                        {
                            Align = TextAnchor.MiddleCenter,
                            Color = HexToRustFormat("#EAEAEAFF"),
                            FontSize = 40,
                            Text = lang.GetMessage("TOP", this, player.UserIDString)
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0 0.9354839",
                            AnchorMax = "1 1"
                        },
                        new CuiOutlineComponent
                        {
                            Color = HexToRustFormat("#000000AE"),
                            Distance = "0.5 0.5"
                        }
                    }
                },
                {
                    new CuiButton
                    {
                        Button =
                        {
                            Command = $"chat.say /stat",
                            Color = "0 0 0 0"
                        },
                        Text =
                        {
                            Align = TextAnchor.MiddleCenter,
                            Color = HexToRustFormat("#EAEAEAFF"),
                            FontSize = 18,
                            Text = lang.GetMessage("GOMAIN", this, player.UserIDString)
                        },
                        RectTransform =
                        {
                            AnchorMin = "0.3665158 0.01108896",
                            AnchorMax = "0.6329185 0.08165347"
                        }
                    },
                    UILayerServer, "GoMainGui"
                },
                new CuiElement
                {
                    Name = $"{UILayerServer}_UI_Layer_Filters",
                    Parent = UILayerServer,
                    Components =
                    {
                        new CuiImageComponent
                        {
                            Color = HexToRustFormat("#00000086")
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0.1239583 0.8916631",
                            AnchorMax = "0.8760417 0.9333302"
                        }
                    }
                },
                {
                    new CuiLabel
                    {
                        Text =
                        {
                            Align = TextAnchor.MiddleCenter,
                            FontSize = 11,
                            Text = lang.GetMessage("AVATAR", this, player.UserIDString)
                        },
                        RectTransform =
                        {
                            AnchorMin = "0 0",
                            AnchorMax = "0.06666667 1"
                        }
                    },
                    $"{UILayerServer}_UI_Layer_Filters"
                },
                {
                    new CuiLabel
                    {
                        Text =
                        {
                            Align = TextAnchor.MiddleCenter,
                            FontSize = 11,
                            Text = lang.GetMessage("NAME", this, player.UserIDString)
                        },
                        RectTransform =
                        {
                            AnchorMin = "0.07132962 0",
                            AnchorMax = "0.1945983 1"
                        }
                    },
                    $"{UILayerServer}_UI_Layer_Filters"
                }
            };

            var x = 0;
            foreach (var obj in _filters)
            {
                ui.Add(new CuiButton
                {
                    Button =
                    {
                        Color = "0 0 0 0",
                        Command = $"filter {obj.Number}"
                    },
                    Text =
                    {
                        Align = TextAnchor.MiddleCenter,
                        FontSize = 11,
                        Text = lang.GetMessage(obj.Name, this, player.UserIDString),
                        FadeIn = 0.1f * x
                    },
                    RectTransform =
                    {
                        AnchorMin = $"{0.2119114 + (x * 0.134)} 0",
                        AnchorMax = $"{0.3185595 + (x * 0.134)} 1"
                    }
                }, $"{UILayerServer}_UI_Layer_Filters");
                x++;
            }

            CuiHelper.DestroyUi(player, UILayerMain);
            CuiHelper.DestroyUi(player, UILayerServer);
            CuiHelper.AddUi(player, ui);
            MathStates(player, 0);
        }

        private void DrawUI_KillStat(BasePlayer player, bool isopen)
        {
            var layer = $"{UILayerMain}_Layer_Statistics";
            var ui = new CuiElementContainer
            {
                {
                    new CuiPanel
                    {
                        Image =
                        {
                            Color = "0 0 0 0"
                        },
                        RectTransform =
                        {
                            AnchorMin = "0.01243009 0.1438849",
                            AnchorMax = "0.197514 0.8561152"
                        }
                    },
                    layer, $"{layer}_Kill"
                },
                new CuiElement
                {
                    Name = $"{layer}_KillTXT",
                    Parent = $"{layer}_Kill",
                    Components =
                    {
                        new CuiTextComponent
                        {
                            Align = TextAnchor.MiddleCenter,
                            Color = HexToRustFormat("#CBCBCBFF"),
                            FontSize = 18,
                            Text = lang.GetMessage("KILL_NAME", this, player.UserIDString)
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0 0.5",
                            AnchorMax = "1 1"
                        },
                        new CuiOutlineComponent
                        {
                            Color = HexToRustFormat("#000000AE"),
                            Distance = "0.5 0.5"
                        }
                    }
                },
                {
                    new CuiButton
                    {
                        Button =
                        {
                            Command = $"kill_more {isopen}",
                            Color = "0 0 0 0"
                        },
                        Text =
                        {
                            Text = " "
                        },
                        RectTransform =
                        {
                            AnchorMin = "0 0",
                            AnchorMax = "1 1"
                        }
                    },
                    $"{layer}_KillTXT"
                },
                new CuiElement
                {
                    Name = $"{layer}_KillLine",
                    Parent = $"{layer}_Kill",
                    Components =
                    {
                        new CuiImageComponent
                        {
                            Color = HexToRustFormat("#CBCBCBFF")
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0 0.49",
                            AnchorMax = "1 0.5"
                        }
                    }
                }
            };

            if (!isopen)
            {
                ui.Add(new CuiElement
                {
                    Name = $"{layer}_KillValue",
                    Parent = $"{layer}_Kill",
                    Components =
                    {
                        new CuiTextComponent
                        {
                            Align = TextAnchor.MiddleCenter,
                            Color = HexToRustFormat("#CBCBCBFF"),
                            FontSize = 16,
                            Text = $"{_dataBase.PlayerDB[player.userID].KillsDB.KillElements["General"]}"
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0 0",
                            AnchorMax = "1 0.5"
                        },
                        new CuiOutlineComponent
                        {
                            Color = HexToRustFormat("#000000AE"),
                            Distance = "0.5 0.5"
                        }
                    }
                });
            }
            else
            {
                var y = 0;
                foreach (var obj in _dataBase.PlayerDB[player.userID].KillsDB.KillElements)
                {
                    ui.Add(new CuiElement
                    {
                        Name = $"{layer}_KillValue",
                        Parent = $"{layer}_Kill",
                        Components =
                        {
                            new CuiTextComponent
                            {
                                Align = TextAnchor.MiddleLeft,
                                Color = HexToRustFormat("#CBCBCBFF"),
                                FontSize = 16,
                                Text =
                                    $"            {lang.GetMessage(obj.Key, this, player.UserIDString)} : {obj.Value}",
                                FadeIn = 0.1f * y
                            },
                            new CuiRectTransformComponent
                            {
                                AnchorMin = $"{0} {0 - (y * 0.5)}",
                                AnchorMax = $"{1} {0.5 - (y * 0.5)}"
                            },
                            new CuiOutlineComponent
                            {
                                Color = HexToRustFormat("#000000AE"),
                                Distance = "0.5 0.5"
                            }
                        }
                    });
                    y++;
                }
            }

            CuiHelper.DestroyUi(player, $"{layer}_Kill");
            CuiHelper.AddUi(player, ui);
        }

        private void DrawUI_DeathsStat(BasePlayer player)
        {
            var ui = new CuiElementContainer();
            var layer = $"{UILayerMain}_Layer_Statistics";

            ui.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0 0 0 0"
                },
                RectTransform =
                {
                    AnchorMin = "0.2099441 0.1438849",
                    AnchorMax = "0.395028 0.8561152"
                }
            }, layer, $"{layer}_Deaths");

            ui.Add(new CuiElement
            {
                Name = $"{layer}_DeathsTXT",
                Parent = $"{layer}_Deaths",
                Components =
                {
                    new CuiTextComponent
                    {
                        Align = TextAnchor.MiddleCenter,
                        Color = HexToRustFormat("#CBCBCBFF"),
                        FontSize = 18,
                        Text = lang.GetMessage("DEATH_NAME", this, player.UserIDString)
                    },
                    new CuiRectTransformComponent
                    {
                        AnchorMin = "0 0.5",
                        AnchorMax = "1 1"
                    },
                    new CuiOutlineComponent
                    {
                        Color = HexToRustFormat("#000000AE"),
                        Distance = "0.5 0.5"
                    }
                }
            });

            ui.Add(new CuiElement
            {
                Name = $"{layer}_DeathsLine",
                Parent = $"{layer}_Deaths",
                Components =
                {
                    new CuiImageComponent
                    {
                        Color = HexToRustFormat("#CBCBCBFF")
                    },
                    new CuiRectTransformComponent
                    {
                        AnchorMin = "0 0.49",
                        AnchorMax = "1 0.5"
                    }
                }
            });
            ui.Add(new CuiElement
            {
                Name = $"{layer}_DeathsValue",
                Parent = $"{layer}_Deaths",
                Components =
                {
                    new CuiTextComponent
                    {
                        Align = TextAnchor.MiddleCenter,
                        Color = HexToRustFormat("#CBCBCBFF"),
                        FontSize = 16,
                        Text = $"{_dataBase.PlayerDB[player.userID].DeathsDB.Death}"
                    },
                    new CuiRectTransformComponent
                    {
                        AnchorMin = "0 0",
                        AnchorMax = "1 0.5"
                    },
                    new CuiOutlineComponent
                    {
                        Color = HexToRustFormat("#000000AE"),
                        Distance = "0.5 0.5"
                    }
                }
            });

            CuiHelper.DestroyUi(player, $"{layer}_Deaths");
            CuiHelper.AddUi(player, ui);
        }

        private void DrawUI_KillAnimalsStat(BasePlayer player, bool isopen)
        {
            var ui = new CuiElementContainer();
            var layer = $"{UILayerMain}_Layer_Statistics";

            ui.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0 0 0 0"
                },
                RectTransform =
                {
                    AnchorMin = "0.4074581 0.1438849",
                    AnchorMax = "0.5925419 0.8561152"
                }
            }, layer, $"{layer}_KillAnimals");

            ui.Add(new CuiElement
            {
                Name = $"{layer}_KillAnimalsTXT",
                Parent = $"{layer}_KillAnimals",
                Components =
                {
                    new CuiTextComponent
                    {
                        Align = TextAnchor.MiddleCenter,
                        Color = HexToRustFormat("#CBCBCBFF"),
                        FontSize = 16,
                        Text = lang.GetMessage("KILLANIMALS_NAME", this, player.UserIDString)
                    },
                    new CuiRectTransformComponent
                    {
                        AnchorMin = "0 0.5",
                        AnchorMax = "1 1"
                    },
                    new CuiOutlineComponent
                    {
                        Color = HexToRustFormat("#000000AE"),
                        Distance = "0.5 0.5"
                    }
                }
            });

            ui.Add(new CuiButton
            {
                Button =
                {
                    Command = $"animals_more {isopen}",
                    Color = "0 0 0 0"
                },
                Text = {Text = " "},
                RectTransform =
                {
                    AnchorMin = "0 0",
                    AnchorMax = "1 1"
                }
            }, $"{layer}_KillAnimalsTXT");

            ui.Add(new CuiElement
            {
                Name = $"{layer}_KillAnimalsLine",
                Parent = $"{layer}_KillAnimals",
                Components =
                {
                    new CuiImageComponent
                    {
                        Color = HexToRustFormat("#CBCBCBFF")
                    },
                    new CuiRectTransformComponent
                    {
                        AnchorMin = "0 0.49",
                        AnchorMax = "1 0.5"
                    }
                }
            });

            if (!isopen)
            {
                ui.Add(new CuiElement
                {
                    Name = $"{layer}_KillAnimalsValue",
                    Parent = $"{layer}_KillAnimals",
                    Components =
                    {
                        new CuiTextComponent
                        {
                            Align = TextAnchor.MiddleCenter,
                            Color = HexToRustFormat("#CBCBCBFF"),
                            FontSize = 16,
                            Text = $"{_dataBase.PlayerDB[player.userID].AnimalDB.AnimalElements["General"]}"
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0 0",
                            AnchorMax = "1 0.5"
                        },
                        new CuiOutlineComponent
                        {
                            Color = HexToRustFormat("#000000AE"),
                            Distance = "0.5 0.5"
                        }
                    }
                });
            }
            else
            {
                var y = 0;
                foreach (var obj in _dataBase.PlayerDB[player.userID].AnimalDB.AnimalElements)
                {
                    ui.Add(new CuiElement
                    {
                        Name = $"{layer}_KillAnimalsValue",
                        Parent = $"{layer}_KillAnimals",
                        Components =
                        {
                            new CuiTextComponent
                            {
                                Align = TextAnchor.MiddleLeft,
                                Color = HexToRustFormat("#CBCBCBFF"),
                                FontSize = 16,
                                Text =
                                    $"            {lang.GetMessage(obj.Key, this, player.UserIDString)} : {obj.Value}",
                                FadeIn = 0.1f * y
                            },
                            new CuiRectTransformComponent
                            {
                                AnchorMin = $"{0} {0 - (y * 0.5)}",
                                AnchorMax = $"{1} {0.5 - (y * 0.5)}"
                            },
                            new CuiOutlineComponent
                            {
                                Color = HexToRustFormat("#000000AE"),
                                Distance = "0.5 0.5"
                            }
                        }
                    });
                    y++;
                }
            }

            CuiHelper.DestroyUi(player, $"{layer}_KillAnimals");
            CuiHelper.AddUi(player, ui);
        }

        private void DrawUI_GatherResourcesStat(BasePlayer player, bool isopen)
        {
            var ui = new CuiElementContainer();
            var layer = $"{UILayerMain}_Layer_Statistics";

            ui.Add(new CuiPanel
            {
                Image =
                {
                    Color = "0 0 0 0"
                },
                RectTransform =
                {
                    AnchorMin = "0.6049721 0.1438849",
                    AnchorMax = "0.790056 0.8561152"
                }
            }, layer, $"{layer}_GatherResources");

            ui.Add(new CuiElement
            {
                Name = $"{layer}_GatherResourcesTXT",
                Parent = $"{layer}_GatherResources",
                Components =
                {
                    new CuiTextComponent
                    {
                        Align = TextAnchor.MiddleCenter,
                        Color = HexToRustFormat("#CBCBCBFF"),
                        FontSize = 16,
                        Text = lang.GetMessage("GATHERRESOURCES_NAME", this, player.UserIDString)
                    },
                    new CuiRectTransformComponent
                    {
                        AnchorMin = "0 0.5",
                        AnchorMax = "1 1"
                    },
                    new CuiOutlineComponent
                    {
                        Color = HexToRustFormat("#000000AE"),
                        Distance = "0.5 0.5"
                    }
                }
            });

            ui.Add(new CuiButton
            {
                Button =
                {
                    Command = $"gather_more {isopen}",
                    Color = "0 0 0 0"
                },
                Text = {Text = " "},
                RectTransform =
                {
                    AnchorMin = "0 0",
                    AnchorMax = "1 1"
                }
            }, $"{layer}_GatherResourcesTXT");

            ui.Add(new CuiElement
            {
                Name = $"{layer}_GatherResourcesLine",
                Parent = $"{layer}_GatherResources",
                Components =
                {
                    new CuiImageComponent
                    {
                        Color = HexToRustFormat("#CBCBCBFF")
                    },
                    new CuiRectTransformComponent
                    {
                        AnchorMin = "0 0.49",
                        AnchorMax = "1 0.5"
                    }
                }
            });

            if (!isopen)
            {
                ui.Add(new CuiElement
                {
                    Name = $"{layer}_GatherResourcesValue",
                    Parent = $"{layer}_GatherResources",
                    Components =
                    {
                        new CuiTextComponent
                        {
                            Align = TextAnchor.MiddleCenter,
                            Color = HexToRustFormat("#CBCBCBFF"),
                            FontSize = 16,
                            Text = $"{_dataBase.PlayerDB[player.userID].ResourcesDB.ResourceElements["General"]}"
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0 0",
                            AnchorMax = "1 0.5"
                        },
                        new CuiOutlineComponent
                        {
                            Color = HexToRustFormat("#000000AE"),
                            Distance = "0.5 0.5"
                        }
                    }
                });
            }
            else
            {
                var y = 0;
                foreach (var obj in _dataBase.PlayerDB[player.userID].ResourcesDB.ResourceElements)
                {
                    ui.Add(new CuiElement
                    {
                        Name = $"{layer}_GatherResourcesValue",
                        Parent = $"{layer}_GatherResources",
                        Components =
                        {
                            new CuiTextComponent
                            {
                                Align = TextAnchor.MiddleLeft,
                                Color = HexToRustFormat("#CBCBCBFF"),
                                FontSize = 16,
                                Text =
                                    $"            {lang.GetMessage(obj.Key, this, player.UserIDString)} : {obj.Value}",
                                FadeIn = 0.1f * y
                            },
                            new CuiRectTransformComponent
                            {
                                AnchorMin = $"{0} {0 - (y * 0.5)}",
                                AnchorMax = $"{1} {0.5 - (y * 0.5)}"
                            },
                            new CuiOutlineComponent
                            {
                                Color = HexToRustFormat("#000000AE"),
                                Distance = "0.5 0.5"
                            }
                        }
                    });
                    y++;
                }
            }

            CuiHelper.DestroyUi(player, $"{layer}_GatherResources");
            CuiHelper.AddUi(player, ui);
        }

        private void DrawUI_ObjectDestroyingStat(BasePlayer player, bool isopen)
        {
            var layer = $"{UILayerMain}_Layer_Statistics";
            var ui = new CuiElementContainer
            {
                {
                    new CuiPanel
                    {
                        Image =
                        {
                            Color = "0 0 0 0" 
                        },
                        RectTransform =
                        {
                            AnchorMin = "0.8024861 0.1438849",
                            AnchorMax = "0.9875699 0.8561152"
                        }
                    },
                    layer, $"{layer}_ObjectDestroying"
                },
                new CuiElement
                {
                    Name = $"{layer}_ObjectDestroyingTXT",
                    Parent = $"{layer}_ObjectDestroying",
                    Components =
                    {
                        new CuiTextComponent
                        {
                            Align = TextAnchor.MiddleCenter,
                            Color = HexToRustFormat("#CBCBCBFF"),
                            FontSize = 16,
                            Text = lang.GetMessage("DESTROYINGOBJECTS_NAME", this, player.UserIDString)
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0 0.5",
                            AnchorMax = "1 1"
                        },
                        new CuiOutlineComponent
                        {
                            Color = HexToRustFormat("#000000AE"),
                            Distance = "0.5 0.5"
                        }
                    }
                },
                {
                    new CuiButton
                    {
                        Button =
                        {
                            Command = $"objects_more {isopen}",
                            Color = "0 0 0 0"
                        },
                        Text =
                        {
                            Text = " "
                        },
                        RectTransform =
                        {
                            AnchorMin = "0 0",
                            AnchorMax = "1 1"
                        }
                    },
                    $"{layer}_ObjectDestroyingTXT"
                },
                new CuiElement
                {
                    Name = $"{layer}_ObjectDestroyingLine",
                    Parent = $"{layer}_ObjectDestroying",
                    Components =
                    {
                        new CuiImageComponent
                        {
                            Color = HexToRustFormat("#CBCBCBFF")
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0 0.49",
                            AnchorMax = "1 0.5"
                        }
                    }
                }
            };

            if (!isopen)
            {
                ui.Add(new CuiElement
                {
                    Name = $"{layer}_ObjectDestroyingValue",
                    Parent = $"{layer}_ObjectDestroying",
                    Components =
                    {
                        new CuiTextComponent
                        {
                            Align = TextAnchor.MiddleCenter,
                            Color = HexToRustFormat("#CBCBCBFF"),
                            FontSize = 19,
                            Text = $"{_dataBase.PlayerDB[player.userID].EntitiesDB.EntityElements["General"]}"
                        },
                        new CuiRectTransformComponent
                        {
                            AnchorMin = "0 0",
                            AnchorMax = "1 0.5"
                        },
                        new CuiOutlineComponent
                        {
                            Color = HexToRustFormat("#000000AE"),
                            Distance = "0.5 0.5"
                        }
                    }
                });
            }
            else
            {
                var y = 0;
                foreach (var obj in _dataBase.PlayerDB[player.userID].EntitiesDB.EntityElements)
                {
                    ui.Add(new CuiElement
                    {
                        Name = $"{layer}_ObjectDestroyingValue",
                        Parent = $"{layer}_ObjectDestroying",
                        Components =
                        {
                            new CuiTextComponent
                            {
                                Align = TextAnchor.MiddleLeft,
                                Color = HexToRustFormat("#CBCBCBFF"),
                                FontSize = 16,
                                Text =
                                    $"            {lang.GetMessage(obj.Key, this, player.UserIDString)} : {obj.Value}",
                                FadeIn = 0.1f * y
                            },
                            new CuiRectTransformComponent
                            {
                                AnchorMin = $"{0} {0 - (y * 0.5)}",
                                AnchorMax = $"{1} {0.5 - (y * 0.5)}"
                            },
                            new CuiOutlineComponent
                            {
                                Color = HexToRustFormat("#000000AE"),
                                Distance = "0.5 0.5"
                            }
                        }
                    });
                    y++;
                }
            }

            CuiHelper.DestroyUi(player, $"{layer}_ObjectDestroying");
            CuiHelper.AddUi(player, ui);
        }

        #endregion 

        #region [ConsoleCommand] / [Консольные команды]

        [ChatCommand("stat")]
        private void OpenMainTop(BasePlayer player)
        {
            CheckInDataBase(player);
          
// ... [Code preview truncated due to length. Full source in attached file] ...

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