Seperate out the NetworkPacketDictonary
This commit is contained in:
1 parent
531fd2572f
commit
3992c3debc
6 files changed
+48
-46
No files matched your search
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Mistox.Attributes {
|
||||
|
||||
public class NetworkPacketDictionary {
|
||||
|
||||
// Fills out the NetworkPacket Lookup Dictionary
|
||||
public static readonly Dictionary<byte, Type> ClientToClientPackets = new();
|
||||
public static readonly Dictionary<byte, Type> ServerToClientPackets = new();
|
||||
public static void BuildNetworkPacketList() {
|
||||
Type[] allClasses = Assembly.GetExecutingAssembly().GetTypes();
|
||||
foreach( Type cur in allClasses) {
|
||||
mPacket attribute = cur.GetCustomAttribute<mPacket>(false);
|
||||
if (attribute != null) {
|
||||
if ( attribute.PacketUse.HasFlag(PacketUsage.ClientToClient) ) {
|
||||
ClientToClientPackets[attribute.ID] = cur;
|
||||
} else if ( attribute.PacketUse.HasFlag(PacketUsage.ClientToServer) ) {
|
||||
ServerToClientPackets[attribute.ID] = cur;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user