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

Commit 11318f1

Browse files
Encapsulate GodotCommands.Enqueue
1 parent 8b29a85 commit 11318f1

4 files changed

Lines changed: 6 additions & 4 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-
GM.GodotCommands.Enqueue(GodotOpcode.ENetPacket, new PacketReader(packet));
174+
GM.EnqueueGodotCmd(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-
GM.GodotCommands.Enqueue(GodotOpcode.Disconnect, opcode);
36+
GM.EnqueueGodotCmd(GodotOpcode.Disconnect, opcode);
3737
if (CTSClientTask != null)
3838
{
3939
CTSClientTask.Cancel();

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-
GM.GodotCommands.Enqueue(GodotOpcode.PopupMessage, message);
139+
GM.EnqueueGodotCmd(GodotOpcode.PopupMessage, message);
140140
NetworkManager.GameClient.Stop();
141141
#endif
142142
Stop();

Scripts/Scenes/Main/GM.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class GM : Node
1111
[Export] public readonly NodePath NodePathGameConsole;
1212
public static ModLoader ModLoader { get; set; }
1313
public static UIGameConsole GameConsole { get; set; }
14-
public static GodotCommands GodotCommands { get; set; }
14+
private static GodotCommands GodotCommands { get; set; }
1515
private static Logger Logger { get; set; }
1616

1717
public static string GameName = "Godot Modules";
@@ -63,6 +63,8 @@ public static void SpawnPopupError(Exception e)
6363
popupError.PopupCentered();
6464
}
6565

66+
public static void EnqueueGodotCmd(GodotOpcode opcode, object data = null) => GodotCommands.Enqueue(opcode, data);
67+
6668
public static void Log(object v, ConsoleColor color = ConsoleColor.Gray) => Logger.Log(v, color);
6769
public static void LogWarning(object v, ConsoleColor color = ConsoleColor.Yellow) => Logger.LogWarning(v, color);
6870
public static void LogDebug(object v, ConsoleColor color = ConsoleColor.Magenta, bool trace = true, [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0) => Logger.LogDebug(v, color, trace, filePath, lineNumber);

0 commit comments

Comments
 (0)