public void Game_Exit()
        {
            Exit = true;
            GameAPI.Console_Write($"ModClientDll: Game_Exit {CurrentConfig.Current.ModToEmpyrionPipeName}");
            OutServer?.SendMessage(new ClientHostComData()
            {
                Command = ClientHostCommand.Game_Exit
            });

            if (!ExposeShutdownHost && CurrentConfig.Current.AutoshutdownModHost && mHostProcess != null)
            {
                try
                {
                    try { mHostProcess.CloseMainWindow(); } catch { }
                    CurrentConfig.Current.HostProcessId = 0;
                    CurrentConfig.Save();

                    Thread.Sleep(1000);
                }
                catch (Exception Error)
                {
                    GameAPI.Console_Write($"ModClientDll: Game_Exit {Error}");
                }
            }

            InServer?.Close();
            OutServer?.Close();
        }
예제 #2
0
        void CheckHostProcess()
        {
            if (Exit)
            {
                return;
            }

            if (ExistsStopFile())
            {
                try
                {
                    if (mHostProcess != null && !mHostProcess.HasExited)
                    {
                        GameAPI.Console_Write($"ModClientDll: stop.txt found");

                        OutServer?.SendMessage(new ClientHostComData()
                        {
                            Command = ClientHostCommand.Game_Exit
                        });
                        Thread.Sleep(1000);

                        InServer?.Close();
                        OutServer?.Close();

                        GameAPI.Console_Write($"ModClientDll: stopped");
                    }
                }
                catch { }

                return;
            }

            if (CurrentConfig.Current.AutostartModHostAfterNSeconds == 0 || !CurrentConfig.Current.AutostartModHost)
            {
                return;
            }
            try { if (mHostProcess != null && !mHostProcess.HasExited)
                  {
                      return;
                  }
            } catch { }

            if (!mHostProcessAlive.HasValue)
            {
                mHostProcessAlive = DateTime.Now;
            }
            if ((DateTime.Now - mHostProcessAlive.Value).TotalSeconds <= CurrentConfig.Current.AutostartModHostAfterNSeconds)
            {
                return;
            }

            mHostProcessAlive = null;

            StartModToEmpyrionPipe();
            StartHostProcess();
            StartEmpyrionToModPipe();
        }
예제 #3
0
 private void StartEmpyrionToModPipe()
 {
     try
     {
         try { OutServer?.Close(); } catch { }
         Thread.Sleep(1000);
         OutServer = new ClientMessagePipe(CurrentConfig.Current.EmpyrionToModPipeName)
         {
             log = GameAPI.Console_Write
         };
     }
     catch (Exception Error)
     {
         GameAPI.Console_Write($"ModClientDll: ClientMessagePipe '{CurrentConfig.Current.EmpyrionToModPipeName} -> {Error}'");
     }
 }