/// <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> /// Unloads all used data by this component /// </summary> protected override void UnloadData() { MyPluginLog.Log("Unloading star system generation data"); SaveData(); StarSystem = null; m_planets?.Clear(); m_suns?.Clear(); m_gasGiants?.Clear(); m_moons?.Clear(); m_mandatoryPlanets?.Clear(); m_mandatoryMoons?.Clear(); m_uniqueMoons?.Clear(); m_uniquePlanets?.Clear(); UnloadNetworking(); Static = null; MyPluginLog.Log("Unloading star system generation data completed"); }