public SimulatedParachute(ModuleParachute mp, SimCurves simCurve, double startTime, int limitChutesStage) : base(mp.part, simCurve)
            {
                this.para  = mp;
                this.state = mp.deploymentState;

                willDeploy = limitChutesStage != -1 && para.part.inverseStage >= limitChutesStage;

                // Work out when the chute was put into its current state based on the current drag as compared to the stowed, semi deployed and fully deployed drag

                double timeSinceDeployment = 0;

                switch (mp.deploymentState)
                {
                case ModuleParachute.deploymentStates.SEMIDEPLOYED:
                    if (mp.Anim.isPlaying)
                    {
                        timeSinceDeployment = mp.Anim[mp.semiDeployedAnimation].time;
                    }
                    else
                    {
                        timeSinceDeployment = 10000000;
                    }
                    break;

                case ModuleParachute.deploymentStates.DEPLOYED:
                    if (mp.Anim.isPlaying)
                    {
                        timeSinceDeployment = mp.Anim[mp.fullyDeployedAnimation].time;
                    }
                    else
                    {
                        timeSinceDeployment = 10000000;
                    }
                    break;

                case ModuleParachute.deploymentStates.STOWED:
                case ModuleParachute.deploymentStates.ACTIVE:
                    // If the parachute is stowed then for some reason para.parachuteDrag does not reflect the stowed drag. set this up by hand.
                    timeSinceDeployment = 10000000;
                    break;

                default:
                    // otherwise set the time since deployment to be a very large number to indcate that it has been in that state for a long time (although we do not know how long!
                    timeSinceDeployment = 10000000;
                    break;
                }

                this.openningTime = startTime - timeSinceDeployment;
            }
            public SimulatedVessel(Vessel v, SimCurves simCurves, double startTime, int limitChutesStage)
            {
                totalMass = 0;

                var oParts = v.Parts;

                count = oParts.Count;

                this.simCurves = simCurves;

                if (parts.Capacity < count)
                {
                    parts.Capacity = count;
                }

                for (int i = 0; i < count; i++)
                {
                    SimulatedPart simulatedPart = null;
                    bool          special       = false;
                    for (int j = 0; j < oParts[i].Modules.Count; j++)
                    {
                        ModuleParachute mp = oParts[i].Modules[j] as ModuleParachute;
                        if (mp != null && v.mainBody.atmosphere)
                        {
                            special       = true;
                            simulatedPart = new SimulatedParachute(mp, simCurves, startTime, limitChutesStage);
                        }
                    }
                    if (!special)
                    {
                        simulatedPart = new SimulatedPart(oParts[i], simCurves);
                    }

                    parts.Add(simulatedPart);
                    totalMass += simulatedPart.totalMass;
                }
            }
Example #3
0
            public SimulatedPart(Part p, SimCurves simCurves)
            {
                Rigidbody rigidbody = p.rb;

                totalMass = rigidbody == null
                    ? 0
                    : rigidbody.mass; // TODO : check if we need to use this or the one without the childMass
                shieldedFromAirstream = p.ShieldedFromAirstream;

                noDrag             = rigidbody == null && !PhysicsGlobals.ApplyDragToNonPhysicsParts;
                hasLiftModule      = p.hasLiftModule;
                bodyLiftMultiplier = p.bodyLiftMultiplier * PhysicsGlobals.BodyLiftMultiplier;

                this.simCurves = simCurves;

                CopyDragCubesList(p.DragCubes, cubes);

                // Rotation to convert the vessel space vesselVelocity to the part space vesselVelocity
                // QuaternionD.LookRotation is not working...
                partToVessel =
                    Quaternion.LookRotation(p.vessel.GetTransform().InverseTransformDirection(p.transform.forward),
                                            p.vessel.GetTransform().InverseTransformDirection(p.transform.up));
                vesselToPart = Quaternion.Inverse(partToVessel);
            }