Compare commits

...

36 commits

Author SHA1 Message Date
3964e268ee ci: bump SDK version 2025-08-11 00:30:52 +02:00
ea77c98c2f style: format code 2025-07-14 23:31:20 +02:00
3f15516985 1.1.0 2025-07-14 00:16:40 +02:00
60706fb255 fix: make sure volume is set to 0 when entering server mode 2025-07-14 00:15:04 +02:00
34d9e9261e feat: added "menu" panic button
This avoids restarting the game when encountering an unknown issue.
2025-07-14 00:14:11 +02:00
b9a7a1c479 fix: catch more edge cases 2025-07-13 23:55:54 +02:00
5eedbf2f1e feat: start/stop server handling
The original app volume is also restored when the server is stopped.
2025-07-13 23:47:40 +02:00
962bcaf199 perf: removed useless info logging 2025-07-13 23:33:10 +02:00
8132f69ed2 fix(breaking): better handling of the server rotation config
The config path was also changed to `BepInEx/config/GBSU/config.json`

Tracks the -maplist argument
2025-07-13 23:32:42 +02:00
4771a41fa7 refactor: unused import 2025-07-13 21:49:21 +02:00
20ca020d02 fix: remove hosting status if it fails 2025-07-13 16:17:37 +02:00
0cb7131435 refactor: wip 2025-07-13 16:16:41 +02:00
4b61948f68 docs: added known issues section 2025-07-13 13:27:51 +02:00
02361d278d refactor: avoid setting a variable (tracking the current scene) changing its value more often than it can be displayed 2025-07-13 12:36:26 +02:00
06c4eba087 1.0.3 2025-07-13 12:23:33 +02:00
31e2cda45b refactor: use MyPluginInfo for plugin attributes 2025-07-13 12:18:40 +02:00
2619d05374 fix: vsync toggle 2025-07-13 12:09:32 +02:00
2e5d5a9942 fix: remove useless cli arguments from in-game guide 2025-07-13 12:06:27 +02:00
b4ffbc0a0d feat: in-game error display 2025-07-12 23:39:20 +02:00
9599a6d652 feat: make 5999 the default serverport 2025-07-12 23:35:32 +02:00
4b7b22aad4 feat: create config folder at runtime 2025-07-12 23:33:41 +02:00
05256ecd8a fix: keep only one server comp 2025-07-12 23:28:33 +02:00
5aa379ca9d fix: null check for localSingleGang 2025-07-12 19:15:51 +02:00
bdc26f2528 1.0.2 2025-03-15 22:21:27 +01:00
89fcf1ed7b refactor: bump severity from info to warning 2025-03-15 22:20:33 +01:00
5c6a96b800 refactor: remove unused import 2025-03-15 22:19:21 +01:00
abe74e4ea5 style: fix spelling mistakes
Add .vscode/settings.json for VSCode/VSCodium users using cspell
2025-03-15 22:19:03 +01:00
4a5c665667 style: remove trailing dot 2025-03-15 22:15:24 +01:00
3258fcc4f5 docs: added contact info for community feedback 2025-03-15 22:14:51 +01:00
6dd459582f 1.0.1 2025-03-15 21:52:46 +01:00
3acfb446d1 perf: deprecate internalCurrentState tracking
It isn't used at the moment.
2025-03-15 21:52:34 +01:00
86a95a8e88 style: minor formatting improvements 2025-03-15 21:48:38 +01:00
c095d824ab fix: resize menu for better score visibility 2025-03-15 21:44:45 +01:00
7af5036fb1 docs: added server config files 2025-03-15 21:42:45 +01:00
0fe4de92fa style: in-game guide formatting
Make the in-game guide look nicer by formatting

Add link to source code for further reference
2025-03-15 21:40:32 +01:00
32080028d6 docs: clarify readme and add new instructions 2025-03-15 21:34:59 +01:00
13 changed files with 679 additions and 174 deletions

28
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,28 @@
{
"cSpell.words": [
"allmaps",
"anavoi",
"Behaviour",
"currentmap",
"Dont",
"Gaboule",
"gamemode",
"GBSU",
"gmenu",
"hlapi",
"maplist",
"netstandard",
"Newtonsoft",
"playercount",
"protontricks",
"rotationconfig",
"serverip",
"serverpassword",
"serverport",
"vsync",
"winecfg",
"WINEDLLOVERRIDES",
"winhttp",
"ZeroTier"
]
}

32
Addons/GBSUClient.cs Normal file
View file

