Skip to content

Basic Concepts

Will Corby edited this page Feb 25, 2025 · 5 revisions

PlayerInfo

Ready

WorldObject

AllObjectsAdded and AllObjectsReady

WorldObjectManager

QSBNetworkBehaviour

QSBPatch

A class containing Harmony patches to apply. An example patch file is:

[HarmonyPatch]
public class TestPatches : QSBPatch
{
	public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
	public override GameVendor PatchVendor => GameVendor.Steam | GameVendor.Epic;

	[HarmonyPrefix]
	[HarmonyPatch(typeof(TypeToPatch), nameof(TypeToPatch.MethodToPatch))]
	public static bool TypeToPatch_MethodToPatch(TypeToPatch __instance)
	{
		if (Remote)
		{
			return true;
		}
		
		// do stuff
		return false;
	}
}

Type must be overridden in each patch class. It lets you choose when your patches are applied.

  • OnClientConnect - Patches are applied when the local player connects to a server, or hosts a server. Patches are unpatched when leaving the server / the server closes.
  • OnServerClientConnect - Patches are applied when the local player hosts a server, and unpatched when the server closes.
  • OnNonServerClientConnect - Patches are only applied when connecting to a server, not hosting it. Patches are unpatched when leaving the server.
  • RespawnTime - Patches are applied when dead, and unpatched when respawning.
  • OnModStart - Patches are applied as soon as the game loads, and are not unpatched.

PatchVendor is an optional override. It lets you determine which vendors the patches are ran on, to let you patch vendor-specific classes.

Remote can be used to check whether a patched method is being called "remotely" (from a message handler or player join/leave handler). Useful to prevent recursion when the patch sends messages that then call the patched method.

QSBMessage

QSBWorldObjectMessage

Clone this wiki locally