//Parachute predeployment
 public void PreDeploy()
 {
     part.stackIcon.SetIconColor(XKCDColors.BrightYellow);
     part.Effect("rcpredeploy");
     DeploymentState = DeploymentStates.PREDEPLOYED;
     parachute.gameObject.SetActive(true);
     cap.gameObject.SetActive(false);
     part.PlayAnimation(semiDeployedAnimation, semiDeploymentSpeed);
     dragTimer.Start();
     part.DragCubes.SetCubeWeight("PACKED", 0);
     part.DragCubes.SetCubeWeight("RCDEPLOYED", 1);
     Fields["currentTemp"].guiActive         = true;
     Fields["chuteDisplayMaxTemp"].guiActive = true;
 }
        /// <summary>
        ///     Creates a new PhysicsWatch from a certain amount of time, starts it, and returns the current instance
        /// </summary>
        /// <param name="seconds">Time to start the watch at, in seconds</param>
        public static PhysicsWatch StartNewFromTime(double seconds)
        {
            var watch = new PhysicsWatch(seconds);

            watch.Start();
            return(watch);
        }
        /// <summary>
        ///     Creates a new PhysicsWatch, starts it, and returns the current instance
        /// </summary>
        public static PhysicsWatch StartNew()
        {
            var watch = new PhysicsWatch();

            watch.Start();
            return(watch);
        }
 /// <summary>
 /// Creates a new PhysicsWatch from a certain amount of time, starts it, and returns the current instance
 /// </summary>
 /// <param name="seconds">Time to start the watch at, in seconds</param>
 public static PhysicsWatch StartNewFromTime(double seconds)
 {
     PhysicsWatch watch = new PhysicsWatch(seconds);
     watch.Start();
     return watch;
 }
 /// <summary>
 /// Creates a new PhysicsWatch, starts it, and returns the current instance
 /// </summary>
 public static PhysicsWatch StartNew()
 {
     PhysicsWatch watch = new PhysicsWatch();
     watch.Start();
     return watch;
 }
        private void FixedUpdate()
        {
            //Flight values
            if (!CompatibilityChecker.IsAllCompatible() ||
                !HighLogic.LoadedSceneIsFlight ||
                FlightGlobals.ActiveVessel == null ||
                part.Rigidbody == null)
            {
                return;
            }
            pos     = part.partTransform.position;
            asl     = FlightGlobals.getAltitudeAtPos(pos);
            trueAlt = asl;
            if (vessel.mainBody.pqsController != null)
            {
                double terrainAlt = vessel.pqsAltitude;
                if (!vessel.mainBody.ocean || terrainAlt > 0)
                {
                    trueAlt -= terrainAlt;
                }
            }

            atmPressure = FlightGlobals.getStaticPressure(asl, vessel.mainBody) * PhysicsGlobals.KpaToAtmospheres;
            atmDensity  = part.atmDensity;
            Vector3 velocity = part.Rigidbody.velocity + Krakensbane.GetFrameVelocityV3f();

            sqrSpeed   = velocity.sqrMagnitude;
            dragVector = -velocity.normalized;

            if (atmDensity > 0)
            {
                CalculateChuteFlux();
            }
            else
            {
                convFlux = 0;
            }

            CalculateSafeToDeployEstimate();

            if (!staged)
            {
                return;
            }
            //Checks if the parachute must disarm
            if (armed)
            {
                part.stackIcon.SetIconColor(XKCDColors.LightCyan);
                if (CanDeploy)
                {
                    armed = false;
                }
            }
            //Parachute deployments
            else
            {
                //Parachutes
                if (CanDeploy)
                {
                    if (IsDeployed)
                    {
                        if (!CalculateChuteTemp())
                        {
                            return;
                        }
                        FollowDragDirection();
                    }

                    part.GetComponentCached(ref rigidbody);
                    switch (DeploymentState)
                    {
                    case DeploymentStates.STOWED:
                    {
                        part.stackIcon.SetIconColor(XKCDColors.LightCyan);
                        if (PressureCheck && RandomDeployment)
                        {
                            PreDeploy();
                        }
                        break;
                    }

                    case DeploymentStates.PREDEPLOYED:
                    {
                        part.AddForceAtPosition(DragForce(0, preDeployedDiameter, 1f / semiDeploymentSpeed),
                                                ForcePosition);
                        if (trueAlt <= deployAltitude && dragTimer.Elapsed.TotalSeconds >= 1f / semiDeploymentSpeed)
                        {
                            Deploy();
                        }
                        break;
                    }

                    case DeploymentStates.DEPLOYED:
                    {
                        part.AddForceAtPosition(DragForce(preDeployedDiameter,
                                                          deployedDiameter,
                                                          1f / deploymentSpeed),
                                                ForcePosition);
                        break;
                    }
                    }
                }
                //Deactivation
                else
                {
                    if (IsDeployed)
                    {
                        Cut();
                    }
                    else
                    {
                        failedTimer.Start();
                        StagingReset();
                    }
                }
            }
        }