28 lines
1.0 KiB
C#
28 lines
1.0 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
} |