Exemple #1
0
        /*public void ClearShielding()
        {
            isShielded = false;
        }

        public void ActivateShielding()
        {
            isShielded = true;
            Cl = 0;
            Cd = 0;
            Cm = 0;
        }*/
        public virtual Vector3d GetVelocity()
        {
            if (HighLogic.LoadedSceneIsFlight)
                return part.Rigidbody.velocity + Krakensbane.GetFrameVelocityV3f()
                    - FARWind.GetWind(FlightGlobals.currentMainBody, part, part.Rigidbody.position);
            else
                return velocityEditor;
        }
Exemple #2
0
 public Vector3d GetVelocity()
 {
     if (HighLogic.LoadedSceneIsFlight)
     {
         return(part.Rigidbody.velocity +
                Krakensbane.GetFrameVelocityV3f() -
                FARWind.GetWind(FlightGlobals.currentMainBody, part, part.Rigidbody.position));
     }
     return(velocityEditor);
 }
Exemple #3
0
        public Vector3d GetVelocity(Vector3 refPoint)
        {
            Vector3d velocity = Vector3.zero;
            if (HighLogic.LoadedSceneIsFlight)
            {
                if (part.Rigidbody)
                    velocity += part.Rigidbody.GetPointVelocity(refPoint);

                velocity += Krakensbane.GetFrameVelocity() - Krakensbane.GetLastCorrection() * TimeWarp.fixedDeltaTime;
                velocity -= FARWind.GetWind(FlightGlobals.currentMainBody, part, part.Rigidbody.position);

                return velocity;
            }
            else
                return velocityEditor;
        }
Exemple #4
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());
                        }
                    }
                }
            }
        }
Exemple #5
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)
            {
                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)
                    {
                        Vector3d velocity = rb.velocity + Krakensbane.GetFrameVelocity()
                                            + FARWind.GetWind(FlightGlobals.currentMainBody, part, rb.position);

                        double soundspeed, v_scalar = velocity.magnitude;

                        double rho = FARAeroUtil.GetCurrentDensity(vessel, out soundspeed);
                        if (rho > 0 && v_scalar > 0.1)
                        {
                            Vector3d force = RunDragCalculation(velocity, v_scalar / soundspeed, rho);
                            rb.AddForceAtPosition(force, GetCoD());
                        }
                    }
                }
            }
        }