Пример #1
0
        public void FixedUpdate()
        {
            currentDrag = 0;

            // With unity objects, "foo" or "foo != null" calls a method to check if
            // it's destroyed. (object)foo != null just checks if it is actually null.
            if (HighLogic.LoadedSceneIsFlight && (object)part != null && FlightGlobals.ready)
            {
                if (animatingPart)
                {
                    UpdatePropertiesWithAnimation();
                }

                if (!isShielded)
                {
                    Rigidbody rb     = part.Rigidbody;
                    Vessel    vessel = part.vessel;

                    // Check that rb is not destroyed, but vessel is just not null
                    if (rb && (object)vessel != null && vessel.atmDensity > 0 && !vessel.packed)
                    {
                        Vector3d velocity = rb.velocity + Krakensbane.GetFrameVelocity()
                                            - FARWind.GetWind(FlightGlobals.currentMainBody, part, rb.position);

                        double machNumber, v_scalar = velocity.magnitude;

                        rho        = FARAeroUtil.GetCurrentDensity(vessel.mainBody, part.transform.position);
                        machNumber = GetMachNumber(vessel.mainBody, vessel.altitude, velocity);
                        if (rho > 0 && v_scalar > 0.1)
                        {
                            double   failureForceScaling = FARAeroUtil.GetFailureForceScaling(vessel);
                            Vector3d force = RunDragCalculation(velocity, machNumber, rho, failureForceScaling);
                            rb.AddForceAtPosition(force, GetCoD());
                        }
                    }
                }
            }
        }