public void Game_Start(ModGameAPI gameAPI) { GameAPI = gameAPI; GameAPI.Console_Write("Mod Network Relay is Starting"); startModServer(gameAPI); GameAPI.Console_Write("Mod Network Relay has been initialized"); }
public ModManager(string folderPath, ModGameAPI api, Regex offlinePattern = null, bool verbose = false) { this.api = api; this.verbose = verbose; if (offlinePattern != null) { this.offlinePattern = offlinePattern; } var cadidatePaths = getCandidateModPaths(folderPath); cadidatePaths.ForEach(x => OnboardMod(x, true)); var modTable = getModTable(modDict.Values.ToList()); api.Console_Write("\n" + modTable); var path = Path.GetFullPath(folderPath); watcher = new FileSystemWatcher() { Path = folderPath, IncludeSubdirectories = true, EnableRaisingEvents = true, }; api.Console_Write($"*** HotloaderMod now watching {path}"); watcher.IncludeSubdirectories = true; watcher.Changed += Watcher_Changed; watcher.Created += Watcher_Created; watcher.Deleted += Watcher_Deleted; watcher.Renamed += Watcher_Renamed; }
public void Game_Start(ModGameAPI dediAPI) { mDllNamesFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetAssembly(GetType()).Location), "DllNames.txt"); mGameAPI = dediAPI; try { mGameAPI.Console_Write($"LoadMod(start): {mDllNamesFileName}"); mAssemblyFileNames = File.ReadAllLines(mDllNamesFileName) .Select(L => L.Trim()) .Where(L => !string.IsNullOrEmpty(L) && !L.StartsWith("#")) .ToArray(); Array.ForEach(mAssemblyFileNames, LoadAssembly); if (mModInstance.Count == 1) { mSingleModInstance = mModInstance.First(); } mGameAPI.Console_Write($"LoadMod(finish:{mModInstance.Count}): {mDllNamesFileName}"); } catch (Exception Error) { mGameAPI.Console_Write($"LoadMod: {mDllNamesFileName} -> {Error}"); } }
public override void Initialize(ModGameAPI dediAPI) { GameAPI = dediAPI; LogLevel = EmpyrionNetAPIDefinitions.LogLevel.Debug; TaskTools.Intervall(60, CheckTimetable); }
public override void Initialize(ModGameAPI dediAPI) { GameAPI = dediAPI; LogLevel = EmpyrionNetAPIDefinitions.LogLevel.Debug; Event_Player_Info += UpdateFactoryItems; }
void ModInterface.Game_Start(ModGameAPI dediAPI) { Broker.api = dediAPI; this.Initialize(dediAPI); this.ChatCommandManager = new ChatCommandManager(this.ChatCommands); }
public void Game_Start(ModGameAPI dediAPI) { GameAPI = dediAPI; GameAPI.Console_Write($"ModClientDll: start"); CurrentConfig = new ConfigurationManager <Configuration>() { ConfigFilename = Path.Combine(Path.GetDirectoryName(Assembly.GetAssembly(GetType()).Location), "Configuration.xml") }; CurrentConfig.Load(); CurrentConfig.Current.EmpyrionToModPipeName = string.Format(CurrentConfig.Current.EmpyrionToModPipeName, Guid.NewGuid().ToString("N")); CurrentConfig.Current.ModToEmpyrionPipeName = string.Format(CurrentConfig.Current.ModToEmpyrionPipeName, Guid.NewGuid().ToString("N")); CurrentConfig.Save(); GameAPI.Console_Write($"ModClientDll (CurrentDir:{Directory.GetCurrentDirectory()}): Config:{CurrentConfig.ConfigFilename}"); InServerMessageHandler = new Dictionary <Type, Action <object> > { { typeof(EmpyrionGameEventData), M => HandleGameEvent((EmpyrionGameEventData)M) }, { typeof(ClientHostComData), M => HandleClientHostCommunication((ClientHostComData)M) } }; new Thread(() => { while (!Exit) { Thread.Sleep(1000); CheckHostProcess(); } }).Start(); GameAPI.Console_Write($"ModClientDll: started"); }
public void Game_Start(ModGameAPI dediAPI) { mDllNamesFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetAssembly(GetType()).Location), "DllNames.txt"); GameAPI = dediAPI; SynchronizationContext.SetSynchronizationContext(new AsyncSynchronizationContext(GameAPI)); try { string CurrentDirectory = Directory.GetCurrentDirectory(); GameAPI.Console_Write($"ModDispatcher(start): {mDllNamesFileName} in {CurrentDirectory}"); mAssemblyFileNames = File.ReadAllLines(mDllNamesFileName) .Select(L => L.Trim()) .Where(L => !string.IsNullOrEmpty(L) && !L.StartsWith("#")) .ToArray(); Array.ForEach(mAssemblyFileNames, LoadAssembly); Directory.SetCurrentDirectory(ProgramPath); try{ Parallel.ForEach(mModInstance, async M => await SafeApiCall(() => M.Game_Start(GameAPI), M, "Game_Start")); } finally{ Directory.SetCurrentDirectory(CurrentDirectory); } GameAPI.Console_Write($"ModDispatcher(finish:{mModInstance.Count}): {mDllNamesFileName}"); } catch (Exception Error) { GameAPI.Console_Write($"ModDispatcher: {mDllNamesFileName} -> {Error}"); } }
public override void Initialize(ModGameAPI aGameAPI) { GameAPI = aGameAPI; TranslateAPI.LogDB = (S, L) => Log(S, L); Log($"**HandleEmpyrionChatAutoTranslate loaded: {string.Join(" ", Environment.GetCommandLineArgs())}", LogLevel.Message); InitializeDB(); LogLevel = Configuration.Current.LogLevel; ChatCommandManager.CommandPrefix = Configuration.Current.CommandPrefix; Event_ChatMessage += (C) => { try { Task.Run(() => EmpyrionChatAutoTranslate_Event_ChatMessage(C)); } catch (Exception error) { Log($"ChatAutoTranslate_Event_ChatMessage: {error}", LogLevel.Error); } }; ChatCommands.Add(new ChatCommand(@"trans help", (I, A) => ExecCommand(SubCommand.Help, I, A), "Show the help")); ChatCommands.Add(new ChatCommand(@"trans set (?<language>.*)", (I, A) => ExecCommand(SubCommand.Set, I, A), "Set the translation language")); ChatCommands.Add(new ChatCommand(@"trans box (?<text>.+)", (I, A) => ExecCommand(SubCommand.Box, I, A), "Translate to a messagebox")); ChatCommands.Add(new ChatCommand(@"trans clear", (I, A) => ExecCommand(SubCommand.Clear, I, A), "Back to the Serverlanguage")); ChatCommands.Add(new ChatCommand(@"trans listall", (I, A) => ExecCommand(SubCommand.ListAll, I, A), "List all translation settings", PermissionType.Moderator)); }
public override void Initialize(ModGameAPI dediAPI) { GameAPI = dediAPI; try { Log($"**EmpyrionGalaxyNavigator loaded: {string.Join(" ", Environment.GetCommandLineArgs())}", LogLevel.Message); LoadConfiguration(); LogLevel = Configuration.Current.LogLevel; ChatCommandManager.CommandPrefix = Configuration.Current.ChatCommandPrefix; GalaxyMap = new GalaxyMap { GalaxyAutoUpdateMinutes = Configuration.Current.GalaxyAutoUpdateMinutes }; GalaxyMap.ReadDbData(Path.Combine(EmpyrionConfiguration.SaveGamePath, "global.db")); ChatCommands.Add(new ChatCommand(@"nav help", (I, A) => DisplayHelp(I.playerId), "display help")); ChatCommands.Add(new ChatCommand(@"nav stop", (I, A) => StopNavigation(I.playerId), "stops navigation")); ChatCommands.Add(new ChatCommand(@"nav updategalaxy", (I, A) => UpdateGalayMap(I.playerId), "force update the galaxy db")); ChatCommands.Add(new ChatCommand(@"nav setwarp (?<LY>.*)", (I, A) => SetWarpDistance(I.playerId, A), "set the warp distance for navigation to (LY)")); ChatCommands.Add(new ChatCommand(@"nav (?<target>.*)", (I, A) => StartNavigation(I.playerId, A), "start a navigation to (target)")); Event_Player_ChangedPlayfield += Navigator_Event_Player_ChangedPlayfield; TaskTools.Intervall(Configuration.Current.MessageLoopMS, () => { try { CheckPlayerNavMessages().Wait(); } catch { } }); } catch (Exception Error) { Log($"**EmpyrionGalaxyNavigator Error: {Error} {string.Join(" ", Environment.GetCommandLineArgs())}", LogLevel.Error); } }
public override void Initialize(ModGameAPI dediAPI) { GameAPI = dediAPI; LogLevel = EmpyrionNetAPIDefinitions.LogLevel.Debug; Event_Player_Info += PlayerManager_Event_Player_Info; }
public override void Initialize(ModGameAPI dediAPI) { GameAPI = dediAPI; LogLevel = EmpyrionNetAPIDefinitions.LogLevel.Debug; PlayerManager = Program.GetManager <PlayerManager>(); TaskTools.Intervall(2000, () => SysteminfoHub?.Clients.All.SendAsync("UPC", JsonConvert.SerializeObject(new { o = CurrentSysteminfo.online, ap = CurrentSysteminfo.activePlayers, apf = CurrentSysteminfo.activePlayfields, c = CurrentSysteminfo.cpuTotalLoad, r = CurrentSysteminfo.ramAvailableMB, tpf = CurrentSysteminfo.totalPlayfieldserver, tpfm = CurrentSysteminfo.totalPlayfieldserverRamMB, })).Wait(1000)); TaskTools.Intervall(30000, () => SysteminfoHub?.Clients.All.SendAsync("Update", JsonConvert.SerializeObject(CurrentSysteminfo)).Wait(1000)); TaskTools.Intervall(5000, UpdateEmpyrionInfos); TaskTools.Intervall(5000, UpdateComputerInfos); TaskTools.Intervall(2000, UpdatePerformanceInfos); CpuTotalLoad = new PerformanceCounter { CategoryName = "Processor", CounterName = "% Processor Time", InstanceName = "_Total" }; RamAvailable = new PerformanceCounter("Memory", "Available MBytes"); }
public override void Initialize(ModGameAPI aGameAPI) { GameAPI = aGameAPI; Log($"**HandleEmpyrionStructureCleanUp loaded: {string.Join(" ", Environment.GetCommandLineArgs())}", LogLevel.Message); InitializeDB(); LogLevel = Configuration.Current.LogLevel; ChatCommandManager.CommandPrefix = Configuration.Current.ChatCommandPrefix; ChatCommands.Add(new ChatCommand(@"struct help", (I, A) => ExecCommand(SubCommand.Help, I, A), "Show the help", PermissionType.Admin)); ChatCommands.Add(new ChatCommand(@"struct list", (I, A) => ExecCommand(SubCommand.List, I, A), "List all structures", PermissionType.Admin)); ChatCommands.Add(new ChatCommand(@"struct calc", (I, A) => ExecCommand(SubCommand.Calc, I, A), "Calc all structures again", PermissionType.Admin)); ChatCommands.Add(new ChatCommand(@"struct cleanup", (I, A) => ExecCommand(SubCommand.CleanUp, I, A), "CleanUp old and unsued structures", PermissionType.Admin)); new Thread(() => { try { CalcStructures(() => { if (Configuration.Current.CleanOnStartUp) { CleanUpStructuresWorker(); } }).Wait(); } catch (Exception error) { Log($"CalcStructures(Initialize): {error}", LogLevel.Error); } }) .Start(); }
void ModInterface.Game_Start(ModGameAPI dediAPI) { Broker.api = dediAPI; elevated = new HashSet <string>(adminConfig.Elevated.Select(x => x.Id)); api = dediAPI; dediAPI.Console_Write(adminConfig.Elevated.First().Id); modManager = new ModManager("Content/Mods/Hotloader/watched", dediAPI, verbose: false); }
public void Game_Start(ModGameAPI dediAPI) { DebugMod.GameAPI = dediAPI; GameAPI.Console_Write("Debug Mod Launched! 12"); unusedSettlementSequenceNumbers = new Queue <ushort>(Enumerable.Range(62000, 62500).Select(x => (ushort)x)); broker = new EmpyrionAPIMessageBroker(dediAPI); }
public override void Initialize(ModGameAPI dediAPI) { GameAPI = dediAPI; API_Exit += () => { try { System.IO.File.Delete(CurrentEBPFile); } catch { } }; TaskTools.Intervall(Math.Max(1, Program.AppSettings.GlobalStructureUpdateInSeconds) * 1000, () => GlobalStructureList()); }
public override void Initialize(ModGameAPI dediAPI) { GameAPI = dediAPI; LogLevel = EmpyrionNetAPIDefinitions.LogLevel.Debug; Event_Faction_Changed += F => UpdateFactions().Wait(); TaskTools.IntervallAsync(10000, UpdateFactions); }
private void startModServer(ModGameAPI gameAPI) { var filePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "Settings.yaml"; config = Configuration.GetConfiguration(filePath); server = new ModTCPServer(gameAPI); server.StartListen(config.GameServerIp, config.GameServerApiPort, PackageReceivedDelegate); }
public override void Initialize(ModGameAPI dediAPI) { GameAPI = dediAPI; LogLevel = EmpyrionNetAPIDefinitions.LogLevel.Debug; TaskTools.Intervall(Math.Max(1, Program.AppSettings.StructureDataUpdateCheckInSeconds) * 1000, () => BackupStructureData()); Event_Playfield_Loaded += P => ActivePlayfields.TryAdd(P.playfield, P.playfield); Event_Playfield_Unloaded += P => ActivePlayfields.TryRemove(P.playfield, out _); }
public override void Initialize(ModGameAPI dediAPI) { this.Update_Received += ExampleMod_Update_Received; this.Event_ChatMessage += ExampleMod_Event_HandleLottoChatMessage; this.Event_GameEvent += ExampleMod_Event_GameEvent; this.Event_Statistics += PlayerDied_Event_Statistics; this.ChatCommands.Add(new ChatCommand(@"/repeat (?<repeat>\S+)", ChatCommand_TestMessage)); this.ChatCommands.Add(new ChatCommand(@"!loudly (?<yellthis>.+)", (data, args) => { var msg = new IdMsgPrio() { id = data.playerId, msg = $"{args["yellthis"].ToUpper()}!!!!!" }; this.Request_InGameMessage_SinglePlayer(msg); })); this.ChatCommands.Add(new ChatCommand(@"/explosion", (data, __) => { var dialogData = new DialogBoxData() { Id = data.playerId, MsgText = "BOOM!", PosButtonText = "yes", NegButtonText = "No" }; this.Request_ShowDialog_SinglePlayer(dialogData, (result) => { var resultInterpreted = result.Value == 0 ? "YES": "NO"; this.Request_InGameMessage_SinglePlayer(resultInterpreted.ToIdMsgPrio(data.playerId)); }); }, "blows it up", PermissionType.Moderator)); this.ChatCommands.Add(new ChatCommand(@"/help", (data, __) => { this.Request_Player_Info(data.playerId.ToId(), (info) => { var playerPermissionLevel = (PermissionType)info.permission; var header = $"Commands available to {info.playerName}; permission level {playerPermissionLevel}\n"; var lines = this.GetChatCommandsForPermissionLevel(playerPermissionLevel) .Select(x => x.ToString()) .OrderBy(x => x.Length).ToList(); lines.Insert(0, header); var dialogData = new DialogBoxData() { Id = data.playerId, MsgText = String.Join("\n", lines.ToArray()) }; Request_ShowDialog_SinglePlayer(dialogData); }); })); }
public override void Initialize(ModGameAPI dediAPI) { DediAPI = dediAPI; LogLevel = LogLevel.Message; Log($"**EmpyrionChatAutoResponder: loaded"); LoadConfiguration(); LogLevel = Configuration.Current.LogLevel; Event_ChatMessage += ChatResponder_Event_ChatMessage; }
public override void Initialize(ModGameAPI dediAPI) { GameAPI = dediAPI; LogLevel = EmpyrionNetAPIDefinitions.LogLevel.Debug; ReadPlayfields(); PlayfieldsWatcher = new FileSystemWatcher(Path.Combine(EmpyrionConfiguration.SaveGamePath, "Templates")); PlayfieldsWatcher.Created += (S, A) => ReadPlayfields(); PlayfieldsWatcher.Deleted += (S, A) => ReadPlayfields(); PlayfieldsWatcher.EnableRaisingEvents = true; }
public void Game_Start(ModGameAPI dediAPI) { GameAPI = dediAPI; players = new List <PlayerInfo>(); GameAPI.Console_Write("Death Messages by joemorin73."); GameAPI.Console_Write("Part of the Empyrion Mod Sample collection."); var filePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "Messages.yaml"; config = Config.Configuration.GetConfiguration(filePath); }
public void Game_Start(ModGameAPI dediAPI) { GameAPI = dediAPI; GameAPI.Console_Write($"ModClientDll: start"); CurrentConfig = new ConfigurationManager <Configuration>() { ConfigFilename = Path.Combine(Path.GetDirectoryName(Assembly.GetAssembly(GetType()).Location), "Configuration.xml") }; CurrentConfig.Load(); CurrentConfig.Current.EmpyrionToModPipeName = string.Format(CurrentConfig.Current.EmpyrionToModPipeName, Guid.NewGuid().ToString("N")); CurrentConfig.Current.ModToEmpyrionPipeName = string.Format(CurrentConfig.Current.ModToEmpyrionPipeName, Guid.NewGuid().ToString("N")); CurrentConfig.Save(); GameAPI.Console_Write($"ModClientDll (CurrentDir:{Directory.GetCurrentDirectory()}): Config:{CurrentConfig.ConfigFilename}"); InServerMessageHandler = new Dictionary <Type, Action <object> > { { typeof(EmpyrionGameEventData), M => HandleGameEvent((EmpyrionGameEventData)M) }, { typeof(ClientHostComData), M => HandleClientHostCommunication((ClientHostComData)M) }, { typeof(ModComData), M => HandleModCommunication((ModComData)M) } }; OutServer = new ClientMessagePipe(CurrentConfig.Current.EmpyrionToModPipeName) { log = GameAPI.Console_Write }; InServer = new ServerMessagePipe(CurrentConfig.Current.ModToEmpyrionPipeName) { log = GameAPI.Console_Write }; InServer.Callback = Msg => { if (InServerMessageHandler.TryGetValue(Msg.GetType(), out Action <object> Handler)) { Handler(Msg); } }; new Thread(() => { while (!Exit) { Thread.Sleep(1000); CheckHostProcess(); } }) { IsBackground = true }.Start(); new Thread(() => ReadGlobalStructureInfoForEvent()) { IsBackground = true }.Start(); GameAPI.Console_Write($"ModClientDll: started"); }
public void Game_Start(ModGameAPI dediAPI) { GameAPI = dediAPI; var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "Settings.yaml"; var config = Configuration.GetConfiguration <Configuration>(configFilePath); var modPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Extensions"; using (var catalog = new AggregateCatalog( new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()), new DirectoryCatalog(modPath, "*Mod.dll"))) { // iterate over all directories in .\Plugins dir and add all Plugin* dirs to catalogs foreach (var path in System.IO.Directory.EnumerateDirectories(modPath, "*", System.IO.SearchOption.TopDirectoryOnly)) { catalog.Catalogs.Add(new DirectoryCatalog(path, "*Mod.dll")); } _container = new CompositionContainer(catalog); try { this._container.ComposeParts(this); //using (_gameServerConnection = new GameServerConnection(config)) //{ _gameServerConnection = new GameServerConnection(config); foreach (var gameMod in _gameMods) { gameMod.Start(_gameServerConnection); } _gameServerConnection.Connect(); // // wait until the user presses Enter. // string input = Console.ReadLine(); // // foreach (var gameMod in _gameMods) // { // gameMod.Stop(); // } // } } catch (CompositionException compositionException) { GameAPI.Console_Write($"NCMR ModHost: {compositionException}"); } } }
public override void Initialize(ModGameAPI dediAPI) { DediAPI = dediAPI; LogLevel = LogLevel.Message; Log($"**EmpyrionForbiddenPlayfields: loaded"); LoadConfiuration(); LogLevel = Configuration.Current.LogLevel; TaskTools.Intervall(30000, () => UpdateFactionData().Wait()); TaskTools.Intervall(1000, () => TestNextPlayer()); }
public override void Initialize(ModGameAPI dediAPI) { GameAPI = dediAPI; OfflineWarpPlayer = new ConfigurationManager <ConcurrentDictionary <int, OfflineWarpPlayerData> >() { ConfigFilename = Path.Combine(EmpyrionConfiguration.SaveGameModPath, @"EWA\DB\OfflineWarpPlayer.json") }; OfflineWarpPlayer.Load(); Event_Player_Connected += GameplayManager_Event_Player_Connected; }
void ModInterface.Game_Start(ModGameAPI dediAPI) { this.LegacyInitialized = true; if (dediAPI == null) { return; } this.LegacyAPI = dediAPI; Broker.api = this.LegacyAPI; RunInitialize(); }
public void Game_Start(ModGameAPI dediAPI) { api = dediAPI; var currentDirectory = Directory.GetCurrentDirectory(); string codeBase = Assembly.GetExecutingAssembly().CodeBase; UriBuilder uri = new UriBuilder(codeBase); string path = Uri.UnescapeDataString(uri.Path); var assemblyDir = Path.GetDirectoryName(path); api.Console_Write($"starting dummy 1 from directory: {currentDirectory}"); api.Console_Write($"launched from assembly in directory: {assemblyDir}"); }
public void Game_Start(ModGameAPI modGameApi) { using (var reader = File.OpenText("epaconfig.yaml")) { var deserializer = new Deserializer(); _config = deserializer.Deserialize <ServerPluginConfiguration>(reader); } _modGameApi = modGameApi; _scriptManager = new ScriptManager(_config.scriptManager, this, _modGameApi); _httpManager = new HttpManager(_config.httpManager, _scriptManager, this); _scriptManager.HandleServerStartup(); _httpManager.StartServer(); }