public void Awake() { if (grid == null) { grid = new GeodesicGrid(5); } showOverlay = Misc.Parse(SettingsManager.GetValue("ShowOverlay"), true); controlWindowPos.x = Misc.Parse(SettingsManager.GetValue("WindowLeft"), 200f); controlWindowPos.y = Misc.Parse(SettingsManager.GetValue("WindowTop"), 200f); var scene = HighLogic.LoadedScene; if (scene != GameScenes.FLIGHT && scene != GameScenes.TRACKSTATION && scene != GameScenes.LOADING && scene != GameScenes.MAINMENU) { enabled = false; } if ((scene == GameScenes.LOADING || scene == GameScenes.MAINMENU) && !Misc.Parse(SettingsManager.GetValue("ShowInMenu"), true)) { enabled = false; } }
public static Deposit GetCellDeposit(string resourceName, CelestialBody body, GeodesicGrid.Cell cell) { if (resourceName == null || body == null || !PlanetDeposits.ContainsKey(resourceName) || !PlanetDeposits[resourceName].ContainsKey(body.name)) { return null; } var pos = cell.GetPosition(); var lat = (float)(Math.Atan2(pos.y, Math.Sqrt(pos.x * pos.x + pos.z * pos.z)) * 180 / Math.PI); var lon = (float)(Math.Atan2(pos.z, pos.x) * 180 / Math.PI); var x = lon + 180f; var y = 90f - lat; foreach (Deposit deposit in PlanetDeposits[resourceName][body.name]) { if (deposit.Shape.PointInPolygon(new Vector2(x, y))) { return deposit; } } return null; }
private static void setCellColor(GeodesicGrid.Cell cell, Color32 color, Color32[] colors) { var idx = cell.GetHashCode() * 6; for (int i = idx; i < idx + 6; i++) { colors[i] = color; } }
private void refreshCellColor(GeodesicGrid.Cell cell, CelestialBody body, Color32[] colors) { setCellColor(cell, KethaneController.Scans[resource.Resource][body.name][cell] ? getDepositColor(resource, KethaneController.GetCellDeposit(resource.Resource, body, cell)) : colorUnknown, colors); }
public void RefreshCellColor(GeodesicGrid.Cell cell, CelestialBody body) { if (body != this.body) { return; } var colors = mesh.colors32; refreshCellColor(cell, body, colors); mesh.colors32 = colors; }