@ -0,0 +1,32 @@
using GB.Core;
using GB.Networking.Utils;
using GB.Platform.Lobby;
using UnityEngine;
namespace GBSU.Addons;
public class GBSUClient : MonoBehaviour
{
public static void JoinServer(string serverip, int serverport)
{
if (!Helper.hosting)
{
LobbyManager.Instance.LobbyStates.IP = serverip;
LobbyManager.Instance.LobbyStates.Port = serverport;
LobbyManager.Instance.LobbyStates.CurrentState = LobbyState.State.Ready | LobbyState.State.InGame;
LobbyManager.Instance.LocalBeasts.SetupNetMemberContext(true);
MonoSingleton<Global>.Instance.UNetManager.LaunchClient(serverip, serverport);
}
else
{
GBSUGui.PushError("You are currently hosting a game! Please stop your server before attempting to join.");
}
}
// this method should be used when something has went wrong
// because players can just use the escape menu to exit
public static void DisconnectFromServer()
{
GBNetUtils.DisconnectSelf(false);
}
}

View file

@ -1,10 +1,7 @@
using System;
using System.IO;
using BepInEx; using BepInEx;
using CoreNet.Config;
using GB.Config;
using GB.Core;
using GB.Game;
using GB.Platform.Lobby; using GB.Platform.Lobby;
using HarmonyLib;
using UnityEngine; using UnityEngine;
#pragma warning disable IDE0051 // Private member is unused #pragma warning disable IDE0051 // Private member is unused
@ -14,31 +11,13 @@ namespace GBSU.Addons;
public class GBSUGui : MonoBehaviour public class GBSUGui : MonoBehaviour
{ {
private bool menu_shown; private bool menu_shown;
private static bool error_shown;
//private string _currentMap; //private string _currentMap;
public Rect gmenu = new(Screen.width / 2, 0, 385f, 590f); public Rect gmenu = new(Screen.width / 2, 0, 385f, 690f);
public Rect error_dialog = new(Screen.width / 2, 0, 520f, 175f);
private static string error_msg = "Unknown error!";
readonly IInputSystem inputSystem = UnityInput.Current; readonly IInputSystem inputSystem = UnityInput.Current;
string serverip = null;
int serverport = 0;
string currentmap;
string _internalCurrentState;
Traverse _internalCurrentStateTraverse;
int vsync_switch;
bool hosting = false;
private void Start()
{
if (CommandLineParser.Instance.KeyExists("-ip"))
{
serverip = CommandLineParser.Instance.GetValueForKey("-ip", true);
}
if (CommandLineParser.Instance.KeyExists("-port"))
{
int.TryParse(CommandLineParser.Instance.GetValueForKey("-port", true), out serverport);
}
_internalCurrentStateTraverse = Traverse.Create(nameof(GameManagerNew)).Field("internalCurrentState");
vsync_switch = QualitySettings.vSyncCount;
}
private void Update() private void Update()
{ {
if (inputSystem.GetKeyDown(KeyCode.RightShift)) if (inputSystem.GetKeyDown(KeyCode.RightShift))
@ -46,9 +25,6 @@ public class GBSUGui : MonoBehaviour
//Plugin.Log.LogInfo("Toggling GBSU menu..."); //Plugin.Log.LogInfo("Toggling GBSU menu...");
ToggleMenu(); ToggleMenu();
} }
currentmap = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
_internalCurrentState = _internalCurrentStateTraverse.GetValue() as string;
} }
private void ToggleMenu() private void ToggleMenu()
@ -70,53 +46,66 @@ public class GBSUGui : MonoBehaviour
GUI.skin.label.alignment = TextAnchor.UpperLeft; GUI.skin.label.alignment = TextAnchor.UpperLeft;
GUILayout.Label($@"==Guide== GUILayout.Label($@"==Guide==
CLI arguments have to be set to join or host: -ip, -port, -servername, -serverpassword Set CLI arguments: -ip, -port (optionally -maplist)
[Hosting] [Hosting]
1. Create a config in Gang Beasts_Data/Config/Rotation/config.json 1. Create a config in Gang Beasts_Data/Config/Rotation/config.json
2.Press the 'Host' button while in the Main Menu. 2. Press the 'Host' button while in the Main Menu
[Joining] [Joining]
1. Go to Online 1. Go to Online
2. Press the 'Join' button."); 2. Press the 'Join' button");
if (GUI.Button(new Rect(320f, 10f, 55f, 30f), "KILL")) if (GUI.Button(new Rect(320f, 10f, 55f, 30f), "KILL"))
{ {
Application.Quit(0); Application.Quit(0);
} }
if (serverip != null && serverport != default) if (GUI.Button(new Rect(320f, 45f, 55f, 30f), "Menu"))
{
Helper.SwitchToMenu();
}
if (Helper.serverip != null)
{ {
if (GUI.Button(new Rect(20f, 260f, 170f, 30f), "Host")) if (GUI.Button(new Rect(20f, 260f, 170f, 30f), "Host"))
{ {
if (LobbyManager.Instance.LobbyStates.SelfState == LobbyState.Game.Menu) if (LobbyManager.Instance.LobbyStates.SelfState == LobbyState.Game.Menu)
{ {
hosting = true; if (File.Exists(Helper.GameConfigPath))
{
AudioListener.volume = 0; // mute game audio try
{
Plugin.AddServerComp(); // add custom GBSU server component GBSUServer.StartServer();
}
RotationConfig gameConfig = GBConfigLoader.LoadRotationConfig("config.json", true); // load rotation config from Config/Rotation/config.json catch (Exception e)
ServerConfig serverConfig = NetConfigLoader.LoadServerConfig(); // load default server config, becauuse it can be overrided by args like -ip and -port {
MonoSingleton<Global>.Instance.UNetManager.LaunchServer(serverConfig); // launch the server with the server config PushError("Looks like you've caught a bug! Please send your log file to us :)\n" + e);
MonoSingleton<Global>.Instance.UNetManager.GetComponent<GameManagerNew>().ChangeRotationConfig(gameConfig, 0); // set server's rotationconfig GBSUServer.StopServer();
}
}
else
{
PushError(@$"No config.json could be found in {Helper.RotationFolderPath}
Make sure to download a file from the examples given and rename it to config.json.
{Helper.FilesInRotationDir()}");
}
}
else
{
PushError("Please stay on the main menu to begin hosting. Tip: You might need to exit your lobby.");
} }
} }
if (GUI.Button(new Rect(195f, 260f, 170f, 30f), "Join")) if (GUI.Button(new Rect(195f, 260f, 170f, 30f), "Join"))
{ {
if (LobbyManager.Instance.LobbyStates.SelfState == LobbyState.Game.Online) if (LobbyManager.Instance.LobbyStates.SelfState == LobbyState.Game.Online)
{ {
if (!hosting && serverip != null && serverport != 0) GBSUClient.JoinServer(Helper.serverip, Helper.serverport);
{ }
LobbyManager.Instance.LobbyStates.IP = serverip; else
LobbyManager.Instance.LobbyStates.Port = serverport; {
LobbyManager.Instance.LobbyStates.CurrentState = LobbyState.State.Ready | LobbyState.State.InGame; PushError("Failed to join lobby! Please select the Online option in-game before joining.");
LobbyManager.Instance.LocalBeasts.SetupNetMemberContext(true);
MonoSingleton<Global>.Instance.UNetManager.LaunchClient(serverip, serverport);
}
} }
} }
} }
if (GUI.Button(new Rect(20f, 295f, 170f, 30f), "Cap FPS to 60")) if (GUI.Button(new Rect(20f, 295f, 170f, 30f), "Cap FPS to 60"))
{ {
Application.targetFrameRate = 60; Application.targetFrameRate = 60;
@ -127,33 +116,49 @@ CLI arguments have to be set to join or host: -ip, -port, -servername, -serverpa
} }
if (GUI.Button(new Rect(20f, 330f, 170f, 30f), "Toggle VSync")) if (GUI.Button(new Rect(20f, 330f, 170f, 30f), "Toggle VSync"))
{ {
if (vsync_switch == 0) Helper.FlipVSync();
}
if (Helper.hosting)
{
if (GUI.Button(new Rect(195f, 330f, 170f, 30f), "Stop server"))
{ {
vsync_switch = 1; GBSUServer.StopServer();
} }
else
{
vsync_switch = 0;
}
QualitySettings.vSyncCount = vsync_switch;
} }
GUI.Label(new Rect(20f, 365f, 365f, 400f), $@"Current map: {currentmap} GUI.Label(new Rect(20f, 365f, 365f, 400f), $@"
Current map: {UnityEngine.SceneManagement.SceneManager.GetActiveScene().name}
Lobby State: {LobbyManager.Instance.LobbyStates.SelfState} Lobby State: {LobbyManager.Instance.LobbyStates.SelfState}
Game State: {_internalCurrentState} VSync: {QualitySettings.vSyncCount}
Vsync: {QualitySettings.vSyncCount}
Target FPS: {Application.targetFrameRate} Target FPS: {Application.targetFrameRate}
{UpdateScoreDisplay()} {UpdateScoreDisplay()}
Made with <3 by anavoi at Gaboule Community (gaboule.com)");
Made with <3 by anavoi at Gaboule Community
Free and open-source software under GPLv3.
Our source code is available at git.gaboule.com/Gaboule/GBSU
Please refer to the documentation for more information.");
GUI.DragWindow(new Rect(0, 0, 10000, 10000)); GUI.DragWindow(new Rect(0, 0, 10000, 10000));
} }
private void ShowError(int window)
{
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
GUILayout.Label(error_msg);
if (GUI.Button(new Rect(420f, 135f, 85f, 30f), "Close"))
{
error_shown = false;
}
GUI.DragWindow(new Rect(0, 0, 10000, 10000));
}
private string UpdateScoreDisplay() private string UpdateScoreDisplay()
{ {
if (hosting) if (Helper.hosting)
{ {
string scoreString = "Score:\n"; string scoreString = "Score:\n";
foreach (var pair in Plugin.GameScore) foreach (var pair in Plugin.GameScore)
@ -165,11 +170,25 @@ Made with <3 by anavoi at Gaboule Community (gaboule.com)");
return null; return null;
} }
public static void PushError(string message)
{
Plugin.Log.LogError(message);
// Push this error to the UI
error_msg = message;
error_shown = true;
}
public void OnGUI() public void OnGUI()
{ {
if (menu_shown) if (menu_shown)
{ {
gmenu = GUILayout.Window(121, gmenu, ShowOurWindow, $"{Plugin.PluginName} [{Plugin.PluginVersion}]"); gmenu = GUILayout.Window(121, gmenu, ShowOurWindow, $"{MyPluginInfo.PLUGIN_NAME} [{MyPluginInfo.PLUGIN_VERSION}]");
}
if (error_shown)
{
error_dialog = GUILayout.Window(122, error_dialog, ShowError, "An error occurred!");
} }
} }
} }

