-
-
Notifications
You must be signed in to change notification settings - Fork 14
API Overview
Multiplayer Mod attempts to synchronise many of the base game’s data structures and events. This enables some of the simpler mods (e.g. Custom Cargo) to function with multiplayer without issue. However, many mods use custom data structures, events, and settings beyond what the base game provides, and as a result, do not integrate seamlessly with the Multiplayer Mod.
The Multiplayer Mod API has been created to allow mod authors to:
- Declare their mod’s compatibility requirements, either through the mod’s
info.jsonfile or programmatically via the API. - Access multiplayer data structures, events, and utilities such as:
- Server and client start/stop events
- Player connection and disconnection events
- Player data including position, ping, and role (host/client)
- Any player’s proximity to an object (for servers)
- Component NetId lookup
- Create custom network packets for synchronising the mod’s own data and events:
- Automatic serialisation/deserialisation for simple packets
- Custom serialisation/deserialisation for complex packets
- Register custom
DV.Logic.Job.Taskserialisers - Register handlers and filters for the in-game chat system
- Register a client-side block to pause loading while the mod prepares assets, receives settings, and states prior to Multiplayer completing the game synchronisation
Mod authors commonly patch other mods and use reflection to achieve compatibility. While this works for many use cases, the drawback is that changes in the target mod can cause both mods to break. Multiplayer Mod is a complex mod in active development and is subject to broad changes in operating philosophy, method names, and data structures, which increases the likelihood of one or more mods breaking when relying on patches and reflection.
The aim of the API is to provide a stable interface, regardless of what changes ‘under the hood’. As such, the API is designed to maintain backwards compatibility as much as possible. This also allows the API to be extended if mod authors require additional events, utilities, or access to more data structures.
There are several ways to consume the API; the most appropriate way will depend on the individual mod’s requirements.
If your mod:
- Is a client-sided tool/enhancement (e.g. Runtime Unity Editor, LightingOverhaul, etc.)
- Is already compatible with multiplayer without integration (e.g. Booklet Organizer, Custom Cargo (and Custom Cargo based mods), etc.)
- Is incompatible with multiplayer1
Please see Declaring Compatibility for instructions on using the Info.json file to declare compatibility.
If your mod:
- Needs to integrate with Multiplayer
Please see Getting Started to learn about the basic concepts Multiplayer Mod uses and a guide to using the API.
1. If your mod is already released and you intend to incorporate Multiplayer integration, this can be used temporarily until integration is complete.
Getting Started
Guides
- The Basics
- Packet Naming Conventions
- Defining Packets
- Registering Packet Listeners
- Sending Packets