Exemplo n.º 1
0
            public bool CalculateHoverThrust(List <IMyTerminalBlock> thrusters, out float atmoPercent, out float hydroPercent, out float ionPercent)
            {
                atmoPercent  = 0;
                hydroPercent = 0;
                ionPercent   = 0;
                double ionThrust   = calculateMaxThrust(thrusters, thrustion);
                double atmoThrust  = calculateMaxThrust(thrusters, thrustatmo);
                double hydroThrust = calculateMaxThrust(thrusters, thrusthydro);

                double   physicalMass = _wicoBlockMaster.GetAllPhysicalMass();
                Vector3D vGrav        = _wicoBlockMaster.GetNaturalGravity();
                double   dGravity     = vGrav.Length() / 9.81;
                double   hoverthrust  = physicalMass * dGravity * 9.810;

                if (atmoThrust > 0)
                {
                    if (atmoThrust < hoverthrust)
                    {
                        atmoPercent  = 100;
                        hoverthrust -= atmoThrust;
                    }
                    else
                    {
                        atmoPercent = (float)(hoverthrust / atmoThrust * 100);
                        if (atmoPercent > 0)
                        {
                            hoverthrust -= (atmoThrust * atmoPercent / 100);
                        }
                    }
                }
                if (hoverthrust < 0.01)
                {
                    hoverthrust = 0;
                }
                //	Echo("ALeft over thrust=" + hoverthrust.ToString("N0"));

                if (ionThrust > 0 && hoverthrust > 0)
                {
                    if (ionThrust < hoverthrust)
                    {
                        ionPercent   = 100;
                        hoverthrust -= ionThrust;
                    }
                    else
                    {
                        ionPercent = (float)(hoverthrust / ionThrust * 100);
                        if (ionPercent > 0)
                        {
                            hoverthrust -= ((ionThrust * ionPercent) / 100);
                        }
                    }
                }
                if (hoverthrust < 0.01)
                {
                    hoverthrust = 0;
                }
                //	Echo("ILeft over thrust=" + hoverthrust.ToString("N0"));

                if (hydroThrust > 0 && hoverthrust > 0)
                {
                    if (hydroThrust < hoverthrust)
                    {
                        hydroPercent = 100;
                        hoverthrust -= hydroThrust;
                    }
                    else
                    {
                        hydroPercent = (float)(hoverthrust / hydroThrust * 100);
                        if (hydroPercent > 0)
                        {
                            hoverthrust -= ((hydroThrust * hydroPercent) / 100);
                        }
                        ;
                    }
                }
                if (atmoPercent < 0.01)
                {
                    atmoPercent = 0;
                }
                if (hydroPercent < 0.01)
                {
                    hydroPercent = 0;
                }
                if (ionPercent < 0.01)
                {
                    ionPercent = 0;
                }

                if (hoverthrust > 0)
                {
                    return(false);
                }
                return(true);
            }