Beispiel #1
0
		protected override void DrawWindowPre(int id)
		{
			v = FlightGlobals.ActiveVessel;

			vlat = SCANUtil.fixLatShift(v.latitude);
			vlon = SCANUtil.fixLonShift(v.longitude);

			//Grab the active scanners on this vessel
			sensors = SCANcontroller.controller.activeSensorsOnVessel(v.id);

			//if (maptraq_frame >= Time.frameCount - 5) //Still not sure what this actually does
			if (true)
			{
				//Check if region below the vessel is scanned
				if (SCANUtil.isCovered(vlon, vlat, data, SCANtype.AltimetryLoRes))
				{
					sensors |= SCANtype.Altimetry;
				}
				else if (SCANUtil.isCovered(vlon, vlat, data, SCANtype.AltimetryHiRes))
				{
					sensors |= SCANtype.Altimetry;
				}
				if (SCANUtil.isCovered(vlon, vlat, data, SCANtype.Biome))
				{
					sensors |= SCANtype.Biome;
				}
			}
		}
Beispiel #2
0
        public int getCoverage(SCANtype type)
        {
            int uncov = 0;

            if ((type & SCANtype.AltimetryLoRes) != SCANtype.Nothing)
            {
                uncov += coverage_count[0];
            }
            if ((type & SCANtype.AltimetryHiRes) != SCANtype.Nothing)
            {
                uncov += coverage_count[1];
            }
            if ((type & SCANtype.Biome) != SCANtype.Nothing)
            {
                uncov += coverage_count[3];
            }
            if ((type & SCANtype.Anomaly) != SCANtype.Nothing)
            {
                uncov += coverage_count[4];
            }
            if ((type & SCANtype.AnomalyDetail) != SCANtype.Nothing)
            {
                uncov += coverage_count[5];
            }
            return(uncov);
        }
        protected override void DrawWindowPre(int id)
        {
            v = FlightGlobals.ActiveVessel;

            vlat = SCANUtil.fixLatShift(v.latitude);
            vlon = SCANUtil.fixLonShift(v.longitude);

            //Grab the active scanners on this vessel
            sensors = SCANcontroller.controller.activeSensorsOnVessel(v.id);

            //if (maptraq_frame >= Time.frameCount - 5) //Still not sure what this actually does
            if (true)
            {
                //Check if region below the vessel is scanned
                if (SCANUtil.isCovered(vlon, vlat, data, SCANtype.AltimetryLoRes))
                {
                    sensors |= SCANtype.Altimetry;
                }
                else if (SCANUtil.isCovered(vlon, vlat, data, SCANtype.AltimetryHiRes))
                {
                    sensors |= SCANtype.Altimetry;
                }
                if (SCANUtil.isCovered(vlon, vlat, data, SCANtype.Biome))
                {
                    sensors |= SCANtype.Biome;
                }
            }
        }
Beispiel #4
0
 internal static bool isCoveredByAll(int lon, int lat, SCANdata data, SCANtype type)
 {
     if (badLonLat(lon, lat))
     {
         return(false);
     }
     return((data.Coverage[lon, lat] & (Int32)type) == (Int32)type);
 }
Beispiel #5
0
 internal SCANresourceType(string s, int i)
 {
     name = s;
     type = (SCANtype)i;
     if ((type & SCANtype.Everything_SCAN) != SCANtype.Nothing)
     {
         Debug.LogWarning("[SCANsat] Attempt To Override Default SCANsat Sensors; Resetting Resource Scanner Type To 0");
         type = SCANtype.Nothing;
     }
 }
Beispiel #6
0
		internal SCANresourceType(string s, int i)
		{
			name = s;
			type = (SCANtype)i;
			if ((type & SCANtype.Everything_SCAN) != SCANtype.Nothing)
			{
				Debug.LogWarning("[SCANsat] Attempt To Override Default SCANsat Sensors; Resetting Resource Scanner Type To 0");
				type = SCANtype.Nothing;
			}
		}
Beispiel #7
0
        public bool isCoveredByAll(double lon, double lat, SCANtype type)
        {
            int ilon = ((int)(lon + 360 + 180)) % 360;
            int ilat = ((int)(lat + 180 + 90)) % 180;

            if (ilon < 0 || ilat < 0 || ilon >= 360 || ilat >= 180)
            {
                return(false);
            }
            return((coverage[ilon, ilat] & (byte)type) == (byte)type);
        }
Beispiel #8
0
        public bool isCoveredByAll(double lon, double lat, SCANtype type)
        {
            int ilon = icLON(lon);
            int ilat = icLAT(lat);

            if (badLonLat(ilon, ilat))
            {
                return(false);
            }
            return((coverage [ilon, ilat] & (byte)type) == (byte)type);
        }
Beispiel #9
0
        internal static bool isCovered(double lon, double lat, SCANdata data, SCANtype type)
        {
            int ilon = icLON(lon);
            int ilat = icLAT(lat);

            if (badLonLat(ilon, ilat))
            {
                return(false);
            }
            return((data.Coverage[ilon, ilat] & (Int32)type) != 0);
        }
