Skip to content
This repository was archived by the owner on Sep 15, 2024. It is now read-only.

Commit eb84931

Browse files
Move some statics to NetworkManager.cs
1 parent 2a9d397 commit eb84931

7 files changed

Lines changed: 11 additions & 13 deletions

File tree

Scripts/Msc/Commands/Command.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
32
using System.Reflection;
43

54
namespace GodotModules

Scripts/Msc/UIPopupCreateLobby.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private void _on_Description_text_changed() =>
7474

7575
private async void _on_Create_pressed()
7676
{
77-
if (GameClient.ConnectingToLobby)
77+
if (NetworkManager.ClientConnectingToLobby)
7878
return;
7979

8080
if (ValidatedName == null || ValidatedDescription == null)

Scripts/Netcode/Client/ENetClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public async void Start(string ip, ushort port)
4949
{
5050
if (IsENetThreadRunning)
5151
{
52-
GameClient.ConnectingToLobby = false;
52+
NetworkManager.ClientConnectingToLobby = false;
5353
Log($"Client is running already");
5454
return;
5555
}

Scripts/Netcode/Client/GameClient.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ namespace GodotModules.Netcode.Client
44
{
55
public class GameClient : ENetClient
66
{
7-
public static bool ConnectingToLobby { get; set; }
8-
public static bool Disconnected { get; set; }
9-
107
public Dictionary<uint, string> Players { get; set; }
118

129
public GameClient()
@@ -33,8 +30,8 @@ protected override void Disconnect(Event netEvent)
3330

3431
private void HandlePeerLeave(DisconnectOpcode opcode)
3532
{
36-
ConnectingToLobby = false;
37-
Disconnected = true;
33+
NetworkManager.ClientConnectingToLobby = false;
34+
NetworkManager.ClientDisconnected = true;
3835
Connected = 0;
3936
GodotCommands.Enqueue(GodotOpcode.Disconnect, opcode);
4037
if (CTSClientTask != null)

Scripts/Netcode/Common/Utils/NetworkManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public override void _Ready()
3434
// SERVER
3535
public static GameServer GameServer { get; set; }
3636
public static ServerSimulation ServerSimulation { get; set; }
37+
public static bool ClientConnectingToLobby { get; set; }
38+
public static bool ClientDisconnected { get; set; }
3739
public static bool ServerAuthoritativeMovement { get; set; }
3840
private static int GameServerStillRunning { get; set; }
3941
public static bool IsServerRunning() => GameServer == null ? false : GameServer.IsRunning;

Scripts/Scenes/Game Servers/SceneGameServers.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public override async void _Ready()
3131

3232
LobbyListings = new();
3333

34-
if (GameClient.Disconnected)
34+
if (NetworkManager.ClientDisconnected)
3535
{
36-
GameClient.Disconnected = false;
36+
NetworkManager.ClientDisconnected = false;
3737
var message = "Disconnected";
3838

3939
switch (NetworkManager.DisconnectOpcode)
@@ -83,11 +83,11 @@ public override void _Input(InputEvent @event)
8383

8484
public async Task JoinServer(LobbyListing info, bool directConnect)
8585
{
86-
if (GameClient.ConnectingToLobby)
86+
if (NetworkManager.ClientConnectingToLobby)
8787
return;
8888

8989
NetworkManager.CurrentLobby = info;
90-
GameClient.ConnectingToLobby = true;
90+
NetworkManager.ClientConnectingToLobby = true;
9191

9292
Logger.Log("Connecting to lobby...");
9393
NetworkManager.StartClient(info.Ip, info.Port);

Scripts/Scenes/Game Servers/UILobbyListing.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class UILobbyListing : Control
2424
public override void _Ready()
2525
{
2626
SceneGameServersScript = SceneManager.GetActiveSceneScript<SceneGameServers>();
27-
GameClient.ConnectingToLobby = false;
27+
NetworkManager.ClientConnectingToLobby = false;
2828
LabelTitle = GetNode<Label>(NodePathLabelTitle);
2929
LabelDescription = GetNode<Label>(NodePathLabelDescription);
3030
LabelPing = GetNode<Label>(NodePathLabelPing);

0 commit comments

Comments
 (0)