public override void OnStart(StartState state) { base.OnStart(state); Events["CheckGoldStrike"].guiActive = showGUI; Events["CheckGoldStrike"].guiActiveUncommand = showGUI; if (HighLogic.LoadedSceneIsFlight == false) { return; } //Vessel Module foreach (VesselModule module in this.part.vessel.vesselModules) { if (module is GoldStrikeVesselModule) { vesselModule = (GoldStrikeVesselModule)module; break; } } //Get asteroid (if any) asteroid = this.part.vessel.FindPartModuleImplementing <ModuleAsteroid>(); }
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); }
public override void OnStart(StartState state) { base.OnStart(state); Events["CheckGoldStrike"].guiActive = showGUI; Events["CheckGoldStrike"].guiActiveUncommand = showGUI; if (HighLogic.LoadedSceneIsFlight == false) { return; } //Minimum travel distance minTravelDistance = GoldStrikeSettings.DistanceBetweenProspects; GameEvents.OnGameSettingsApplied.Add(onGameSettingsApplied); //Vessel Module foreach (VesselModule module in this.part.vessel.vesselModules) { if (module is GoldStrikeVesselModule) { vesselModule = (GoldStrikeVesselModule)module; break; } } //Get asteroid (if any) asteroid = this.part.vessel.FindPartModuleImplementing <ModuleAsteroid>(); }