Skip to content

minidogg/FiberLib

Repository files navigation

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);
		}
	}
}

Building

  1. Run setup.cmd and follow instructions
  2. Select build mode (Debug, Release, Thunderstore (only packages built dll))
  3. Done