Beispiel #10
0
        /* DATA: map passes and coverage (passes >= 1)*/
        public void registerPass(double lon, double lat, SCANtype type)
        {
            int ilon = icLON(lon);
            int ilat = icLAT(lat);

            if (badLonLat(ilon, ilat))
            {
                return;
            }
            coverage [ilon, ilat] |= (byte)type;
        }
Beispiel #11
0
        internal static void registerPass(double lon, double lat, SCANdata data, SCANtype type)
        {
            int ilon = SCANUtil.icLON(lon);
            int ilat = SCANUtil.icLAT(lat);

            if (SCANUtil.badLonLat(ilon, ilat))
            {
                return;
            }
            data.Coverage[ilon, ilat] |= (Int32)type;
        }
Beispiel #12
0
        public void registerPass(double lon, double lat, SCANtype type)
        {
            // fudging coordinates a bit because KSP may return them unclipped
            int ilon = ((int)(lon + 360 + 180)) % 360;
            int ilat = ((int)(lat + 180 + 90)) % 180;

            if (ilon < 0 || ilat < 0 || ilon >= 360 || ilat >= 180)
            {
                return;
            }
            coverage[ilon, ilat] |= (byte)type;
        }
Beispiel #13
0
		protected override void DrawWindowPre(int id)
		{
			//Keep the map updated with the current vessel location and status
			v = FlightGlobals.ActiveVessel;
			data = SCANUtil.getData(v.mainBody);
			if (data == null)
			{
				data = new SCANdata(v.mainBody);
				SCANcontroller.controller.addToBodyData(v.mainBody, data);
			}
			sensors = SCANcontroller.controller.activeSensorsOnVessel(v.id);
			data.updateImages(sensors);
		}
Beispiel #14
0
        internal SCANresourceGlobal(string resource, float trans, float defMin, float defMax, Color minC, Color maxC, SCANresourceType t)
        {
            name = resource;
            resourceTransparency = trans;
            lowResourceColor     = minC;
            highResourceColor    = maxC;
            defaultMinValue      = defMin;
            defaultMaxValue      = defMax;
            resourceType         = t;
            sType = resourceType.Type;

            setDefaultValues();
        }
Beispiel #15
0
 protected override void DrawWindowPre(int id)
 {
     //Keep the map updated with the current vessel location and status
     v    = FlightGlobals.ActiveVessel;
     data = SCANUtil.getData(v.mainBody);
     if (data == null)
     {
         data = new SCANdata(v.mainBody);
         SCANcontroller.controller.addToBodyData(v.mainBody, data);
     }
     sensors = SCANcontroller.controller.activeSensorsOnVessel(v.id);
     data.updateImages(sensors);
 }
Beispiel #16
0
		internal SCANresourceGlobal(string resource, float trans, float defMin, float defMax, Color minC, Color maxC, SCANresourceType t)
		{
			name = resource;
			resourceTransparency = trans;
			lowResourceColor = minC;
			highResourceColor = maxC;
			defaultMinValue = defMin;
			defaultMaxValue = defMax;
			resourceType = t;
			sType = resourceType.Type;

			setDefaultValues();
		}
Beispiel #17
0
 internal SCANresourceGlobal(SCANresourceGlobal copy)
 {
     name = copy.name;
     resourceTransparency = copy.resourceTransparency;
     lowResourceColor     = copy.lowResourceColor;
     highResourceColor    = copy.highResourceColor;
     sType             = copy.sType;
     resourceType      = copy.resourceType;
     masterBodyConfigs = copyBodyConfigs(copy);
     defaultLowColor   = copy.defaultLowColor;
     defaultHighColor  = copy.defaultHighColor;
     defaultTrans      = copy.defaultTrans;
     defaultMinValue   = copy.defaultMinValue;
     defaultMaxValue   = copy.defaultMaxValue;
 }
Beispiel #18
0
        public override void OnDecodeFromConfigNode()
        {
            resourceType = SCANcontroller.getResourceType(name);
            sType        = resourceType.Type;

            setDefaultValues();
            try
            {
                masterBodyConfigs = Resource_Planetary_Config.ToDictionary(a => a.BodyName, a => a);
            }
            catch (Exception e)
            {
                SCANUtil.SCANlog("Error while loading SCANsat body resource config settings: {0}", e);
            }
        }
Beispiel #19
0
		internal SCANresourceGlobal(SCANresourceGlobal copy)
		{
			name = copy.name;
			resourceTransparency = copy.resourceTransparency;
			lowResourceColor = copy.lowResourceColor;
			highResourceColor = copy.highResourceColor;
			sType = copy.sType;
			resourceType = copy.resourceType;
			masterBodyConfigs = copyBodyConfigs(copy);
			defaultLowColor = copy.defaultLowColor;
			defaultHighColor = copy.defaultHighColor;
			defaultTrans = copy.defaultTrans;
			defaultMinValue = copy.defaultMinValue;
			defaultMaxValue = copy.defaultMaxValue;
		}