View file

@ -1,3 +1,6 @@
using CoreNet.Config;
using GB.Config;
using GB.Core;
using GB.Game; using GB.Game;
using HarmonyLib; using HarmonyLib;
using UnityEngine; using UnityEngine;
@ -23,12 +26,45 @@ public class GBSUServer : MonoBehaviour
//_gmInit = AccessTools.Method(typeof(GameMode), "Init"); //_gmInit = AccessTools.Method(typeof(GameMode), "Init");
localSingleGang = Traverse.Create(nameof(GameMode)).Field("localSingleGang"); localSingleGang = Traverse.Create(nameof(GameMode)).Field("localSingleGang");
gameTimer = Traverse.Create(nameof(GameMode)).Field("timer"); gameTimer = Traverse.Create(nameof(GameMode)).Field("timer");
AudioListener.volume = 0; // mute game audio
} }
void SetLocalGangToOff() void SetLocalGangToOff()
{ {
localSingleGang.SetValue(false); localSingleGang?.SetValue(false);
} }
public static void StartServer()
{
if (!Helper.hosting)
{
Helper.hosting = true;
Plugin.AddServerComp(); // add custom GBSU server component
RotationConfig gameConfig = GBConfigLoader.LoadRotationConfig(null); // the argument doesn't matter as we do stuff in the method
ServerConfig serverConfig = NetConfigLoader.LoadServerConfig(); // load default server config, because it can be overridden by args like -ip and -port
MonoSingleton<Global>.Instance.UNetManager.LaunchServer(serverConfig); // launch the server with the server config
MonoSingleton<Global>.Instance.UNetManager.GetComponent<GameManagerNew>().ChangeRotationConfig(gameConfig, 0); // set server's rotationconfig
}
}
public static void StopServer()
{
// WIP: At the moment the only way to stop the server is to exit/kill the game
Helper.hosting = false;
AudioListener.volume = Helper.saved_volume; // restore volume
// stop network listener
MonoSingleton<Global>.Instance.UNetManager.StopServer();
// destroy GBSU server comp
Plugin.DestroyServerComp();
// go back to main menu
Helper.SwitchToMenu();
}
/* /*
public string GetRemainingRoundTime() public string GetRemainingRoundTime()
{ {

View file

@ -1,9 +1,21 @@
using System; using System;
using System.IO;
using GB.Core;
using GB.Networking.Utils;
using GB.Platform.Lobby;
using UnityEngine;
using UnityEngine.Analytics; using UnityEngine.Analytics;
using UnityEngine.SceneManagement;
namespace GBSU.Addons; namespace GBSU.Addons;
public class Helper public class Helper
{ {
public static string RotationFolderPath = BepInEx.Paths.BepInExRootPath + "/config/GBSU/";
public static string GameConfigPath = RotationFolderPath + "config.json";
public static string serverip = null;
public static int serverport = 5999;
public static bool hosting = false;
public static float saved_volume;
public static void DisableAnalytics() public static void DisableAnalytics()
{ {
// Try disabling analytics https://docs.unity3d.com/ScriptReference/Analytics.Analytics-deviceStatsEnabled.html // Try disabling analytics https://docs.unity3d.com/ScriptReference/Analytics.Analytics-deviceStatsEnabled.html
@ -14,7 +26,93 @@ public class Helper
} }
catch (Exception e) catch (Exception e)
{ {
Plugin.Log.LogInfo("Failed to disable analytics: " + e.Message); Plugin.Log.LogWarning("Failed to disable analytics: " + e.Message);
}
}
public static void CreateRotationFolder()
{
try
{
Plugin.Log.LogInfo("Creating rotation folder at " + RotationFolderPath);
Directory.CreateDirectory(RotationFolderPath);
}
catch (Exception e)
{
Plugin.Log.LogError("Could not create rotation folder path: " + e.Message);
}
}
public static string FilesInRotationDir()
{
// https://stackoverflow.com/a/14877330
DirectoryInfo d = new(RotationFolderPath);
FileInfo[] files = d.GetFiles();
int number = files.Length;
// no files?
if (number == 0)
{
return @"No files were found in the directory.";
}
else
{
string names = "";
foreach (FileInfo file in files)
{
names = file.Name + " " + names;
}
return $"There are {number} files: {names}";
}
}
public static void FlipVSync()
{
if (QualitySettings.vSyncCount == 0)
{
QualitySettings.vSyncCount = 1;
}
else
{
QualitySettings.vSyncCount = 0;
}
}
public static void CheckCustomRotationPath()
{
// Did the host request to use their own rotation config path?
if (CommandLineParser.Instance.KeyExists("-maplist"))
{
GameConfigPath = CommandLineParser.Instance.GetValueForKey("-maplist");
Plugin.Log.LogInfo("Set custom rotation config path at " + GameConfigPath);
}
}
public static void SwitchToMenu()
{
if (hosting)
{
GBSUGui.PushError("Please press the Stop server button instead!");
}
else
{
// uhm, time to panic!
// let's begin by disconnecting if theres an active connection
try
{
GBNetUtils.DisconnectSelf(false);
}
catch (Exception e)
{
Plugin.Log.LogWarning("Couldn't disconnect from server:\n" + e);
}
// go back to main menu
SceneManager.LoadScene(Global.MENU_SCENE_NAME);
// make sure our lobby state is menu
LobbyManager.Instance.LobbyStates.SelfState = LobbyState.Game.Menu;
} }
} }
} }

View file

@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>GBSU</AssemblyName> <AssemblyName>GBSU</AssemblyName>
<Product>Gang Beasts Server Utility</Product> <Product>Gang Beasts Server Utility</Product>
<Version>1.0.0</Version> <Version>1.1.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<RestoreAdditionalProjectSources> <RestoreAdditionalProjectSources>
@ -42,5 +42,8 @@
<Reference Include="UnityEngine.CoreModule"> <Reference Include="UnityEngine.CoreModule">
<HintPath>ref/UnityEngine.CoreModule.dll</HintPath> <HintPath>ref/UnityEngine.CoreModule.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json.dll">
<HintPath>ref/Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
</Project> </Project>

35
Patches/ConfigLoader.cs Normal file
View file

@ -0,0 +1,35 @@
using System;
using System.IO;
using GB.Config;
using GBSU.Addons;
using HarmonyLib;
using Newtonsoft.Json;
namespace GBSU.Patches;
[HarmonyPatch]
class ConfigLoaderPatch
{
[HarmonyPatch(typeof(GBConfigLoader), "LoadRotationConfig")]
private static bool Prefix(ref RotationConfig __result)
{
string text = ""; // contents of file
Plugin.Log.LogInfo("Loading custom rotation config...");
// Reading from file
try
{
text = File.ReadAllText(Helper.GameConfigPath);
Plugin.Log.LogDebug("Provided rotation config:\n" + text);
RotationConfig rc = JsonConvert.DeserializeObject<RotationConfig>(text);
__result = rc;
}
catch (Exception e)
{
GBSUGui.PushError("Couldn't read game config file. A few details:\n" + e);
}
return false; // skip
}
}

View file

@ -50,7 +50,6 @@ class HandleScorePatch
Plugin.Log.LogDebug("Done processing all scores!"); Plugin.Log.LogDebug("Done processing all scores!");
} }
Plugin.Log.LogInfo("Not letting HandleScore run...");
return false; return false;
} }
} }

View file

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using BepInEx; using BepInEx;
using BepInEx.Logging; using BepInEx.Logging;
@ -11,7 +11,7 @@ using UnityEngine;
namespace GBSU; namespace GBSU;
[BepInPlugin(PluginGUID, PluginName, PluginVersion)] [BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
[BepInProcess("Gang Beasts.exe")] [BepInProcess("Gang Beasts.exe")]
public class Plugin : BaseUnityPlugin public class Plugin : BaseUnityPlugin
{ {
@ -40,15 +40,40 @@ public class Plugin : BaseUnityPlugin
{ {
// Plugin startup logic // Plugin startup logic
Log = base.Logger; Log = base.Logger;
Log.LogInfo($"\n------\nPlugin {PluginName} [{PluginVersion}] is loaded!\n------\n"); Log.LogInfo($"\n------\nPlugin {MyPluginInfo.PLUGIN_NAME} [{MyPluginInfo.PLUGIN_VERSION}] is loaded!\n------\n");
HarmonyFileLog.Enabled = true; HarmonyFileLog.Enabled = true;
var harmony = new Harmony(PluginGUID); var harmony = new Harmony(MyPluginInfo.PLUGIN_GUID);
harmony.PatchAll(Assembly.GetExecutingAssembly()); harmony.PatchAll(Assembly.GetExecutingAssembly());
GBSUCompInit(); GBSUCompInit();
Helper.DisableAnalytics(); // thank me later Helper.DisableAnalytics(); // thank me later
// create server config path
Helper.CreateRotationFolder();
Log.LogDebug("Server game config should be found at " + Helper.GameConfigPath);
// Parse CLI arguments
if (CommandLineParser.Instance.KeyExists("-ip"))
{
Helper.serverip = CommandLineParser.Instance.GetValueForKey("-ip", false);
}
else
{
GBSUGui.PushError("Couldn't find the -ip CLI argument. Please refer to the documentation.");
}
if (CommandLineParser.Instance.KeyExists("-port"))
{
int.TryParse(CommandLineParser.Instance.GetValueForKey("-port", false), out Helper.serverport);
}
// "-maplist" CLI
Helper.CheckCustomRotationPath();
// store app volume in a variable to restore it if needed
Helper.saved_volume = AudioListener.volume;
} }
private static void GBSUCompInit() private static void GBSUCompInit()
@ -62,10 +87,22 @@ public class Plugin : BaseUnityPlugin
public static void AddServerComp() public static void AddServerComp()
{ {
DestroyServerComp();
Log.LogDebug("Adding GBSUServer component");
GBSUCompContainer.AddComponent<GBSUServer>(); GBSUCompContainer.AddComponent<GBSUServer>();
} }
public const string PluginGUID = "com.gaboule.plugins.gbsu"; public static void DestroyServerComp()
public const string PluginName = "Gang Beasts Server Utility"; {
public const string PluginVersion = "1.0.0"; Component[] comps = GBSUCompContainer.GetComponents(typeof(Component));
foreach (var comp in comps)
{
Log.LogDebug("iterating thru singleton comps");
if (comp is GBSUServer)
{
Log.LogDebug("GBSUServer component was found! Destroying it");
Destroy(comp);
}
}
}
} }

View file

@ -1,55 +1,55 @@
# GBSU (Gang Beasts Server Utility) # GBSU (Gang Beasts Server Utility)
This mod allows you to connect to a Gang Beast server in recent versions (through LAN or Internet) by utilizing developer methods found in the game assembly. This mod allows you to connect to a Gang Beasts server in recent versions (through LAN or Internet) by utilizing developer methods found in the game assembly.
**NOTICE: This is not a "Cement" mod, and we don't want to be affiliated with their developers. This mod is standalone, and will work best on its own!** **NOTICE: This is not a "Cement" mod, and we don't want to be affiliated with their developers. This mod is standalone, and will work best on its own!**
# Features # Features
- LAN (ethernet switches at LAN parties) and Online (port forwarding, Zerotier, Wireguard) multiplayer - LAN (Ethernet switches at LAN parties) and Online (port forwarding, ZeroTier, Wireguard) multiplayer
- Custom score handling made by the server (we don't want to use the game's score handler) - Custom score handling made by the server (we don't want to use the game's score handler)
# Installation # Installation
The mod is made for the game version **1.17.39_WS_8af7688** running on Unity **v2020.3.5.8426922** (check your version in the Settings menu in-game) 1. Check your game version in the "Settings" menu in-game. If the version is **1.17.39_WS_8af7688**, we fully support it.
Other versions *MIGHT* work with the mod. Try at your own risk.* 2. Check whether your game is Mono or IL2CPP: Go to 'Gang Beasts_Data'
- If you have a folder called `MonoBleedingEdge` or the `Gang Beasts_Data/Managed` folder contains a file called 'Assembly-CSharp.dll': your game is **Mono**. Continue to [Mono instructions](#mono).
1. Check whether your game is Mono or IL2CPP: Go to 'Gang Beasts_Data' - If you have a il2cpp_data folder: your game is **IL2CPP**. Continue to [IL2CPP instructions](#il2cpp).
- If you have a il2cpp_data folder: your game is **IL2CPP**
- If you have a folder called `MonoBleedingEdge` or the `Gang Beasts_Data/Managed` folder contains a file called 'Assembly-CSharp.dll': your game is **Mono**
2. **Follow the instructions based on the game type:**
## Mono ## Mono
Go to https://github.com/BepInEx/BepInEx/releases and get the latest stable release for Mono x64 (on Windows). 1. [Download the latest **BepInEx 5 stable** release for Mono x64](https://github.com/BepInEx/BepInEx/releases). As of March 2025, we recommend getting `BepInEx_win_x64_5.4.23.2.zip`
2. Extract the zip file contents into your root game folder (where the Gang Beasts.exe file is, and not in the 'Gang Beasts_Data' folder!)
1. As of March 2025, what we recommend doing is getting `BepInEx_win_x64_5.4.23.2.zip`.
2. Extract the zip file contents into your root game folder (not in the 'Gang Beasts_Data' folder!)
3. Launch the game once. 3. Launch the game once.
4. Get the mod from our releases page. 4. Get the mod from our [releases page](https://git.gaboule.com/Gaboule/GBSU/releases).
5. Put the .dll file in the `BepInEx/plugins` folder. 5. Put the .dll file in the `BepInEx/plugins` folder.
6. Launch the game with launch arguments `-ip 1.2.3.4` and `-port 5999` with the IP address and port of the server you want to host or connect to. 6. Launch the game with launch arguments `-ip 1.2.3.4` and `-port 5999` with the IP address and port of the server you want to host or connect to.
7. You're good to go! Learn how to use the mod in [usage](#usage) - To set those arguments on Steam, [please refer to this guide](https://help.steampowered.com/en/faqs/view/7D01-D2DD-D75E-2955).
7. You're good to go! Learn how to use the mod in [usage](#usage).
## IL2CPP ## IL2CPP
**WIP**: The mod will be ported to MelonLoader and recent game versions in the future. **WIP**: You're currently out of luck! The mod doesn't support your game version at the moment. It will be ported to MelonLoader in the future. Try downgrading your game by getting older versions in Steam Betas or by using [DepotDownloader](https://github.com/SteamRE/DepotDownloader).
# Usage # Usage
Press `Right Shift` to open the mod GUI. Because of how the game is made, you need to be very careful when executing the steps else you will need to restart it. (will be fixed in future versions) Press `Right Shift` to open the mod GUI. Because of how the game is made, you need to be very careful when executing the steps else you will need to restart it. (will be fixed in future versions)
## Server (host) ## Server (host)
1. Open the mod menu and press **Host** while you're in the main menu. ### Setting up the server
2. Don't pay attention to what's displayed on the game. It will be an infinite loading screen after the first round. 1. Open the `BepInEx` folder in the "server" game instance files.
2. Create a `GBSU` folder in `config`.
3. Download the [one of the config files](https://git.gaboule.com/Gaboule/GBSU/src/branch/main/docs/configs) and place it inside the `GBSU` folder.
4. Rename the file to `config.json`
**Tip: your config file can also be anywhere else! Use the -maplist argument followed by the path to the file,** for example `-ip 192.168.1.2 -port 5999 -maplist "/home/user/mycustomconfig.json"`
### Configuring your custom server settings
* If you set `"random": true`, the map order will be randomized.
* Some maps may have different names in-game compared to their actual titles. Make sure to refer to the [`allmaps` configs](https://git.gaboule.com/Gaboule/GBSU/src/branch/main/docs/configs) for the map names.
### Launching the server
Once the config file is in place, host your server by pressing the **Host** button in the mod menu. Don't pay attention to what's displayed on the game. It will be an infinite loading screen after the first round.
## Client (player) ## Client (player)
1. In the game menu, choose **Online**. 1. In the game menu, choose **Online**.
2. Make sure to use a different color than your friends. 2. If you're planning to team up with friends, make sure your server config is set to the `gang` gamemode and choose a shared color. Otherwise, use a different color than your friends.
3. Open the mod menu and press **Join**. 3. Open the mod menu and press **Join**.
# Known Issues
- Scores tab on the server is expected be wrong. This is a temporary implementation and the scores will be reworked.
- The server is not headless.
- If you want to play on your server, you need to launch a different game instance. It is not possible to connect to the server after launching it at the moment.
- Getting the current scene isn't the most efficient way at the moment.
# Troubleshooting # Troubleshooting
## I press the Host/Join button and nothing works! ## I press the Host/Join button and nothing works!
1. Make sure you're in Online mode if you're **joining** a server. 1. Make sure you're in Online mode if you're **joining** a server.
@ -64,8 +64,19 @@ On Steam, simply put `WINEDLLOVERRIDES="winhttp.dll=n,b" %command%` in your laun
If it's still not working, try using `winecfg` for your prefix or `protontricks` and go to the libraries tab in Wine Configuration. Simply add `winhttp` as an override and check if it's correctly set as "native, then builtin" (or "n,b"). If it's still not working, try using `winecfg` for your prefix or `protontricks` and go to the libraries tab in Wine Configuration. Simply add `winhttp` as an override and check if it's correctly set as "native, then builtin" (or "n,b").
# Known issues
- This mode uses the game's netcode. It is poorly made, and you get noticeable latency on localhost (RTT is 10ms). It seems that there's no client-side prediction.
- The custom score handler only tracks through colors, and is only visible on the host side.
# Contact us
## Need help?
Ask us on [Matrix](https://matrix.to/#/#gbsu:gaboule.com).
## Feature requests or bug reports
Want a new feature? Found a bug? [Open an issue!](https://git.gaboule.com/Gaboule/GBSU/issues) Please note that a Gaboule account is currently required. This will change once Forgejo supports federation. Alternatively, feel free to reach out to us for general feedback or questions.
# Developer information # Developer information
- The mod is made for BepInEx 5 - The mod is made for BepInEx 5
- The targeted Unity version is `2020.3.5f1` - The targeted Unity version is `2020.3.5f1`
- The TFM is `netstandard2.0` - The TFM is `netstandard2.0`
- The mod is built using .NET SDK `9.0.103` - The mod is built using .NET SDK `9.0.304`

View file

@ -0,0 +1,93 @@
{
"random": true,
"games": [
{
"mode": "gang",
"map": "rooftop"
},
{
"mode": "gang",
"map": "ring"
},
{
"mode": "gang",
"map": "blimp"
},
{
"mode": "gang",
"map": "containers"
},
{
"mode": "gang",
"map": "elevators"
},
{
"mode": "gang",
"map": "girders"
},
{
"mode": "gang",
"map": "gondola"
},
{
"mode": "gang",
"map": "grind"
},
{
"mode": "gang",
"map": "incinerator"
},
{
"mode": "gang",
"map": "ring"
},
{
"mode": "gang",
"map": "towers"
},
{
"mode": "gang",
"map": "train"
},
{
"mode": "gang",
"map": "trucks"
},
{
"mode": "gang",
"map": "aquarium"
},
{
"mode": "gang",
"map": "billboard"
},
{
"mode": "gang",
"map": "buoy"
},
{
"mode": "gang",
"map": "chute"
},
{
"mode": "gang",
"map": "billboard"
},
{
"mode": "gang",
"map": "lighthouse"
},
{
"mode": "gang",
"map": "subway"
},
{
"mode": "gang",
"map": "vents"
},
{
"mode": "gang",
"map": "wheel"
}
]
}

View file

@ -0,0 +1,93 @@
{
"random": true,
"games": [
{
"mode": "melee",
"map": "rooftop"
},
{
"mode": "melee",
"map": "ring"
},
{
"mode": "melee",
"map": "blimp"
},
{
"mode": "melee",
"map": "containers"
},
{
"mode": "melee",
"map": "elevators"
},
{
"mode": "melee",
"map": "girders"
},
{
"mode": "melee",
"map": "gondola"
},
{
"mode": "melee",
"map": "grind"
},
{
"mode": "melee",
"map": "incinerator"
},
{
"mode": "melee",
"map": "ring"
},
{
"mode": "melee",
"map": "towers"
},
{
"mode": "melee",
"map": "train"
},
{
"mode": "melee",
"map": "trucks"
},
{
"mode": "melee",
"map": "aquarium"
},
{
"mode": "melee",
"map": "billboard"
},
{
"mode": "melee",
"map": "buoy"
},
{
"mode": "melee",
"map": "chute"
},
{
"mode": "melee",
"map": "billboard"
},
{
"mode": "melee",
"map": "lighthouse"
},
{
"mode": "melee",
"map": "subway"
},
{
"mode": "melee",
"map": "vents"
},
{
"mode": "melee",
"map": "wheel"
}
]
}

21
docs/configs/waves.json Normal file
View file

@ -0,0 +1,21 @@
{
"random": true,
"games": [
{
"mode": "waves",
"map": "rooftop"
},
{
"mode": "waves",
"map": "incinerator"
},
{
"mode": "waves",
"map": "subway"
},
{
"mode": "waves",
"map": "grind"
}
]
}