darmuh-MirrorPlumber icon

MirrorPlumber

Utility BepInEx Mod that allows modders to utilize various Mirror Networking functions at runtime

Last updated 2 weeks ago
Total downloads 1793
Total rating 3 
Categories Tools Libraries All Clients
Dependency string darmuh-MirrorPlumber-0.3.1
Dependants 1 other package depends on this package

README

Mirror Plumber

Utility BepInEx Mod that allows modders to utilize various Mirror Networking functions at runtime

This was built for YAPYAP, however, it should work in any other unity game that utilizes the same style of Mirror Networking.

Features:

  • Plumber class which facilitates all the internal plumbing Mirror requires to get a NetworkBehaviour working at runtime.

    • Mirror does not recognize it's Attribute tags at runtime so you'll need to utilize this Plumber in order to get things working. (without a patcher or Mirror's weaver)*
    • Currently supports Commands, ClientRpcs, TargetRpcs, and Psuedo-SyncVars (PlumbVars). See ExampleNetBehaviour.cs
  • BehaviourAdder class handles adding custom classes that inherit NetworkBehaviour to existing Prefabs.

    • Currently supports adding custom NetworkBehaviour classes to the Player Prefab and any prefab in NetworkManager's spawnPrefabs list.
    • The classes are hooked into the prefabs during a NetworkManager Awake prefix patch.
    • You will need to supply the assetId for any non-player prefab you wish to add a custom NetworkBehaviour class to.
    • NOTE: Prefabs cannot contain more than 64 NetworkBehaviours
    • NOTE 2: You will still need to have MirrorPlumber perform the plumbing of your NetworkBehaviour class for it to properly network.
    • NOTE 3: When adding a NetworkBehaviour to the Player Prefab, keep in mind your NetworkBehaviour will be on every instance of the Player Prefab. Not just the local instance.
  • GameObjectExtensions class which holds useful gameobject extension methods that pertain to Mirror and MirrorPlumber.

    • TryRegisterPrefab Attempts to add a given gameobject to an internal MirrorPlumber list of game objects that will be registered at Mirror's NetworkClient.Initialize
      • If the prefab is null or does not contain a NetworkIdentity this will return false
    • TryGetAssetId Attempts to provide you with a given gameobject's NetworkIdentity assetId.
      • If the game object is null or does not have a NetworkIdentity, returns false
    • TryUntrackPrefab Attempts to remove a given gameobject (prefab) from the internal MirrorPlumber list of game objects that will be registered at NetworkClient.Initialize
      • If the gameobject is null, does not contain a NetworkIdentity, or is not already in the list it will return false.
    • TrySpawnOnServer Attempts to spawn a given gameobject (prefab) on the server
      • If the prefab is null or Mirror's NetworkClient does not contain the prefab in it's prefabs list, this will return false.

Examples:

Documentation:

  • Documentation is WIP, for now you can view the old readme which had a lot of good but poorly organized information.
  • It is HIGHLY recommended to reference Mirror's own documentation