Exemple #1
0
            //Cycles through the inventory to catalog the requested items
            private void searchInventory(IMyTerminalBlock vfCargo, List <string> vfType, string vfSubType = "All")
            {
                if ((vfCargo.IsFunctional))
                {
                    //Items in facilities can only be listed and accessed in general functions at their proccessed items inventory. Don't touch the raw stuff
                    int index;
                    if (vfCargo is IMyRefinery || vfCargo is IMyAssembler)
                    {
                        index = 1;
                    }
                    else
                    {
                        index = 0;
                    }
                    IMyInventory vlInventory = vfCargo.GetInventory(index);
                    __totalVolume   += vlInventory.MaxVolume;
                    __currentVolume += vlInventory.CurrentVolume;
                    MyFixedPoint vlFreeSpace = vlInventory.MaxVolume - vlInventory.CurrentVolume;
                    __count++;
                    var vlItemLst = fillListFromInventory(vlInventory);
                    //each vlI corresponds to a slot in the inventory. items may be divided into different stacks
                    //despite being the same component type and subtype

                    for (int vlI = 0; vlI < vlItemLst.Count; vlI++)
                    {
                        //check if the item in question is within the search parametres
                        if (foundItemInInventory(vlItemLst[vlI], vfType, vfSubType))
                        {
                            //The way 6 is ridiculous. To directly compare if the itemlist has an item, I have to construct an entire IMyInventoryItem type.
                            //I can't compare it with a simple item ID, which is STUPID! Instead I have to make the following
                            cargoLst.addItem(vfCargo.GetId(), vlFreeSpace, vlItemLst[vlI].Type.TypeId.ToString(), vlItemLst[vlI].Type.SubtypeId.ToString(), vlItemLst[vlI].Amount, vlI);
                        }
                        else
                        {
                            //adds empty string just to mark the ID and freespace
                            cargoLst.addItem(vfCargo.GetId(), vlFreeSpace, "", "", 0, 0);
                        }
                    }
                }
            }