Пример #1
0
 internal static void InitBiomeMap(PlanetData PD)
 {
     foreach (Cell cell in Cell.AtLevel(PD.gridLevel))
     {
         PD.biomes[cell] = ScienceUtil.GetExperimentBiome(PD.body, WeatherFunctions.GetCellLatitude(cell), WeatherFunctions.GetCellLongitude(cell));
     }
 }
Пример #2
0
        private string CurrentBiome(DMModuleScienceAnimate baseModuleExperiment)
        {
            var experimentSituation = ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel);

            if (!baseModuleExperiment.experiment.BiomeIsRelevantWhile(experimentSituation))
            {
                return(string.Empty);
            }

            if ((baseModuleExperiment.bioMask & (int)experimentSituation) == 0)
            {
                return(string.Empty);
            }

            var currentVessel = FlightGlobals.ActiveVessel;
            var currentBody   = FlightGlobals.currentMainBody;

            if (currentVessel != null && currentBody != null)
            {
                if (!string.IsNullOrEmpty(currentVessel.landedAt))
                {
                    //big thanks to xEvilReeperx for this one.
                    return(Vessel.GetLandedAtString(currentVessel.landedAt));
                }
                else
                {
                    return(ScienceUtil.GetExperimentBiome(currentBody, currentVessel.latitude, currentVessel.longitude));
                }
            }
            else
            {
                _AutomatedScienceSamplerInstance.Log("currentVessel && currentBody == null");
            }
            return(string.Empty);
        }
Пример #3
0
        private static ImpactScienceData createSpectralData(CelestialBody crashBody, Vessel crashVessel, uint flightID)
        {
            double crashVelocity = crashVessel.srf_velocity.magnitude;

            Log("Velocity=" + crashVelocity);
            float  crashMasss  = crashVessel.GetTotalMass() * 1000;
            double crashEnergy = 0.5 * crashMasss * crashVelocity * crashVelocity; //KE of crash

            ScienceExperiment experiment = ResearchAndDevelopment.GetExperiment("ImpactSpectrometer");
            String            biome      = ScienceUtil.GetExperimentBiome(crashBody, crashVessel.latitude, crashVessel.longitude);
            CBAttributeMapSO  m          = crashBody.BiomeMap;

            CBAttributeMapSO.MapAttribute[] atts = m.Attributes;
            ScienceSubject subject = ResearchAndDevelopment.GetExperimentSubject(experiment, ExperimentSituations.InSpaceLow, crashBody, biome, biome);
            double         science = subject.scienceCap;

            Log("Impact took place in " + biome + " at " + crashVessel.latitude + "," + crashVessel.longitude);
            String flavourText = "Impact at <<1>> on <<2>>";

            science  = Math.Max(0, science - subject.science);
            science /= subject.subjectValue;

            ImpactScienceData data = new ImpactScienceData(ImpactScienceData.DataTypes.Spectral,
                                                           0, biome, crashVessel.latitude,
                                                           (float)(science * subject.dataScale), 1f, 0, subject.id,
                                                           Localizer.Format(flavourText, biome, crashBody.GetDisplayName()), false, flightID);

            ScreenMessages.PostScreenMessage(
                Localizer.Format("#autoLOC_Screen_Spectrum", biome, crashBody.GetDisplayName()),
                5.0f, ScreenMessageStyle.UPPER_RIGHT);

            return(data);
        }
Пример #4
0
        private void OnGUI()
        {
            if (HighLogic.LoadedSceneIsEditor)
            {
                return;
            }

            if (mapLocationMode)
            {
                if (!MapView.MapIsEnabled)
                {
                    mapLocationMode = false;
                    return;
                }

                PlaceTargetAtCursor();
                GUI.Label(
                    new Rect(Input.mousePosition.x + 15, Screen.height - Input.mousePosition.y, 200, 50),
                    "Latitude:" + this.targetLatitude.ToString("F") + "\n" +
                    "Longitude:" + this.targetLongitude.ToString("F") + "\n" +
                    "Biome:" + ScienceUtil.GetExperimentBiome(this.vessel.mainBody, targetLatitude, targetLongitude)
                    );
                // Lock the waypoint if user clicks
                if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
                {
                    FindPath();
                    if (distanceToTarget > 0)
                    {
                        BonVoyage.Instance.ShowModuleControl();
                        mapLocationMode = false;
                        MapView.ExitMapView();
                    }
                }
            }
        }
