You are viewing a potentially older version of this package. View all versions.
Rein-NetLib-0.0.2 icon

NetLib

A networking library for mods. Currently in beta and looking for feedback.

Date uploaded 4 years ago
Version 0.0.2
Download link Rein-NetLib-0.0.2.zip
Downloads 1038
Dependency string Rein-NetLib-0.0.2

This mod requires the following mods to function

bbepis-BepInExPack-3.1.0 icon
bbepis-BepInExPack

Unified BepInEx all-in-one modding pack - plugin framework, detour library

Preferred version: 3.1.0

README

NetLib is a networking library for mods. Currently beta and looking for feedback.

For Users:

Install:

  • Download
  • Open the Zip file
  • Locate NetLib.dll inside the zip
  • Right click on it and select copy
  • Navigate to RoR2 directory
  • Open the BepInEx folder
  • Open the Plugins folder inside BepInEx
  • Right click, click new, then folder
  • Name the folder NetLib
  • Open the folder
  • Right click, and select paste
  • You're done

Uninstall

  • Navigate to RoR2 directory
  • Open BepInEx folder
  • Open the plugins folder
  • Locate either NetLib.dll, or the NetLib folder and delete them
  • You're done

Bug reporting

If you see errors or bugs of any kind please create an issue on github, or you can DM me on discord (@Rein#7551)

For Developers:

What does it do?

There are three major functionalities offered by NetLib:

Framework

NetLib offers a framework for sending messages over network. The framework is heavily styled after UNet (the style of networking present in base game) with a few key differences:

  • Uses a single message index for all messages (Helps ensure mod interoperability)
  • Forces proper structure of messages through inheritance
  • Simplified process for sending the messages
  • Catches most errors before they reach game code

BuiltIns

In addition to the framework, NetLib also offers built-in implementations of commonly used networking functionality. These BuiltIns are wrapped in a single static method. The BuiltIns are also heavily commented and documented, and serve as a good way to get started with writing a custom message type. There are two (and a half) BuiltIns currently:

  • ExampleTest, which is really just a debugging message that enters a message into chat over network.
  • SendBuff, which allows a client to send a message to server to add or remove buffs from a body.
  • SendDamage, which allows a more flexible way to send damage to server than BulletMessages, in that you can choose what parts of the damage process occur.

Extensions

NetLib also contains numerous NetworkWriter and NetworkReader extension methods. Many of these are direct mappings to the In-Game functions (even the private ones). These are intended to make it easier to work with readers and writers, and will be expanded upon in the future to include things such as caching and other performance boosts.

Why should I use it?

Right Now:

  • You want to help locate bugs
  • You have feature ideas
  • You have nothing better to do

After release:

  • You want your mods to work in multiplayer and want to write as little networking code as possible.
  • You're tired of writing your own seperate framework inside of every mod you release.

How do I use it?

Using BuiltIns:

  • Add: a reference in your project to NetLib.dll
  • Add: [BepInDependency( NetLib.NetLib.guid, BepInDependency.DependencyFlags.HardDependency )] to your plugin attributes
  • Add: Dependency to your manifest
  • Add: using NetLib; to your usings in the script(s) that need to use them.
  • Add: Logic to your code that will make sure that all clients aren't executing the function. typically: if( something.isAuthority ) SomeBuiltInFunc();
  • You're done.

Writing custom messages:

  • WIP

Can I help?

Sure

How can I help?

Do standard github things.

  • Issues for bugs or feature requests
  • Pull requests
  • Writing docs

Changelog

0.0.2

Breaking changes

  • N/A

Changes

  • Fixed major bugs in extensions for DamageInfo and ProcChainMask (They also will perform better since the expressions are compiled load time instead of on first use)
  • Some internal stuff for allowing extensions to do things on plugin constructor (Like caching methods)

0.0.1

Breaking changes

  • N/A

Changes

  • N/A