Пример #1
0
        public EngineCluster BestForManeuver(Vector3 dV)
        {
            var           dVm       = dV.magnitude;
            var           loc_dV    = -VSL.LocalDir(dV);
            var           min_score = float.MaxValue;
            EngineCluster best      = null;

            for (int j = 0, clustersCount = clusters.Count; j < clustersCount; j++)
            {
                var c      = clusters[j];
                var score  = VSL.Torque.NoEngines.RotationTime2Phase(Utils.Angle2(loc_dV, c.Dir), 1);
                var thrust = c.MaxThrust.magnitude;
                var ttb    = VSL.Engines.TTB(dVm, thrust, (float)c.MaxMassFlow, 1);
                if (VSL.Info.Countdown > 0 && score + ttb / 2 > VSL.Info.Countdown)
                {
                    continue;
                }
                if (ttb < ManeuverAutopilot.C.ClosestCluster)
                {
                    ttb = 0;
                }
                score += ttb;
                var fuel = VSL.Engines.FuelNeeded(dVm, (float)(thrust / c.MaxMassFlow));
                if (fuel / VSL.Physics.M > ManeuverAutopilot.C.EfficientCluster)
                {
                    score += fuel * ManeuverAutopilot.C.EfficiencyWeight;
                }
                if (score < min_score)
                {
                    min_score = score;
                    best      = c;
                }
            }
            return(best ?? Closest(loc_dV));
        }
            public EngineCluster Fastest(Vector3 dV)
            {
//				Log("Requested fasted cluster for: {}", dV);//debug
                var           dVm      = dV.magnitude;
                var           loc_dV   = VSL.LocalDir(dV);
                var           min_time = float.MaxValue;
                EngineCluster fastest  = null;

                for (int j = 0, clustersCount = clusters.Count; j < clustersCount; j++)
                {
                    var c    = clusters[j];
                    var time = VSL.Torque.NoEngines.RotationTime(Vector3.Angle(loc_dV, c.Dir), 1);
//					Log("Dir {}, Angle {}, Rot.time: {}, coutdown {}", c.Dir, Vector3.Angle(loc_dV, c.Dir), time, VSL.Info.Countdown);//debug
                    if (VSL.Info.Countdown > 0 && time > VSL.Info.Countdown)
                    {
                        continue;
                    }
                    time += VSL.Engines.TTB(dVm, c.MaxThrust.magnitude, (float)c.MaxMassFlow, 1);
//					Log("MThrust {}, Rot+ttb: {} < min time {}", c.MaxThrust, time, min_time);//debug
                    if (time < min_time)
                    {
                        min_time = time;
                        fastest  = c;
                    }
                }
//				Log("Fasted cluster: {}", fastest);//debug
                return(fastest ?? Closest(loc_dV));
            }
Пример #3
0
 bool activate(EngineCluster cluster)
 {
     if (cluster == null || cluster == Active)
     {
         return(false);
     }
     Deactivate();
     cluster.Enable();
     CFG.ActiveProfile.Update(VSL.Engines.All, true);
     Active = cluster;
     return(true);
 }
            bool activate(EngineCluster cluster)
            {
                if (cluster == null || cluster == Active)
                {
                    return(false);
                }
                Deactivate();
                cluster.Enable();
                CFG.ActiveProfile.Update(VSL.Engines.All, true);
//				Log("Activated: {}\nAll engines: {}\nProfile: {}", cluster, VSL.Engines.All, CFG.ActiveProfile);//debug
                Active = cluster;
                return(true);
            }
Пример #5
0
        EngineCluster find_closest(Vector3 local_dir, out float min_dist)
        {
            min_dist = float.MaxValue;
            EngineCluster closest = null;

            for (int j = 0, clustersCount = clusters.Count; j < clustersCount; j++)
            {
                var c = clusters[j];
                var d = c.DistanceTo(local_dir);
                if (d < min_dist)
                {
                    min_dist = d;
                    closest  = c;
                }
            }
            return(closest);
        }
            public EngineCluster BestForManeuver(Vector3 dV)
            {
//				Log("Requested best cluster for maneuver: {}", dV);//debug
                var           dVm       = dV.magnitude;
                var           loc_dV    = VSL.LocalDir(dV);
                var           min_score = float.MaxValue;
                EngineCluster best      = null;

                for (int j = 0, clustersCount = clusters.Count; j < clustersCount; j++)
                {
                    var c     = clusters[j];
                    var score = VSL.Torque.NoEngines.RotationTime(Vector3.Angle(loc_dV, c.Dir), 1);
//					Log("Dir {}, Angle {}, Rot.time: {}, coutdown {}", c.Dir, Vector3.Angle(loc_dV, c.Dir), score, VSL.Info.Countdown);//debug
                    var thrust = c.MaxThrust.magnitude;
                    var ttb    = VSL.Engines.TTB(dVm, thrust, (float)c.MaxMassFlow, 1);
                    if (VSL.Info.Countdown > 0 && score + ttb / 2 > VSL.Info.Countdown)
                    {
                        continue;
                    }
                    if (ttb < GLB.MAN.ClosestCluster)
                    {
                        ttb = 0;
                    }
                    score += ttb;
                    var fuel = VSL.Engines.FuelNeeded(dVm, (float)(thrust / c.MaxMassFlow));
                    if (fuel / VSL.Physics.M > GLB.MAN.EfficientCluster)
                    {
                        score += fuel * GLB.MAN.EfficiencyWeight;
                    }
//					Log("ttb {}, fuel {}, score {} < min score {}", ttb, fuel, score, min_score);//debug
                    if (score < min_score)
                    {
                        min_score = score;
                        best      = c;
                    }
                }
//				Log("Best cluster: {}", best);//debug
                return(best ?? Closest(loc_dV));
            }
Пример #7
0
        public EngineCluster Fastest(Vector3 dV)
        {
            var           dVm      = dV.magnitude;
            var           loc_dir  = -VSL.LocalDir(dV);
            var           min_time = float.MaxValue;
            EngineCluster fastest  = null;

            for (int j = 0, clustersCount = clusters.Count; j < clustersCount; j++)
            {
                var c    = clusters[j];
                var time = VSL.Torque.NoEngines.RotationTime2Phase(Utils.Angle2(loc_dir, c.Dir), 1);
                if (VSL.Info.Countdown > 0 && time > VSL.Info.Countdown)
                {
                    continue;
                }
                time += VSL.Engines.TTB(dVm, c.MaxThrust.magnitude, (float)c.MaxMassFlow, 1);
                if (time < min_time)
                {
                    min_time = time;
                    fastest  = c;
                }
            }
            return(fastest ?? Closest(loc_dir));
        }