feat: start/stop server handling

The original app volume is also restored when the server is stopped.
This commit is contained in:
anavoi 2025-07-13 23:47:40 +02:00
commit 5eedbf2f1e
4 changed files with 35 additions and 7 deletions

View file

@ -67,20 +67,14 @@ Set CLI arguments: -ip, -port (optionally -maplist)
{
if (File.Exists(Helper.GameConfigPath))
{
Helper.hosting = true;
AudioListener.volume = 0; // mute game audio
try
{
Plugin.AddServerComp(); // add custom GBSU server component
GBSUServer.StartServer();
}
catch (Exception e)
{
PushError("Looks like you've caught a bug! Please send your log file to us :)\n" + e);
Helper.hosting = false;
Plugin.DestroyServerComp();
GBSUServer.StopServer();
}
}
else
@ -131,6 +125,13 @@ Make sure to download a file from the examples given and rename it to config.jso
{
Helper.FlipVSync();
}
if (Helper.hosting)
{
if (GUI.Button(new Rect(195f, 330f, 170f, 30f), "Stop server"))
{
GBSUServer.StopServer();
}
}
GUI.Label(new Rect(20f, 365f, 365f, 400f), $@"