Ejemplo n.º 1
0
 private List <Surface> Surfaces()
 {
     if (surfaces == null)
     {
         surfaces = BodySurfaceObservation.CreateVisibleSurfaces();
     }
     return(surfaces);
 }
Ejemplo n.º 2
0
        internal override bool VesselsMeetCondition(List <Vessel> vessels, EvaluationContext context, out string statusLabel)
        {
            if (minSurface == 0 ||  vessels.Count == 0)
            {
                statusLabel = string.Empty;
                return(vessels.Count > 0);
            }

            Vector3d bodyPosition = context.BodyPosition(context.targetBody);

            double visible         = 100.0 * BodySurfaceObservation.VisibleSurface(vessels, context, bodyPosition, minElevation, Surfaces());
            string observedPercStr = Lib.HumanReadablePerc(visible / 100.0) + " / " + Lib.HumanReadablePerc(minSurface / 100.0);

            observedPercStr = Lib.Color(observedPercStr, visible > minSurface ? Lib.Kolor.Green : Lib.Kolor.Red);
            statusLabel     = Localizer.Format("#KerCon_XofSurfaceObserved", observedPercStr);
            return(visible > minSurface);
        }
        private void UpdateSunObservationStatus()
        {
            // determine sun surface observation status for all suns in the system
            vesselsPerSun.Clear();
            foreach (var entries in EquipmentStates.states)
            {
                foreach (var e in entries.Value)
                {
                    if (e.id == Configuration.SunObservationEquipment && e.value == EquipmentState.nominal)
                    {
                        Vessel v = FlightGlobals.FindVessel(entries.Key);
                        if (v != null)
                        {
                            var sun = Sim.GetParentStar(v.mainBody);
                            if (!vesselsPerSun.ContainsKey(sun))
                            {
                                vesselsPerSun[sun] = new List <Vessel>();
                            }
                            vesselsPerSun[sun].Add(v);
                        }
                    }
                }
            }

            foreach (var e in vesselsPerSun)
            {
                var sun     = e.Key;
                var vessels = e.Value;
                if (solarSurfaces == null)
                {
                    solarSurfaces = BodySurfaceObservation.CreateVisibleSurfaces();
                }

                var context = new EvaluationContext(GetUniverseEvaluator(), null, sun);
                context.SetTime(Planetarium.GetUniversalTime());
                Vector3d sunPosition = context.BodyPosition(sun);

                var observedSurface = (float)BodySurfaceObservation.VisibleSurface(vessels, context, sunPosition, Configuration.MinSunObservationAngle, solarSurfaces);
                API.SetStormObservationQuality(sun, observedSurface);
                Utils.LogDebug($"Solar surface observation for {sun.displayName}: {(observedSurface * 100.0).ToString("F2")}%");
            }
        }