Skip to content

Repository files navigation

API for R.E.P.O that allows for networking using Steamworks.

Important

This does not allow you to host lobbies using steam or enable local hosting!

This is an API for Mod Developers so they can offload their mods' networking off of the REPO Photon servers to help the REPO devs save bandwidth.

Check the Full Documentation for up-to-date Docs

Basic documentation is as follows

Set version compatibility

Method A

[RSNVersionCompatibility(VersionCompatibility.Strict,optional:false)]// Defaults[BepInPlugin(...)]classExampleModPlugin:BaseUnityPlugin{...}

Method B

classExampleModPlugin:BaseUnityPlugin{privatevoidAwake(){RepoSteamNetwork.SetVersionCompatibility(VersionCompatibility.Strict,plugin:this);}}

Create network packet

publicclassExamplePacket:NetworkPacket<ExamplePacket>{publicstringExampleDataString;publicVector3ExampleVector;protectedoverridevoidWriteData(SocketMessagesocketMessage){socketMessage.Write(ExampleDataString);socketMessage.Write(ExampleVector);}protectedoverridevoidReadData(SocketMessagesocketMessage){ExampleDataString=socketMessage.Read<string>();ExampleVector=socketMessage.Read<Vector3>();}}

Register network packet

RepoSteamNetwork.RegisterPacket<ExamplePacket>();

Setup callback

Method A

Register callback

{
...RepoSteamNetwork.AddCallback<ExamplePacket>(OnExamplePacketReceived);
...}privatestaticvoidOnExamplePacketReceived(ExamplePacketpacket){// Do stuff with your packet dataDebug.Log($"Received ExamplePacket Data: ({packet.ExampleDataString}, {packet.ExampleVector})");}

Method B

Do your callback in ReadData in your packet

publicclassExamplePacket:NetworkPacket<ExamplePacket>{
...protectedoverridevoidReadData(SocketMessagesocketMessage){ExampleDataString=socketMessage.Read<string>();ExampleVector=socketMessage.Read<Vector3>();// Do stuff with your data hereDebug.Log($"Received ExamplePacket Data: ({ExampleDataString}, {ExampleVector})");}}

Send Packet

varpacket=newExamplePacket{ExampleDataString="Example string here",ExampleVector=Vector3.One,}// By default sends packet to everyone including the user who sends the packet
RepoSteamNetwork.SendPacket(packet);// or send it only to the hostRepoSteamNetwork.SendPacket(packet,NetworkDestination.HostOnly);

About

No description, website, or topics provided.

Resources

Stars

12 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages