public void toggleTransfer()
        {
            transferActive = !transferActive;
            dropDown       = false;

            if (transferActive)
            {
                for (int i = 0; i < selectedResources.Count; i++)
                {
                    TransferGroup t = selectedResources[i];

                    t.toggleTransfer();
                }

                transferComplete = evaModule.transferSpeed * (float)(selectedResources.Select(s => s.TransferScale).Max(a => Math.Abs(a)) / 100);
            }
            else
            {
                for (int i = 0; i < selectedResources.Count; i++)
                {
                    TransferGroup t = selectedResources[i];

                    t.finishTransfer();
                }

                transferComplete = 0;
            }
        }
        private void transferStep()
        {
            float time = Time.fixedDeltaTime;

            if (transferComplete <= 0)
            {
                transferActive = false;
                for (int i = 0; i < selectedResources.Count; i++)
                {
                    TransferGroup t = selectedResources[i];

                    t.finishTransfer();
                }
                return;
            }

            transferComplete -= time;

            for (int i = 0; i < selectedResources.Count; i++)
            {
                TransferGroup t = selectedResources[i];

                t.transferResources(time, evaModule.transferSpeed);
            }
        }
        private void toggleSelectedResource(TransferGroup t)
        {
            if (LFLOXTransferLink)
            {
                if (t.Resource.Name == "LiquidFuel" || t.Resource.Name == "Oxidizer")
                {
                    return;
                }
            }

            if (allowedStockResources.ContainsKey(t.Resource.Name))
            {
                if (selectedResources.Contains(t))
                {
                    selectedResources.Remove(t);
                }
                else if (selectedResources.Count < evaModule.MaxTransfers)
                {
                    selectedResources.Add(t);
                }
            }
            else if (allowedOtherResources.ContainsKey(t.Resource.Name))
            {
                if (selectedResources.Contains(t))
                {
                    selectedResources.Remove(t);
                }
                else if (selectedResources.Count < evaModule.MaxTransfers)
                {
                    selectedResources.Add(t);
                }
            }

            updateResources(true, true);
        }
        private void addResource(string name)
        {
            if (allowedStockResources.ContainsKey(name))
            {
                return;
            }

            if (!EVATransfer_Startup.loadedResources.ContainsKey(name))
            {
                return;
            }

            TransferableResource r = EVATransfer_Startup.loadedResources[name];

            if (r == null)
            {
                return;
            }

            TransferGroup t = new TransferGroup(r);

            if (t == null)
            {
                return;
            }

            allowedStockResources.Add(name, t);
        }
        private void updateResources(bool values, bool parts)
        {
            for (int i = 0; i < selectedResources.Count; i++)
            {
                TransferGroup t = selectedResources[i];

                t.updateValues(values, parts, evaModule.fillMode);
            }
        }
        private void drawDropDown(int id)
        {
            if (!dropDown)
            {
                return;
            }

            if (WindowRect.height < 350)
            {
                WindowOptions = new GUILayoutOption[3] {
                    GUILayout.Width(300), GUILayout.Height(120), GUILayout.MaxHeight(350)
                };
            }

            WindowRect.height = 350;

            ddRect = new Rect(20, 65, 240, 260);
            GUI.Box(ddRect, "");

            Rect view = new Rect(0, 0, 220, allowedOtherResources.Count * 25);

            dropDownScroll = GUI.BeginScrollView(ddRect, dropDownScroll, view);

            Rect r = new Rect(2, 2, 220, 23);

            for (int i = 0; i < allowedOtherResources.Count; i++)
            {
                TransferGroup t = allowedOtherResources.ElementAt(i).Value;

                if (!t.OnBoard)
                {
                    continue;
                }

                if (r.yMin >= (dropDownScroll.y - 25) && r.yMax <= (dropDownScroll.y + 285))
                {
                    if (GUI.Button(r, t.Resource.Name, selectedResources.Contains(t) ? EVATransfer_Startup.activeButton : EVATransfer_Startup.button))
                    {
                        toggleSelectedResource(t);
                        WindowOptions = new GUILayoutOption[3] {
                            GUILayout.Width(300), GUILayout.Height(120), GUILayout.MaxHeight(120)
                        };
                        dropDown = false;
                    }
                }
                r.y += 25;
            }

            GUI.EndScrollView();
        }
        private void toggleLFLOXTransfer()
        {
            if (lfloxGroup == null)
            {
                return;
            }

            LFLOXTransferLink = !LFLOXTransferLink;

            if (LFLOXTransferLink)
            {
                TransferGroup LF  = allowedStockResources["LiquidFuel"];
                TransferGroup LOX = allowedStockResources["Oxidizer"];

                if (LF == null || LOX == null)
                {
                    return;
                }

                if (selectedResources.Contains(LF))
                {
                    selectedResources.Remove(LF);
                }
                if (selectedResources.Contains(LOX))
                {
                    selectedResources.Remove(LOX);
                }

                if (selectedResources.Count < evaModule.MaxTransfers)
                {
                    lfloxGroup.updateVessels(sourceVessel, targetVessel);
                    selectedResources.Insert(0, lfloxGroup);
                }
                else
                {
                    LFLOXTransferLink = false;
                }
            }
            else
            {
                if (selectedResources.Contains(lfloxGroup))
                {
                    selectedResources.Remove(lfloxGroup);
                }
            }

            updateResources(true, true);
        }
        private void addAllResources()
        {
            foreach (TransferableResource r in EVATransfer_Startup.loadedResources.Values)
            {
                switch (r.Name)
                {
                case "LiquidFuel":
                case "Oxidizer":
                case "MonoPropellant":
                case "XenonGas":
                case "ElectricCharge":
                case "Ore":
                    continue;
                }

                if (r.Mode == ResourceTransferMode.NONE)
                {
                    continue;
                }

                if (allowedOtherResources.ContainsKey(r.Name))
                {
                    continue;
                }

                if (r == null)
                {
                    continue;
                }

                TransferGroup t = new TransferGroup(r);

                if (t == null)
                {
                    return;
                }

                allowedOtherResources.Add(r.Name, t);
            }
        }
        private void toggleSelectedResource(TransferGroup t)
        {
            if (LFLOXTransferLink)
            {
                if (t.Resource.Name == "LiquidFuel" || t.Resource.Name == "Oxidizer")
                    return;
            }

            if (allowedStockResources.ContainsKey(t.Resource.Name))
            {
                if (selectedResources.Contains(t))
                    selectedResources.Remove(t);
                else if (selectedResources.Count < evaModule.MaxTransfers)
                    selectedResources.Add(t);
            }
            else if (allowedOtherResources.ContainsKey(t.Resource.Name))
            {
                if (selectedResources.Contains(t))
                    selectedResources.Remove(t);
                else if (selectedResources.Count < evaModule.MaxTransfers)
                    selectedResources.Add(t);
            }

            updateResources(true, true);
        }
        private void addResource(string name)
        {
            if (allowedStockResources.ContainsKey(name))
                return;

            if (!EVATransfer_Startup.loadedResources.ContainsKey(name))
                return;

            TransferableResource r = EVATransfer_Startup.loadedResources[name];

            if (r == null)
                return;

            TransferGroup t = new TransferGroup(r);

            if (t == null)
                return;

            allowedStockResources.Add(name, t);
        }
        private void addAllResources()
        {
            foreach (TransferableResource r in EVATransfer_Startup.loadedResources.Values)
            {
                switch (r.Name)
                {
                    case "LiquidFuel":
                    case "Oxidizer":
                    case "MonoPropellant":
                    case "XenonGas":
                    case "ElectricCharge":
                    case "Ore":
                        continue;
                }

                if (r.Mode == ResourceTransferMode.NONE)
                    continue;

                if (allowedOtherResources.ContainsKey(r.Name))
                    continue;

                if (r == null)
                    continue;

                TransferGroup t = new TransferGroup(r);

                if (t == null)
                    return;

                allowedOtherResources.Add(r.Name, t);
            }
        }
        private void resourceLabels(int id)
        {
            if (selectedResources.Count <= 0)
            {
                return;
            }

            GUILayout.Space(30);

            Rect r = new Rect(40, 78, 80, 20);

            GUI.Label(r, sourceVessel.vesselName, EVATransfer_Startup.labelBig);

            r.x += 130;

            GUI.Label(r, targetVessel.vesselName, EVATransfer_Startup.labelBig);

            r.y += 17;

            for (int i = 0; i < selectedResources.Count; i++)
            {
                TransferGroup t = selectedResources[i];

                t.drawResourceGroup(r.y, transferActive, dropDown);

                if (t.drawCloseGroup(WindowRect.width - 21, r.y + 12, transferActive, dropDown))
                {
                    toggleSelectedResource(t);
                }

                if (t == lfloxGroup)
                {
                    GUILayout.Space(80);
                    r.y += 78;
                }
                else
                {
                    GUILayout.Space(52);
                    r.y += 50;
                }
            }

            if (selectedResources.Any(a => Math.Abs(a.TransferScale) > 0.1))
            {
                GUILayout.Space(25);

                r.x      = 10;
                r.y     += 10;
                r.width  = WindowRect.width - 20;
                r.height = 20;

                if (dropDown)
                {
                    GUI.Label(r, transferActive ? "Stop Transfer" : "Begin Transfer", EVATransfer_Startup.button);
                }
                else
                {
                    if (GUI.Button(r, transferActive ? "Stop Transfer" : "Begin Transfer"))
                    {
                        toggleTransfer();
                    }
                }
            }
        }