private IEnumerator fireCamera(bool saveToFile) { _lazerObj.enabled = true; yield return(new WaitForSeconds(0.75f)); _lazerObj.enabled = false; RaycastHit hit = new RaycastHit(); if (Physics.Raycast(_lazerObj.transform.position, _lookTransform.forward, out hit)) { if (hit.distance < 10f) { Utilities.Log_Debug("Hit Planet"); Transform t = hit.collider.transform; while (t != null) { if (PlanetNames.Contains(t.name)) { break; } t = t.parent; } if (t != null) { CelestialBody body = FlightGlobals.Bodies.Find(c => c.name == t.name); doScience(body); } else { ScreenMessages.PostScreenMessage("No Terrain in Range to analyse", 3f, ScreenMessageStyle.UPPER_CENTER); } } } if (saveToFile) { Utilities.Log_Debug("Saving to File"); int i = 0; while ((File.Exists <TSTChemCam>("ChemCam_" + DateTime.Now.ToString("d-m-y") + "_" + i + ".png")) || (File.Exists <TSTChemCam>("ChemCam_" + DateTime.Now.ToString("d-m-y") + "_" + i + "Large.png"))) { i++; } _camera.saveToFile("ChemCam_" + DateTime.Now.ToString("d-m-y") + "_" + i, "ChemCam"); ScreenMessages.PostScreenMessage("Picture saved", 3f, ScreenMessageStyle.UPPER_CENTER); } }
private IEnumerator fireCamera(bool saveToFile) { _lazerObj.enabled = true; yield return(new WaitForSeconds(0.75f)); _lazerObj.enabled = false; RaycastHit hit = new RaycastHit(); if (Physics.Raycast(_lazerObj.transform.position, _lookTransform.forward, out hit)) { if (hit.distance < 10f) { Utilities.Log_Debug("Hit Planet"); Transform t = hit.collider.transform; bool traversing = true; while (traversing) { for (int pnI = 0; pnI < PlanetNames.Count; pnI++) { if (t.name.Contains(PlanetNames[pnI])) { traversing = false; break; } } if (traversing) { //not found yet, go up to parent. if (t.parent == null) { traversing = false; //If parent is null we are done. } t = t.parent; // go to parent. } } if (t != null) //We found a match. { CelestialBody body = FlightGlobals.Bodies.Find(c => t.name.Contains(c.bodyName)); if (body != null) { doScience(body); } else { ScreenMessages.PostScreenMessage(cacheautoLOC_TST_0048, 3f, ScreenMessageStyle.UPPER_CENTER); } } else { ScreenMessages.PostScreenMessage(cacheautoLOC_TST_0048, 3f, ScreenMessageStyle.UPPER_CENTER); } } } if (saveToFile) { Utilities.Log_Debug("Saving to File"); int i = 0; while ((File.Exists <TSTChemCam>("ChemCam_" + DateTime.Now.ToString("d-m-y") + "_" + i + ".png")) || (File.Exists <TSTChemCam>("ChemCam_" + DateTime.Now.ToString("d-m-y") + "_" + i + "Large.png"))) { i++; } _camera.saveToFile("ChemCam_" + DateTime.Now.ToString("d-m-y") + "_" + i, "ChemCam"); ScreenMessages.PostScreenMessage(cacheautoLOC_TST_0049, 3f, ScreenMessageStyle.UPPER_CENTER); } }