Byte-Nova / Rimworld-Together

A Community Driven Multiplayer Mod!
https://steamcommunity.com/sharedfiles/filedetails/?id=3005289691
Other
62 stars 28 forks source link

Network changes #170

Closed Byte-Nova closed 1 week ago

Byte-Nova commented 1 week ago

Short and concise description about my pull request:

TODOs:

Contributing:

If the above is true, I have also uploaded a PR to this project's Guide so users can find information about it.

The link to said PR is: (The link to your guide PR goes here).

Longer / More informative description about what my pull request does:

[!NOTE]
This new implementation removes the PacketHandler classes from client and server, and a new way to create and execute packets has been added. As a quick rundown on the new implementation, here's a couple examples on the system.

Ex on how packets are now created (taken from the aid manager class):

Packet packet = Packet.CreatePacketFromObject(nameof(AidManager), aidData);

Ex on how packets are now handled (taken from the listener class):

MethodManager.ExecuteMethod(packet.header, defaultParserMethodName, new object[] { packet });

[!WARNING]
This new approach requires that any class capable of handling packets (basically every manager in the project) has a function called ParsePacket. Any manager without this class correctly implemented will just refuse to handle the packet.

Ex on required class in the manager (taken from the aid manager class):

public static void ParsePacket(Packet packet)
{
     //Do your stuff in here
}