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

Commit c0497a2

Browse files
make use of new()
1 parent ca95b05 commit c0497a2

15 files changed

Lines changed: 24 additions & 26 deletions

File tree

Scripts/Netcode/Client/ENetClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public ENetClient()
3636
Running = false;
3737
Connected = 0;
3838
OutgoingId = 0;
39-
Outgoing = new ConcurrentDictionary<int, ClientPacket>();
40-
ENetCmds = new ConcurrentQueue<ENetCmd>();
39+
Outgoing = new();
40+
ENetCmds = new();
4141
DisconnectOpcode = DisconnectOpcode.Disconnected;
4242
}
4343

Scripts/Netcode/Client/GameClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class GameClient : ENetClient
1212

1313
public GameClient()
1414
{
15-
Players = new Dictionary<uint, string>();
15+
Players = new();
1616
}
1717

1818
protected override void Connect(Event netEvent)

Scripts/Netcode/Common/Core/PacketReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public class PacketReader : IDisposable
1212

1313
public PacketReader(Packet packet)
1414
{
15-
Stream = new MemoryStream(ReadBuffer);
16-
Reader = new BinaryReader(Stream);
15+
Stream = new(ReadBuffer);
16+
Reader = new(Stream);
1717
packet.CopyTo(ReadBuffer);
1818
packet.Dispose();
1919
}

Scripts/Netcode/Common/Core/PacketWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public class PacketWriter : IDisposable
1010

1111
public PacketWriter()
1212
{
13-
Stream = new MemoryStream();
14-
Writer = new BinaryWriter(Stream);
13+
Stream = new();
14+
Writer = new(Stream);
1515
}
1616

1717
public void Write(byte v) => Writer.Write(v);

Scripts/Netcode/Common/Data/DataPlayer.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ public class DataPlayer
77
public string Username { get; set; }
88
public bool Ready { get; set; }
99
public bool Host { get; set; }
10-
public Direction DirectionHorizontal { get; set; }
11-
public Direction DirectionVertical { get; set; }
1210
public Vector2 Position { get; set; }
1311
}
1412
}

Scripts/Netcode/Server/ENetServer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ public ENetServer()
2828
{
2929
Running = false;
3030
SomeoneConnected = false;
31-
ENetCmds = new ConcurrentQueue<ENetCmd>();
32-
Outgoing = new ConcurrentQueue<ServerPacket>();
33-
Peers = new Dictionary<uint, Peer>();
31+
ENetCmds = new();
32+
Outgoing = new();
33+
Peers = new();
3434
}
3535

3636
/// <summary>

Scripts/Netcode/Server/GameServer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ public class GameServer : ENetServer
1717

1818
public GameServer()
1919
{
20-
Players = new Dictionary<uint, DataPlayer>();
20+
Players = new();
2121

22-
EmitClientPositions = new Timer(1000);
22+
EmitClientPositions = new(1000);
2323
EmitClientPositions.Elapsed += EmitClientPositionsCallback;
2424
EmitClientPositions.AutoReset = true;
2525
}

Scripts/Netcode/Web/WebClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public class WebClient
2525

2626
public WebClient()
2727
{
28-
Client = new HttpClient();
28+
Client = new();
2929
Client.Timeout = TimeSpan.FromSeconds(5);
3030

31-
TimerPingMasterServer = new Timer(WebClient.WEB_PING_INTERVAL);
31+
TimerPingMasterServer = new(WebClient.WEB_PING_INTERVAL);
3232
TimerPingMasterServer.AutoReset = true;
33-
TimerPingMasterServer.Elapsed += new ElapsedEventHandler(OnTimerPingMasterServerEvent);
33+
TimerPingMasterServer.Elapsed += new(OnTimerPingMasterServerEvent);
3434
}
3535

3636
public async Task<WebServerResponse<string>> Post(string path, Dictionary<string, string> values)

Scripts/Scenes/Game Servers/SceneGameServers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public override async void _Ready()
2727
Instance = this;
2828
ServerList = GetNode<VBoxContainer>(NodePathServerList);
2929
ServerCreationPopup = GetNode<UIPopupCreateLobby>(NodePathServerCreationPopup);
30-
LobbyListings = new Dictionary<string, LobbyListing>();
30+
LobbyListings = new();
3131

3232
if (Disconnected)
3333
{

Scripts/Scenes/Game/ClientPlayer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public override void _Ready()
2626

2727
if (GameClient.Running)
2828
{
29-
EmitPosition = new Timer(1000);
29+
EmitPosition = new(1000);
3030
EmitPosition.Elapsed += EmitPositionCallback;
3131
EmitPosition.AutoReset = true;
3232
EmitPosition.Enabled = true;

0 commit comments

Comments
 (0)