Beispiel #20
0
 public void drawHeightScanline(SCANtype type)
 {
     Color[] cols_height_map_small = map_small.GetPixels(0, scanline, 360, 1);
     for(int ilon=0; ilon<360; ilon+=1) {
         int scheme = 0;
         float val = heightmap[ilon, scanline];
         if(val == 0 && isCovered(ilon - 180, scanline - 90, SCANtype.Altimetry)) {
             if(body.pqsController == null) {
                 heightmap[ilon, scanline] = 0;
                 cols_height_map_small[ilon] = Color.Lerp(Color.black, Color.white, UnityEngine.Random.value);
                 continue;
             } else {
                 // convert to radial vector
                 double rlon = Mathf.Deg2Rad * (ilon - 180);
                 double rlat = Mathf.Deg2Rad * (scanline - 90);
                 Vector3d rad = new Vector3d(Math.Cos(rlat) * Math.Cos(rlon), Math.Sin(rlat), Math.Cos(rlat) * Math.Sin(rlon));
                 // query terrain controller for elevation at this point
                 val = (float)Math.Round(body.pqsController.GetSurfaceHeight(rad) - body.pqsController.radius, 1);
                 if(val == 0) val = -0.001f; // this is terrible
                 heightmap[ilon, scanline] = val;
             }
         }
         Color c = Color.black;
         if(val != 0) {
             if(isCovered(ilon - 180, scanline - 90, SCANtype.AltimetryHiRes)) c = SCANmap.heightToColor(val, scheme);
             else c = SCANmap.heightToColor(val, 1);
         } else {
             c = Color.grey;
             if(scanline % 30 == 0 && ilon % 3 == 0) {
                 c = Color.white;
             } else if(ilon % 30 == 0 && scanline % 3 == 0) {
                 c = Color.white;
             }
         }
         if(type != SCANtype.Nothing) {
             if(!isCoveredByAll(ilon - 180, scanline - 90, type)) {
                 c = Color.Lerp(c, Color.black, 0.5f);
             }
         }
         cols_height_map_small[ilon] = c;
     }
     map_small.SetPixels(0, scanline, 360, 1, cols_height_map_small);
     scanline = scanline + 1;
     if(scanline >= 180) {
         scanstep += 1;
         scanline = 0;
     }
 }
Beispiel #21
0
 //Updates the red scanning line
 internal void updateImages(SCANtype type)
 {
     if (palette.small_redline == null)
     {
         palette.small_redline = new Color[360];
         for (int i = 0; i < 360; i++)
         {
             palette.small_redline[i] = palette.red;
         }
     }
     drawHeightScanline(type);
     if (scanline < 179)
     {
         map_small.SetPixels(0, scanline + 1, 360, 1, palette.small_redline);
     }
     map_small.Apply();
 }
Beispiel #22
0
 public void updateImages(SCANtype type)
 {
     if (redline == null)
     {
         redline = new Color[360];
         for (int i = 0; i < 360; i++)
         {
             redline[i] = Color.red;
         }
     }
     drawHeightScanline(type);
     if (scanline < 179)
     {
         map_small.SetPixels(0, scanline + 1, 360, 1, redline);
     }
     map_small.Apply();
 }
Beispiel #23
0
        public double getCoveragePercentage(SCANtype type)
        {
            if (type == SCANtype.Nothing)
            {
                type = SCANtype.AltimetryLoRes | SCANtype.AltimetryHiRes | SCANtype.Biome | SCANtype.Anomaly;
            }
            double cov = getCoverage(type);

            if (cov <= 0)
            {
                cov = 100;
            }
            else
            {
                cov = Math.Min(99.9d, 100 - cov * 100d / (360d * 180d * SCANcontroller.countBits((int)type)));
            }
            return(cov);
        }
Beispiel #24
0
 public void updateCoverage()
 {
     for (int i = 0; i < 6; ++i)
     {
         SCANtype t  = (SCANtype)(1 << i);
         int      cc = 0;
         for (int x = 0; x < 360; ++x)
         {
             for (int y = 0; y < 180; ++y)
             {
                 if ((coverage[x, y] & (byte)t) == 0)
                 {
                     ++cc;
                 }
             }
         }
         coverage_count[i] = cc;
     }
 }
Beispiel #25
0
        internal static double getCoveragePercentage(SCANdata data, SCANtype type)
        {
            if (data == null)
            {
                return(0);
            }
            double cov = 0d;

            if (type == SCANtype.Nothing)
            {
                type = SCANtype.AltimetryLoRes | SCANtype.AltimetryHiRes | SCANtype.Biome | SCANtype.Anomaly;
            }
            cov = data.getCoverage(type);
            if (cov <= 0)
            {
                cov = 100;
            }
            else
            {
                cov = Math.Min(99.9d, 100 - cov * 100d / (360d * 180d * countBits((int)type)));
            }
            return(cov);
        }
Beispiel #26
0
		public override void OnDecodeFromConfigNode()
		{
			resourceType = SCANcontroller.getResourceType(name);
			sType = resourceType.Type;

			setDefaultValues();
			try
			{
				masterBodyConfigs = Resource_Planetary_Config.ToDictionary(a => a.BodyName, a => a);
			}
			catch (Exception e)
			{
				SCANUtil.SCANlog("Error while loading SCANsat body resource config settings: {0}", e);
			}
		}
