public void AddSystem(HSystem system) { _systems.Add(system.ID, system); system.HostSector = this; }
private void TableAddSystem(HSystem system) { dgvSurvey.Columns["dgvSurveyColumnZone"].Visible = _columnVisability["dgvSurveyColumnZone"] && !_optionSystemWide; dgvSurvey.Columns["dgvSurveyColumnDiameter"].Visible = _columnVisability["dgvSurveyColumnDiameter"] && !_optionSystemWide; dgvSurvey.Columns["dgvSurveyColumnBodyType"].Visible = _columnVisability["dgvSurveyColumnBodyType"] && !_optionSystemWide; if (_optionSystemWide) { // SystemWide mode dgvSurvey.Rows.Add(); DataGridViewRow row = dgvSurvey.Rows[dgvSurvey.RowCount - 1]; row.Cells["dgvSurveyColumnGalaxy"].Value = system.HostSector.HostGalaxy; row.Cells["dgvSurveyColumnSector"].Value = system.HostSector; row.Cells["dgvSurveyColumnSystem"].Value = system; row.Cells["dgvSurveyColumnWorld"].Value = system.CelestialBodies.Values.Count(x => x.Type != CelestialBodyType.Star && x.Type != CelestialBodyType.Ring) + " worlds (" + system.HabitbleCount() + " habitable)"; row.Cells["dgvSurveyColumnOrbit"].Value = system.CelestialBodies.Values.Count(x => x.Type == CelestialBodyType.Star) + " Stars"; row.Cells["dgvSurveyColumnCoordinates"].Value = system.Coord; foreach (Resource resource in system.BestResources().Values) { TableAddResourceRow(row, resource); } } else { // Normal HazeronScouter mode foreach (CelestialBody planet in system.CelestialBodies.Values) { foreach (Zone zone in planet.ResourceZones) { dgvSurvey.Rows.Add(); DataGridViewRow row = dgvSurvey.Rows[dgvSurvey.RowCount - 1]; row.Cells["dgvSurveyColumnGalaxy"].Value = system.HostSector.HostGalaxy; row.Cells["dgvSurveyColumnSector"].Value = system.HostSector; row.Cells["dgvSurveyColumnSystem"].Value = system; row.Cells["dgvSurveyColumnWorld"].Value = planet; row.Cells["dgvSurveyColumnZone"].Value = zone; switch (planet.Orbit) { case CelestialBodyOrbit.Inferno: row.Cells["dgvSurveyColumnOrbit"].Value = "Inferno"; break; case CelestialBodyOrbit.Inner: row.Cells["dgvSurveyColumnOrbit"].Value = "Inner"; break; case CelestialBodyOrbit.Habitable: row.Cells["dgvSurveyColumnOrbit"].Value = "Habitable"; break; case CelestialBodyOrbit.Outer: row.Cells["dgvSurveyColumnOrbit"].Value = "Outer"; break; case CelestialBodyOrbit.Frigid: row.Cells["dgvSurveyColumnOrbit"].Value = "Frigid"; break; } row.Cells["dgvSurveyColumnCoordinates"].Value = system.Coord; switch (planet.Type) { case CelestialBodyType.Star: row.Cells["dgvSurveyColumnBodyType"].Value = "Star"; break; case CelestialBodyType.NeutronStar: row.Cells["dgvSurveyColumnBodyType"].Value = "Neutron Star"; break; case CelestialBodyType.BlackHole: row.Cells["dgvSurveyColumnBodyType"].Value = "Black Holes"; break; case CelestialBodyType.Planet: row.Cells["dgvSurveyColumnBodyType"].Value = "Planet"; break; case CelestialBodyType.Moon: row.Cells["dgvSurveyColumnBodyType"].Value = "Moon"; break; case CelestialBodyType.GasGiant: row.Cells["dgvSurveyColumnBodyType"].Value = "Gas Giant"; break; case CelestialBodyType.Titan: row.Cells["dgvSurveyColumnBodyType"].Value = "Titan"; break; case CelestialBodyType.Ring: row.Cells["dgvSurveyColumnBodyType"].Value = "Ring"; break; case CelestialBodyType.Planetoid: row.Cells["dgvSurveyColumnBodyType"].Value = "Planetoid"; break; case CelestialBodyType.RingworldArc: row.Cells["dgvSurveyColumnBodyType"].Value = "Ringworld Arc"; break; } if (planet.Diameter > 0 && planet.Type != CelestialBodyType.Ring) { row.Cells["dgvSurveyColumnDiameter"].Value = planet.Diameter; } foreach (Resource resource in zone.Resources.Values) { TableAddResourceRow(row, resource); } } } } }
public bool Equals(HSystem system) { return(_id == system.ID); }
private void StarMapSearch() { toolStripStatusLabel1.Text = "Searching star map..."; List <HSystem> selectedSystems = new List <HSystem>(); // Selection of center if (rabSelectionDropdown.Checked) // Dropdown search { if (cobSelectionSector.SelectedIndex > 0) // Selected sector { if (cobSelectionSystem.SelectedIndex > 0) // Selected system { HSystem system = (cobSelectionSystem.SelectedItem as HSystem); selectedSystems.Add(system); coord = system.Coord; } else // All systems in sector { Sector sector = (cobSelectionSector.SelectedItem as Sector); selectedSystems.AddRange(sector.Systems.Values); coord = sector.Coord; } } else // All sectors in galaxy { Galaxy galaxy = (cobSelectionGalaxy.SelectedItem as Galaxy); foreach (Sector sector in galaxy.Sectors.Values) { selectedSystems.AddRange(sector.Systems.Values); } coord = new Coordinate(); } } else if (rabSelectionCoordinate.Checked) // Coordinate search { if (!_errorCoordinate) { string[] coordinateArray = tbxSelectionCoordinate.Text.Split(new string[] { ", ", " ", "," }, StringSplitOptions.RemoveEmptyEntries); coord = new Coordinate( Double.Parse(coordinateArray[0], System.Globalization.NumberStyles.Number, Hazeron.NumberFormat), Double.Parse(coordinateArray[1], System.Globalization.NumberStyles.Number, Hazeron.NumberFormat), Double.Parse(coordinateArray[2], System.Globalization.NumberStyles.Number, Hazeron.NumberFormat)); HSystem system = _systems.Values.SingleOrDefault(x => x.Coord.Equals(coord)); if (system == null) { IEnumerable <Sector> sectors = _sectors.Values.Where(x => x.Coord.Distance(coord) < 10); foreach (Sector sector in sectors) { selectedSystems.AddRange(sector.Systems.Values.Where(x => x.Coord.Distance(coord) < 0.5)); } } } else { MessageBox.Show(this, "The entered coordinate is not valid. Pleaese check it for errors or use another selection type.", "Invalid Coordinate", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else // Error? { throw new Exception("No selection type selected!?"); } // Filters for surounding systmes if (rabFilterRange.Checked && nudFilterRange.Value > 0) // Range filter { foreach (Sector sector in _sectors.Values) { double dist = coord.Distance(sector.Coord); if (dist <= (double)nudFilterRange.Value + 15) { foreach (HSystem system in sector.Systems.Values) { if (!selectedSystems.Contains(system)) { dist = coord.Distance(system.Coord); if (dist <= (double)nudFilterRange.Value) { selectedSystems.Add(system); } } } } } } else if (rabFilterWormhole.Checked && nudFilterWormhole.Value > 0) // Wormhole filter { if (selectedSystems.Count == 0) { MessageBox.Show(this, "The entered coordinate did not yield a system." + Environment.NewLine + "If no system is at or very close to the coordinate, then it is impossible to filter with wormhole jumps.", "No System at Coordinate", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (rabSelectionDropdown.Checked && cobSelectionSector.SelectedIndex == 0) { // If all sectors are selected, don't bother with this. } else { List <HSystem> nextWormholeReach = selectedSystems.ToList(); for (int i = 0; i < nudFilterWormhole.Value; i++) { List <HSystem> currentWormholeReach = nextWormholeReach.ToList(); nextWormholeReach.Clear(); foreach (HSystem system in currentWormholeReach) { foreach (HSystem destinationSystem in system.WormholeLinks) { if (!selectedSystems.Contains(destinationSystem)) { nextWormholeReach.Add(destinationSystem); selectedSystems.Add(destinationSystem); } } } } } } // Initialize all selected systems that aren't already initialized. _hStarMap.InitializeSystems(selectedSystems.Where(x => !x.Initialized).ToList()); toolStripProgressBar1.Value = 0; toolStripProgressBar1.Step = 1; toolStripProgressBar1.Maximum = selectedSystems.Count; toolStripProgressBar1.Visible = true; // Clear and fill the table. TableClear(); foreach (HSystem system in selectedSystems) { TableAddSystem(system); toolStripProgressBar1.PerformStep(); } toolStripProgressBar1.Visible = false; dgvSurvey.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader); toolStripStatusLabel1.Text = selectedSystems.Count + " systems found resulting in " + dgvSurvey.Rows.Count + " entries"; }