public GoldStrikeLode AddLode(int planetID, string biome, double longitude, double lattitude, double altitude, string resourceName, double amountRemaining) { GoldStrikeLode lode = new GoldStrikeLode(); Dictionary <string, GoldStrikeLode> lodeMap = null; string planetBiomeKey = planetID.ToString() + biome; string lodeKey = longitude.ToString() + lattitude.ToString() + resourceName; //Setup the new lode lode.resourceName = resourceName; lode.longitude = longitude; lode.lattitude = lattitude; lode.biome = biome; lode.amountRemaining = amountRemaining; lode.planetID = planetID; //Get the lode map if (goldStrikeLodes.ContainsKey(planetBiomeKey) == false) { lodeMap = new Dictionary <string, GoldStrikeLode>(); goldStrikeLodes.Add(planetBiomeKey, lodeMap); } lodeMap = goldStrikeLodes[planetBiomeKey]; //Add the new lode lodeMap.Add(lodeKey, lode); goldStrikeLodes[planetBiomeKey] = lodeMap; debugLog("Added new lode: " + lode.ToString()); //Save the game GamePersistence.SaveGame("quicksave", HighLogic.SaveFolder, SaveMode.BACKUP); return(lode); }
protected void findNearestLode() { //Do we have an asteroid? asteroid = this.part.vessel.FindPartModuleImplementing <ModuleAsteroid>(); if (asteroid == null) { nearestLode = null; lodeStatus = Localizer.Format(statusNoNearbyName); lodeResourceName = "N/A"; debugLog("No lode found nearby because there's no captured asteroid."); return; } //Find the nearest lode (if any) debugLog("Looking for a prospect lode for asteroid " + asteroid.AsteroidName); nearestLode = WBIPathfinderScenario.Instance.FindNearestLode(asteroid); if (nearestLode != null) { lodeStatus = Localizer.Format(statusOKName); lodeResourceName = nearestLode.resourceName; lodeAbundance = nearestLode.abundance * 100.0f; debugLog("nearestLode: " + nearestLode.ToString()); } else { lodeStatus = Localizer.Format(statusNoNearbyName); lodeResourceName = "N/A"; debugLog("No lode found nearby."); } }
public bool SituationIsValid() { debugLog("SituationIsValid: checking..."); GoldStrikeLode lode = null; //Do we have enough crew? if (minimumCrew > 0) { if (this.part.protoModuleCrew.Count < minimumCrew) { ScreenMessages.PostScreenMessage(this.part.partInfo.title + "Must be staffed with at least " + minimumCrew + " crewmembers.", kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER); status = Localizer.Format(statusInsufficientCrewName); return(false); } } //Can we prospect the location? switch (WBIGoldStrikeScenario.Instance.GetProspectSituation(this.part.vessel, out lode, out prospectResources)) { case ProspectSituations.NoResourcesToProspect: status = Localizer.Format(statusNoResources); ScreenMessages.PostScreenMessage("No resource lodes detected here. Try traveling further.", kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER); return(false); case ProspectSituations.InvalidVesselSituation: debugLog("Vessel situation not valid"); ScreenMessages.PostScreenMessage("Vessel must be landed, splashed, or in orbit/docked with an asteroid attached", kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER); status = Localizer.Format(statusNAName); return(false); case ProspectSituations.LodeAlreadyExists: if (lode != null) { debugLog("Situation not valid, existing lode found: " + lode.ToString()); string message = string.Format("You already found a vein of {0:s} at this location. It has {1:f2} units remaining.", lode.resourceName, lode.amountRemaining); ScreenMessages.PostScreenMessage(message, kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER); status = Localizer.Format(statusAlreadyProspectedName); } return(false); case ProspectSituations.AsteroidProspected: debugLog("Asteroid has already been prospected"); ScreenMessages.PostScreenMessage("Asteroid has already been prospected.", kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER); status = Localizer.Format(statusAlreadyProspectedName); if (!WBIGoldStrikeScenario.debugProspectAlwaysSuccessful) { return(false); } else { debugLog("Debug: Prospect is guaranteed"); return(true); } //A-OK default: status = Localizer.Format(statusReadyName); return(true); } }
protected void findNearestLode() { int planetID; string biomeName; double longitude = 0f; double latitude = 0f; if (this.part.vessel.situation == Vessel.Situations.LANDED || this.part.vessel.situation == Vessel.Situations.PRELAUNCH) { longitude = this.part.vessel.longitude; latitude = this.part.vessel.latitude; //Find the nearest lode (if any) GoldStrikeUtils.GetBiomeAndPlanet(out biomeName, out planetID, this.part.vessel); nearestLode = WBIPathfinderScenario.Instance.FindNearestLode(planetID, biomeName, longitude, latitude, maxHarvestRange); if (nearestLode != null) { lodeStatus = Localizer.Format(statusOKName); lodeResourceName = nearestLode.resourceName; debugLog("nearestLode: " + nearestLode.ToString()); } else { lodeStatus = Localizer.Format(statusNoNearbyName); lodeResourceName = "N/A"; debugLog("No lode found nearby."); } } }
protected void updateNearestLode() { int planetID; string biomeName; double longitude = 0f; double latitude = 0f; if (this.part.vessel.situation == Vessel.Situations.LANDED || this.part.vessel.situation == Vessel.Situations.PRELAUNCH) { longitude = this.part.vessel.longitude; latitude = this.part.vessel.latitude; } //Find the nearest lode (if any) GoldStrikeUtils.GetBiomeAndPlanet(out biomeName, out planetID, this.part.vessel, asteroid); nearestLode = WBIPathfinderScenario.Instance.FindNearestLode(planetID, biomeName, longitude, latitude); if (nearestLode != null) { debugLog("nearestLode: " + nearestLode.ToString()); } }
public GoldStrikeLode AddLode(ModuleAsteroid asteroid, string resourceName, float abundance) { int planetID; string biomeName; GoldStrikeUtils.GetBiomeAndPlanet(out biomeName, out planetID, null, asteroid); GoldStrikeLode lode = new GoldStrikeLode(); Dictionary <string, GoldStrikeLode> lodeMap = null; string planetBiomeKey = planetID.ToString() + biomeName; //Setup the new lode lode.resourceName = resourceName; lode.longitude = 0; lode.lattitude = 0; lode.biome = biomeName; lode.abundance = abundance; lode.planetID = planetID; //Get the lode map if (goldStrikeLodes.ContainsKey(planetBiomeKey) == false) { lodeMap = new Dictionary <string, GoldStrikeLode>(); goldStrikeLodes.Add(planetBiomeKey, lodeMap); debugLog("Added new goldStrikeLode with planetBiomeKey: " + planetBiomeKey); } lodeMap = goldStrikeLodes[planetBiomeKey]; //Add the new lode lodeMap.Add(asteroid.AsteroidName, lode); goldStrikeLodes[planetBiomeKey] = lodeMap; debugLog("Added new lode: " + lode.ToString()); //Save the game GamePersistence.SaveGame("quicksave", HighLogic.SaveFolder, SaveMode.BACKUP); return(lode); }
public bool SituationIsValid() { debugLog("SituationIsValid: checking..."); CBAttributeMapSO.MapAttribute biome = null; string biomeName = string.Empty; int planetID = int.MaxValue; bool vesselSituationIsValid = false; double longitude = 0f; double latitude = 0f; double altitude = 0f; GoldStrikeLode lode = null; //If we're landed then we're ok to check prospect situation. if (this.part.vessel.situation == Vessel.Situations.LANDED || this.part.vessel.situation == Vessel.Situations.PRELAUNCH) { biome = Utils.GetCurrentBiome(this.part.vessel); biomeName = biome.name; planetID = this.part.vessel.mainBody.flightGlobalsIndex; longitude = this.part.vessel.longitude; latitude = this.part.vessel.latitude; altitude = this.part.vessel.altitude; vesselSituationIsValid = true; debugLog("Vessel is landed or prelaunch"); } //If we're docked or orbiting, and we have an asteroid, then we're ok to check prospect situation. if ((this.part.vessel.situation == Vessel.Situations.ORBITING || this.part.vessel.situation == Vessel.Situations.DOCKED) && asteroid != null) { biomeName = asteroid.AsteroidName; vesselSituationIsValid = true; debugLog("Vessel has an asteroid"); } //If the flight situation is bad then we're done. if (vesselSituationIsValid == false) { debugLog("Vessel situation not valid"); ScreenMessages.PostScreenMessage("Vessel must be landed or in orbit/docked with an asteroid attached", kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER); return(false); } //If we don't have sufficient ore abundance then we're done. if (!HasSufficientAbundance()) { return(false); } //Can we prospect the location? switch (WBIPathfinderScenario.Instance.GetProspectSituation(planetID, biomeName, longitude, latitude, altitude, out lode)) { case ProspectSituations.LodeAlreadyExists: if (lode != null) { debugLog("Situation not valid, existing lode found: " + lode.ToString()); string message = string.Format("You already found a vein of {0:s} at this location. It has {1:f2} units remaining.", lode.resourceName, lode.amountRemaining); ScreenMessages.PostScreenMessage(message, kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER); } return(false); case ProspectSituations.NotEnoughDistance: debugLog("Vessel has not traveled enough distance between prospects"); ScreenMessages.PostScreenMessage("Vessel must travel further before prospecting again.", kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER); return(false); case ProspectSituations.OutOfChances: debugLog("Out of prospecting chances for this area or asteroid"); ScreenMessages.PostScreenMessage("Out of prospecting chances in this area.", kMessageDisplayTime, ScreenMessageStyle.UPPER_CENTER); //Enable option to reset chances. Events["ResetProspects"].guiActive = true; Events["ResetProspects"].guiActiveUnfocused = true; return(false); //A-OK default: return(true); } }