private void tryMoveItem(IMyTerminalBlock Parent, IMyInventory SourceInventory, List <IMyTerminalBlock> TargetBlocks, IMyInventoryItem Item) { bool isPending = true; for (int i = 0; i < TargetBlocks.Count && isPending; i++) { debug(" Target Block (" + (i + 1).ToString() + ") " + TargetBlocks[i].CustomName + " has " + TargetBlocks[i].GetInventoryCount().ToString() + " inventories"); for (int inv = 0; inv < TargetBlocks[i].GetInventoryCount() && isPending; inv++) { IMyInventory TargetInventory = TargetBlocks[i].GetInventory(inv); bool connected = SourceInventory.IsConnectedTo(TargetInventory); debug(" Inventory is" + (connected ? " " : " not ") + " connected."); if (connected) { isPending = !SourceInventory.TransferItemTo(TargetInventory, SourceInventory.GetItems().IndexOf(Item), null, true); debug(" Try transfering \"" + Item.ToString() + "\" from \"" + Parent.CustomName + "\" to \"" + TargetBlocks[i].CustomName + "\" => " + (isPending ? "still pending." : "done."), LOG_LVL_INFO); } } } }
private void doSortInventory(IMyTerminalBlock Block, IMyInventory Inventory, Dictionary <string, List <IMyTerminalBlock> > targets) { debug(" Item Count: " + Inventory.GetItems().Count.ToString()); for (int i_Item = Inventory.GetItems().Count - 1; i_Item >= 0; i_Item--) { IMyInventoryItem Item = Inventory.GetItems()[i_Item]; debug(" Start Sorting Item " + (i_Item + 1).ToString() + "/" + Inventory.GetItems().Count.ToString() + ": " + Item.ToString()); doSortItem(Block, Inventory, Item, targets); debug(" End Sorting Item " + (i_Item + 1).ToString() + "/" + Inventory.GetItems().Count.ToString() + ": " + Item.ToString()); } }