public static void ConsumeResource(PartResourceDefinition resource, double amtToTake)
        {
            double needed  = amtToTake;
            var    resName = resource.name;
            var    whpList = LogisticsTools.GetRegionalWarehouses(FlightGlobals.ActiveVessel, "USI_ModuleResourceWarehouse");
            var    count   = whpList.Count;

            for (int i = 0; i < count; ++i)
            {
                var whp = whpList[i];
                if (whp.Modules.Contains("USI_ModuleResourceWarehouse"))
                {
                    var wh = whp.FindModuleImplementing <USI_ModuleResourceWarehouse>();
                    if (!wh.localTransferEnabled)
                    {
                        continue;
                    }
                }
                if (whp.Resources.Contains(resName))
                {
                    var res = whp.Resources[resName];
                    if (res.amount >= needed)
                    {
                        res.amount -= needed;
                        needed      = 0;
                        break;
                    }
                    else
                    {
                        needed    -= res.amount;
                        res.amount = 0;
                    }
                }
            }
        }
        public static double GetStorageSpace(string resName)
        {
            double foundStorage = 0;
            var    whpList      = LogisticsTools.GetRegionalWarehouses(FlightGlobals.ActiveVessel, "USI_ModuleResourceWarehouse");
            var    count        = whpList.Count;

            for (int i = 0; i < count; ++i)
            {
                var whp = whpList[i];
                if (whp.Modules.Contains("USI_ModuleResourceWarehouse"))
                {
                    var wh = whp.FindModuleImplementing <USI_ModuleResourceWarehouse>();
                    if (!wh.localTransferEnabled)
                    {
                        continue;
                    }
                }
                if (whp.Resources.Contains(resName))
                {
                    var res = whp.Resources[resName];
                    foundStorage += res.maxAmount - res.amount;
                }
            }
            return(foundStorage);
        }
        public static void AddResource(PartResourceDefinition resource, double amtToGive)
        {
            double remaining = amtToGive;
            var    resName   = resource.name;
            var    whpList   = LogisticsTools.GetRegionalWarehouses(FlightGlobals.ActiveVessel, "USI_ModuleResourceWarehouse");
            var    count     = whpList.Count;

            for (int i = 0; i < count; ++i)
            {
                if (remaining <= ResourceUtilities.FLOAT_TOLERANCE)
                {
                    break;
                }

                var whp = whpList[i];
                if (whp.Modules.Contains("USI_ModuleResourceWarehouse"))
                {
                    var wh = whp.FindModuleImplementing <USI_ModuleResourceWarehouse>();
                    if (!wh.localTransferEnabled)
                    {
                        continue;
                    }
                }
                if (whp.Resources.Contains(resName))
                {
                    var res   = whp.Resources[resName];
                    var space = res.maxAmount - res.amount;
                    if (space >= remaining)
                    {
                        res.amount += remaining;
                        remaining   = 0;
                        break;
                    }
                    else
                    {
                        remaining -= res.amount;
                        res.amount = res.maxAmount;
                    }
                }
            }
        }