protected float Sample(ProfileableResource resource, Vector3 worldPos, float noiseScalar) { float abundance = 0f; AbundanceRequest req = new AbundanceRequest(); double alt; double lat; double lon; part.vessel.mainBody.GetLatLonAlt(new Vector3d(worldPos.x, worldPos.y, worldPos.z), out lat, out lon, out alt); req.BodyId = FlightGlobals.GetBodyIndex(part.vessel.mainBody); req.ResourceName = resource.resourceName; req.Latitude = lat; req.Altitude = alt; req.Longitude = lon; // Sample atmo req.ResourceType = HarvestTypes.Atmospheric; abundance += ResourceMap.Instance.GetAbundance(req); if (resource.useAtmo) { abundance = abundance * (float)part.vessel.mainBody.GetPressure(alt); } // Sample exo req.ResourceType = HarvestTypes.Exospheric; abundance = abundance + ResourceMap.Instance.GetAbundance(req); //Utils.Log(String.Format("[ModuleProfilingScanner]: Sampling position {0}, geocentric alt {1}, lat {2} lon {3}\n Noise: {4} Result: {5}", worldPos.ToString(), alt, lat, lon, noiseScalar, abundance)); abundance = abundance + noiseScalar * UnityEngine.Random.Range(-1.0f, 1.0f); return(Mathf.Clamp(abundance, 0f, 10000f)); }