public void registerSensor(Vessel v, SCANdata.SCANtype sensors, double fov, double min_alt, double max_alt, double best_alt) { registerSensor(v.id, sensors, fov, min_alt, max_alt, best_alt); knownVessels[v.id].vessel = v; knownVessels[v.id].latitude = fixLatitude(v.latitude); knownVessels[v.id].longitude = fixLongitude(v.longitude); }
protected override void OnLoad(ConfigNode node) { base.OnLoad(node); title = node.GetValue("title"); coverage = ConfigNodeUtil.ParseValue <double>(node, "coverage"); scanType = ConfigNodeUtil.ParseValue <SCANdata.SCANtype>(node, "scanType"); targetBody = ConfigNodeUtil.ParseValue <CelestialBody>(node, "targetBody"); }
public SCANsensor getSensorStatus(Vessel v, SCANdata.SCANtype sensor) { if (!knownVessels.ContainsKey(v.id)) { return(null); } if (!knownVessels[v.id].sensors.ContainsKey(sensor)) { return(null); } return(knownVessels[v.id].sensors[sensor]); }
public SCANdata.SCANtype activeSensorsOnVessel(Guid id) { if (!knownVessels.ContainsKey(id)) { return(SCANdata.SCANtype.Nothing); } SCANdata.SCANtype sensors = SCANdata.SCANtype.Nothing; foreach (SCANdata.SCANtype s in knownVessels[id].sensors.Keys) { sensors |= s; } return(sensors); }
public bool isVesselKnown(Guid id, SCANdata.SCANtype sensor) { if (!knownVessels.ContainsKey(id)) { return(false); } SCANdata.SCANtype all = SCANdata.SCANtype.Nothing; foreach (SCANdata.SCANtype s in knownVessels[id].sensors.Keys) { all |= s; } return((all & sensor) != SCANdata.SCANtype.Nothing); }
public void registerSensor(Guid id, SCANdata.SCANtype sensors, double fov, double min_alt, double max_alt, double best_alt) { if (!knownVessels.ContainsKey(id)) { knownVessels[id] = new SCANvessel(); } SCANvessel sv = knownVessels[id]; sv.id = id; foreach (SCANdata.SCANtype sensor in Enum.GetValues(typeof(SCANdata.SCANtype))) { if (countBits((int)sensor) != 1) { continue; } if ((sensor & sensors) == SCANdata.SCANtype.Nothing) { continue; } double this_fov = fov, this_min_alt = min_alt, this_max_alt = max_alt, this_best_alt = best_alt; if (this_max_alt <= 0) { this_min_alt = 5000; this_max_alt = 500000; this_best_alt = 200000; this_fov = 5; if ((sensor & SCANdata.SCANtype.AltimetryHiRes) != SCANdata.SCANtype.Nothing) { this_fov = 3; } if ((sensor & SCANdata.SCANtype.AnomalyDetail) != SCANdata.SCANtype.Nothing) { this_min_alt = 0; this_max_alt = 2000; this_best_alt = 0; this_fov = 1; } } if (!sv.sensors.ContainsKey(sensor)) { sv.sensors[sensor] = new SCANsensor(); } SCANsensor s = sv.sensors[sensor]; s.sensor = sensor; s.fov = this_fov; s.min_alt = this_min_alt; s.max_alt = this_max_alt; s.best_alt = this_best_alt; } }
//Update the Kethane database - used after background scanning private void updateKethaneData(SCANdata.SCANtype type) { print("[SCAN Kethane] Updating Kethane Database"); for (int ilat = 0; ilat < 180; ilat++) { for (int ilon = 0; ilon < 360; ilon++) { if (SCANUtil.isCovered(ilon, ilat, body, (int)type)) { cell = getKethaneCell(ilon - 180, ilat - 90); if (!KethaneData.Current[resource.name][body].IsCellScanned(cell)) { KethaneData.Current[resource.name][body].ScanCell(cell); } } } } }
public SCANsatCoverage(double coverage, SCANdata.SCANtype scanType, CelestialBody targetBody, string title) : base() { this.title = title; if (title == null) { // Re-label a couple of scan names to make them nicer nameRemap["AltimetryLoRes"] = "Low resolution altimetry"; nameRemap["AltimetryHiRes"] = "High resolution altimetry"; string scanTypeName = nameRemap.ContainsKey(scanType.ToString()) ? nameRemap[scanType.ToString()] : scanType.ToString(); this.title = scanTypeName + " scan: " + coverage.ToString("N0") + "% coverage of " + targetBody.PrintName(); } this.coverage = coverage; this.scanType = scanType; this.targetBody = targetBody; }
//Reset the resource value array - quicker than rebuildKethaneData (), called on map resets private void rebuildResourceValue(SCANdata.SCANtype type) { if (!rebuildingValue) { print("[SCAN Kethane] Rebuilding Value Array"); rebuildingValue = true; } SCANdata data = SCANUtil.getData(body); for (int ilat = 4 * rebuildValueStep; ilat < 4 * (rebuildValueStep + 1); ilat++) { for (int ilon = 0; ilon < 360; ilon++) { if (SCANUtil.isCovered(ilon, ilat, body, (int)type)) { if (data.kethaneValueMap[ilon, ilat] == 0) //Only check unassigned values { cell = getKethaneCell(ilon - 180, ilat - 90); double?depositValue = KethaneData.Current[resource.name][body].Resources.GetQuantity(cell); if (depositValue != null) { updateResourceValue(ilon, ilat, depositValue, data); } else { updateResourceValue(ilon, ilat, -1d, data); //Give empty cells -1 resources, account for this later on } } } } } rebuildValueStep++; if (rebuildValueStep >= 45) { print("[SCAN Kethane] Value Array Rebuilt"); rebuildingValue = false; } }
public void unregisterSensor(Vessel v, SCANdata.SCANtype sensors) { if (!knownVessels.ContainsKey(v.id)) { return; } SCANvessel sv = knownVessels[v.id]; sv.id = v.id; sv.vessel = v; foreach (SCANdata.SCANtype sensor in Enum.GetValues(typeof(SCANdata.SCANtype))) { if ((sensors & sensor) == SCANdata.SCANtype.Nothing) { continue; } if (!sv.sensors.ContainsKey(sensor)) { continue; } sv.sensors.Remove(sensor); } }
private void updateResourceArray(int lon, int lat, SCANdata.SCANtype type, SCANdata data) { data.coverage[lon, lat] |= (Int32)type; }
public void registerPass(CelestialBody body, float lon, float lat, SCANdata.SCANtype type) { getData(body).registerPass(lon, lat, type); }
public ScienceData getAvailableScience(Vessel v, SCANdata.SCANtype sensor, bool notZero) { SCANdata data = getData(v.mainBody); ScienceData sd = null; ScienceExperiment se = null; ScienceSubject su = null; bool found = false; string id = null; double coverage = 0f; if (v.mainBody.pqsController != null) { if (!found && (sensor & SCANdata.SCANtype.AltimetryLoRes) != SCANdata.SCANtype.Nothing) { found = true; id = "SCANsatAltimetryLoRes"; coverage = data.getCoveragePercentage(SCANdata.SCANtype.AltimetryLoRes); } if (!found && (sensor & SCANdata.SCANtype.AltimetryHiRes) != SCANdata.SCANtype.Nothing) { found = true; id = "SCANsatAltimetryHiRes"; coverage = data.getCoveragePercentage(SCANdata.SCANtype.AltimetryHiRes); } } if (v.mainBody.BiomeMap != null) { if (!found && (sensor & SCANdata.SCANtype.Biome) != SCANdata.SCANtype.Nothing) { found = true; id = "SCANsatBiomeAnomaly"; coverage = data.getCoveragePercentage(SCANdata.SCANtype.Biome | SCANdata.SCANtype.Anomaly); } } if (!found) { return(null); } se = ResearchAndDevelopment.GetExperiment(id); if (se == null) { return(null); } su = ResearchAndDevelopment.GetExperimentSubject(se, ExperimentSituations.InSpaceHigh, v.mainBody, "surface"); if (su == null) { return(null); } print("[SCANsat] coverage " + coverage.ToString("F1") + ", science cap " + su.scienceCap.ToString("F1") + ", subject value " + su.subjectValue.ToString("F2") + ", science value " + su.scientificValue.ToString("F2") + ", science " + su.science.ToString("F2")); su.scientificValue = 1; float science = (float)coverage; if (science > 95) { science = 100; } if (science < 30) { science = 0; } science = science / 100f; science = Mathf.Max(0, (science * su.scienceCap) - su.science); print("[SCANsat] remaining science: " + science.ToString("F1") + ", base = " + (se.baseValue).ToString("F1")); science /= Mathf.Max(0.1f, su.scientificValue); science /= su.subjectValue; print("[SCANsat] result = " + science.ToString("F2")); if (notZero && science <= 0) { science = 0.00001f; } sd = new ScienceData(science, 1f, 0f, id, se.experimentTitle + " of " + v.mainBody.theName); sd.subjectID = su.id; return(sd); }