Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d301955609 | ||
![]() |
264daf7515 |
@@ -94,27 +94,11 @@ namespace Torch.Server
|
||||
|
||||
_server.Init();
|
||||
|
||||
var uiThread = new Thread(() =>
|
||||
{
|
||||
var ui = new TorchUI(_server);
|
||||
if (!Config.Autostart && !Config.TempAutostart) return;
|
||||
|
||||
SynchronizationContext.SetSynchronizationContext(
|
||||
new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));
|
||||
|
||||
ui.ShowDialog();
|
||||
});
|
||||
|
||||
uiThread.SetApartmentState(ApartmentState.STA);
|
||||
uiThread.Start();
|
||||
|
||||
if (Config.Autostart || Config.TempAutostart)
|
||||
{
|
||||
Config.TempAutostart = false;
|
||||
_server.Start();
|
||||
}
|
||||
|
||||
uiThread.Join();
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task RunSteamCmdAsync(IConfiguration configuration)
|
||||
|
37
Torch.Server/Managers/UiManager.cs
Normal file
37
Torch.Server/Managers/UiManager.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Threading;
|
||||
using System.Windows.Threading;
|
||||
using JetBrains.Annotations;
|
||||
using Torch.Managers;
|
||||
|
||||
namespace Torch.Server.Managers;
|
||||
|
||||
public class UiManager(TorchServer torchInstance) : Manager(torchInstance)
|
||||
{
|
||||
[CanBeNull] private Thread _uiThread;
|
||||
[CanBeNull] private Dispatcher _dispatcher;
|
||||
|
||||
public override void Attach()
|
||||
{
|
||||
_uiThread = new Thread(() =>
|
||||
{
|
||||
var ui = new TorchUI(torchInstance);
|
||||
|
||||
_dispatcher = Dispatcher.CurrentDispatcher;
|
||||
|
||||
SynchronizationContext.SetSynchronizationContext(
|
||||
new DispatcherSynchronizationContext(_dispatcher));
|
||||
|
||||
ui.ShowDialog();
|
||||
});
|
||||
|
||||
_uiThread.SetApartmentState(ApartmentState.STA);
|
||||
_uiThread.Start();
|
||||
}
|
||||
|
||||
public override void Detach()
|
||||
{
|
||||
_dispatcher?.InvokeShutdown();
|
||||
if (Thread.CurrentThread != _uiThread)
|
||||
_uiThread?.Join();
|
||||
}
|
||||
}
|
@@ -56,6 +56,8 @@ namespace Torch.Server
|
||||
if (config.EntityManagerEnabled)
|
||||
AddManager(new EntityControlManager(this));
|
||||
AddManager(new RemoteAPIManager(this));
|
||||
if (!ApplicationContext.Current.IsService && !config.NoGui)
|
||||
AddManager(new UiManager(this));
|
||||
|
||||
var sessionManager = Managers.GetManager<ITorchSessionManager>();
|
||||
sessionManager.AddFactory(_ => new MultiplayerManagerDedicated(this));
|
||||
@@ -185,7 +187,7 @@ namespace Torch.Server
|
||||
|
||||
if (IsRunning || HasRun)
|
||||
{
|
||||
Restart();
|
||||
Restart(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -65,7 +65,8 @@ internal static class AssemblyRewriter
|
||||
{
|
||||
using var assembly = AssemblyDefinition.ReadAssembly(inputStream, new()
|
||||
{
|
||||
AssemblyResolver = resolver
|
||||
AssemblyResolver = resolver,
|
||||
ReadSymbols = true
|
||||
});
|
||||
foreach (var fieldDefinition in FindAllToRewrite(assembly.MainModule))
|
||||
{
|
||||
|
@@ -293,15 +293,20 @@ namespace Torch
|
||||
{
|
||||
}
|
||||
|
||||
private bool _disposed = false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void Destroy()
|
||||
{
|
||||
if (_disposed) return;
|
||||
Game.SignalDestroy();
|
||||
if (!Game.WaitFor(VRageGame.GameState.Destroyed))
|
||||
Log.Warn("Failed to wait for the game to be destroyed");
|
||||
Game = null;
|
||||
|
||||
Managers.Detach();
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
Reference in New Issue
Block a user