FiberLib-FiberLib icon

FiberLib

FiberLib is a library mod for sending and receiving packets from a Bopl Battle Mod. It is currently in a bare bones state and only includes necessary tools, but will soon include more utilities for making the developer experience simpler.

Last updated a year ago
Total downloads 6467
Total rating 3 
Categories Mods Libraries
Dependency string FiberLib-FiberLib-1.2.0
Dependants 3 other packages depend on this package

This mod requires the following mods to function

BepInEx-BepInExPack-5.4.2100 icon
BepInEx-BepInExPack

BepInEx pack for Mono Unity games. Preconfigured and ready to use.

Preferred version: 5.4.2100

README

logo

FiberLib

FiberLib is a library mod for sending and receiving packets from a Bopl Battle Mod. It is currently in a bare bones state and only includes necessary tools, but will soon include more utilities for making the developer experience simpler.

Documentation

(This project still under development, so API can change)

  1. First make a global static variable for signature to send/recive packets
public static Signature signature;
  1. Register a packet recive handler
public class MyMod : BaseUnityPlugin
{
	private void ReciveHandler(Packet packet, Connection connection, NetIdentity identity)
	{
		byte[] data = packet.data;
		Console.WriteLine($"recived {data.length} bytes");
	}

	private void Awake()
	{
		signature = PacketManager.RegisterPacketReciveHandler(ReciveHandler);
	}
}
  1. Send Packet
public class MyMod : BaseUnityPlugin
{
	private void OnGUI()
	{
		if (GUI.Button(new Rect(0, 50, 170f, 30f), "Send Packet"))
		{
			Console.WriteLine("Sending packet!");
			Packet packet = new Packet(signature, Encoding.UTF8.GetBytes("Hello, World!"))
			PacketManager.SendPacket(packet);
		}
	}
}