public static float getLift(ModuleKerBalloon thisBalloon)
        {
            float atmoPressure = (float)FlightGlobals.getStaticPressure(thisBalloon.part.transform.position);
            float coefficient  = (thisBalloon.minLift - thisBalloon.maxLift) / Mathf.Pow(thisBalloon.maxAtmoPressure, 2);
            float x            = Mathf.Pow(atmoPressure - thisBalloon.maxAtmoPressure - thisBalloon.minAtmoPressure, 2);
            float yInt         = thisBalloon.maxLift;

            float lift = coefficient * x + yInt;
            float max  = lift;

            float liftLimit = (thisBalloon.vessel.GetTotalMass() * (float)FlightGlobals.getGeeForceAtPosition(thisBalloon.transform.position).magnitude) / lift;

            lift *= liftLimit * thisBalloon.targetTWR;


            if (thisBalloon.speedLimiter && HighLogic.CurrentGame.Parameters.CustomParams <KerBSettings>().speedLimiterEnabled)
            {
                if (thisBalloon.vessel.verticalSpeed < thisBalloon.maxSpeed * (1 - thisBalloon.maxSpeedTolerence))
                {
                    thisBalloon.speedAdjust += thisBalloon.speedAdjustStep * (thisBalloon.maxSpeed - (float)thisBalloon.vessel.verticalSpeed);
                }
                else if (thisBalloon.vessel.verticalSpeed > thisBalloon.maxSpeed * (1 + thisBalloon.maxSpeedTolerence))
                {
                    thisBalloon.speedAdjust -= thisBalloon.speedAdjustStep * ((float)thisBalloon.vessel.verticalSpeed - thisBalloon.maxSpeed);
                }
                thisBalloon.speedAdjust = Mathf.Clamp(thisBalloon.speedAdjust, thisBalloon.speedAdjustMin, thisBalloon.speedAdjustMax);
                lift *= thisBalloon.speedAdjust;
            }
            if (thisBalloon.isInflated || thisBalloon.isInflating)
            {
                lift /= getInflatedBalloons(thisBalloon.vessel).Count;
            }
            lift = Mathf.Clamp(lift, 0, max);
            return(lift);
        }
Ejemplo n.º 2
0
        public static float getLift(ModuleKerBalloon thisBalloon)
        {
            float num     = (float)FlightGlobals.getStaticPressure(thisBalloon.part.transform.position);
            float num2    = (thisBalloon.minLift - thisBalloon.maxLift) / Mathf.Pow(thisBalloon.maxAtmoPressure, 2f);
            float num3    = Mathf.Pow(num - thisBalloon.maxAtmoPressure - thisBalloon.minAtmoPressure, 2f);
            float maxLift = thisBalloon.maxLift;
            float num4    = num2 * num3 + maxLift;
            float max     = num4;
            float num5    = thisBalloon.vessel.GetTotalMass() * (float)FlightGlobals.getGeeForceAtPosition(thisBalloon.transform.position).magnitude / num4;

            num4 *= num5 * thisBalloon.targetTWR;
            if (thisBalloon.speedLimiter)
            {
                if (thisBalloon.vessel.verticalSpeed < (double)(thisBalloon.maxSpeed * (1f - thisBalloon.maxSpeedTolerence)))
                {
                    thisBalloon.speedAdjust += thisBalloon.speedAdjustStep * (thisBalloon.maxSpeed - (float)thisBalloon.vessel.verticalSpeed);
                }
                else if (thisBalloon.vessel.verticalSpeed > (double)(thisBalloon.maxSpeed * (1f + thisBalloon.maxSpeedTolerence)))
                {
                    thisBalloon.speedAdjust -= thisBalloon.speedAdjustStep * ((float)thisBalloon.vessel.verticalSpeed - thisBalloon.maxSpeed);
                }
                thisBalloon.speedAdjust = Mathf.Clamp(thisBalloon.speedAdjust, thisBalloon.speedAdjustMin, thisBalloon.speedAdjustMax);
                num4 *= thisBalloon.speedAdjust;
            }
            if (thisBalloon.isInflated || thisBalloon.isInflating)
            {
                num4 /= (float)getInflatedBalloons(thisBalloon.vessel).Count;
            }
            return(Mathf.Clamp(num4, 0f, max));
        }
