public double GetDistanceFromLastLocation(Vessel vessel)
        {
            double distance = 0;

            //Pull last prospect location from the vessel module.
            GoldStrikeVesselModule vesselModule = null;

            foreach (VesselModule module in vessel.vesselModules)
            {
                if (module is GoldStrikeVesselModule)
                {
                    vesselModule = (GoldStrikeVesselModule)module;
                    break;
                }
            }
            if (vesselModule == null)
            {
                return(double.MaxValue);
            }

            //If we've never set a prospect location then we're automatically ok.
            if (!vesselModule.HasLastProspectLocation())
            {
                return(double.MaxValue);
            }

            //Calculate the distance
            distance = Utils.HaversineDistance(vesselModule.lastProspectLongitude, vesselModule.lastProspectLatitude,
                                               vessel.longitude, vessel.latitude, vessel.mainBody);

            return(distance);
        }
示例#2
0
        protected double getDistanceFromLastLocation()
        {
            double distance = 0f;

            if (vesselModule == null)
            {
                return(0f);
            }

            //If we have no last prospect then the distance is zero.
            if (!vesselModule.HasLastProspectLocation())
            {
                vesselModule.UpdateLastProspectLocation();
                return(0f);
            }

            //In kilometers
            distance = Utils.HaversineDistance(vesselModule.lastProspectLongitude, vesselModule.lastProspectLatitude,
                                               this.part.vessel.longitude, this.part.vessel.latitude, this.part.vessel.mainBody);

            return(distance);
        }
示例#3
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            if (HighLogic.LoadedSceneIsFlight == false)
            {
                return;
            }

            //If we don't have a last prospect location then the distance is zero.
            if (vesselModule.HasLastProspectLocation() == false)
            {
                status = Localizer.Format(statusReadyName);
                nextProspectDistance = 0f;
                return;
            }

            //If we have an asteroid, then check its prospect status.
            //Priority is to check for captured asteroids before checking to see if we've prospected a particular planetary biome.
            if (asteroid != null)
            {
                if (WBIPathfinderScenario.Instance.IsAsteroidProspected(asteroid))
                {
                    status = Localizer.Format(statusAlreadyProspectedName);
                    nextProspectDistance = 0;
                    return;
                }

                //Ready to be prospected.
                else
                {
                    status = Localizer.Format(statusReadyName);
                    nextProspectDistance = 0;
                }

                //Done
                return;
            }

            //No asteroid, check prospect distance if we're landed
            if (this.part.vessel.situation == Vessel.Situations.LANDED || this.part.vessel.situation == Vessel.Situations.PRELAUNCH)
            {
                double distance = getDistanceFromLastLocation();

                //Update distance to next prospect
                nextProspectDistance = (minTravelDistance - distance);
                if (nextProspectDistance <= 0.00001f)
                {
                    nextProspectDistance = 0f;
                    status = Localizer.Format(statusReadyName);
                }

                else
                {
                    status = Localizer.Format(statusGoFartherName);
                }
            }

            //No asteroid and not landed.
            else
            {
                status = Localizer.Format(statusNoAsteroidName);
                nextProspectDistance = 0;
            }
        }