Пример #5
0
        private string BiomeString(ScienceExperiment experiment = null)
        {
            if (experiment != null && !experiment.BiomeIsRelevantWhile(ScienceUtil.GetExperimentSituation(vessel)))
            {
                return(string.Empty);
            }
            if (vessel == null || body == null)
            {
                return(string.Empty);
            }
            if (body.BiomeMap == null)
            {
                return(string.Empty);
            }
            var v = vessel.EVALadderVessel;

            if (!string.IsNullOrEmpty(v.landedAt))
            {
                return(Vessel.GetLandedAtString(v.landedAt));
            }
            else
            {
                return(ScienceUtil.GetExperimentBiome(body, v.latitude, v.longitude));
            }
        }
Пример #6
0
        public void doScience(CelestialBody planet)
        {
            Utilities.Log_Debug("Doing Science for {0}", planet.theName);
            ScienceExperiment experiment = ResearchAndDevelopment.GetExperiment(ExperimentID);

            Utilities.Log_Debug("Got experiment");
            string biome = "";

            biome = part.vessel.landedAt != string.Empty ? part.vessel.landedAt : ScienceUtil.GetExperimentBiome(planet, FlightGlobals.ship_latitude, FlightGlobals.ship_longitude);
            ScienceSubject subject = ResearchAndDevelopment.GetExperimentSubject(experiment, ScienceUtil.GetExperimentSituation(vessel), planet, biome);

            Utilities.Log_Debug("Got subject");
            if (experiment.IsAvailableWhile(ScienceUtil.GetExperimentSituation(vessel), planet))
            {
                ScienceData data = new ScienceData(experiment.baseValue * subject.dataScale, xmitDataScalar, labBoostScalar, subject.id, subject.title, false, part.flightID);
                Utilities.Log_Debug("Got data");
                _scienceData.Add(data);
                Utilities.Log_Debug("Added Data");
                ScreenMessages.PostScreenMessage("Collected Science for " + planet.theName, 3f, ScreenMessageStyle.UPPER_CENTER);
                if (TSTProgressTracker.isActive)
                {
                    TSTProgressTracker.OnChemCamFire(planet, biome);
                }
            }
            updateAvailableEvents();
        }
        protected string CurrentBiome(ScienceExperiment baseExperiment)
        {
            if (!baseExperiment.BiomeIsRelevantWhile(ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel)))
            {
                return(string.Empty);
            }
            var currentVessel = FlightGlobals.ActiveVessel;
            var currentBody   = FlightGlobals.currentMainBody;

            if (currentVessel != null && currentBody != null)
            {
                if (currentVessel.isEVA)
                {
                    currentVessel = currentVessel.EVALadderVessel;
                }
                if (!string.IsNullOrEmpty(currentVessel.landedAt))
                {
                    //big thanks to xEvilReeperx for this one.
                    return(Vessel.GetLandedAtString(currentVessel.landedAt));
                }
                else
                {
                    return(ScienceUtil.GetExperimentBiome(currentBody, currentVessel.latitude, currentVessel.longitude));
                }
            }
            else
            {
                Log("currentVessel && currentBody == null");
            }
            return(string.Empty);
        }
Пример #8
0
        public bool GetBiome(double lat, double lon, out string biome)
        {
            biome = string.Empty;

            // Convert to radians
            lat *= Mathf.Deg2Rad;
            lon *= Mathf.Deg2Rad;

            Vessel vessel = FlightGlobals.ActiveVessel;

            if (vessel == null || vessel.mainBody.BiomeMap == null || vessel.mainBody.BiomeMap.MapName == null || vessel.mainBody.BiomeMap.Attributes.Length == 0)
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(vessel.landedAt))
            {
                biome = Vessel.GetLandedAtString(vessel.landedAt);
                return(true);
            }

            biome = ScienceUtil.GetExperimentBiome(vessel.mainBody, lat, lon);

            return(true);
        }
