示例#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);
            }
        }
示例#2
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);
            }
        }