Ejemplo n.º 3
0
        void SetSymmetryValues(int balloonSize, ModuleKerBalloon mkb, BalloonInfo b, int selectedPlanet, string payload)
        {
            Log.Info("SetSymmetryValues, persistentId: " + mkb.part.persistentId);

            mkb.balloonSize     = balloonSize;
            mkb.lastBalloonSize = lastBalloonSize;
            mkb.recommendedBody = b.recommendedBody;
            mkb.bodyG           = GetBodyG(recommendedBody);
            //Log.Info("recommendedBody: " + b.recommendedBody + ", bodyName: " + recommendedBody + ", bodyG: " + bodyG);
            mkb.minAtmoPressure       = b.minAtmoPressure;
            mkb.maxAtmoPressure       = b.maxAtmoPressure;
            mkb.minScale              = b.minScale;
            mkb.maxScale              = b.maxScale;
            mkb.minLift               = b.minLift;
            mkb.maxLift               = b.maxLift;
            mkb.targetTWR             = b.targetTWR;
            mkb.liftLimit             = liftLimit;
            mkb.speedLimiter          = b.speedLimiter;
            mkb.maxSpeed              = b.maxSpeed;
            mkb.maxSpeedTolerence     = b.maxSpeedTolerence;
            mkb.speedAdjustStep       = b.speedAdjustStep;
            mkb.speedAdjustMin        = b.speedAdjustMin;
            mkb.speedAdjustMax        = b.speedAdjustMax;
            mkb.CFGballoonObject      = b.CFGballoonObject;
            mkb.CFGropeObject         = b.CFGropeObject;
            mkb.CFGcapObject          = b.CFGcapObject;
            mkb.CFGliftPointObject    = b.CFGliftPointObject;
            mkb.CFGballoonPointObject = b.CFGballoonPointObject;


            mkb.payload         = payload;
            mkb.selectedPayload = selectedPayload;
            mkb.bodyName        = b.recommendedBody;
        }
Ejemplo n.º 4
0
        public static float getScale(ModuleKerBalloon thisBalloon)
        {
            float num      = (float)FlightGlobals.getStaticPressure(thisBalloon.part.transform.position);
            float num2     = (thisBalloon.maxScale - thisBalloon.minScale) / Mathf.Pow(thisBalloon.maxAtmoPressure, 2f);
            float num3     = Mathf.Pow(num - thisBalloon.maxAtmoPressure - thisBalloon.minAtmoPressure, 2f);
            float minScale = thisBalloon.minScale;

            return(num2 * num3 + minScale);
        }
        public static float getScale(ModuleKerBalloon thisBalloon)
        {
            float atmoPressure = (float)FlightGlobals.getStaticPressure(thisBalloon.part.transform.position);
            float coefficient  = (thisBalloon.maxScale - thisBalloon.minScale) / Mathf.Pow(thisBalloon.maxAtmoPressure, 2);
            float x            = Mathf.Pow(atmoPressure - thisBalloon.maxAtmoPressure - thisBalloon.minAtmoPressure, 2);
            float yInt         = thisBalloon.minScale;

            float scale = coefficient * x + yInt;

            return(scale);
        }
Ejemplo n.º 6
0
        public static List <ModuleKerBalloon> getInflatedBalloons(Vessel vessel)
        {
            List <ModuleKerBalloon> list = new List <ModuleKerBalloon>();

            foreach (Part part in vessel.parts)
            {
                if ((bool)((Component)part).GetComponent <ModuleKerBalloon>())
                {
                    ModuleKerBalloon component = ((Component)part).GetComponent <ModuleKerBalloon>();
                    if ((component.isInflated || component.isInflating) && !component.hasBurst)
                    {
                        list.Add(component);
                    }
                }
            }
            return(list);
        }
        public static List <ModuleKerBalloon> getInflatedBalloons(Vessel vessel)
        {
            List <ModuleKerBalloon> balloons = new List <ModuleKerBalloon>();

            foreach (Part part in vessel.parts)
            {
                if (part.GetComponent <ModuleKerBalloon>())
                {
                    ModuleKerBalloon balloon = part.GetComponent <ModuleKerBalloon>();
                    if ((balloon.isInflated || balloon.isInflating) && !balloon.hasBurst)
                    {
                        balloons.Add(balloon);
                    }
                }
            }
            return(balloons);
        }