// Broken, don't know how to fix!

        //base.LateUpdate();
        // If in the editor
        //if (HighLogic.LoadedSceneIsEditor)
        //{

        //    // If we have a panel animation...
        //    if (base.animationName != "")
        //    {

        //        if (StartDeployed != startDeployedLast)
        //        {


        //            if (StartDeployed)
        //            {
        //                // Play the animation
        //                foreach (AnimationState a in deployStates)
        //                {
        //                    Debug.Log("X");
        //                    a.speed = 1f;
        //                    a.normalizedTime = 1f;
        //                }
        //                base.panelState = ModuleDeployableSolarPanel.panelStates.EXTENDED;
        //            } else
        //            {

        //                // Reverse the animation
        //                foreach (AnimationState a in deployStates)
        //                {

        //                    a.speed = -1f;
        //                    a.normalizedTime = 0f;
        //                }
        //                base.panelState = ModuleDeployableSolarPanel.panelStates.RETRACTED;
        //            }
        //            StartDeployed = startDeployedLast;
        //            //Unbreak the persistance
        //            base.stateString = Enum.GetName(typeof(ModuleDeployableSolarPanel.panelStates),base.panelState);
        //            GetComponentInChildren<Animation>().Play(base.animationName);
        //        }
        //    }

        //}


        public override void OnFixedUpdate()
        {
            base.OnFixedUpdate();
            if (HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                if (heatModule == null)
                {
                    Utils.LogError("No SystemHeat Module on part!");
                    return;
                }
                else
                {
                    // Heat rejection from panels
                    float availableHeatRejection = 0f;

                    // If an animation name is present, assume deployable
                    if (base.animationName != "")
                    {
                        if (base.panelState != ModuleDeployableSolarPanel.panelStates.EXTENDED && base.panelState != ModuleDeployableSolarPanel.panelStates.BROKEN)
                        {
                            // Utils.Log("Closed! " + HeatRadiated.ToString());
                            availableHeatRejection += HeatRadiated;
                        }
                        else if (base.panelState == ModuleDeployableSolarPanel.panelStates.BROKEN)
                        {
                            // Utils.Log("Broken!! " + 0.ToString());
                            availableHeatRejection = 0f;
                        }
                        else
                        {
                            // Utils.Log("Open! " + HeatRadiatedExtended.ToString());
                            availableHeatRejection += HeatRadiatedExtended;
                        }
                    }
                    // always radiate
                    else
                    {
                        availableHeatRejection += HeatRadiated;
                    }

                    // Add the heat via the HeatModule
                    float actualHeat = (float)heatModule.ConsumeHeat(availableHeatRejection * TimeWarp.fixedDeltaTime);

                    // Update the UI widget
                    HeatRejectionGUI = String.Format("{0:F3} MW", availableHeatRejection);

                    if (HeatAnimation != "" && heatStates != null)
                    {
                        foreach (AnimationState state in heatStates)
                        {
                            state.normalizedTime = Mathf.MoveTowards(state.normalizedTime, Mathf.Clamp01((actualHeat / TimeWarp.fixedDeltaTime) / availableHeatRejection), 0.1f * TimeWarp.fixedDeltaTime);
                        }
                    }
                }
            }
        }
        protected void FixedUpdate()
        {
            if (HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                if (heatModule == null)
                {
                    Utils.LogError("No SystemHeat Module on part!");
                    return;
                }
                if (Enabled)
                {
                    bool   success     = true;;
                    float  heatChange  = 0f;
                    string errorReason = "";

                    if (ResourceUse > 0f)
                    {
                        double req = part.RequestResource(ResourceName, (double)(ResourceUse * TimeWarp.fixedDeltaTime));
                        if (req >= ResourceUse * TimeWarp.fixedDeltaTime)
                        {
                            success = CalculateConvection(out errorReason, out heatChange);
                        }
                        else
                        {
                            errorReason = ResourceName + " deprived!";
                        }
                    }
                    else
                    {
                        success = CalculateConvection(out errorReason, out heatChange);
                    }

                    if (success)
                    {
                        HeatStatus = String.Format("{0:F0}", heatChange);
                        heatModule.ConsumeHeat((double)heatChange);
                    }
                    else
                    {
                        HeatStatus = errorReason;
                        DisableConvector();
                    }
                }
            }
        }