Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
StaticNetcodeLib
A library/patcher for NGO in a static context.
| Date uploaded | 5 months ago |
| Version | 1.2.0 |
| Download link | xilophor-StaticNetcodeLib-1.2.0.zip |
| Downloads | 486037 |
| Dependency string | xilophor-StaticNetcodeLib-1.2.0 |
This mod requires the following mods to function
BepInEx-BepInExPack
BepInEx pack for Mono Unity games. Preconfigured and ready to use.
Preferred version: 5.4.2100Lordfirespeed-OdinSerializer
Fast, robust, powerful and extendible .NET serializer built for Unity
Preferred version: 2024.2.2700README
StaticNetcodeLib
This lib allows BepInEx mods to use Netcode for GameObjects in a static context.
Usage
Add the appropriate BepInDependency attribute to your plugin class, like so:
[BepInDependency(StaticNetcodeLib.Guid, DependencyFlags.HardDependency)]
public class ExampleMod : BaseUnityPlugin
Then add the StaticNetcode attribute to any classes that have static rpcs.
[StaticNetcode]
public class ExampleNetworkingClass
After that, you can simply use Server & Client Rpcs as you normally would (even outside NetworkBehaviours), but in a static context, like so:
[ClientRpc]
public static void ExampleClientRpc(string exampleString)
{
ExampleMod.Logger.LogDebug(exampleString);
}
/* ... */
ExampleClientRpc("Hello, world!");
Note: The Rpc attribute params are not respected for this. For example, ServerRpcs are static and thus cannot have an owner, and are used as if it had the RequireOwnership = false parameter.
Acknowledgements
Thank you @Lordfirespeed for being my rubber ducky.
CHANGELOG
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[Unreleased]
[v1.2.0]
Changed
- Updated OdinSerializer dependency to the latest version.
Fixed
- Fixed serialization error by reworking serialization to include type-specific deserialization.
[v1.1.1]
Fixed
- Resolved Null Reference Error related to MethodBases
- Resolved Lag Spikes occurring when transmitting packets.
[v1.1.0]
Changed
- The static RPCs should now serialize anything you throw at it.
[v1.0.3]
Changed
- Internal Refactoring
Fixed
- Fixed failure to patch static rpcs
[v1.0.2]
Fixed
- Fixed error when an installed mod did not get loaded
[v1.0.1]
Changed
- Internal Refactoring
- Updated README
[v1.0.0]
Added
- Added static RPC patching