public static void LoadConfiguration(string rootFile, string[] customFiles) { if (rootFile == null) { return; } configuration = new EmpyrionConfiguration(rootFile); if (customFiles != null) { foreach (string file in customFiles) { configuration.Load(file); } } if (EmpyrionConfigurationChanged != null) { EmpyrionConfigurationChanged(); } }
/// <summary> /// Called by Empyrion when the mod is first loaded. /// </summary> /// <param name="modAPI">Provides access to the Empyrion game state.</param> public void Init(IModApi modAPI) { EmpyrionApi = modAPI; Application = modAPI.Application; Log.LogReceived += Log_LogReceived; if (this.NetworkServerHost == null) { try { this.NetworkServerHost = new ModServerHost(); this.NetworkServerHost.Server.BindEndPoints.Add(new IPEndPoint(IPAddress.Loopback, Connection.DefaultPort)); this.NetworkServerHost.Server.Start(); } catch (Exception ex) { Log.Warn("Failed to create DCE server. Remote connections will not be possible from client systems. " + ex.Message); this.NetworkServerHost = null; } } if (this.GameStateProcessor == null) { this.GameStateProcessor = new GameStateProcessor(); } Application.OnPlayfieldLoaded += Application_OnPlayfieldLoaded; Application.OnPlayfieldUnloading += Application_OnPlayfieldUnloading; string contentPath = Application.GetPathFor(AppFolder.Content); string localizationPath = Path.Combine(contentPath, @"Extras\Localization.csv"); string exampleConfigPath = Path.Combine(contentPath, @"Configuration\Config_Example.ecf"); string customConfigPath = Path.Combine(contentPath, @"Configuration\Config.ecf"); try { if (Localization == null) { Localization = new Localization(localizationPath); } } catch (Exception ex) { Log.Warn($"Failed to load localization file {localizationPath}. {ex.Message}"); } try { if (Configuration == null) { Configuration = new EmpyrionConfiguration(exampleConfigPath); Log.Info("Loaded default configuration file."); try { Configuration.Load(customConfigPath); Log.Info("Loaded custom configuration file."); } catch { Log.Info("Did not load custom configuration file."); } } } catch (Exception ex) { Log.Warn($"Failed to load configuration files from {contentPath}. {ex.Message}"); } Log.Info("Dark City server extension initialization done."); }