32 lines
No EOL
1 KiB
C#
32 lines
No EOL
1 KiB
C#
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);
|
|
}
|
|
} |