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

Commit e6b1ea6

Browse files
Remove all statics from GodotCommands.cs
1 parent eb84931 commit e6b1ea6

5 files changed

Lines changed: 10 additions & 7 deletions

File tree

Scripts/Netcode/Client/ENetClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private Task ENetThreadWorker(string ip, ushort port)
171171
continue;
172172
}
173173

174-
GodotCommands.Enqueue(GodotOpcode.ENetPacket, new PacketReader(packet));
174+
GameManager.GodotCommands.Enqueue(GodotOpcode.ENetPacket, new PacketReader(packet));
175175
break;
176176

177177
case EventType.Timeout:

Scripts/Netcode/Client/GameClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private void HandlePeerLeave(DisconnectOpcode opcode)
3333
NetworkManager.ClientConnectingToLobby = false;
3434
NetworkManager.ClientDisconnected = true;
3535
Connected = 0;
36-
GodotCommands.Enqueue(GodotOpcode.Disconnect, opcode);
36+
GameManager.GodotCommands.Enqueue(GodotOpcode.Disconnect, opcode);
3737
if (CTSClientTask != null)
3838
{
3939
CTSClientTask.Cancel();

Scripts/Netcode/Client/GodotCommands.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace GodotModules
44
{
5-
public static class GodotCommands
5+
public class GodotCommands
66
{
7-
private static ConcurrentQueue<ThreadCmd<GodotOpcode>> GodotCmdQueue = new ConcurrentQueue<ThreadCmd<GodotOpcode>>();
7+
private ConcurrentQueue<ThreadCmd<GodotOpcode>> GodotCmdQueue = new ConcurrentQueue<ThreadCmd<GodotOpcode>>();
88

9-
public static void Enqueue(GodotOpcode opcode, object data = null) => GodotCmdQueue.Enqueue(new ThreadCmd<GodotOpcode>(opcode, data));
9+
public void Enqueue(GodotOpcode opcode, object data = null) => GodotCmdQueue.Enqueue(new ThreadCmd<GodotOpcode>(opcode, data));
1010

11-
public static async Task Dequeue()
11+
public async Task Dequeue()
1212
{
1313
if (GodotCmdQueue.TryDequeue(out ThreadCmd<GodotOpcode> cmd))
1414
{

Scripts/Netcode/Common/Server/ENetServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private Task ENetThreadWorker(ushort port, int maxClients)
136136
var message = $"A server is running on port {port} already! {e.Message}";
137137
Log(message);
138138
#if CLIENT
139-
GodotCommands.Enqueue(GodotOpcode.PopupMessage, message);
139+
GameManager.GodotCommands.Enqueue(GodotOpcode.PopupMessage, message);
140140
NetworkManager.GameClient.Stop();
141141
#endif
142142
Stop();

Scripts/Scenes/Main/GameManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public class GameManager : Node
1010
[Export] public readonly NodePath NodePathGameConsole;
1111
public static UIGameConsole GameConsole { get; set; }
1212

13+
public static GodotCommands GodotCommands { get; set; }
14+
1315
public static string GameName = "Godot Modules";
1416
public static OptionsData Options { get; set; }
1517
public static SceneTree GameTree { get; set; }
@@ -18,6 +20,7 @@ public override void _Ready()
1820
{
1921
GameTree = GetTree();
2022
GameConsole = GetNode<UIGameConsole>(NodePathGameConsole);
23+
GodotCommands = new GodotCommands();
2124
}
2225

2326
public override async void _Process(float delta)

0 commit comments

Comments
 (0)