/// <summary>
        /// Creates all GPSs that are persistent.
        /// </summary>
        private void AddAllPersistentGps()
        {
            var settings = MySettingsSession.Static.Settings.GeneratorSettings.GPSSettings;

            foreach (var item in StarSystem.GetAllObjects())
            {
                switch (item.Type)
                {
                case MySystemObjectType.MOON:
                    if (settings.MoonGPSMode == MyGPSGenerationMode.PERSISTENT || settings.MoonGPSMode == MyGPSGenerationMode.PERSISTENT_HIDDEN)
                    {
                        MyGPSManager.Static.AddPersistentGps(item.DisplayName, MOON_GPS_COLOR, item.CenterPosition, item.Id, settings.MoonGPSMode == MyGPSGenerationMode.PERSISTENT_HIDDEN);
                    }
                    break;

                case MySystemObjectType.PLANET:
                    if (settings.PlanetGPSMode == MyGPSGenerationMode.PERSISTENT || settings.PlanetGPSMode == MyGPSGenerationMode.PERSISTENT_HIDDEN)
                    {
                        MyGPSManager.Static.AddPersistentGps(item.DisplayName, PLANET_GPS_COLOR, item.CenterPosition, item.Id, settings.PlanetGPSMode == MyGPSGenerationMode.PERSISTENT_HIDDEN);
                    }
                    break;

                case MySystemObjectType.ASTEROIDS:
                    if (settings.AsteroidGPSMode == MyGPSGenerationMode.PERSISTENT || settings.AsteroidGPSMode == MyGPSGenerationMode.PERSISTENT_HIDDEN)
                    {
                        MySystemAsteroids asteroid = item as MySystemAsteroids;
                        MyAbstractAsteroidObjectProvider provider = null;
                        if (MyAsteroidObjectsManager.Static.AsteroidObjectProviders.TryGetValue(asteroid.AsteroidTypeName, out provider))
                        {
                            var shape = provider.GetAsteroidObjectShape(asteroid);

                            if (shape == null)
                            {
                                break;
                            }

                            MyGPSManager.Static.AddPersistentGps(item.DisplayName, RING_GPS_COLOR, shape.GetPointInShape(true), item.Id, settings.AsteroidGPSMode == MyGPSGenerationMode.PERSISTENT_HIDDEN);
                        }
                    }
                    break;
                }
            }
        }
        /// <summary>
        /// Loads the data for the system generator and filters the definition according to
        /// the global config
        /// </summary>
        public override void LoadData()
        {
            MyPluginLog.Log("Load Star system generator component");

            Static = this;

            LoadNetworking();

            if (!MySettingsSession.Static.IsEnabled())
            {
                return;
            }

            MyPluginLog.Log("Loading definitions and network data");
            var data = LoadSystemData();

            StarSystem = data;

            MyPluginLog.Log("Loaded system data. Checking Asteroid objects");

            if (StarSystem != null && StarSystem.CenterObject != null)
            {
                foreach (var obj in StarSystem.GetAllObjects())
                {
                    if (obj.Type == MySystemObjectType.ASTEROIDS)
                    {
                        var asteroid = obj as MySystemAsteroids;

                        var provider = MyAsteroidObjectsManager.Static.AsteroidObjectProviders[asteroid.AsteroidTypeName];
                        if (!provider.TryLoadObject(asteroid))
                        {
                            MyPluginLog.Log("No data found associated with asteroid object " + asteroid.DisplayName + " (" + asteroid.Id + "), Removing it.", LogLevel.WARNING);
                            StarSystem.RemoveObject(asteroid.Id);
                        }
                    }
                }
            }

            MyPluginLog.Log("All asteroid objects checked");

            m_planets          = new List <MyPlanetGeneratorDefinition>();
            m_moons            = new List <MyPlanetGeneratorDefinition>();
            m_suns             = new List <MyPlanetGeneratorDefinition>();
            m_gasGiants        = new List <MyPlanetGeneratorDefinition>();
            m_mandatoryPlanets = new List <MyPlanetGeneratorDefinition>();
            m_mandatoryMoons   = new List <MyPlanetGeneratorDefinition>();

            MyPluginLog.Log("Load Star system generator component completed");
        }
        /// <summary>
        /// Builds the edit menu
        /// </summary>
        private void BuildEditMenu()
        {
            MyPluginLog.Debug("Adding edit menu");

            if (m_fetchedStarSytem == null || ForceFetchStarSystem)
            {
                MyPluginLog.Debug("Fetching system data");

                MyGuiControlRotatingWheel m_loadingWheel = new MyGuiControlRotatingWheel(position: Vector2.Zero);
                m_loadingWheel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER;

                Controls.Add(m_loadingWheel);

                MyStarSystemGenerator.Static.GetStarSystem(delegate(MyObjectBuilder_SystemData starSystem)
                {
                    m_fetchedStarSytem   = starSystem;
                    m_selectedObject     = null;
                    ShouldRecreate       = true;
                    ForceFetchStarSystem = false;
                });
                return;
            }

            var     topCombo = GetCombo();
            Vector2 start    = topCombo.Position + new Vector2(0, MARGIN_VERT * 2 + GetCombo().Size.Y);
            Vector2 end      = start + new Vector2(topCombo.Size.X, 0.8f - MARGIN_VERT);

            MyGuiControlLabel systemObjsLabel = new MyGuiControlLabel(null, null, "System Objects");

            systemObjsLabel.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;
            systemObjsLabel.Position    = start;

            Controls.Add(systemObjsLabel);

            m_systemObjectsBox = new MyGuiControlListbox();
            m_systemObjectsBox.VisibleRowsCount = 8;
            m_systemObjectsBox.Size             = new Vector2(m_usableWidth, m_systemObjectsBox.Size.Y);
            m_systemObjectsBox.Position         = start;
            m_systemObjectsBox.PositionY       += systemObjsLabel.Size.Y + MARGIN_VERT;
            m_systemObjectsBox.OriginAlign      = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP;

            foreach (var obj in m_fetchedStarSytem.GetAllObjects())
            {
                if (obj.Type == MySystemObjectType.EMPTY)
                {
                    continue;
                }
                m_systemObjectsBox.Add(new MyGuiControlListbox.Item(new System.Text.StringBuilder(obj.DisplayName), userData: obj));
            }

            if (m_selectedObject != null)
            {
                m_systemObjectsBox.SelectByUserData(m_selectedObject);
            }
            m_systemObjectsBox.ItemsSelected += OnSystemObjectSelect;


            Controls.Add(m_systemObjectsBox);

            MyGuiControlSeparatorList sep = new MyGuiControlSeparatorList();

            sep.AddHorizontal(new Vector2(m_systemObjectsBox.Position.X, m_systemObjectsBox.Position.Y + m_systemObjectsBox.Size.Y + MARGIN_VERT), m_usableWidth);

            BuildEditingSubMenu();

            sep.AddHorizontal(new Vector2(m_scrollPane.Position.X - m_scrollPane.Size.X / 2, m_scrollPane.Position.Y + m_scrollPane.Size.Y), m_usableWidth);

            Controls.Add(sep);

            MyPluginLog.Debug("Added edit menu");
        }