Пример #9
0
        public override void Draw(Unity.Flight.ISectionModule section)
        {
            var biome = ScienceUtil.GetExperimentBiome(FlightGlobals.ActiveVessel.mainBody, FlightGlobals.ActiveVessel.latitude, FlightGlobals.ActiveVessel.longitude);

            biome = ScienceUtil.GetBiomedisplayName(FlightGlobals.ActiveVessel.mainBody, biome);
            this.DrawLine(biome, section.IsHud);
        }
Пример #10
0
 void BiomeParser(StringBuilder result, CommonInfo info)
 {
     if (info.Vessel != null)
     {
         result.Append(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(ScienceUtil.GetExperimentBiome(info.Vessel.mainBody, info.Vessel.latitude, info.Vessel.longitude).ToLower()));
     }
 }
Пример #11
0
        //This method handles generating the surface or asteroid sample ScienceData
        private ScienceData sampleData(ModuleAsteroid m)
        {
            ScienceExperiment    exp = null;
            ScienceSubject       sub = null;
            ExperimentSituations expSit;
            ScienceData          data = null;
            string biome = "";

            if (m != null)
            {
                exp = asteroidExp;
            }
            else
            {
                exp = surfaceExp;
            }

            if (exp == null)
            {
                return(null);
            }

            expSit = ScienceUtil.GetExperimentSituation(vessel);

            if (exp.IsAvailableWhile(expSit, vessel.mainBody))
            {
                if (exp.BiomeIsRelevantWhile(expSit))
                {
                    if (!string.IsNullOrEmpty(vessel.landedAt))
                    {
                        biome = Vessel.GetLandedAtString(vessel.landedAt);
                    }
                    else
                    {
                        biome = ScienceUtil.GetExperimentBiome(vessel.mainBody, vessel.latitude, vessel.longitude);
                    }
                }

                if (m != null)
                {
                    sub = ResearchAndDevelopment.GetExperimentSubject(exp, expSit, m.part.partInfo.name + m.part.flightID, m.part.partInfo.title, vessel.mainBody, biome);
                }
                else
                {
                    sub = ResearchAndDevelopment.GetExperimentSubject(exp, expSit, vessel.mainBody, biome);
                }

                if (sub == null)
                {
                    return(null);
                }

                data = new ScienceData(exp.baseValue * exp.dataScale, this.xmitDataScalar, 0f, sub.id, sub.title, false, part.flightID);

                return(data);
            }

            return(null);
        }
Пример #12
0
 // Stock version throws an IndexOutOfRangeException when the body biome map is not defined
 public static string GetExperimentBiomeSafe(this CelestialBody body, double lat, double lon)
 {
     if (body.BiomeMap == null || body.BiomeMap.Attributes.Length == 0)
     {
         return(string.Empty);
     }
     return(ScienceUtil.GetExperimentBiome(body, lat, lon));
 }
Пример #13
0
        // Recalculates the current situation of the active vessel.
        private void RecalculateSituation( )
        {
//_logger.Trace( "RecalculateSituation Start" );

            var vessel = FlightGlobals.ActiveVessel;

            if (vessel == null)
            {
                if (_currentSituation != null)
                {
                    _currentSituation = null;
                    if (SituationChanged != null)
                    {
                        SituationChanged(this, null);
                    }
                }
                return;
            }

            var body      = vessel.mainBody;
            var situation = ScienceUtil.GetExperimentSituation(vessel);

            var biome    = ScienceUtil.GetExperimentBiome(body, vessel.latitude, vessel.longitude);
            var subBiome = string.IsNullOrEmpty(vessel.landedAt)
                                ? null
                                : Vessel.GetLandedAtString(vessel.landedAt).Replace(" ", "");

            var dataCount = vessel.FindPartModulesImplementing <IScienceDataContainer>( ).Sum(x => x.GetData( ).Length);

            if (_lastDataCount != dataCount)
            {
//				_logger.Trace( "Collected new science!" );
                _lastDataCount = dataCount;
                ScheduleExperimentUpdate( );
            }

            if (
                _currentSituation != null &&
                _currentSituation.Biome == biome &&
                _currentSituation.ExperimentSituation == situation &&
                _currentSituation.Body.CelestialBody == body &&
                _currentSituation.SubBiome == subBiome
                )
            {
                return;
            }
            var Body = new Body(body);

            _currentSituation = new Situation(Body, situation, biome, subBiome);

            if (SituationChanged != null)
            {
                SituationChanged(this, new NewSituationData(Body, situation, biome, subBiome));
            }
//_logger.Trace( "RecalculateSituation Done" );
        }
