private void DrawCapacitor(DischargeCapacitor cap)
        {
            GUILayout.BeginHorizontal(gui_bg);
            // Capacitor Name Field
            GUILayout.Label(cap.part.partInfo.title, gui_header, GUILayout.MaxHeight(32f), GUILayout.MinHeight(32f));
            // Properties
            GUILayout.BeginVertical();
            GUILayout.Label(String.Format("{0:F0}% Charged", GetChargePercent(cap)), gui_text);
            GUILayout.Label(String.Format("{0:F0} Sc/s", GetCurrentRate(cap)), gui_text);
            GUILayout.EndVertical();
            // Changeables

            GUILayout.BeginVertical();
            // Bar
            GUILayout.BeginHorizontal();
            GUILayout.Label("Customize Discharge Rate", gui_text, GUILayout.MaxWidth(150f), GUILayout.MinWidth(150f));
            cap.dischargeActual = GUILayout.HorizontalSlider(cap.dischargeActual, cap.ChargeRate / 2f, cap.ChargeRate, GUILayout.MaxWidth(100f), GUILayout.MinWidth(100f));
            GUILayout.Label(String.Format("Rate: {0:F0} Ec/s", cap.dischargeActual), gui_text);
            GUILayout.EndHorizontal();
            // Buttons
            GUILayout.BeginHorizontal();
            cap.Enabled = GUILayout.Toggle(cap.Enabled, "Recharge Enabled");
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Discharge ", GUILayout.MaxWidth(150f), GUILayout.MinWidth(150f)))
            {
                cap.Discharge();
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();
        }
 // Gets the current charge or discharge rate of a capacitor
 private float GetCurrentRate(DischargeCapacitor cap)
 {
     if (cap.Discharging)
     {
         return(-cap.DischargeRate);
     }
     else if (cap.Enabled && cap.CurrentCharge < cap.MaximumCharge)
     {
         return(cap.ChargeRate * cap.ChargeRatio);
     }
     else
     {
         return(0f);
     }
 }
 // Gets a capacitor's percent charge
 private float GetChargePercent(DischargeCapacitor cap)
 {
     return((cap.CurrentCharge / cap.MaximumCharge) * 100f);
 }
 // Gets the current charge or discharge rate of a capacitor
 private float GetCurrentRate(DischargeCapacitor cap)
 {
     if (cap.Discharging)
     {
         return -cap.DischargeRate;
     } else if (cap.Enabled && cap.CurrentCharge < cap.MaximumCharge)
     {
         return cap.ChargeRate*cap.ChargeRatio;
     } else
     {
         return 0f;
     }
 }
 // Gets a capacitor's percent charge
 private float GetChargePercent(DischargeCapacitor cap)
 {
     return (cap.CurrentCharge / cap.MaximumCharge) *100f;
 }
        private void DrawCapacitor(DischargeCapacitor cap)
        {
            GUILayout.BeginHorizontal(gui_bg);
            // Capacitor Name Field
            GUILayout.Label(cap.part.partInfo.title, gui_header, GUILayout.MaxHeight(32f), GUILayout.MinHeight(32f));
            // Properties
            GUILayout.BeginVertical();
                GUILayout.Label(String.Format("{0:F0}% Charged", GetChargePercent(cap)), gui_text);
                GUILayout.Label(String.Format("{0:F0} Sc/s",  GetCurrentRate(cap)), gui_text);
            GUILayout.EndVertical();
            // Changeables

            GUILayout.BeginVertical();
            // Bar
            GUILayout.BeginHorizontal();
                GUILayout.Label("Customize Discharge Rate", gui_text, GUILayout.MaxWidth(150f), GUILayout.MinWidth(150f));
                cap.dischargeSlider = GUILayout.HorizontalSlider(cap.dischargeSlider, 50f, 100f, GUILayout.MaxWidth(100f), GUILayout.MinWidth(100f));
                GUILayout.Label(String.Format("Rate: {0:F0} Ec/s", cap.dischargeActual), gui_text);
            GUILayout.EndHorizontal();
            // Buttons
            GUILayout.BeginHorizontal();
                cap.Enabled = GUILayout.Toggle(cap.Enabled, "Recharge Enabled");
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Discharge ", GUILayout.MaxWidth(150f), GUILayout.MinWidth(150f)))
                {
                    cap.Discharge();
                }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();
        }