public void mouseWindow(int windowID) { Cell cell = hoverCell.Value; float lat = WeatherFunctions.GetCellLatitude(cell); float lon = WeatherFunctions.GetCellLongitude(cell); GUILayout.BeginVertical(); GUILayout.Label(String.Format("Cell: {0:D5} cycle: {1:D}", cell.Index, CellUpdater.run)); GUILayout.Label("Lat: " + lat + " °"); GUILayout.Label("Lon: " + lon + " °"); GUILayout.Label(String.Format("Geodesic: {0:G}", Math.Sqrt(cell.Position.x * cell.Position.x + cell.Position.y * cell.Position.y + cell.Position.z * cell.Position.z))); GUILayout.Label(String.Format("ΔT(KSP-KWS): {0:+0.000;-0.000}°", (WeatherSimulator.GetInitTemperature(PD, currentLayer, cell) - WeatherFunctions.GetCellTemperature(PD.index, currentLayer, cell)))); double DDD = 0.0; double DDD2 = 0.0; int n = 0; foreach (Cell neighbor in cell.GetNeighbors(PD.gridLevel)) { double DeltaDistance = WeatherFunctions.GetDistanceBetweenCells(PD.index, cell, neighbor, WeatherFunctions.GetCellAltitude(PD.index, currentLayer, cell)); DDD += DeltaDistance; DDD2 += DeltaDistance * DeltaDistance; n++; } DDD /= n; DDD2 /= n; GUILayout.Label(String.Format("ΔDistanceδ: {0:0.000000}", Math.Sqrt(Math.Abs(DDD2 - DDD * DDD)) / DDD)); GUILayout.Label(String.Format("flowPChange: {0:+00.000;-00.000}", PD.LiveMap[currentLayer][cell].flowPChange)); GUILayout.EndVertical(); }
private static Color32 getStratoCellColor(int layer, Cell cell) { double?deposit = 0; double deposit2 = 0; switch (resource.Resource) { case "Temperature": deposit = PD.LiveStratoMap[layer][cell].temperature; break; case "Delta Temp": deposit = (WeatherSimulator.GetInitTemperature(PD, currentLayer, cell) - WeatherFunctions.GetCellTemperature(PD.index, currentLayer, cell)); break; case "Temp. Change": deposit = PD.LiveStratoMap[layer][cell].TempChange; break; case "Pressure": deposit = PD.LiveStratoMap[layer][cell].pressure; break; case "Pressure Delta": deposit = ((PD.LiveMap[0][cell].pressure - FlightGlobals.getStaticPressure(0, PD.body) * 1000) * PD.LiveStratoMap[layer][cell].pressure / PD.LiveMap[0][cell].pressure + PD.LiveStratoMap[layer][cell].flowPChange); break; } var scanned = true; var color = (revealAll ? deposit != null : scanned) ? getDepositColor(resource, deposit, deposit2) : colorUnknown; return(color); }
public void Awake() { //this is a comment Logger("Awoke!"); DontDestroyOnLoad(this); Logger("Checking basic files"); WeatherDatabase.BasicSanityCheck(); WeatherSettings.SettingsFileIntegrityCheck(); if (WeatherDatabase.BasicFileIntegrityCheck()) { Logger("Integrity check passed, continuing"); } else { Logger("Integrity check failed, quitting."); return; } //init planet WeatherDatabase.LoadInitPlanetaryData(); WeatherSettings.LoadSettings(); GameEvents.onGameSceneSwitchRequested.Add(scene => { if (scene.from == GameScenes.MAINMENU && scene.to == GameScenes.SPACECENTER) { prepToNew = true; } else if (scene.from == GameScenes.SPACECENTER && scene.to == GameScenes.MAINMENU) { prepToDestroy = true; sim = null; Destroy(this.gameObject.GetComponent <WeatherSimulator>()); Destroy(this.gameObject.GetComponent <MapOverlay>()); Destroy(this.gameObject.GetComponent <WeatherGUI.WeatherGUI>()); prepToDestroy = false; } }); GameEvents.onGameStateLoad.Add(node => { if (HighLogic.LoadedScene == GameScenes.SPACECENTER && prepToNew) { //new up simulator sim = this.gameObject.AddComponent <WeatherSimulator>(); this.gameObject.AddComponent <MapOverlay>(); this.gameObject.AddComponent <WeatherGUI.WeatherGUI>(); prepToNew = false; } if (HighLogic.LoadedScene == GameScenes.MAINMENU && prepToDestroy) { sim = null; Destroy(this.gameObject.GetComponent <WeatherSimulator>()); Destroy(this.gameObject.GetComponent <MapOverlay>()); Destroy(this.gameObject.GetComponent <WeatherGUI.WeatherGUI>()); prepToDestroy = false; } }); }
public void mouseWindow(int windowID) { Cell cell = hoverCell.Value; float lat = WeatherFunctions.GetCellLatitude(cell); float lon = WeatherFunctions.GetCellLongitude(cell); GUILayout.BeginVertical(); GUILayout.Label(String.Format("Cell: {0:D5} cycle: {1:D}", cell.Index, CellUpdater.run)); GUILayout.Label("Lat: " + lat + " °"); GUILayout.Label("Lon: " + lon + " °"); GUILayout.Label(String.Format("Geodesic: {0:G}", Math.Sqrt(cell.Position.x * cell.Position.x + cell.Position.y * cell.Position.y + cell.Position.z * cell.Position.z))); GUILayout.Label(String.Format("ΔT(KSP-KWS): {0:+0.000;-0.000}°", (WeatherSimulator.GetInitTemperature(PD, currentLayer, cell) - WeatherFunctions.GetCellTemperature(PD.index, currentLayer, cell)))); GUILayout.Label(String.Format("δ Temp: {0:+0.000000;-0.000000}°/s", currentLayer < PD.LiveMap.Count ? PD.LiveMap[currentLayer][cell].TempChange : PD.LiveStratoMap[currentLayer - PD.LiveMap.Count][cell].TempChange)); double DDD = 0.0; double DDD2 = 0.0; int n = 0; foreach (Cell neighbor in cell.GetNeighbors(PD.gridLevel)) { double DeltaDistance = WeatherFunctions.GetDistanceBetweenCells(PD.index, cell.Position, neighbor.Position, WeatherFunctions.GetCellAltitude(PD.index, currentLayer, cell)); DDD += DeltaDistance; DDD2 += DeltaDistance * DeltaDistance; n++; } DDD /= n; DDD2 /= n; GUILayout.Label(String.Format("ΔDistanceδ: {0:0.000000}", Math.Sqrt(Math.Abs(DDD2 - DDD * DDD)) / DDD)); GUILayout.Label(String.Format("CentroidΔ: {0:0.000000}", (cell.Position - PD.LiveSoilMap[cell].centroid).magnitude)); GUILayout.Label(String.Format("flowPChange: {0:+00.000;-00.000}", currentLayer < PD.LiveMap.Count ? PD.LiveMap[currentLayer][cell].flowPChange : PD.LiveStratoMap[currentLayer - PD.LiveMap.Count][cell].flowPChange)); GUILayout.Label(String.Format("Pressure Δ: {0:+000.00;-000.00}", currentLayer < PD.LiveMap.Count ? ((PD.LiveMap[0][cell].pressure - FlightGlobals.getStaticPressure(0, PD.body) * 1000) * PD.LiveMap[currentLayer][cell].pressure / PD.LiveMap[0][cell].pressure + PD.LiveMap[currentLayer][cell].flowPChange) : ((PD.LiveMap[0][cell].pressure - FlightGlobals.getStaticPressure(0, PD.body) * 1000) * PD.LiveStratoMap[currentLayer - PD.LiveMap.Count][cell].pressure / PD.LiveMap[0][cell].pressure + PD.LiveStratoMap[currentLayer - PD.LiveMap.Count][cell].flowPChange))); GUILayout.EndVertical(); }
private static Color32 getCellColor(int layer, Cell cell) { double?deposit = 0; double deposit2 = 0; switch (resource.Resource) { case "Temperature": deposit = PD.LiveMap[layer][cell].temperature; break; case "Delta Temp": deposit = (WeatherSimulator.GetInitTemperature(PD, currentLayer, cell) - WeatherFunctions.GetCellTemperature(PD.index, currentLayer, cell)); break; case "Temp. Change": deposit = PD.LiveMap[layer][cell].TempChange; break; case "Pressure": deposit = PD.LiveMap[layer][cell].pressure; break; case "Pressure Delta": deposit = ((PD.LiveMap[0][cell].pressure - FlightGlobals.getStaticPressure(0, PD.body) * 1000) * PD.LiveMap[layer][cell].pressure / PD.LiveMap[0][cell].pressure + PD.LiveMap[layer][cell].flowPChange); break; case "Wind H Speed": deposit = WeatherFunctions.GetCellwindH(PD.index, layer, cell); break; case "Wind H Vector": //deposit = WeatherFunctions.GetCellwindDir(PD.index, layer, cell); deposit = PD.LiveMap[layer][cell].windVector.x; deposit2 = PD.LiveMap[layer][cell].windVector.z; break; case "Wind Vertical": deposit = PD.LiveMap[layer][cell].windVector.y; break; case "Rel. Humidity": deposit = PD.LiveMap[layer][cell].relativeHumidity; break; case "Cloud water": deposit = PD.LiveMap[layer][cell].cloud.getwaterContent(); deposit2 = WeatherFunctions.GetSunriseFactor(PD.index, cell); break; case "Geodesy": // deposit = Math.Sqrt(cell.Position.x * cell.Position.x + cell.Position.y * cell.Position.y + cell.Position.z * cell.Position.z); deposit = (cell.Position - PD.LiveSoilMap[cell].centroid).magnitude; break; case "DeltaDistanceDiff": double DDD = 0.0; double DDD2 = 0.0; int n = 0; foreach (Cell neighbor in cell.GetNeighbors(PD.gridLevel)) { double DeltaDistance = WeatherFunctions.GetDistanceBetweenCells(PD.index, cell.Position, neighbor.Position, WeatherFunctions.GetCellAltitude(PD.index, layer, cell)); DDD += DeltaDistance; DDD2 += DeltaDistance * DeltaDistance; n++; } DDD /= n; DDD2 /= n; deposit = Math.Sqrt(Math.Abs(DDD2 - DDD * DDD)) / DDD; break; } var scanned = true; var color = (revealAll ? deposit != null : scanned) ? getDepositColor(resource, deposit, deposit2) : colorUnknown; return(color); }