Пример #14
0
        public string CurrentBiome()
        {
            if (FlightGlobals.ActiveVessel.landedAt != string.Empty)
            {
                return(Vessel.GetLandedAtString(FlightGlobals.ActiveVessel.landedAt));
            }
            string biome = ScienceUtil.GetExperimentBiome(FlightGlobals.ActiveVessel.mainBody, FlightGlobals.ActiveVessel.latitude, FlightGlobals.ActiveVessel.longitude);

            return("" + biome);
        }
Пример #15
0
 void LandingZoneParser(StringBuilder result, CommonInfo info)
 {
     if (info.Vessel != null)
     {
         var landedAt = (string.IsNullOrEmpty(info.Vessel.landedAt))
             ? ScienceUtil.GetExperimentBiome(info.Vessel.mainBody, info.Vessel.latitude, info.Vessel.longitude)
             : Vessel.GetLandedAtString(info.Vessel.landedAt); // http://forum.kerbalspaceprogram.com/threads/123896-Human-Friendly-Landing-Zone-Title
         result.Append(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(landedAt.ToLower()));
     }
 }
Пример #16
0
        private StringValue GetCurrentBiome()
        {
            var vessel = FlightGlobals.ActiveVessel;
            var body   = FlightGlobals.ActiveVessel.mainBody;
            var Biome  = string.IsNullOrEmpty(vessel.landedAt)
           ? ScienceUtil.GetExperimentBiome(body, vessel.latitude, vessel.longitude)
           : Vessel.GetLandedAtString(vessel.landedAt).Replace(" ", "");

            return(Biome);
        }
Пример #17
0
        public string CurrentRawBiome()
        {
            if (vessel.landedAt != string.Empty)
            {
                return(vessel.landedAt);
            }
            string biome = ScienceUtil.GetExperimentBiome(mainBody, vessel.latitude, vessel.longitude);

            return("" + biome);
        }
Пример #18
0
 ///<summary>
 /// Returns the name of the biome for a point
 /// takes parameter <CelestialBody>, <double lng>, <double lat>
 ///</summary>
 internal string GetScannedBiomeName(CelestialBody body, double lng, double lat)
 {
     if ((SCANWrapper.IsCovered(lng, lat, body, "Biome")) || ((HasKerbNet("Biome")) && (IsInKerbNetFoV(body, lng, lat))))
     {
         return(ScienceUtil.GetExperimentBiome(body, lat, lng));
     }
     else
     {
         return("unknown");
     }
 }
Пример #19
0
        // FIXME: see what MJ + Biomatic do?
        string currentBiome()
        {
            if (mainBody.BiomeMap != null)
            {
                return(!string.IsNullOrEmpty(vessel.landedAt)
                                    ? Vessel.GetLandedAtString(vessel.landedAt)
                                    : ScienceUtil.GetExperimentBiome(mainBody,
                                                                     vessel.latitude, vessel.longitude));
            }

            return(string.Empty);
        }