Beispiel #27
0
		internal static void registerPass ( double lon, double lat, SCANdata data, SCANtype type ) {
			int ilon = SCANUtil.icLON(lon);
			int ilat = SCANUtil.icLAT(lat);
			if (SCANUtil.badLonLat(ilon, ilat)) return;
			data.Coverage[ilon, ilat] |= (Int32)type;
		}
Beispiel #28
0
		private void registerSensor(Guid id, SCANtype sensors, double fov, double min_alt, double max_alt, double best_alt)
		{
			if (id == null)
				return;
			if (!knownVessels.ContainsKey(id))
				knownVessels[id] = new SCANvessel();
			SCANvessel sv = knownVessels[id];
			sv.id = id;
			sv.vessel = FlightGlobals.Vessels.FirstOrDefault(a => a.id == id);
			if (sv.vessel == null)
			{
				knownVessels.Remove(id);
				return;
			}
			foreach (SCANtype sensor in Enum.GetValues(typeof(SCANtype)))
			{
				if (SCANUtil.countBits((int)sensor) != 1)
					continue;
				if ((sensor & sensors) == SCANtype.Nothing)
					continue;
				double this_fov = fov;
				double this_min_alt = min_alt;
				double this_max_alt = max_alt;
				double 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 & SCANtype.AltimetryHiRes) != SCANtype.Nothing) this_fov = 3;
					if ((sensor & SCANtype.AnomalyDetail) != 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;
			}
		}
Beispiel #29
0
		internal void unregisterSensor(Vessel v, SCANtype sensors)
		{
			if (!knownVessels.ContainsKey(v.id))
				return;

			SCANvessel sv = knownVessels[v.id];
			sv.id = v.id;
			sv.vessel = v;
			foreach (SCANtype sensor in Enum.GetValues(typeof(SCANtype)))
			{
				if ((sensors & sensor) == SCANtype.Nothing)
					continue;
				if (!sv.sensors.ContainsKey(sensor))
					continue;

				sv.sensors.Remove(sensor);
			}
			if (sv.sensors.Count == 0)
			{
				knownVessels.Remove(v.id);
				SCANUtil.SCANdebugLog("Unregister Vessel");
			}
		}
Beispiel #30
0
 public void drawHeightScanline(SCANtype type)
 {
     Color[] cols_height_map_small = map_small.GetPixels(0, scanline, 360, 1);
     for (int ilon = 0; ilon < 360; ilon += 1)
     {
         int   scheme = 0;
         float val    = heightmap[ilon, scanline];
         if (val == 0 && isCovered(ilon - 180, scanline - 90, SCANtype.Altimetry))
         {
             if (body.pqsController == null)
             {
                 heightmap[ilon, scanline]   = 0;
                 cols_height_map_small[ilon] = Color.Lerp(Color.black, Color.white, UnityEngine.Random.value);
                 continue;
             }
             else
             {
                 // convert to radial vector
                 double   rlon = Mathf.Deg2Rad * (ilon - 180);
                 double   rlat = Mathf.Deg2Rad * (scanline - 90);
                 Vector3d rad  = new Vector3d(Math.Cos(rlat) * Math.Cos(rlon), Math.Sin(rlat), Math.Cos(rlat) * Math.Sin(rlon));
                 // query terrain controller for elevation at this point
                 val = (float)Math.Round(body.pqsController.GetSurfaceHeight(rad) - body.pqsController.radius, 1);
                 if (val == 0)
                 {
                     val = -0.001f;                                  // this is terrible
                 }
                 heightmap[ilon, scanline] = val;
             }
         }
         Color c = Color.black;
         if (val != 0)
         {
             if (isCovered(ilon - 180, scanline - 90, SCANtype.AltimetryHiRes))
             {
                 c = SCANmap.heightToColor(val, scheme);
             }
             else
             {
                 c = SCANmap.heightToColor(val, 1);
             }
         }
         else
         {
             c = Color.grey;
             if (scanline % 30 == 0 && ilon % 3 == 0)
             {
                 c = Color.white;
             }
             else if (ilon % 30 == 0 && scanline % 3 == 0)
             {
                 c = Color.white;
             }
         }
         if (type != SCANtype.Nothing)
         {
             if (!isCoveredByAll(ilon - 180, scanline - 90, type))
             {
                 c = Color.Lerp(c, Color.black, 0.5f);
             }
         }
         cols_height_map_small[ilon] = c;
     }
     map_small.SetPixels(0, scanline, 360, 1, cols_height_map_small);
     scanline = scanline + 1;
     if (scanline >= 180)
     {
         scanstep += 1;
         scanline  = 0;
     }
 }
Beispiel #31
0
		internal static bool isCovered(double lon, double lat, SCANdata data, SCANtype type)
		{
			int ilon = icLON(lon);
			int ilat = icLAT(lat);
			if (badLonLat(ilon, ilat)) return false;
			return (data.Coverage[ilon, ilat] & (Int32)type) != 0;
		}
