Ejemplo n.º 1
0
        public void Main(string argument, UpdateType updateSource)
        {
            var debug = string.Empty;

            //AutoMove.Get(GridTerminalSystem).MoveAll(Welder1DesiredQuantities.Keys.ToList(), "S.HERM Cargo Components Container", new List<string>{ "Welder 1 Cargo Container" });
            //AutoMove.Get(GridTerminalSystem).MoveAll(ores, "S.HERM Cargo Ore / Ingot Container", new List<string>() { });
            //AutoMove.Get(GridTerminalSystem).MoveAll(new List<string>() { "Ice" }, "S.HERM Cargo Ice Container", new List<string>() { });
            // Fill welder contents
            //debug = AutoMove.Get(GridTerminalSystem).MoveToQuota("S.HERM Cargo Components Container", "Welder 1 Cargo Container", Welder1DesiredQuantities);

            // Show contents of components container
            ShowContainerContents.Get(GridTerminalSystem).PrintContents("S.HERM LCD Components", "S.HERM Cargo Components Container", "=== S.HERM Cargo Components ===");

            // Show contents of ores container
            ShowContainerContents.Get(GridTerminalSystem).PrintContents("S.HERM LCD Ores", "S.HERM Cargo Ore / Ingot Container", "=== S.HERM Cargo Ore / Ingot ===");

            // Show contents of welder1 container
            ShowContainerContents.Get(GridTerminalSystem).PrintContents("S.HERM LCD Welder 1", "Welder 1 Cargo Container", "=== Welder 1 contents ===");

            //Debug messages
            var lcds = GridBlocksHelper.Prefixed(GridTerminalSystem, "S.HERM LCD Airlock debug").GetLcdsPrefixed();

            if (lcds.Count == 0)
            {
                throw new Exception(string.Format("No lcd found with name starting with {0}", "S.HERM LCD Airlock debug"));
            }

            // Print the message on the lcd(s)
            LcdOutputHelper.ShowMessageOnLcd(lcds[0], new LcdOutputHelper.LcdMessage("Debug:\n" + debug));
        }
        public void PrintContentsWithSubtype(string lcdName, string containerName, string title, int timer)
        {
            var results = StringifyContainerContent(containerName);

            var containers = GridBlocksHelper.Prefixed(GTS, containerName).GetCargoContainers();

            if (containers.Count == 0)
            {
                results = "Container not found.";
            }

            var items = CargoHelper.GetItemsInInventory(containers[0].GetInventory(0));

            var itemsString = items.Select(item => item.ItemName + "(" + (item.IsOre ? "Ore" : "Ingot") + ")" + " - " + item.Quantity);

            results = String.Join("\n", itemsString);

            //public List<string> GetItemsInInventory(string containerName)
            //{
            //    // Get containers
            //    var containers = GridBlocksHelper.Prefixed(GTS, containerName).GetCargoContainers();
            //    if (containers.Count == 0)
            //        return new List<string> { "Container not found." };

            //    // Get items in inventories
            //    var itemsInDestinyInventory = CargoHelper.GetItemsInInventories(containers);

            //    // Build a string with the items
            //    return itemsInDestinyInventory.Values.Select(item => item.ItemName + " - " + item.Quantity).ToList();
            //}

            PrintResultsOnLcd(lcdName, results, title, timer);
        }
        public string StringifyContainerContent(string containerName)
        {
            // Get containers
            var containers = GridBlocksHelper.Prefixed(GTS, containerName).GetCargoContainers();

            if (containers.Count == 0)
            {
                return("Container not found.");
            }

            return(StringifyContainerContent(containers));
        }
        public void PrintResultsOnLcd(string lcdName, string results, string title = "=================================", int timer = 0)
        {
            //Get the lcd(s)
            var lcds = GridBlocksHelper.Prefixed(GTS, lcdName).GetLcdsPrefixed();

            if (lcds.Count == 0)
            {
                throw new Exception(string.Format("No lcd found with name starting with {0}", lcdName));
            }

            // Print the message on the lcd(s)
            LcdOutputHelper.ShowResultWithProgress(lcds, results, title, timer);
        }
        public string StringifyContainerContent(string containerName, Dictionary <string, int> componentDesiredQuantities)
        {
            // Get containers
            var containers = GridBlocksHelper.Prefixed(GTS, containerName).GetCargoContainers();

            if (containers.Count == 0)
            {
                return("Container not found.");
            }

            // Get items in inventories
            var inventories             = containers.SelectMany(t => InventoryHelper.GetInventories(t));
            var itemsInDestinyInventory = CargoHelper.GetItemsInInventories(inventories);

            // Build a string with the items
            var itemsString = string.Empty;

            if (componentDesiredQuantities == null || componentDesiredQuantities.Count == 0)
            {
                foreach (var item in itemsInDestinyInventory.Values)
                {
                    itemsString += item.ItemName + " - " + item.Quantity + "\n";
                }
                return(itemsString);
            }

            foreach (var desired in componentDesiredQuantities)
            {
                var quantity = itemsInDestinyInventory.ContainsKey(desired.Key) ? itemsInDestinyInventory[desired.Key].Quantity : 0;
                if (quantity == 0 && desired.Value == 0)
                {
                    continue;
                }
                var percentage = getPercentage(quantity, desired.Value);

                itemsString += desired.Key + " - " + quantity + "(" + percentage + "%) " + (percentage < 100 ? "<=========" : string.Empty) + "\n";
            }

            return(itemsString);
        }