Пример #20
0
        public static string GetVesselBiome(Vessel vessel)
        {
            vessel.checkLanded();
            vessel.checkSplashed();

            switch (vessel.situation)
            {
            case Situations.LANDED:
            case Situations.SPLASHED:
            case Situations.PRELAUNCH:
                if (string.IsNullOrEmpty(vessel.landedAt))
                {
                    return(ScienceUtil.GetExperimentBiome(
                               vessel.mainBody,
                               vessel.latitude,
                               vessel.longitude));
                }
                else
                {
                    return(GetVesselLandedAtBiome(vessel.landedAt));
                }

            case Situations.ORBITING:
                var altitude =
                    ScienceUtil.GetExperimentSituation(vessel) == ExperimentSituations.InSpaceLow ?
                    "" :
                    "High";
                var ecc = vessel.GetOrbit().eccentricity > 0.1d ?
                          "Eccentric" :
                          "";
                var suffix = string.Empty;
                if (!string.IsNullOrEmpty(altitude))
                {
                    suffix = altitude;
                }
                if (!string.IsNullOrEmpty(ecc))
                {
                    if (!string.IsNullOrEmpty(suffix))
                    {
                        suffix += "/";
                    }
                    suffix += ecc;
                }
                if (!string.IsNullOrEmpty(suffix))
                {
                    suffix = ":Too " + suffix;
                }
                return($"Orbit{suffix}");

            default:
                return(string.Empty);
            }
        }
Пример #21
0
        private bool CheckBiome(Vessel vessel)
        {
            // Fixes problems with special biomes like KSC buildings (total different naming)
            if (landedSituations.Contains(vessel.situation))
            {
                if (Vessel.GetLandedAtString(vessel.landedAt) == biome)
                {
                    return(true);
                }
            }

            return(ScienceUtil.GetExperimentBiome(vessel.mainBody, vessel.latitude, vessel.longitude) == biome);
        }
Пример #22
0
        public static string biome(Vessel v, string sit)
        {
            switch (sit)
            {
            case "Surface":
            case "Atmosphere":
            case "Ocean":
                return(ScienceUtil.GetExperimentBiome(v.mainBody, v.latitude, v.longitude));

            default:
                return(string.Empty);
            }
        }
Пример #23
0
 /// <summary>
 /// Gets the biome of the specified vessel, as used in science reports.
 /// </summary>
 /// <param name="vessel"></param>
 /// <returns></returns>
 private static string GetBiome(Vessel vessel)
 {
     if (string.IsNullOrEmpty(vessel.landedAt))
     {
         return(ScienceUtil.GetExperimentBiome(vessel.mainBody, vessel.latitude, vessel.longitude));
     }
     else
     {
         // This is for the micro-biomes around KSC ("LaunchPad", etc.) If you call ScienceUtil.GetExperimentBiome,
         // it just says "Shores".
         return(Vessel.GetLandedAtString(vessel.landedAt));
     }
 }
Пример #24
0
        internal void FinalizeExperiment()
        {
            Log.Info("FinalizeExperiment");

            ScienceExperiment labExp = ResearchAndDevelopment.GetExperiment(activeExperiment.activeExpid);


            string displayBiome = "";

            if (vessel.landedAt != string.Empty)
            {
                activeExperiment.biomeSit = Vessel.GetLandedAtString(vessel.landedAt);
                displayBiome = Localizer.Format(vessel.displaylandedAt);
            }
            else
            {
                activeExperiment.biomeSit = ScienceUtil.GetExperimentBiome(vessel.mainBody, vessel.latitude, vessel.longitude);
                displayBiome = ScienceUtil.GetBiomedisplayName(vessel.mainBody, activeExperiment.biomeSit);
            }

            ModuleScienceExperiment exp = activeExperiment.mse;

#if DEBUG
            var step = "Get Subject";
#endif
            ScienceSubject labSub = ResearchAndDevelopment.GetExperimentSubject(labExp, activeExperiment.expSit, vessel.mainBody, activeExperiment.biomeSit, displayBiome);
            labSub.title         = $"{labExp.experimentTitle}";
            labSub.subjectValue *= labBoostScalar;
            labSub.scienceCap    = labExp.scienceCap * labSub.subjectValue;

#if DEBUG
            step = "Calculate Points";
#endif
            float sciencePoints = labExp.baseValue * labExp.dataScale;

            ScienceData labData = new ScienceData(sciencePoints, exp.xmitDataScalar, 0, labSub.id, labSub.title, false, vessel.rootPart.flightID);

#if DEBUG
            step = "Add Experiment";
#endif
            _storedData.Add(labData);

#if DEBUG
            step = "Show Dialog";
#endif
            Utils.DisplayScreenMsg(Localizer.Format("#autoLOC_238419", vessel.rootPart.partInfo.title, labData.dataAmount, labSub.title));
            ReviewDataItem(labData);

            expStatuses.Remove(activeExperiment.Key);
            activeExperiment = null;
        }