Beispiel #32
0
		//Updates the red scanning line
		internal void updateImages(SCANtype type)
		{
			if (palette.small_redline == null)
			{
				palette.small_redline = new Color[360];
				for (int i = 0; i < 360; i++)
					palette.small_redline[i] = palette.red;
			}
			drawHeightScanline(type);
			if (scanline < 179)
			{
				map_small.SetPixels(0, scanline + 1, 360, 1, palette.small_redline);
			}
			map_small.Apply();
		}
Beispiel #33
0
 public int getCoverage( SCANtype type )
 {
     int uncov = 0;
     if ((type & SCANtype.AltimetryLoRes) != SCANtype.Nothing)
         uncov += coverage_count [0];
     if ((type & SCANtype.AltimetryHiRes) != SCANtype.Nothing)
         uncov += coverage_count [1];
     if ((type & SCANtype.Biome) != SCANtype.Nothing)
         uncov += coverage_count [3];
     if ((type & SCANtype.Anomaly) != SCANtype.Nothing)
         uncov += coverage_count [4];
     if ((type & SCANtype.AnomalyDetail) != SCANtype.Nothing)
         uncov += coverage_count [5];
     return uncov;
 }
Beispiel #34
0
 //Draws the actual map texture
 internal void drawHeightScanline(SCANtype type)
 {
     Color[] cols_height_map_small = map_small.GetPixels(0, scanline, 360, 1);
     for (int ilon = 0; ilon < 360; ilon += 1)
     {
         int   scheme = SCANcontroller.controller.colours;
         float val    = heightmap[ilon, scanline];
         if (val == 0)
         {                 //Some preparation for bigger changes in map caching, automatically calculate elevation for every point on the small map, only display scanned areas
             if (body.pqsController == null)
             {
                 heightmap[ilon, scanline]   = 0;
                 cols_height_map_small[ilon] = palette.lerp(palette.black, palette.white, UnityEngine.Random.value);
                 continue;
             }
             else
             {
                 // convert to radial vector
                 val = (float)SCANUtil.getElevation(body, ilon - 180, scanline - 90);
                 if (val == 0)
                 {
                     val = -0.001f;                             // this is terrible
                 }
                 heightmap[ilon, scanline] = val;
             }
         }
         Color c = palette.black;
         if (SCANUtil.isCovered(ilon, scanline, this, SCANtype.Altimetry))
         {                 //We check for coverage down here now, after elevation data is collected
             if (SCANUtil.isCovered(ilon, scanline, this, SCANtype.AltimetryHiRes))
             {
                 c = palette.heightToColor(val, scheme, this);
             }
             else
             {
                 c = palette.heightToColor(val, 1, this);
             }
         }
         else
         {
             c = palette.grey;
             if (scanline % 30 == 0 && ilon % 3 == 0)
             {
                 c = palette.white;
             }
             else if (ilon % 30 == 0 && scanline % 3 == 0)
             {
                 c = palette.white;
             }
         }
         if (type != SCANtype.Nothing)
         {
             if (!SCANUtil.isCoveredByAll(ilon, scanline, this, type))
             {
                 c = palette.lerp(c, palette.black, 0.5f);
             }
         }
         cols_height_map_small[ilon] = c;
     }
     map_small.SetPixels(0, scanline, 360, 1, cols_height_map_small);
     scanline = scanline + 1;
     if (scanline >= 180)
     {
         scanstep += 1;
         scanline  = 0;
     }
 }
Beispiel #35
0
        internal int getCoverage(SCANtype type)
        {
            int uncov = 0;

            if ((type & SCANtype.AltimetryLoRes) != SCANtype.Nothing)
            {
                uncov += coverage_count[0];
            }
            if ((type & SCANtype.AltimetryHiRes) != SCANtype.Nothing)
            {
                uncov += coverage_count[1];
            }
            if ((type & SCANtype.Biome) != SCANtype.Nothing)
            {
                uncov += coverage_count[3];
            }
            if ((type & SCANtype.Anomaly) != SCANtype.Nothing)
            {
                uncov += coverage_count[4];
            }
            if ((type & SCANtype.AnomalyDetail) != SCANtype.Nothing)
            {
                uncov += coverage_count[5];
            }
            if ((type & SCANtype.Kethane) != SCANtype.Nothing)
            {
                uncov += coverage_count[6];
            }
            if ((type & SCANtype.MetallicOre) != SCANtype.Nothing)
            {
                uncov += coverage_count[7];
            }
            if ((type & SCANtype.Ore) != SCANtype.Nothing)
            {
                uncov += coverage_count[8];
            }
            if ((type & SCANtype.Kethane_4) != SCANtype.Nothing)
            {
                uncov += coverage_count[9];
            }
            if ((type & SCANtype.Uraninite) != SCANtype.Nothing)
            {
                uncov += coverage_count[10];
            }
            if ((type & SCANtype.Thorium) != SCANtype.Nothing)
            {
                uncov += coverage_count[11];
            }
            if ((type & SCANtype.Alumina) != SCANtype.Nothing)
            {
                uncov += coverage_count[12];
            }
            if ((type & SCANtype.Water) != SCANtype.Nothing)
            {
                uncov += coverage_count[13];
            }
            if ((type & SCANtype.Aquifer) != SCANtype.Nothing)
            {
                uncov += coverage_count[14];
            }
            if ((type & SCANtype.Minerals) != SCANtype.Nothing)
            {
                uncov += coverage_count[15];
            }
            if ((type & SCANtype.Substrate) != SCANtype.Nothing)
            {
                uncov += coverage_count[16];
            }
            if ((type & SCANtype.KEEZO) != SCANtype.Nothing)
            {
                uncov += coverage_count[17];
            }
            if ((type & SCANtype.Karbonite) != SCANtype.Nothing)
            {
                uncov += coverage_count[18];
            }
            if ((type & SCANtype.Regolith_10) != SCANtype.Nothing)
            {
                uncov += coverage_count[19];
            }
            if ((type & SCANtype.Regolith_11) != SCANtype.Nothing)
            {
                uncov += coverage_count[20];
            }
            return(uncov);
        }
