public GridCargo ReadAllCargo() { var inventoryBlocks = GridBlocksHelper.Get(GTS).GetAllInventoryBlocks(); var inventories = inventoryBlocks.SelectMany(t => InventoryHelper.GetInventories(t)); Items = CargoHelper.GetItemsInInventories(inventories); return(this); }
public void Sort(string groupName) { var groupBlocks = GridBlocksHelper.Get(GTS).GetGroupBlocks(groupName); var groupInventories = groupBlocks.SelectMany(t => InventoryHelper.GetInventories(t)); var groupCargo = CargoHelper.GetItemsInInventories(groupInventories); var oresBlocks = GridBlocksHelper.Get(GTS).GetGroupBlocks(oresGroup); var ingotsBlocks = GridBlocksHelper.Get(GTS).GetGroupBlocks(ingotsGroup); var componentsBlocks = GridBlocksHelper.Get(GTS).GetGroupBlocks(componentsGroup); }
public string StringifyContainerContent(List <IMyTerminalBlock> inventoryBlocks) { // Get items in inventories var inventories = inventoryBlocks.SelectMany(t => InventoryHelper.GetInventories(t)); var itemsInDestinyInventory = CargoHelper.GetItemsInInventories(inventories); // Build a string with the items var itemsString = string.Empty; foreach (var item in itemsInDestinyInventory.Values) { itemsString += item.ItemName + " - " + item.Quantity + "\n"; } return(itemsString); }
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); }