internal override SubRequirementState VesselMeetsCondition(Vessel vessel, EvaluationContext context) { SolarElevationState state = new SolarElevationState(); var vesselPosition = context.VesselPosition(vessel); var mainBodyPosition = context.BodyPosition(vessel.mainBody); var sunPosition = context.BodyPosition(Lib.GetParentSun(vessel.mainBody)); var a = vesselPosition - mainBodyPosition; var b = sunPosition - mainBodyPosition; state.solarElevation = Vector3d.Angle(a, b); state.requirementMet = true; if (min != double.MinValue && state.solarElevation < min) { state.requirementMet = false; } if (max != double.MaxValue && state.solarElevation > max) { state.requirementMet = false; } return(state); }
internal override string GetLabel(Vessel vessel, EvaluationContext context, SubRequirementState state) { SolarElevationState elevationState = (SolarElevationState)state; string degreesString = elevationState.solarElevation.ToString("F1") + " °"; return(Localizer.Format("Solar elevation: <<1>>", Lib.Color(degreesString, elevationState.requirementMet ? Lib.Kolor.Green : Lib.Kolor.Red))); }