Beispiel #36
0
        private ScienceData getAvailableScience(SCANtype sensor, bool notZero)
        {
            SCANdata data = SCANUtil.getData(vessel.mainBody);

            if (data == null)
            {
                return(null);
            }
            ScienceData       sd = null;
            ScienceExperiment se = null;
            ScienceSubject    su = null;
            bool   found         = false;
            string id            = null;
            double coverage      = 0f;
            float  multiplier    = 1f;

            if (!found && (sensor & SCANtype.AltimetryLoRes) != SCANtype.Nothing)
            {
                found = true;
                if (vessel.mainBody.pqsController == null)
                {
                    multiplier = 0.5f;
                }
                id       = "SCANsatAltimetryLoRes";
                coverage = SCANUtil.getCoveragePercentage(data, SCANtype.AltimetryLoRes);
            }
            else if (!found && (sensor & SCANtype.AltimetryHiRes) != SCANtype.Nothing)
            {
                found = true;
                if (vessel.mainBody.pqsController == null)
                {
                    multiplier = 0.5f;
                }
                id       = "SCANsatAltimetryHiRes";
                coverage = SCANUtil.getCoveragePercentage(data, SCANtype.AltimetryHiRes);
            }
            else if (!found && (sensor & SCANtype.Biome) != SCANtype.Nothing)
            {
                found = true;
                if (vessel.mainBody.BiomeMap == null)
                {
                    multiplier = 0.5f;
                }
                id       = "SCANsatBiomeAnomaly";
                coverage = SCANUtil.getCoveragePercentage(data, SCANtype.Biome);
            }
            if (!found)
            {
                return(null);
            }
            se = ResearchAndDevelopment.GetExperiment(id);
            if (se == null)
            {
                return(null);
            }

            su = ResearchAndDevelopment.GetExperimentSubject(se, ExperimentSituations.InSpaceHigh, vessel.mainBody, "surface");
            if (su == null)
            {
                return(null);
            }

            su.scienceCap *= multiplier;

            SCANUtil.SCANlog("Coverage: {0}, Science cap: {1}, Subject value: {2}, Scientific value: {3}, Science: {4}", new object[5] {
                coverage.ToString("F1"), su.scienceCap.ToString("F1"), su.subjectValue.ToString("F2"), su.scientificValue.ToString("F2"), 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);

            SCANUtil.SCANlog("Remaining science: {0}, Base value: {1}", new object[2] {
                science.ToString("F1"), se.baseValue.ToString("F1")
            });

            science /= Mathf.Max(0.1f, su.scientificValue);             //look 10 lines up; this is always 1...
            science /= su.subjectValue;

            SCANUtil.SCANlog("Resulting science value: {0}", new object[1] {
                science.ToString("F2")
            });

            if (notZero && science <= 0)
            {
                science = 0.00001f;
            }

            sd       = new ScienceData(science * su.dataScale, 1f, 0f, su.id, se.experimentTitle + " of " + vessel.mainBody.theName);
            su.title = sd.title;
            return(sd);
        }
Beispiel #37
0
		private ScienceData getAvailableScience(SCANtype sensor, bool notZero)
		{
			SCANdata data = SCANUtil.getData(vessel.mainBody);
			if (data == null)
				return null;
			ScienceData sd = null;
			ScienceExperiment se = null;
			ScienceSubject su = null;
			bool found = false;
			string id = null;
			double coverage = 0f;
			float multiplier = 1f;

			if (!found && (sensor & SCANtype.AltimetryLoRes) != SCANtype.Nothing)
			{
				found = true;
				if (vessel.mainBody.pqsController == null)
					multiplier = 0.5f;
				id = "SCANsatAltimetryLoRes";
				coverage = SCANUtil.getCoveragePercentage(data, SCANtype.AltimetryLoRes);
			}
			else if (!found && (sensor & SCANtype.AltimetryHiRes) != SCANtype.Nothing)
			{
				found = true;
				if (vessel.mainBody.pqsController == null)
					multiplier = 0.5f;
				id = "SCANsatAltimetryHiRes";
				coverage = SCANUtil.getCoveragePercentage(data, SCANtype.AltimetryHiRes);
			}
			else if (!found && (sensor & SCANtype.Biome) != SCANtype.Nothing)
			{
				found = true;
				if (vessel.mainBody.BiomeMap == null)
					multiplier = 0.5f;
				id = "SCANsatBiomeAnomaly";
				coverage = SCANUtil.getCoveragePercentage(data, SCANtype.Biome);
			}
			if (!found) return null;
			se = ResearchAndDevelopment.GetExperiment(id);
			if (se == null) return null;

			su = ResearchAndDevelopment.GetExperimentSubject(se, ExperimentSituations.InSpaceHigh, vessel.mainBody, "surface");
			if (su == null) return null;

			su.scienceCap *= multiplier;

			SCANUtil.SCANlog("Coverage: {0}, Science cap: {1}, Subject value: {2}, Scientific value: {3}, Science: {4}", new object[5] { coverage.ToString("F1"), su.scienceCap.ToString("F1"), su.subjectValue.ToString("F2"), su.scientificValue.ToString("F2"), 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);

			SCANUtil.SCANlog("Remaining science: {0}, Base value: {1}", new object[2] { science.ToString("F1"), se.baseValue.ToString("F1") });

			science /= Mathf.Max(0.1f, su.scientificValue); //look 10 lines up; this is always 1...
			science /= su.subjectValue;

			SCANUtil.SCANlog("Resulting science value: {0}", new object[1] { science.ToString("F2") });

			if (notZero && science <= 0) science = 0.00001f;

			sd = new ScienceData(science * su.dataScale, 1f, 0f, su.id, se.experimentTitle + " of " + vessel.mainBody.theName);
			su.title = sd.title;
			return sd;
		}
Beispiel #38
0
 public bool isCoveredByAll(double lon, double lat, SCANtype type)
 {
     int ilon = ((int)(lon + 360 + 180)) % 360;
     int ilat = ((int)(lat + 180 + 90)) % 180;
     if(ilon < 0 || ilat < 0 || ilon >= 360 || ilat >= 180) return false;
     return (coverage[ilon, ilat] & (byte)type) == (byte)type;
 }
Beispiel #39
0
		internal int getCoverage(SCANtype type)
		{
			int uncov = 0;
			if ((type & SCANtype.AltimetryLoRes) != SCANtype.Nothing)
				uncov += coverage_count[0];
			if ((type & SCANtype.AltimetryHiRes) != SCANtype.Nothing)
				uncov += coverage_count[1];
			if ((type & SCANtype.Biome) != SCANtype.Nothing)
				uncov += coverage_count[3];
			if ((type & SCANtype.Anomaly) != SCANtype.Nothing)
				uncov += coverage_count[4];
			if ((type & SCANtype.AnomalyDetail) != SCANtype.Nothing)
				uncov += coverage_count[5];
			if ((type & SCANtype.Kethane) != SCANtype.Nothing)
				uncov += coverage_count[6];
			if ((type & SCANtype.MetallicOre) != SCANtype.Nothing)
				uncov += coverage_count[7];
			if ((type & SCANtype.Ore) != SCANtype.Nothing)
				uncov += coverage_count[8];
			if ((type & SCANtype.Kethane_4) != SCANtype.Nothing)
				uncov += coverage_count[9];
			if ((type & SCANtype.Uraninite) != SCANtype.Nothing)
				uncov += coverage_count[10];
			if ((type & SCANtype.Thorium) != SCANtype.Nothing)
				uncov += coverage_count[11];
			if ((type & SCANtype.Alumina) != SCANtype.Nothing)
				uncov += coverage_count[12];
			if ((type & SCANtype.Water) != SCANtype.Nothing)
				uncov += coverage_count[13];
			if ((type & SCANtype.Aquifer) != SCANtype.Nothing)
				uncov += coverage_count[14];
			if ((type & SCANtype.Minerals) != SCANtype.Nothing)
				uncov += coverage_count[15];
			if ((type & SCANtype.Substrate) != SCANtype.Nothing)
				uncov += coverage_count[16];
			if ((type & SCANtype.KEEZO) != SCANtype.Nothing)
				uncov += coverage_count[17];
			if ((type & SCANtype.Karbonite) != SCANtype.Nothing)
				uncov += coverage_count[18];
			if ((type & SCANtype.Regolith_10) != SCANtype.Nothing)
				uncov += coverage_count[19];
			if ((type & SCANtype.Regolith_11) != SCANtype.Nothing)
				uncov += coverage_count[20];
			return uncov;
		}
Beispiel #40
0
 public double getCoveragePercentage( SCANtype type )
 {
     if (type == SCANtype.Nothing) {
         type = SCANtype.AltimetryLoRes | SCANtype.AltimetryHiRes | SCANtype.Biome | SCANtype.Anomaly;
     }
     double cov = getCoverage (type);
     if (cov <= 0) {
         cov = 100;
     } else {
         cov = Math.Min (99.9d , 100 - cov * 100d / (360d * 180d * SCANcontroller.countBits ((int)type)));
     }
     return cov;
 }
Beispiel #41
0
		//Draws the actual map texture
		internal void drawHeightScanline(SCANtype type)
		{
			Color[] cols_height_map_small = map_small.GetPixels(0, scanline, 360, 1);
			for (int ilon = 0; ilon < 360; ilon += 1)
			{
				int scheme = SCANcontroller.controller.colours;
				float val = heightmap[ilon, scanline];
				if (val == 0)
				{ //Some preparation for bigger changes in map caching, automatically calculate elevation for every point on the small map, only display scanned areas
					if (body.pqsController == null)
					{
						heightmap[ilon, scanline] = 0;
						cols_height_map_small[ilon] = palette.lerp(palette.black, palette.white, UnityEngine.Random.value);
						continue;
					}
					else
					{
						// convert to radial vector
						val = (float)SCANUtil.getElevation(body, ilon - 180, scanline - 90);
						if (val == 0)
							val = -0.001f; // this is terrible
						heightmap[ilon, scanline] = val;
					}
				}
				Color c = palette.black;
				if (SCANUtil.isCovered(ilon, scanline, this, SCANtype.Altimetry))
				{ //We check for coverage down here now, after elevation data is collected
					if (SCANUtil.isCovered(ilon, scanline, this, SCANtype.AltimetryHiRes))
						c = palette.heightToColor(val, scheme, this);
					else
						c = palette.heightToColor(val, 1, this);
				}
				else
				{
					c = palette.grey;
					if (scanline % 30 == 0 && ilon % 3 == 0)
					{
						c = palette.white;
					}
					else if (ilon % 30 == 0 && scanline % 3 == 0)
					{
						c = palette.white;
					}
				}
				if (type != SCANtype.Nothing)
				{
					if (!SCANUtil.isCoveredByAll(ilon, scanline, this, type))
					{
						c = palette.lerp(c, palette.black, 0.5f);
					}
				}
				cols_height_map_small[ilon] = c;
			}
			map_small.SetPixels(0, scanline, 360, 1, cols_height_map_small);
			scanline = scanline + 1;
			if (scanline >= 180)
			{
				scanstep += 1;
				scanline = 0;
			}
		}
Beispiel #42
0
 public bool isCoveredByAll( double lon , double lat , SCANtype type )
 {
     int ilon = icLON(lon);
     int ilat = icLAT(lat);
     if (badLonLat(ilon,ilat)) return false;
     return (coverage [ilon, ilat] & (byte)type) == (byte)type;
 }
Beispiel #43
0
		internal static bool isCoveredByAll (int lon, int lat, SCANdata data, SCANtype type)
		{
			if (badLonLat(lon,lat)) return false;
			return (data.Coverage[lon, lat] & (Int32)type) == (Int32)type;
		}
Beispiel #44
0
 /* DATA: map passes and coverage (passes >= 1)*/
 public void registerPass( double lon , double lat , SCANtype type )
 {
     int ilon = icLON(lon);
     int ilat = icLAT(lat);
     if (badLonLat(ilon,ilat)) return;
     coverage [ilon, ilat] |= (byte)type;
 }
Beispiel #45
0
		internal SCANsensor getSensorStatus(Vessel v, SCANtype sensor)
		{
			if (!knownVessels.ContainsKey(v.id))
				return null;
			if (!knownVessels[v.id].sensors.ContainsKey(sensor))
				return null;

			return knownVessels[v.id].sensors[sensor];
		}
Beispiel #46
0
 public void updateImages( SCANtype type )
 {
     if (redline == null) {
         redline = new Color[360];
         for (int i=0; i<360; i++)
             redline [i] = Color.red;
     }
     drawHeightScanline (type);
     if (scanline < 179) {
         map_small.SetPixels (0 , scanline + 1 , 360 , 1 , redline);
     }
     map_small.Apply ();
 }
Beispiel #47
0
		internal bool isVesselKnown(Guid id, SCANtype sensor)
		{
			if (!knownVessels.ContainsKey(id))
				return false;

			SCANtype all = SCANtype.Nothing;
			foreach (SCANtype s in knownVessels[id].sensors.Keys)
				all |= s;

			return (all & sensor) != SCANtype.Nothing;
		}
Beispiel #48
0
		internal static double getCoveragePercentage(SCANdata data, SCANtype type )
		{
			if (data == null)
				return 0;
			double cov = 0d;
			if (type == SCANtype.Nothing)
				type = SCANtype.AltimetryLoRes | SCANtype.AltimetryHiRes | SCANtype.Biome | SCANtype.Anomaly;          
			cov = data.getCoverage (type);
			if (cov <= 0)
				cov = 100;
			else
				cov = Math.Min (99.9d , 100 - cov * 100d / (360d * 180d * countBits((int)type)));
			return cov;
		}
Beispiel #49
0
		internal void registerSensor(Vessel v, 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 = SCANUtil.fixLatShift(v.latitude);
			knownVessels[v.id].longitude = SCANUtil.fixLonShift(v.longitude);
		}
Beispiel #50
0
 public void registerPass(double lon, double lat, SCANtype type)
 {
     // fudging coordinates a bit because KSP may return them unclipped
     int ilon = ((int)(lon + 360 + 180)) % 360;
     int ilat = ((int)(lat + 180 + 90)) % 180;
     if(ilon < 0 || ilat < 0 || ilon >= 360 || ilat >= 180) return;
     coverage[ilon, ilat] |= (byte)type;
 }