Пример #25
0
        void OnCalculateBackgroundRadiationTemperature(ModularFlightIntegrator flightIntegrator, ModularScatter system)
        {
            List <GameObject> scatters = system.scatterObjects;
            Vessel            vessel   = flightIntegrator.Vessel;
            CelestialBody     _body    = system.body;

            if (_body != vessel.mainBody)
            {
                return;
            }

            for (Int32 i = 0; i < scatters.Count; i++)
            {
                GameObject scatter = scatters[i];

                if (scatter?.activeSelf != true)
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(biomeName))
                {
                    String biome = ScienceUtil.GetExperimentBiome(_body, vessel.latitude, vessel.longitude);

                    if (biomeName != biome)
                    {
                        continue;
                    }
                }

                Single distance = distanceCurve.Evaluate(Vector3.Distance(vessel.transform.position, scatter.transform.position));

                Double altitude  = altitudeCurve.Evaluate((Single)Vector3d.Distance(vessel.transform.position, _body.transform.position));
                Double latitude  = latitudeCurve.Evaluate((Single)vessel.latitude);
                Double longitude = longitudeCurve.Evaluate((Single)vessel.longitude);

                Double newTemp = altitude * latitude * longitude * ambientTemp;

                if (heatMap)
                {
                    Double x = ((450 - vessel.longitude) % 360) / 360.0;
                    Double y = (vessel.latitude + 90) / 180.0;
                    Double m = heatMap.GetPixelFloat(x, y);
                    newTemp *= m;
                }

                KopernicusHeatManager.NewTemp(newTemp, sumTemp);
            }
        }
Пример #26
0
        string currentBiome() // some crazy nonsense to get the actual biome string
        {
            if (FlightGlobals.ActiveVessel != null)
            {
                if (FlightGlobals.ActiveVessel.mainBody.BiomeMap != null)
                {
                    return(!string.IsNullOrEmpty(FlightGlobals.ActiveVessel.landedAt)
                                    ? Vessel.GetLandedAtString(FlightGlobals.ActiveVessel.landedAt)
                                    : ScienceUtil.GetExperimentBiome(FlightGlobals.ActiveVessel.mainBody,
                                                                     FlightGlobals.ActiveVessel.latitude, FlightGlobals.ActiveVessel.longitude));
                }
            }

            return(string.Empty);
        }
Пример #27
0
        /*
         * Whether this vessel meets the parameter condition.
         */
        protected override bool VesselMeetsCondition(Vessel vessel)
        {
            LoggingUtil.LogVerbose(this, "Checking VesselMeetsCondition: " + vessel.id);

            // Fixes problems with special biomes like KSC buildings (total different naming)
            if (landedSituations.Contains(vessel.situation))
            {
                if (Vessel.GetLandedAtString(vessel.landedAt) == biome)
                {
                    return(true);
                }
            }

            return(ScienceUtil.GetExperimentBiome(vessel.mainBody, vessel.latitude, vessel.longitude) == biome);
        }
Пример #28
0
        // Recalculates the current situation of the active vessel.
        private void RecalculateSituation( )
        {
//_logger.Trace( "RecalculateSituation Start" );

            var vessel = FlightGlobals.ActiveVessel;

            if (vessel == null)
            {
                if (_currentSituation != null)
                {
                    _currentSituation = null;
                    if (SituationChanged != null)
                    {
                        SituationChanged(this, null);
                    }
                }
                return;
            }

            var celestialBody = vessel.mainBody;
            var situation     = ScienceUtil.GetExperimentSituation(vessel);

            var biome    = ScienceUtil.GetExperimentBiome(celestialBody, vessel.latitude, vessel.longitude);
            var subBiome = string.IsNullOrEmpty(vessel.landedAt)
                                ? null
                                : Vessel.GetLandedAtString(vessel.landedAt).Replace(" ", "");

            if (
                _currentSituation != null &&
                _currentSituation.Biome == biome &&
                _currentSituation.ExperimentSituation == situation &&
                _currentSituation.Body.CelestialBody == celestialBody &&
                _currentSituation.SubBiome == subBiome
                )
            {
                return;
            }

            var body = new Body(celestialBody);

            _currentSituation = new Situation(body, situation, biome, subBiome);

            if (SituationChanged != null)
            {
                SituationChanged(this, new NewSituationData(body, situation, biome, subBiome));
            }
//_logger.Trace( "RecalculateSituation Done" );
        }
