Ejemplo n.º 1
0
        internal void DumpAllResources()
        {
            List <string> otherResourcesList =
                (from s in SMAddon.SmVessel.PartsByResource.Keys
                 where SMConditions.TypeOfResource(s) == SMConditions.ResourceType.Pump
                 select s).ToList();
            uint pumpId = TransferPump.GetPumpIdFromHash(string.Join("", otherResourcesList.ToArray()),
                                                         SMAddon.SmVessel.Vessel.parts.First(), SMAddon.SmVessel.Vessel.parts.Last(), TransferPump.TypePump.Dump,
                                                         TransferPump.TriggerButton.Preflight);
            List <TransferPump> pumpList =
                otherResourcesList.Select(
                    resource =>
                    new TransferPump(resource, TransferPump.TypePump.Dump, TransferPump.TriggerButton.Preflight,
                                     TransferPump.CalcRemainingResource(SMAddon.SmVessel.PartsByResource[resource], resource))
            {
                FromParts = SMAddon.SmVessel.PartsByResource[resource],
                PumpId    = pumpId
            }).ToList();

            if (!TransferPump.PumpsInProgress(pumpId).Any())
            {
                SMAddon.SmVessel.TransferPumps.AddRange(pumpList);
                ProcessController.DumpResources(SMAddon.SmVessel.TransferPumps);
            }
            else
            {
                TransferPump.AbortAllPumpsInProcess(pumpId);
            }
        }
Ejemplo n.º 2
0
 internal static void ToggleDumpResource(string resourceName, uint pumpId)
 {
     if (!TransferPump.IsPumpInProgress(pumpId))
     {
         //Fired by Resource Dump on Manifest Window.
         TransferPump pump = new TransferPump(resourceName, TransferPump.TypePump.Dump, TransferPump.TriggerButton.Manifest,
                                              TransferPump.CalcRemainingResource(SMAddon.SmVessel.PartsByResource[resourceName], resourceName))
         {
             FromParts = SMAddon.SmVessel.PartsByResource[resourceName],
             PumpId    = pumpId
         };
         List <TransferPump> pumps = new List <TransferPump>
         {
             pump
         };
         ProcessController.DumpResources(pumps);
     }
     else
     {
         TransferPump.AbortAllPumpsInProcess(pumpId);
     }
 }
Ejemplo n.º 3
0
        internal static void ToggleDumpResource(List <Part> partList, List <string> resourceNames, uint pumpId)
        {
            // This routine is called by the dump part button on the Transfer Window interface.
            // This routine is also called by the dump docked vessel button on the Transfer window interface.
            List <TransferPump> pumpList =
                resourceNames.Select(
                    resource =>
                    new TransferPump(resource, TransferPump.TypePump.Dump, TransferPump.TriggerButton.Transfer,
                                     TransferPump.CalcRemainingResource(partList, resource))
            {
                FromParts = partList,
                PumpId    = pumpId,
                PumpRatio = 1
            }).ToList();

            if (!TransferPump.PumpsInProgress(pumpId).Any())
            {
                ProcessController.DumpResources(pumpList);
            }
            else
            {
                TransferPump.AbortAllPumpsInProcess(pumpId);
            }
        }
Ejemplo n.º 4
0
 internal static bool CanResourceBeDumped(string resourceName)
 {
     return(TransferPump.CalcRemainingResource(SMAddon.SmVessel.PartsByResource[resourceName], resourceName) >
            SMSettings.Tolerance &&
            IsResourceTypeOther(resourceName));
 }