using System; using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; using Oxide.Core; using Oxide.Game.Rust.Cui; using UnityEngine; namespace Oxide.Plugins { [Info("GatherLootMultiplier", "tofurahie", "1.0.11")] internal class GatherLootMultiplier : RustPlugin { #region Static private const string Layer = "UI_GatherLootMultiplier"; private Configuration _config; private Dictionary ItemCategories = new Dictionary { [(int)ItemCategory.Weapon] = ItemCategory.Weapon.ToString(), [(int)ItemCategory.Construction] = ItemCategory.Construction.ToString(), [(int)ItemCategory.Items] = ItemCategory.Items.ToString(), [(int)ItemCategory.Resources] = ItemCategory.Resources.ToString(), [(int)ItemCategory.Attire] = ItemCategory.Attire.ToString(), [(int)ItemCategory.Tool] = ItemCategory.Tool.ToString(), [(int)ItemCategory.Medical] = ItemCategory.Medical.ToString(), [(int)ItemCategory.Food] = ItemCategory.Food.ToString(), [(int)ItemCategory.Ammunition] = ItemCategory.Ammunition.ToString(), [(int)ItemCategory.Traps] = ItemCategory.Traps.ToString(), [(int)ItemCategory.Misc] = ItemCategory.Misc.ToString(), [(int)ItemCategory.Component] = ItemCategory.Component.ToString(), [(int)ItemCategory.Electrical] = ItemCategory.Electrical.ToString(), [(int)ItemCategory.Fun] = ItemCategory.Fun.ToString() }; #region Classes private class Data { public List ModifierLootBoxes = new List(); } private class Configuration { [JsonProperty(PropertyName = "[LOOT] Items for which the rate does not change", ObjectCreationHandling = ObjectCreationHandling.Replace)] public List blockItems = new List(); [JsonProperty(PropertyName = "Increase production for Chainsaw")] public bool chainsawRate = true; [JsonProperty(PropertyName = "Increase production for Excavator")] public bool excavatorRate = true; [JsonProperty(PropertyName = "Increase production for Querry")] public bool querryRate = true; [JsonProperty(PropertyName = "Increase production for Pump Jack")] public bool pumpJackRate = true; [JsonProperty(PropertyName = "[GATHER] Rate")] public float gatherRate = 1; [JsonProperty(PropertyName = "Increase production for jackhammer")] public bool jackhammerRate = true; [JsonProperty(PropertyName = "[LOOT] Rate for category", ObjectCreationHandling = ObjectCreationHandling.Replace)] public Dictionary lootCategoriesRate = new Dictionary { [(int)ItemCategory.Weapon] = 1, [(int)ItemCategory.Construction] = 1, [(int)ItemCategory.Items] = 1, [(int)ItemCategory.Resources] = 1, [(int)ItemCategory.Attire] = 1, [(int)ItemCategory.Tool] = 1, [(int)ItemCategory.Medical] = 1, [(int)ItemCategory.Food] = 1, [(int)ItemCategory.Ammunition] = 1, [(int)ItemCategory.Traps] = 1, [(int)ItemCategory.Misc] = 1, [(int)ItemCategory.Component] = 1, [(int)ItemCategory.Electrical] = 1, [(int)ItemCategory.Fun] = 1 }; [JsonProperty(PropertyName = "[LOOT] Rate for item(don't stack with rate for category)", ObjectCreationHandling = ObjectCreationHandling.Replace)] public Dictionary personalRate = new Dictionary(); [JsonProperty(PropertyName = "Ignored list", ObjectCreationHandling = ObjectCreationHandling.Replace)] public List ignoreList = new List(); } #endregion #endregion #region Config protected override void LoadConfig() { base.LoadConfig(); try { _config = Config.ReadObject(); if (_config == null) throw new Exception(); SaveConfig(); } catch { PrintError("Your configuration file contains an error. Using default configuration values."); LoadDefaultConfig(); } } protected override void SaveConfig() { Config.WriteObject(_config); } protected override void LoadDefaultConfig() { _config = new Configuration(); } #endregion #region OxideHooks private void OnServerInitialized() { LoadData(); var existContainers = new List(); foreach (var check in BaseNetworkable.serverEntities.OfType()) { if (check.net == null || !_data.ModifierLootBoxes.Contains(check.net.ID.Value)) continue; existContainers.Add(check.net.ID.Value); OnLootSpawn(check); } _data.ModifierLootBoxes = existContainers; SaveData(); } private void Unload() { SaveData(); foreach (var check in BasePlayer.activePlayerList) CuiHelper.DestroyUi(check, Layer + ".bg"); } private void OnLootSpawn(LootContainer container) => NextTick(()=>{ if (container?.net == null || container.OwnerID != 0 || _data == null) return; if (_data.ModifierLootBoxes.Contains(container.net.ID.Value)) return; _data.ModifierLootBoxes.Add(container.net.ID.Value); float modify; foreach (var check in container.inventory.itemList) { if (check == null) continue; if (_config.blockItems.Contains(check.info.shortname)) continue; if (_config.ignoreList.Contains(check.info.shortname)) continue; if (_config.personalRate.TryGetValue(check.info.shortname, out modify)) { check.amount = (int)(check.amount * modify); return; } check.amount = (int)(check.amount * _config.lootCategoriesRate[(int)check.info.category]); } }); private void OnEntityKill(LootContainer container) { if (container?.net == null) return; _data.ModifierLootBoxes.Remove(container.net.ID.Value); } private void OnDispenserGather(ResourceDispenser dispenser, BasePlayer player, Item item) { if (player == null || item == null || _config.ignoreList.Contains(item.info.shortname)) return; var name = player.GetActiveItem()?.info?.shortname; if (name == "jackhammer" && !_config.jackhammerRate) return; if (name == "chainsaw" && !_config.chainsawRate) return; item.amount = (int)(_config.gatherRate * item.amount); } private void OnDispenserBonus(ResourceDispenser dispenser, BasePlayer player, Item item) { if (player == null || item == null || _config.ignoreList.Contains(item.info.shortname)) return; var name = player.GetActiveItem()?.info?.shortname; if (name == "jackhammer" && !_config.jackhammerRate) return; if (name == "chainsaw" && !_config.chainsawRate) return; item.amount = (int)(_config.gatherRate * item.amount); } private void OnCollectiblePickup(CollectibleEntity collectible, BasePlayer player) { if (player == null || collectible == null) return; foreach (var check in collectible.itemList) { if (_config.ignoreList.Contains(check.itemDef.shortname)) continue; check.amount *= _config.gatherRate; } } private void OnGrowableGathered(GrowableEntity plant, Item item, BasePlayer player) { if (player == null || item == null || _config.ignoreList.Contains(item.info.shortname)) return; item.amount = (int)(_config.gatherRate * item.amount); } private void OnQuarryGather(MiningQuarry quarry, Item item) { if (quarry == null || item == null || !_config.querryRate || _config.ignoreList.Contains(item.info.shortname)) return; item.amount = (int)(_config.gatherRate * item.amount); } private void OnSurveyGather(SurveyCharge survey, Item item) { if (survey == null || item == null || !_config.pumpJackRate || _config.ignoreList.Contains(item.info.shortname)) return; item.amount = (int)(_config.gatherRate * item.amount); } private void OnExcavatorGather(ExcavatorArm arm, Item item) { if (arm == null || item == null || !_config.excavatorRate || _config.ignoreList.Contains(item.info.shortname)) return; item.amount = (int)(_config.gatherRate * item.amount); } #endregion #region Commands [ChatCommand("rs")] private void cmdChatrs(BasePlayer player, string command, string[] args) { if (!player.IsAdmin) return; ShowUIMain(player); } [ConsoleCommand("UI_GLM")] private void cmdConsole(ConsoleSystem.Arg arg) { if (arg == null || arg.Args == null) return; var player = arg.Player(); switch (arg.Args[0]) { case "ADDLEFTPANEL": ShowUIAddItemLeft(player, arg.Args.Length > 1 ? string.Join(" ", arg.Args.Skip(1)).ToLower() : ""); break; case "ADDRIGHTPANEL": ShowUIAddItemRight(player, arg.Args.Length > 1 ? string.Join(" ", arg.Args.Skip(1)).ToLower() : ""); break; case "ADDLOWERLEFTPANEL": ShowUIAddItemLowerLeft(player, arg.Args.Length > 1 ? string.Join(" ", arg.Args.Skip(1)).ToLower() : ""); break; case "ADDBLOCK": switch (arg.Args[1]) { case "L": _config.personalRate.Add(arg.Args[2], 1); ShowUIMain(player); break; case "R": _config.blockItems.Add(arg.Args[2]); ShowUIMain(player); break; case "LL": _config.ignoreList.Add(arg.Args[2]); ShowUIMain(player); break; } SaveConfig(); break; case "CHANGEGATHER": _config.lootCategoriesRate[arg.GetInt(1)] = arg.GetFloat(2); ShowUIMain(player); SaveConfig(); break; case "CHANGELOOT": _config.gatherRate = arg.GetFloat(1); ShowUIMain(player); SaveConfig(); break; case "ADDPERSONALRATE": _config.personalRate[arg.Args[1]] = arg.GetFloat(2); ShowUIMain(player); SaveConfig(); break; case "CHANGECHAINSAW": _config.chainsawRate = !_config.chainsawRate; ShowUIMain(player); SaveConfig(); break; case "EXCAVATOR": _config.excavatorRate = !_config.excavatorRate; ShowUIMain(player); SaveConfig(); break; case "QUERY": _config.querryRate = !_config.querryRate; ShowUIMain(player); SaveConfig(); break; case "PUMPJACK": _config.pumpJackRate = !_config.pumpJackRate; ShowUIMain(player); SaveConfig(); break; case "CHANGEJACKHAMMER": _config.jackhammerRate = !_config.jackhammerRate; ShowUIMain(player); SaveConfig(); break; case "REMOVEBLOCK": _config.blockItems.Remove(arg.Args[1]); ShowUIMain(player); SaveConfig(); break; case "REMOVEIGNORE": _config.ignoreList.Remove(arg.Args[1]); ShowUIMain(player); SaveConfig(); break; case "SHOWPAGE": ShowUIMain(player, arg.GetInt(1), arg.GetInt(2), arg.GetInt(3)); break; } } #endregion #region UI private void ShowUIMain(BasePlayer player, int personalRatePage = 0, int blockedItemsPage = 0, int ignoreListPage = 0) { var container = new CuiElementContainer(); container.Add(new CuiPanel { CursorEnabled = true, RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" }, Image = { Color = "0 0 0 0.7", Material = "https://i.imgur.com/hteS8Lf.png" } }, "Overlay", Layer + ".bg"); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-192 -320", OffsetMax = "192 288" }, Image = { Color = "0 0 0 0.96" } }, Layer + ".bg", Layer + ".mainPanel"); Outline(ref container, Layer + ".mainPanel"); container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 1", AnchorMax = "1 1", OffsetMin = "0 -38", OffsetMax = "-38 0" }, Text = { Text = "SERVER RATES", Font = "robotocondensed-regular.ttf", FontSize = 28, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiButton { RectTransform = { AnchorMin = "1 1", AnchorMax = "1 1", OffsetMin = "-38 -38", OffsetMax = "0 0" }, Button = { Color = "0 0 0 0", Close = Layer + ".bg" }, Text = { Text = "×", Font = "robotocondensed-regular.ttf", FontSize = 32, Align = TextAnchor.MiddleCenter, Color = "0.56 0.58 0.64 1.00" } }, Layer + ".mainPanel", Layer + ".buttonClose"); Outline(ref container, Layer + ".buttonClose"); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 1", AnchorMax = "1 1", OffsetMin = "0 -38", OffsetMax = "0 -36" }, Image = { Color = "1 1 1 1" } }, Layer + ".mainPanel"); #region List var posX = 50; var posY = -68; var rowHeight = 20; #region Row - 18 container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + 90} {posY + rowHeight}" }, Text = { Text = "Gather: ", Font = "robotocondensed-regular.ttf", FontSize = 16, Align = TextAnchor.MiddleLeft, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX + 90} {posY}", OffsetMax = $"{posX + 115} {posY + rowHeight}" }, Image = { Color = "0.3 0.3 0.3 0.6" } }, Layer + ".mainPanel"); container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX + 90} {posY}", OffsetMax = $"{posX + 115} {posY + rowHeight}" }, Text = { Text = $"{_config.gatherRate}", Font = "robotocondensed-regular.ttf", FontSize = 14, Align = TextAnchor.MiddleCenter, Color = "1 1 0 1" } }, Layer + ".mainPanel"); container.Add(new CuiElement { Parent = Layer + ".mainPanel", Components = { new CuiInputFieldComponent { Align = TextAnchor.MiddleCenter, CharsLimit = 3, FontSize = 14, Command = "UI_GLM CHANGELOOT" }, new CuiRectTransformComponent { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX + 90} {posY}", OffsetMax = $"{posX + 115} {posY + rowHeight}" } } }); #endregion posY -= 25; #region Row - 19 container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + 90} {posY + rowHeight}" }, Text = { Text = "Chainsaw: ", Font = "robotocondensed-regular.ttf", FontSize = 16, Align = TextAnchor.MiddleLeft, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiButton { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX + 90} {posY}", OffsetMax = $"{posX + 115} {posY + rowHeight}" }, Button = { Color = "0 0 0 0", Command = "UI_GLM CHANGECHAINSAW" }, Text = { Text = _config.chainsawRate ? "ON" : "OFF", Font = "robotocondensed-regular.ttf", FontSize = 14, Align = TextAnchor.MiddleCenter, Color = _config.chainsawRate ? "0 1 0 1" : "1 0 0 1" } }, Layer + ".mainPanel"); #endregion posY -= 25; #region Row - 20 container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + 90} {posY + rowHeight}" }, Text = { Text = "Jackhammer: ", Font = "robotocondensed-regular.ttf", FontSize = 16, Align = TextAnchor.MiddleLeft, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiButton { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX + 90} {posY}", OffsetMax = $"{posX + 115} {posY + rowHeight}" }, Button = { Color = "0 0 0 0", Command = "UI_GLM CHANGEJACKHAMMER" }, Text = { Text = _config.jackhammerRate ? "ON" : "OFF", Font = "robotocondensed-regular.ttf", FontSize = 14, Align = TextAnchor.MiddleCenter, Color = _config.jackhammerRate ? "0 1 0 1" : "1 0 0 1" } }, Layer + ".mainPanel"); #endregion posY -= 25; #region Row - 21 container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + 90} {posY + rowHeight}" }, Text = { Text = "Excavator: ", Font = "robotocondensed-regular.ttf", FontSize = 16, Align = TextAnchor.MiddleLeft, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiButton { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX + 90} {posY}", OffsetMax = $"{posX + 115} {posY + rowHeight}" }, Button = { Color = "0 0 0 0", Command = "UI_GLM EXCAVATOR" }, Text = { Text = _config.excavatorRate ? "ON" : "OFF", Font = "robotocondensed-regular.ttf", FontSize = 14, Align = TextAnchor.MiddleCenter, Color = _config.excavatorRate ? "0 1 0 1" : "1 0 0 1" } }, Layer + ".mainPanel"); #endregion posY -= 25; #region Row - 22 container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + 90} {posY + rowHeight}" }, Text = { Text = "Query: ", Font = "robotocondensed-regular.ttf", FontSize = 16, Align = TextAnchor.MiddleLeft, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiButton { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX + 90} {posY}", OffsetMax = $"{posX + 115} {posY + rowHeight}" }, Button = { Color = "0 0 0 0", Command = "UI_GLM QUERY" }, Text = { Text = _config.querryRate ? "ON" : "OFF", Font = "robotocondensed-regular.ttf", FontSize = 14, Align = TextAnchor.MiddleCenter, Color = _config.querryRate ? "0 1 0 1" : "1 0 0 1" } }, Layer + ".mainPanel"); #endregion posY -= 25; #region Row - 23 container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + 90} {posY + rowHeight}" }, Text = { Text = "Pump Jack: ", Font = "robotocondensed-regular.ttf", FontSize = 16, Align = TextAnchor.MiddleLeft, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiButton { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX + 90} {posY}", OffsetMax = $"{posX + 115} {posY + rowHeight}" }, Button = { Color = "0 0 0 0", Command = "UI_GLM PUMPJACK" }, Text = { Text = _config.pumpJackRate ? "ON" : "OFF", Font = "robotocondensed-regular.ttf", FontSize = 14, Align = TextAnchor.MiddleCenter, Color = _config.pumpJackRate ? "0 1 0 1" : "1 0 0 1" } }, Layer + ".mainPanel"); #endregion posY -= 25; foreach (var check in _config.lootCategoriesRate) { container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + 90} {posY + rowHeight}" }, Text = { Text = $"{ItemCategories[check.Key]}: ", Font = "robotocondensed-regular.ttf", FontSize = 16, Align = TextAnchor.MiddleLeft, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX + 90} {posY}", OffsetMax = $"{posX + 115} {posY + rowHeight}" }, Image = { Color = "0.3 0.3 0.3 0.6" } }, Layer + ".mainPanel"); container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX + 90} {posY}", OffsetMax = $"{posX + 115} {posY + rowHeight}" }, Text = { Text = $"{check.Value}", Font = "robotocondensed-regular.ttf", FontSize = 14, Align = TextAnchor.MiddleCenter, Color = "1 1 0 1" } }, Layer + ".mainPanel"); container.Add(new CuiElement { Parent = Layer + ".mainPanel", Components = { new CuiInputFieldComponent { Align = TextAnchor.MiddleCenter, CharsLimit = 3, FontSize = 14, Command = $"UI_GLM CHANGEGATHER {check.Key}" }, new CuiRectTransformComponent { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX + 90} {posY}", OffsetMax = $"{posX + 115} {posY + rowHeight}" } } }); posY -= 25; if (posY > -370) continue; posX += 160; posY = -68; } #endregion #region UnderList var itemSize = 45; var spaceItem = 4; container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 1", AnchorMax = "1 1", OffsetMin = "0 -440", OffsetMax = "0 -410" }, Text = { Text = "Personal rate", Font = "robotocondensed-regular.ttf", FontSize = 20, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiButton { RectTransform = { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "15 130", OffsetMax = "45 175" }, Button = { Color = "0 0 0 0", Command = $"UI_GLM SHOWPAGE {personalRatePage - 1} {blockedItemsPage} {ignoreListPage}" }, Text = { Text = "<", Font = "robotocondensed-regular.ttf", FontSize = 26, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiButton { RectTransform = { AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-45 130", OffsetMax = "-15 175" }, Button = { Color = "0 0 0 0", Command = $"UI_GLM SHOWPAGE {personalRatePage + 1} {blockedItemsPage} {ignoreListPage}" }, Text = { Text = ">", Font = "robotocondensed-bold.ttf", FontSize = 20, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel"); posY = 130; posX = 45; var counting = 0; foreach (var check in _config.personalRate.Skip(5 * personalRatePage).Take(5)) { container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + itemSize} {posY + itemSize}" }, Image = { Color = "0 0 0 0.6" } }, Layer + ".mainPanel", Layer + ".mainItem" + counting); container.Add(new CuiElement { Parent = Layer + ".mainItem" + counting, Components = { new CuiImageComponent { ItemId = ItemManager.FindItemDefinition(check.Key).itemid }, new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "6 6", OffsetMax = "40 40" } } }); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 0.5", AnchorMax = "1 0.5", OffsetMin = "0 -10", OffsetMax = "0 10" }, Image = { Color = "0.3 0.3 0.3 0.45" } }, Layer + ".mainItem" + counting); container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" }, Text = { Text = check.Value.ToString(), Font = "robotocondensed-regular.ttf", FontSize = 15, Align = TextAnchor.MiddleCenter, Color = "1 0.5 0 1" } }, Layer + ".mainItem" + counting); container.Add(new CuiElement { Parent = Layer + ".mainItem" + counting, Components = { new CuiInputFieldComponent { Align = TextAnchor.MiddleCenter, CharsLimit = 3, FontSize = 15, Command = $"UI_GLM ADDPERSONALRATE {check.Key}" }, new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1" } } }); posX += itemSize + spaceItem; counting++; } container.Add(new CuiButton { RectTransform = { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + itemSize} {posY + itemSize}" }, Button = { Color = "0 0 0 0", Command = "UI_GLM ADDLEFTPANEL" }, Text = { Text = "+", Font = "robotocondensed-regular.ttf", FontSize = 28, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 1", AnchorMax = "1 1", OffsetMin = "0 -500", OffsetMax = "0 -470" }, Text = { Text = "Blocked items", Font = "robotocondensed-regular.ttf", FontSize = 20, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiButton { RectTransform = { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "15 75", OffsetMax = "45 120" }, Button = { Color = "0 0 0 0", Command = $"UI_GLM SHOWPAGE {personalRatePage} {blockedItemsPage - 1} {ignoreListPage}" }, Text = { Text = "<", Font = "robotocondensed-regular.ttf", FontSize = 26, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiButton { RectTransform = { AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-45 75", OffsetMax = "-15 120" }, Button = { Color = "0 0 0 0", Command = $"UI_GLM SHOWPAGE {personalRatePage} {blockedItemsPage + 1} {ignoreListPage}" }, Text = { Text = ">", Font = "robotocondensed-bold.ttf", FontSize = 20, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel"); posY = 75; posX = 45; var blockRates = _config.blockItems.Skip(5 * blockedItemsPage).Take(5).ToList(); foreach (var check in blockRates) { container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + itemSize} {posY + itemSize}" }, Image = { Color = "0 0 0 0.6" } }, Layer + ".mainPanel", Layer + ".mainPanel" + posX); container.Add(new CuiElement { Parent = Layer + ".mainPanel" + posX, Components = { new CuiImageComponent { ItemId = ItemManager.FindItemDefinition(check).itemid }, new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "5 5", OffsetMax = "41 41" } } }); container.Add(new CuiButton { RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" }, Button = { Color = "0 0 0 0", Command = $"UI_GLM REMOVEBLOCK {check}" }, Text = { Text = "", Font = "robotocondensed-bold.ttf", FontSize = 15, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel" + posX); posX += itemSize + spaceItem; } container.Add(new CuiButton { RectTransform = { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + itemSize} {posY + itemSize}" }, Button = { Color = "0 0 0 0", Command = "UI_GLM ADDRIGHTPANEL" }, Text = { Text = "+", Font = "robotocondensed-regular.ttf", FontSize = 28, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 1", AnchorMax = "1 1", OffsetMin = "0 -560", OffsetMax = "0 -530" }, Text = { Text = "Ignore for", Font = "robotocondensed-regular.ttf", FontSize = 20, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiButton { RectTransform = { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "15 15", OffsetMax = "45 60" }, Button = { Color = "0 0 0 0", Command = $"UI_GLM SHOWPAGE {personalRatePage} {blockedItemsPage} {ignoreListPage - 1}" }, Text = { Text = "<", Font = "robotocondensed-regular.ttf", FontSize = 26, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel"); container.Add(new CuiButton { RectTransform = { AnchorMin = "1 0", AnchorMax = "1 0", OffsetMin = "-45 15", OffsetMax = "-15 60" }, Button = { Color = "0 0 0 0", Command = $"UI_GLM SHOWPAGE {personalRatePage} {blockedItemsPage} {ignoreListPage + 1}" }, Text = { Text = ">", Font = "robotocondensed-bold.ttf", FontSize = 20, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel"); posY = 15; posX = 45; var ignoreList = _config.ignoreList.Skip(5 * ignoreListPage).Take(5).ToList(); foreach (var check in ignoreList) { container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + itemSize} {posY + itemSize}" }, Image = { Color = "0 0 0 0.6" } }, Layer + ".mainPanel", Layer + ".mainPanel" + posX); container.Add(new CuiElement { Parent = Layer + ".mainPanel" + posX, Components = { new CuiImageComponent { ItemId = ItemManager.FindItemDefinition(check).itemid }, new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "5 5", OffsetMax = "41 41" } } }); container.Add(new CuiButton { RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" }, Button = { Color = "0 0 0 0", Command = $"UI_GLM REMOVEIGNORE {check}" }, Text = { Text = "", Font = "robotocondensed-bold.ttf", FontSize = 15, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel" + posX); posX += itemSize + spaceItem; } container.Add(new CuiButton { RectTransform = { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + itemSize} {posY + itemSize}" }, Button = { Color = "0 0 0 0", Command = "UI_GLM ADDLOWERLEFTPANEL" }, Text = { Text = "+", Font = "robotocondensed-regular.ttf", FontSize = 28, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".mainPanel"); #endregion container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 0", AnchorMax = "1 0", OffsetMin = "0 198", OffsetMax = "0 200" }, Image = { Color = "1 1 1 1" } }, Layer + ".mainPanel"); CuiHelper.DestroyUi(player, Layer + ".bg"); CuiHelper.AddUi(player, container); } private void ShowUIAddItemRight(BasePlayer player, string request = "") { var allItems = new List(); var count = 0; foreach (var check in ItemManager.itemList) { if (count == 16) break; if (_config.blockItems.Contains(check.shortname) || _config.personalRate.ContainsKey(check.shortname) || !check.displayName.english.ToLower().Contains(request)) continue; allItems.Add(check); count++; } var container = new CuiElementContainer(); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "217 -72", OffsetMax = "473 216" }, Image = { Color = "0 0 0 0.95" } }, Layer + ".bg", Layer + ".addItemPanelRight"); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 1", AnchorMax = "1 1", OffsetMin = "0 -38", OffsetMax = "-38 0" }, Image = { Color = "0.3 0.3 0.3 0.8" } }, Layer + ".addItemPanelRight", Layer + ".input"); container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" }, Text = { Text = "SEARCH", Font = "robotocondensed-regular.ttf", FontSize = 15, Align = TextAnchor.MiddleCenter, Color = "0.6 0.6 0.6 1" } }, Layer + ".input"); container.Add(new CuiElement { Parent = Layer + ".input", Components = { new CuiInputFieldComponent { Align = TextAnchor.MiddleCenter, CharsLimit = 8, FontSize = 15, Command = "UI_GLM ADDRIGHTPANEL" }, new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1" } } }); container.Add(new CuiButton { RectTransform = { AnchorMin = "1 1", AnchorMax = "1 1", OffsetMin = "-38 -38", OffsetMax = "0 0" }, Button = { Color = "0 0 0 0", Close = Layer + ".addItemPanelRight" }, Text = { Text = "×", Font = "robotocondensed-regular.ttf", FontSize = 32, Align = TextAnchor.MiddleCenter, Color = "0.56 0.58 0.64 1.00" } }, Layer + ".addItemPanelRight", Layer + ".buttonClose"); Outline(ref container, Layer + ".buttonClose"); Outline(ref container, Layer + ".addItemPanelRight"); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 1", AnchorMax = "1 1", OffsetMin = "0 -38", OffsetMax = "0 -36" }, Image = { Color = "1 1 1 1" } }, Layer + ".addItemPanelRight"); var itemSize = 46; var spaceItem = 4; var posY = -111; var posX = 30; for (var i = 0; i < allItems.Count; i++) { container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + itemSize} {posY + itemSize}" }, Image = { Color = "0 0 0 0.65" } }, Layer + ".addItemPanelRight", Layer + ".addItemPanelRight" + posX); container.Add(new CuiElement { Parent = Layer + ".addItemPanelRight" + posX, Components = { new CuiImageComponent { ItemId = ItemManager.FindItemDefinition(allItems[i].shortname).itemid }, new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "5 5", OffsetMax = "41 41" } } }); container.Add(new CuiButton { RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" }, Button = { Color = "0 0 0 0", Command = $"UI_GLM ADDBLOCK R {allItems[i].shortname}" }, Text = { Text = "", Font = "robotocondensed-bold.ttf", FontSize = 15, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".addItemPanelRight" + posX); posX += itemSize + spaceItem; if (posX < itemSize * 4) continue; posX = 30; posY -= itemSize + spaceItem; } CuiHelper.DestroyUi(player, Layer + ".addItemPanelRight"); CuiHelper.AddUi(player, container); } private void ShowUIAddItemLeft(BasePlayer player, string request = "") { var allItems = new List(); var count = 0; foreach (var check in ItemManager.itemList) { if (count == 16) break; if (_config.blockItems.Contains(check.shortname) || _config.personalRate.ContainsKey(check.shortname) || !check.displayName.english.ToLower().Contains(request)) continue; allItems.Add(check); count++; } var container = new CuiElementContainer(); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-473 -72", OffsetMax = "-217 216" }, Image = { Color = "0 0 0 0.95" } }, Layer + ".bg", Layer + ".addItemPanelLeft"); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 1", AnchorMax = "1 1", OffsetMin = "0 -38", OffsetMax = "-38 0" }, Image = { Color = "0.3 0.3 0.3 0.8" } }, Layer + ".addItemPanelLeft", Layer + ".input"); container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" }, Text = { Text = "SEARCH", Font = "robotocondensed-regular.ttf", FontSize = 15, Align = TextAnchor.MiddleCenter, Color = "0.6 0.6 0.6 1" } }, Layer + ".input"); container.Add(new CuiElement { Parent = Layer + ".input", Components = { new CuiInputFieldComponent { Align = TextAnchor.MiddleCenter, CharsLimit = 8, FontSize = 15, Command = "UI_GLM ADDLEFTPANEL" }, new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1" } } }); container.Add(new CuiButton { RectTransform = { AnchorMin = "1 1", AnchorMax = "1 1", OffsetMin = "-38 -38", OffsetMax = "0 0" }, Button = { Color = "0 0 0 0", Close = Layer + ".addItemPanelLeft" }, Text = { Text = "×", Font = "robotocondensed-regular.ttf", FontSize = 32, Align = TextAnchor.MiddleCenter, Color = "0.56 0.58 0.64 1.00" } }, Layer + ".addItemPanelLeft", Layer + ".buttonClose"); Outline(ref container, Layer + ".buttonClose"); Outline(ref container, Layer + ".addItemPanelLeft"); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 1", AnchorMax = "1 1", OffsetMin = "0 -38", OffsetMax = "0 -36" }, Image = { Color = "1 1 1 1" } }, Layer + ".addItemPanelLeft"); var itemSize = 46; var spaceItem = 4; var posY = -111; var posX = 30; for (var i = 0; i < allItems.Count; i++) { container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + itemSize} {posY + itemSize}" }, Image = { Color = "0 0 0 0.65" } }, Layer + ".addItemPanelLeft", Layer + ".addItemPanelLeft" + posX); container.Add(new CuiElement { Parent = Layer + ".addItemPanelLeft" + posX, Components = { new CuiImageComponent { ItemId = ItemManager.FindItemDefinition(allItems[i].shortname).itemid }, new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "5 5", OffsetMax = "41 41" } } }); container.Add(new CuiButton { RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" }, Button = { Color = "0 0 0 0", Command = $"UI_GLM ADDBLOCK L {allItems[i].shortname}" }, Text = { Text = "", Font = "robotocondensed-bold.ttf", FontSize = 15, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".addItemPanelLeft" + posX); posX += itemSize + spaceItem; if (posX < itemSize * 4) continue; posX = 30; posY -= itemSize + spaceItem; } CuiHelper.DestroyUi(player, Layer + ".addItemPanelLeft"); CuiHelper.AddUi(player, container); } private void ShowUIAddItemLowerLeft(BasePlayer player, string request = "") { var allItems = new List(); var count = 0; foreach (var check in ItemManager.itemList) { if (count == 16) break; if (_config.blockItems.Contains(check.shortname) || _config.personalRate.ContainsKey(check.shortname) || _config.ignoreList.Contains(check.shortname) || !check.displayName.english.ToLower().Contains(request)) continue; allItems.Add(check); count++; } var container = new CuiElementContainer(); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0.5 0.5", AnchorMax = "0.5 0.5", OffsetMin = "-473 -360", OffsetMax = "-217 -72" }, Image = { Color = "0 0 0 0.95" } }, Layer + ".bg", Layer + ".addItemPanelLowerLeft"); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 1", AnchorMax = "1 1", OffsetMin = "0 -38", OffsetMax = "-38 0" }, Image = { Color = "0.3 0.3 0.3 0.8" } }, Layer + ".addItemPanelLowerLeft", Layer + ".input"); container.Add(new CuiLabel { RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" }, Text = { Text = "SEARCH", Font = "robotocondensed-regular.ttf", FontSize = 15, Align = TextAnchor.MiddleCenter, Color = "0.6 0.6 0.6 1" } }, Layer + ".input"); container.Add(new CuiElement { Parent = Layer + ".input", Components = { new CuiInputFieldComponent { Align = TextAnchor.MiddleCenter, CharsLimit = 8, FontSize = 15, Command = "UI_GLM ADDLOWERLEFTPANEL" }, new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1" } } }); container.Add(new CuiButton { RectTransform = { AnchorMin = "1 1", AnchorMax = "1 1", OffsetMin = "-38 -38", OffsetMax = "0 0" }, Button = { Color = "0 0 0 0", Close = Layer + ".addItemPanelLeft" }, Text = { Text = "×", Font = "robotocondensed-regular.ttf", FontSize = 32, Align = TextAnchor.MiddleCenter, Color = "0.56 0.58 0.64 1.00" } }, Layer + ".addItemPanelLowerLeft", Layer + ".buttonClose"); Outline(ref container, Layer + ".buttonClose"); Outline(ref container, Layer + ".addItemPanelLowerLeft"); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 1", AnchorMax = "1 1", OffsetMin = "0 -38", OffsetMax = "0 -36" }, Image = { Color = "1 1 1 1" } }, Layer + ".addItemPanelLowerLeft"); var itemSize = 46; var spaceItem = 4; var posY = -111; var posX = 30; for (var i = 0; i < allItems.Count; i++) { container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 1", AnchorMax = "0 1", OffsetMin = $"{posX} {posY}", OffsetMax = $"{posX + itemSize} {posY + itemSize}" }, Image = { Color = "0 0 0 0.65" } }, Layer + ".addItemPanelLowerLeft", Layer + ".addItemPanelLowerLeft" + posX); container.Add(new CuiElement { Parent = Layer + ".addItemPanelLowerLeft" + posX, Components = { new CuiImageComponent { ItemId = ItemManager.FindItemDefinition(allItems[i].shortname).itemid }, new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "0 0", OffsetMin = "5 5", OffsetMax = "41 41" } } }); container.Add(new CuiButton { RectTransform = { AnchorMin = "0 0", AnchorMax = "1 1" }, Button = { Color = "0 0 0 0", Command = $"UI_GLM ADDBLOCK LL {allItems[i].shortname}" }, Text = { Text = "", Font = "robotocondensed-bold.ttf", FontSize = 15, Align = TextAnchor.MiddleCenter, Color = "1 1 1 1" } }, Layer + ".addItemPanelLowerLeft" + posX); posX += itemSize + spaceItem; if (posX < itemSize * 4) continue; posX = 30; posY -= itemSize + spaceItem; } CuiHelper.DestroyUi(player, Layer + ".addItemPanelLowerLeft"); CuiHelper.AddUi(player, container); } private void Outline(ref CuiElementContainer container, string parent, string color = "1 1 1 1", string size = "2") { container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 0", AnchorMax = "1 0", OffsetMin = "0 0", OffsetMax = $"0 {size}" }, Image = { Color = color } }, parent); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 1", AnchorMax = "1 1", OffsetMin = $"0 -{size}", OffsetMax = "0 0" }, Image = { Color = color } }, parent); container.Add(new CuiPanel { RectTransform = { AnchorMin = "0 0", AnchorMax = "0 1", OffsetMin = $"0 {size}", OffsetMax = $"{size} -{size}" }, Image = { Color = color } }, parent); container.Add(new CuiPanel { RectTransform = { AnchorMin = "1 0", AnchorMax = "1 1", OffsetMin = $"-{size} {size}", OffsetMax = $"0 -{size}" }, Image = { Color = color } }, parent); } #endregion #region Data private Data _data; private void LoadData() => _data = Interface.Oxide.DataFileSystem.ExistsDatafile($"{Name}/data") ? Interface.Oxide.DataFileSystem.ReadObject($"{Name}/data") : new Data(); private void OnServerSave() => SaveData(); private void SaveData() { if (_data != null) Interface.Oxide.DataFileSystem.WriteObject($"{Name}/data", _data); } #endregion } }