Пример #29
0
        internal void DrawMarkers()
        {
            if (this.SystemState == SystemStates.NoTargetSelected)
            {
                return;
            }

            if (MapView.MapIsEnabled)
            {
                GuiUtils.DrawMapViewGroundMarker(this.m_virtualTarget.Location,
                                                 this.SystemState == SystemStates.TargetSelected ? POSITION_COLOR : PICKING_COLOR);

                if (this.SystemState == SystemStates.PickingTarget && this.m_isMouseOverPickingBody)
                {
                    var coords = this.m_virtualTarget.Location.Coordinates;
                    GUI.Label(new Rect(Input.mousePosition.x + 15, Screen.height - Input.mousePosition.y, 200, 50),
                              coords.ToStringDecimal() + "\n"
                              + ScienceUtil.GetExperimentBiome(this.m_virtualTarget.Location.Body, coords.Latitude, coords.Longitude));
                }
            }
            else
            {
                double distance = this.m_virtualTarget.GetDistance(this.vessel);
                double radius;
                if (distance < 1000)
                {
                    radius = 30;
                }
                else if (distance < 10000)
                {
                    radius = 300;
                }
                else if (distance < 100000)
                {
                    radius = 3000;
                }
                else
                {
                    radius = -1;
                }

                if (radius > 0)
                {
                    GuiUtils.DrawMapViewGroundMarker(this.m_virtualTarget.Location, POSITION_COLOR, radius: radius);
                }
            }
        }
Пример #30
0
        ///<summary>
        ///returns the amount of a given resource for a body and place
        /// takes the args <body> <geocoordinates> and <resource-string> in any order
        ///</summary>
        public ScalarDoubleValue GetResourceByName(params Structure[] args)
        {
            if (args.Length != 3)
            {
                return(null);
            }
            BodyTarget     body       = args.Where(s => s.GetType() == typeof(BodyTarget)).Cast <BodyTarget>().First();
            GeoCoordinates coordinate = args.Where(s => s.GetType() == typeof(GeoCoordinates)).Cast <GeoCoordinates>().First();
            StringValue    s_type     = args.Where(s => s.GetType() == typeof(StringValue)).Cast <StringValue>().First();

            if (resourceNames == null)
            {
                resourceNames = ResourceMap.Instance.FetchAllResourceNames(HarvestTypes.Planetary);
            }

            var resourceName = resourceNames.FirstOrDefault(name => string.Equals(name, s_type, StringComparison.InvariantCultureIgnoreCase));

            if (resourceName == null)
            {
                throw new kOS.Safe.Exceptions.KOSException("invalid resource type");
            }

            if ((SCANWrapper.IsCovered(coordinate.Longitude, coordinate.Latitude, body.Body, "ResourceHiRes")) || ((HasKerbNet("Resource") && (IsInKerbNetFoV(body.Body, coordinate.Longitude, coordinate.Latitude)))))
            {
                float amount   = 0f;
                var   aRequest = new AbundanceRequest
                {
                    Latitude        = coordinate.Latitude,
                    Longitude       = coordinate.Longitude,
                    BodyId          = body.Body.flightGlobalsIndex,
                    ResourceName    = resourceName,
                    ResourceType    = HarvestTypes.Planetary,
                    Altitude        = 0,
                    CheckForLock    = SCANWrapper.GetResourceBiomeLock(),
                    BiomeName       = ScienceUtil.GetExperimentBiome(body.Body, coordinate.Latitude, coordinate.Longitude),
                    ExcludeVariance = false,
                };

                amount = ResourceMap.Instance.GetAbundance(aRequest);
                return(amount);
            }
            else
            {
                return(-1.0);
            }
        }