Пример #1
0
        new virtual public void FixedUpdate()
        {
            realIsp           = 0f;
            finalThrust       = 0f;
            fuelFlowGui       = 0f;
            requestedThrottle = 0f;

            SetUnflameout();
            if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                // nothing to see here
                return;
            }
            // so we must be in flight
            if (TimeWarping())
            {
                currentThrottle = 0f;
                return;
            }

            if (EngineIgnited && !flameout)
            {
                requestedThrottle = vessel.ctrlState.mainThrottle;
            }
            UpdateThrottle();

            ambientTherm.FromVesselAmbientConditions(vessel, useExtTemp);

            UpdateFlightCondition(ambientTherm,
                                  vessel.altitude,
                                  vessel.srf_velocity,
                                  vessel.mach,
                                  vessel.mainBody.atmosphereContainsOxygen,
                                  CheckTransformsUnderwater());
            CalculateEngineParams();
            UpdateTemp();

            if (finalThrust > 0f)
            {
                // now apply the thrust
                if (part.Rigidbody != null)
                {
                    int       tCount        = thrustTransforms.Count;
                    float     thrustPortion = finalThrust / tCount;
                    Transform t;
                    for (int i = 0; i < tCount; ++i)
                    {
                        t = thrustTransforms[i];
                        Vector3 axis = useZaxis ? -t.forward : -t.up;
                        part.Rigidbody.AddForceAtPosition(thrustRot * (axis * thrustPortion), t.position + t.rotation * thrustOffset, ForceMode.Force);
                    }
                }
                EngineExhaustDamage();

                double thermalFlux = tempRatio * tempRatio * heatProduction * vessel.VesselValues.HeatProduction.value * PhysicsGlobals.InternalHeatProductionFactor * part.thermalMass;
                part.AddThermalFlux(thermalFlux);
            }
            FXUpdate();
            if (flameout || !EngineIgnited)
            {
                SetFlameout();
            }
        }
Пример #2
0
        private void FixedUpdate()
        {
            if (!HighLogic.LoadedSceneIsFlight || !vessel)
            {
                return;
            }
            if (vessel.altitude > vessel.mainBody.atmosphereDepth)
            {
                return;
            }
            int newCount = vessel.Parts.Count;

            if (partsCount != newCount)
            {
                partsCount = newCount;
                updatePartsList();
            }


            InletArea  = 0d;
            EngineArea = 0d;
            OverallTPR = 0d;
            AreaRatio  = 0d;

            for (int j = engineList.Count - 1; j >= 0; --j)
            {
                ModuleEnginesSolver e = engineList[j];
                if ((object)e != null && e.EngineIgnited)
                {
                    EngineArea += e.Need_Area;
                }
            }

            for (int j = inletList.Count - 1; j >= 0; --j)
            {
                AJEInlet i = inletList[j];
                if ((object)i != null)
                {
                    double area = i.UsableArea();
                    InletArea  += area;
                    OverallTPR += area * i.overallTPR;
                }
            }

            if (InletArea > 0d)
            {
                if (EngineArea > 0d)
                {
                    AreaRatio   = Math.Min(1d, InletArea / EngineArea);
                    OverallTPR /= InletArea;
                    OverallTPR *= AreaRatio;
                }
                else
                {
                    AreaRatio = 1d;
                }
            }

            AmbientTherm.FromVesselAmbientConditions(vessel);
            Mach = vessel.mach;

            // Transform from static frame to vessel frame, increasing total pressure and temperature
            if (vessel.srfSpeed < 0.01d)
            {
                InletTherm.CopyFrom(AmbientTherm);
            }
            else
            {
                InletTherm.FromChangeReferenceFrame(AmbientTherm, vessel.srfSpeed);
            }
            InletTherm.P *= OverallTPR; // TPR accounts for loss of total pressure by inlet

            // Push parameters to each engine

            for (int i = engineList.Count - 1; i >= 0; --i)
            {
                engineList[i].UpdateInletEffects(InletTherm, AreaRatio, OverallTPR);
            }
        }