-
-
Notifications
You must be signed in to change notification settings - Fork 14
API Reference
Namespace: MPAPI.Interfaces
Interface for interacting with Multiplayer mod client instances.
public interface IClientGets Player Id of the local player.
public abstract byte PlayerId { get; }Remarks:
The local player does not have an IPlayer object.
Gets IPlayer objects for all players connected to the server.
public abstract IReadOnlyCollection<IPlayer> Players { get; }Gets number of players currently connected to the server.
public abstract int PlayerCount { get; }Gets connection state for the client.
public abstract bool IsConnected { get; }Gets ping for the client.
public abstract int Ping { get; }Registers a block to prevent the client from sending the 'Ready' signal to the server until all mods have called 'CancelReadyBlock'.
void RegisterReadyBlock(ModInfo modInfo)modInfo ModInfo
Mod information.
Remarks:
Only required if the mod needs complete loading prior to receiving game state from the server.
Cancels a previously registered ready block.
void CancelReadyBlock(ModInfo modInfo)modInfo ModInfo
Mod information.
Remarks:
All registered blocks must be cancelled prior to the client sending the 'Ready' signal to the server.
Gets the IPlayer for player by Id.
IPlayer GetPlayer(byte playerId)playerId Byte
IPlayer
IPlayer object if found, otherwise null.
Register a packet type that uses automatic serialisation.
void RegisterPacket<T>(ClientPacketHandler<T> handler)T
Packet type implementing IPacket.
handler ClientPacketHandler<T>
Handler to call when packet is received.
Register a packet type that uses manual serialisation.
void RegisterSerializablePacket<T>(ClientPacketHandler<T> handler)T
Packet type implementing ISerializablePacket.
handler ClientPacketHandler<T>
Handler to call when packet is received.
Send a packet based on IPacket to the server.
void SendPacketToServer<T>(T packet, bool reliable)T
Packet type.
packet T
Packet to send.
reliable Boolean
Whether to send reliably.
Send a packet based on ISerializablePacket to the server.
void SendSerializablePacketToServer<T>(T packet, bool reliable)T
Packet type.
packet T
Packet to send.
reliable Boolean
Whether to send reliably.
Event fired when a player connects.
public abstract event Action<IPlayer> OnPlayerConnected;Remarks:
The event handler receives an IPlayer object for the connected player.
Event fired when a player disconnects, but before the IPlayer object is destroyed.
public abstract event Action<IPlayer> OnPlayerDisconnected;Remarks:
The event handler receives an IPlayer object for the disconnected player.
Namespace: MPAPI.Interfaces
Main interface for interacting with the Multiplayer mod.
public interface IMultiplayerAPIGets the version of the Multiplayer API that the Multiplayer mod supports.
public abstract string SupportedApiVersion { get; }Gets the version of the Multiplayer mod itself.
public abstract string MultiplayerVersion { get; }Gets whether the multiplayer mod is currently loaded and active.
public abstract bool IsMultiplayerLoaded { get; }Returns true if either a host or client exist.
public abstract bool IsConnected { get; }Gets whether this instance is host.
public abstract bool IsHost { get; }Gets whether this instance is a dedicated server.
public abstract bool IsDedicatedServer { get; }Gets whether this current session is single player.
public abstract bool IsSinglePlayer { get; }The number of ticks per second (currently 24). Used to calculate the fixed tick interval: TICK_INTERVAL = 1.0f / TICK_RATE.
public abstract uint TICK_RATE { get; }The current game tick.
public abstract uint CurrentTick { get; }Sets the mod's compatibility requirements.
void SetModCompatibility(string modId, MultiplayerCompatibility compatibility)modId String
String representing the your mod's Id (ModEntry.Info.Id).
compatibility MultiplayerCompatibility
ModCompatibility flags representing installation host/client requirements.
Gets the NetId for an object.
bool TryGetNetId<T>(T obj, UInt16& netId)T
obj T
The object you want the NetId for.
netId UInt16&
When this method returns, contains the NetId associated with the specified object, if found; otherwise, 0.
Boolean
True if a NetId for the object was found; otherwise, false.
Gets the object for a NetId.
bool TryGetObjectFromNetId<T>(ushort netId, T& obj)T
netId UInt16
The non-zero NetId for the object.
obj T&
When this method returns, contains the object associated with the NetId, if found; otherwise null.
Boolean
True if the object was found; otherwise, false.
Gets the NetId for an object.
bool TryGetNetId<T>(T obj, UInt32& netId)T
obj T
The object you want the NetId for.
netId UInt32&
When this method returns, contains the NetId associated with the specified object, if found; otherwise, 0.
Boolean
True if a NetId for the object was found; otherwise, false.
Gets the object for a NetId.
bool TryGetObjectFromNetId<T>(uint netId, T& obj)T
netId UInt32
The non-zero NetId for the object.
obj T&
When this method returns, contains the object associated with the NetId, if found; otherwise null.
Boolean
True if the object was found; otherwise, false.
Registers a PaintTheme and returns its netId.
uint RegisterPaintTheme(PaintTheme theme)theme PaintTheme
The DV.Customization.Paint.PaintTheme to be registered.
UInt32
Non-zero, unique Id if the theme was successfully registered, otherwise 0.
Remarks:
PaintThemes must be registered each time the client or server starts, registration is not persistent across sessions.
Unregisters a PaintTheme.
void UnregisterPaintTheme(PaintTheme theme)theme PaintTheme
The DV.Customization.Paint.PaintTheme to be unregistered.
Remarks:
Base game PaintThemes cannot be unregistered.
Registers a TaskNetworkData<T> serialiser/deserialiser for a custom DV.Logic.Job.Task type for multiplayer synchronisation.
bool RegisterTaskType<TCustomTask, TTaskNetworkData>(TaskType taskType)TCustomTask
The concrete DV.Logic.Job.Task type to register.
TTaskNetworkData
The TaskNetworkData<T> type that handles serialisation and deserialisation for .
Must have a parameterless constructor and implement TaskNetworkData<T>.FromTask(Task) to convert from the task.
taskType TaskType
The DV.Logic.Job.TaskType enum value associated with this task type.
Boolean
true if the task type was successfully registered; false if the task type was already registered or registration failed.
Remarks:
This method automatically handles conversion by instantiating , calling its TaskNetworkData<T>.FromTask(Task) method for serialisation, and creating empty instances for deserialisation.
Unregisters a previously registered custom DV.Logic.Job.Task type.
bool UnregisterTaskType<TCustomTask>(TaskType taskType)TCustomTask
The concrete DV.Logic.Job.Task type to unregister.
taskType TaskType
The DV.Logic.Job.TaskType enum value associated with the task type to unregister.
Boolean
true if the task type was successfully unregistered; false if the task type was not found or is a base-game task type.
Remarks:
This method allows removal of custom or extended task types from the multiplayer system. Base-game task types cannot be unregistered.
Converts an IEnumerable collection of DV.Logic.Job.Task into an array of TaskNetworkData.
TaskNetworkData[] ConvertTasks(IEnumerable<Task> tasks)tasks IEnumerable<Task>
The collection of tasks to convert.
TaskNetworkData[]
An array of TaskNetworkData representing the tasks.
Converts a DV.Logic.Job.Task into a TaskNetworkData.
TaskNetworkData ConvertTask(Task task)task Task
The task to convert.
TaskNetworkData
A TaskNetworkData representing the task.
Retrieves a TaskNetworkData for the specified DV.Logic.Job.TaskType.
TaskNetworkData ConvertTask(TaskType taskType)taskType TaskType
The task type to convert.
TaskNetworkData
A TaskNetworkData representing the task.
Event fired when a game/network tick occurs. Ticks occur at a fixed interval (TICK_INTERVAL = 1/TICK_RATE) and are useful for synchronisation, batching, and processing changes.
The tick parameter can be used to determine if non-reliable packets have been dropped and to sequence actions for rollbacks or preventing stale data from being processed.
Example: In Multiplayer's TrainCar simulation sync, small changes are cached when they occur but sent as a single packet per TrainCar when OnTick fires, reducing network overhead.
public abstract event Action<uint> OnTick;Remarks:
The event handler receives a UInt32 representing the current tick number.
Namespace: MPAPI.Interfaces
Provides methods for mapping between built-in game objects and their network identifiers in the Multiplayer system.
public interface INetIdProviderRemarks:
This interface enables bidirectional lookup between game objects and their corresponding network IDs, which are used to synchronise object references across the network. Only objects that are actively synchronised by Multiplayer mod will have associated network identifiers.
Additional objects from the base-game will be added as Multiplayer features are implemented. If there are specific object types you would like to see supported, please create an issue on the Multiplayer Mod GitHub repository.
Attempts to retrieve the network identifier for the specified object.
bool TryGetNetId<T>(T obj, UInt16& netId)T
The type of object to get the network ID for. Must be a reference type.
obj T
The object to get the network identifier for.
netId UInt16&
When this method returns, contains the network identifier associated with the object if found;
otherwise, the default value for the type.
Boolean
true if the network identifier was successfully retrieved; otherwise, false.
Attempts to retrieve the object associated with the specified network identifier.
bool TryGetObject<T>(ushort netId, T& obj)T
The type of object to retrieve. Must be a reference type.
netId UInt16
The network identifier of the object to retrieve.
obj T&
When this method returns, contains the object associated with the network identifier if found;
otherwise, the default value for the type.
Boolean
true if the object was successfully retrieved; otherwise, false.
Attempts to retrieve the network identifier for the specified object.
bool TryGetNetId<T>(T obj, UInt32& netId)T
The type of object to get the network ID for. Must be a reference type.
obj T
The object to get the network identifier for.
netId UInt32&
When this method returns, contains the network identifier associated with the object if found;
otherwise, the default value for the type.
Boolean
true if the network identifier was successfully retrieved; otherwise, false.
Remarks:
This method is for network identifiers represented as unsigned 32-bit integers, and is typically used where V2 types are involved.
Attempts to retrieve the object associated with the specified network identifier.
bool TryGetObject<T>(uint netId, T& obj)T
The type of object to retrieve. Must be a reference type.
netId UInt32
The network identifier of the object to retrieve.
obj T&
When this method returns, contains the object associated with the network identifier if found;
otherwise, the default value for the type.
Boolean
true if the object was successfully retrieved; otherwise, false.
Remarks:
This method is for network identifiers represented as unsigned 32-bit integers, and is typically used where V2 types are involved.
Namespace: MPAPI.Interfaces
Represents a player in the multiplayer session, providing access to player state and information.
public interface IPlayerGets the identifier for the player within the session.
public abstract byte PlayerId { get; }Remarks:
This identifier can be used as a network ID for referencing the player across the network. If the player leaves the session the Id will be reassigned to the next player to join.
Gets the username/display name of the player.
public abstract string Username { get; }Gets the current world position of the player.
public abstract Vector3 Position { get; }Vector3
Gets the current Y-axis rotation of the player.
public abstract float RotationY { get; }Gets a value indicating whether the player has finished loading the game world.
public abstract bool IsLoaded { get; }Boolean
true if the player has completed world loading and is ready to receive game state updates; otherwise, false.
Gets a value indicating whether this player is the host of the multiplayer session.
public abstract bool IsHost { get; }Boolean
true if the player is the session host; otherwise, false.
Gets the current network ping/latency for this player.
public abstract int Ping { get; }Int32
The one-way time in milliseconds between the server and this player.
Gets a value indicating whether this player is on a car.
public abstract bool IsOnCar { get; }Boolean
true if the player is on a car; otherwise, false.
Gets the train car that the player is currently occupying.
public abstract TrainCar OccupiedCar { get; }TrainCar
The TrainCar instance the player is on, or null if the player is not on any car.
Namespace: MPAPI.Interfaces
Interface for interacting with Multiplayer mod server instances.
public interface IServerGets number of players currently connected to the server.
public abstract int PlayerCount { get; }Gets IPlayer objects for all players connected to the server.
public abstract IReadOnlyCollection<IPlayer> Players { get; }Gets IPlayer for player by Id.
IPlayer GetPlayer(byte id)id Byte
Id for the player.
IPlayer
IPlayer object if found, otherwise null.
Register a packet type that uses automatic serialisation.
void RegisterPacket<T>(ServerPacketHandler<T> handler)T
Packet type implementing IPacket.
handler ServerPacketHandler<T>
Handler to call when packet is received.
Register a packet type that uses manual serialisation.
void RegisterSerializablePacket<T>(ServerPacketHandler<T> handler)T
Packet type implementing ISerializablePacket.
handler ServerPacketHandler<T>
Handler to call when packet is received.
Send a packet based on IPacket to all connected players.
void SendPacketToAll<T>(T packet, bool reliable, bool excludeSelf, IPlayer excludePlayer)T
Packet type.
packet T
Packet to send.
reliable Boolean
Whether to send reliably.
excludeSelf Boolean
Sends the packet to the local client when false, skips sending to the local client when true.
excludePlayer IPlayer
IPlayer To be excluded from this broadcast.
Send a packet based on ISerializablePacket to all connected players.
void SendSerializablePacketToAll<T>(T packet, bool reliable, bool excludeSelf, IPlayer excludePlayer)T
Packet type.
packet T
Packet to send.
reliable Boolean
Whether to send reliably.
excludeSelf Boolean
Sends the packet to the local client when false, skips sending to the local client when true.
excludePlayer IPlayer
IPlayer To be excluded from this broadcast.
Send a packet based on IPacket to a specific player.
void SendPacketToPlayer<T>(T packet, IPlayer player, bool reliable)T
Packet type.
packet T
Packet to send.
player IPlayer
Target player.
reliable Boolean
Whether to send reliably.
Send a packet based on ISerializablePacket to a specific player.
void SendSerializablePacketToPlayer<T>(T packet, IPlayer player, bool reliable)T
Packet type.
packet T
Packet to send.
player IPlayer
Target player.
reliable Boolean
Whether to send reliably.
Returns the distance (Square Magnitude) of the closest player to a given GameObject.
float AnyPlayerSqrMag(GameObject gameObject)gameObject GameObject
GameObject to compare players against.
Single
Returns the distance (Square Magnitude) of the closest player, or float.MaxValue if no player is nearby.
Returns the distance (Square Magnitude) of the closest player to a given point.
float AnyPlayerSqrMag(Vector3 anchor)anchor Vector3
Anchor point to compare players against.
Single
Returns the distance (Square Magnitude) of the closest player, or float.MaxValue if no player is nearby.
Sends a server chat message.
void SendServerChatMessage(string message, IPlayer excludePlayer)message String
Message to be sent.
excludePlayer IPlayer
Player to exclude. If null, message will go to all players.
Remarks:
Server chat messages are messsages sent from the server, not from a specific player and will be stylised as such.
Sends a chat message to a specific player.
void SendWhisperChatMessage(string message, IPlayer player)message String
Message to be sent.
player IPlayer
Recipient player.
Registers a chat command e.g. /server and optional short command '/s'.
bool RegisterChatCommand(string commandLong, string commandShort, Func<string> helpMessage, ChatCommandCallback callback)commandLong String
Command to be filtered for, without a leading '/' e.g. 'server'.
commandShort String
Optional short command to be filtered for, without a leading '/' e.g. 's'.
helpMessage Func<String>
Optional callback for a help message e.g. \r\n\t\t/s "]]>. It is recommended to provide localisation/translation for this string.
callback ChatCommandCallback
Action to execute when the command is triggered. First parameter contains message without the command e.g. '/command parameter1 parameter2' will become 'parameter1 parameter2', second parameter is the player who executed the command.
Boolean
True if the command was successfully registered, false if registration failed (e.g. command already exists).
Registers a chat filter that processes non-command messages in registration order.
Filters form a chain where each filter can either allow the message to continue to the next filter or block further processing.
If all filters return true, the message will be sent to all players (default action).
This filter also applies to whispered messages, regardless of source (player or server).
void RegisterChatFilter(ChatFilterDelegate callback)callback ChatFilterDelegate
Filter function type ChatFilterDelegate that processes the message. First delegate parameter is the message content, second parameter is the player who sent the message. Return true to pass the message to the next filter/default action, false to block propagation.
Event fired when a player connects and is authenticated, but before the player receives game state information.
public abstract event Action<IPlayer> OnPlayerConnected;Remarks:
The event handler receives an IPlayer object for the connected player. This event is not triggered for the local-client player on the host.
Event fired when a player disconnects, but before the IPlayer object is destroyed.
public abstract event Action<IPlayer> OnPlayerDisconnected;Remarks:
The event handler receives an IPlayer object for the connected player.
Event fired when a player has signalled they are ready for game state information.
public abstract event Action<IPlayer> OnPlayerReady;Remarks:
This event occurs after the server has sent the game state, it does not guarantee the player has finished generating all cars, jobs, etc.
Namespace: MPAPI.Interfaces.Packets
Base interface for packets using automatic serialisation.
public interface IPacketNamespace: MPAPI.Interfaces.Packets
Base interface for packets using manual serialisation. Implementing classes must handle their own serialisation/deserialisation.
public interface ISerializablePacketSerialise the packet data to the provided BinaryWriter.
void Serialize(BinaryWriter writer)writer BinaryWriter
BinaryWriter to serialise data to.
Deserialise the packet data from the provided BinaryReader.
void Deserialize(BinaryReader reader)reader BinaryReader
BinaryReader to deserialise data from.
Namespace: MPAPI
Provides an API interface for accessing Multiplayer Mod functionality and managing server/client instances.
public static class MultiplayerAPIInheritance Object → MultiplayerAPI
Remarks:
This class serves as the main entry point for the Multiplayer API, providing events for server and client lifecycle management, and access to the current server, client, and API instances.
Gets the version of the Multiplayer API DLL that is currently loaded.
public static string LoadedApiVersion { get; }String
The version string of the API DLL.
Gets the version of the Multiplayer API that the Multiplayer mod supports.
public static string SupportedApiVersion { get; }String
The supported API version string, or null if multiplayer is not loaded.
Remarks:
This indicates the API version that the Multiplayer mod was built against and is compatible with. If this differs from MultiplayerAPI.LoadedApiVersion, there may be compatibility issues.
Gets the version of the Multiplayer mod itself.
public static string MultiplayerVersion { get; }String
The Multiplayer mod version string, or null if multiplayer is not loaded.
Gets whether the Multiplayer mod is available.
public static bool IsMultiplayerLoaded { get; }Gets the current API instance (null if Multiplayer mod is not loaded).
public static IMultiplayerAPI Instance { get; }Gets the current Server API instance (null if Multiplayer mod is not loaded or server not running).
public static IServer Server { get; }Gets the current Client API instance (null if Multiplayer mod is not loaded or client not running).
public static IClient Client { get; }Event fired when a server instance has been created.
public static event Action<IServer> ServerStarted;Remarks:
This event provides access to the IServer instance that was started.
Event fired when a client instance has been created.
public static event Action<IClient> ClientStarted;Remarks:
This event provides access to the IClient instance that was started.
Event fired when a server instance is stopped.
public static event Action ServerStopped;Event fired when a client instance is stopped.
public static event Action ClientStopped;Namespace: MPAPI.Types
Defines how a mod works with multiplayer functionality.
public enum MultiplayerCompatibilityInheritance Object → ValueType → Enum → MultiplayerCompatibility
Implements IComparable, ISpanFormattable, IFormattable, IConvertible
| Name | Value | Description |
|---|---|---|
| Undefined | 0 | Mod has not defined compatibility. If the host is using this mod all clients must also have it. If a client is using this mod and the host is not, the client will be unable to join the game. |
| Incompatible | 1 | Mod is incompatible with multiplayer. The mod must be disabled if Multiplayer Mod is enabled. |
| All | 2 | Mod must be installed on the host and all clients. Players without this mod will be unable to join the game. Mods are responsible for disabling behaviour when connecting to a host without the mod. |
| Host | 3 | Mod must be installed on the host. Mods are responsible for disabling their behaviour if the player is not the host. |
| Client | 4 | Mod has no effect on the game play and can be ignored. This should be used for client-only mods e.g. GUI enhancements, controller mods, RUE, etc. |
Namespace: MPAPI.Types
Base class for serialising and deserialising job task data for transmission by Multiplayer mod. Not intended for direct use; inherit via TaskNetworkData<T>.
public abstract class TaskNetworkDataInheritance Object → TaskNetworkData
Gets or sets the unique network identifier for this task within its job.
public ushort TaskNetId { get; set; }Gets or sets the current state of the task.
See DV.Logic.Job.TaskState for possible values.
public TaskState State { get; set; }TaskState
Gets or sets the time at which the task started, in seconds since the job began.
public float TaskStartTime { get; set; }Gets or sets the time at which the task finished, in seconds since the job began.
public float TaskFinishTime { get; set; }Gets or sets a value indicating whether this is the last task in the job sequence.
public bool IsLastTask { get; set; }Gets or sets the time limit for completing the task, in seconds.
public float TimeLimit { get; set; }Gets or sets the type of the task.
See DV.Logic.Job.TaskType for possible values.
public TaskType TaskType { get; set; }TaskType
protected TaskNetworkData()Serialises the task network data to the specified BinaryWriter. Implementations should write all relevant fields for network transmission.
public abstract void Serialize(BinaryWriter writer)writer BinaryWriter
The BinaryWriter to write data to.
Remarks:
The first line of the implementation should call MPAPI.Types.TaskNetworkData1.SerializeCommon(System.IO.BinaryWriter)`.
Deserialises the task network data from the specified BinaryReader. Implementations should read all relevant fields in the same order and size as written by TaskNetworkData.Serialize(BinaryWriter).
public abstract void Deserialize(BinaryReader reader)reader BinaryReader
The BinaryReader to read data from.
Remarks:
The first line of the implementation should call MPAPI.Types.TaskNetworkData1.DeserializeCommon(System.IO.BinaryReader)`.
Converts this TaskNetworkData instance into a DV.Logic.Job.Task object
compatible with the job/task system, and adds them to the provided dictionary.
public abstract Task ToTask(Dictionary`2& netIdToTask)netIdToTask [Dictionary2&](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2&)<br> A reference to a [Dictionary<TKey, TValue>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2) that will be populated with deserialized DV.Logic.Job.Task instances. Each key is a netTaskId (ushort), and each value is the corresponding DV.Logic.Job.Task` object.
Task
A DV.Logic.Job.Task instance representing the deserialized data.
Remarks:
Implementations should add all relevant DV.Logic.Job.Task instances to netIdToTask.
This allows aggregation of multiple tasks from different TaskNetworkData objects into a single dictionary.
Gets a list of car IDs (UInt16) associated with this task.
public abstract List<ushort> GetCars()List<UInt16>
A list of car IDs relevant to the task.
Namespace: MPAPI.Types
Generic abstract base class providing type-safe conversion for serialising and deserialising job task data.
Inherit from this class to implement serialisers for custom DV.Logic.Job.Task types.
public abstract class TaskNetworkData<T> : TaskNetworkDataT
The concrete type that inherits from this class.
Inheritance Object → TaskNetworkData → TaskNetworkData<T>
Gets or sets the unique network identifier for this task within its job.
public ushort TaskNetId { get; set; }Gets or sets the current state of the task.
See DV.Logic.Job.TaskState for possible values.
public TaskState State { get; set; }TaskState
Gets or sets the time at which the task started, in seconds since the job began.
public float TaskStartTime { get; set; }Gets or sets the time at which the task finished, in seconds since the job began.
public float TaskFinishTime { get; set; }Gets or sets a value indicating whether this is the last task in the job sequence.
public bool IsLastTask { get; set; }Gets or sets the time limit for completing the task, in seconds.
public float TimeLimit { get; set; }Gets or sets the type of the task.
See DV.Logic.Job.TaskType for possible values.
public TaskType TaskType { get; set; }TaskType
protected TaskNetworkData()Populates this TaskNetworkData instance from the specified DV.Logic.Job.Task object.
public abstract T FromTask(Task task)task Task
The DV.Logic.Job.Task to extract data from.
T
This instance, populated with data from the provided task.
Remarks:
This method is called by Multiplayer mod when serialising a job.
Extracts and populates the common task data fields from the specified DV.Logic.Job.Task object.
Should be called as the first step in the FromTask implementation of derived classes.
protected void FromTaskCommon(Task task)task Task
The DV.Logic.Job.Task to extract data from.
Populates common task data fields to the specified DV.Logic.Job.Task object.
Should be called after the new task has been instantiated ToTask implementation of derived classes.
protected void ToTaskCommon(Task task)task Task
The DV.Logic.Job.Task to populate.
Serialises the common task data fields to the specified BinaryWriter.
Should be called as the first step in the Serialize implementation of derived classes.
protected void SerializeCommon(BinaryWriter writer)writer BinaryWriter
The BinaryWriter to write data to.
Deserialises the common task data fields from the specified BinaryReader.
Should be called as the first step in the Deserialize implementation of derived classes.
protected void DeserializeCommon(BinaryReader reader)reader BinaryReader
The BinaryReader to read data from.
Namespace: MPAPI.Util
Provides extension methods for BinaryWriter and BinaryReader to handle arrays and Unity types.
public static class BinaryReaderWriterExtensionsInheritance Object → BinaryReaderWriterExtensions
Attributes ExtensionAttribute
Serialises a UInt16 array.
public static void WriteUShortArray(BinaryWriter writer, UInt16[] array)writer BinaryWriter
The BinaryWriter to write to.
array UInt16[]
The UInt16 array to write. If null, writes 0 as the length.
Serialises an Int32 array.
public static void WriteInt32Array(BinaryWriter writer, Int32[] array)writer BinaryWriter
The BinaryWriter to write to.
array Int32[]
The Int32 array to serialise. If null, serialises 0 as the length.
Serialises a UnityEngine.Vector3.
public static void WriteVector3(BinaryWriter writer, Vector3 vector)writer BinaryWriter
The BinaryWriter to write to.
vector Vector3
The UnityEngine.Vector3 to serialise.
Serialises a UnityEngine.Quaternion.
public static void WriteQuaternion(BinaryWriter writer, Quaternion quaternion)writer BinaryWriter
The BinaryWriter to write to.
quaternion Quaternion
The UnityEngine.Quaternion to serialise.
Deserialises a UInt16 array.
public static UInt16[] ReadUShortArray(BinaryReader reader)reader BinaryReader
The BinaryReader to deserialise from.
UInt16[]
The deserialised UInt16 array.
Deserialises an Int32 array.
public static Int32[] ReadInt32Array(BinaryReader reader)reader BinaryReader
The BinaryReader to deserialise from.
Int32[]
The deserialised Int32 array.
Deserialises a UnityEngine.Vector3.
public static Vector3 ReadVector3(BinaryReader reader)reader BinaryReader
The BinaryReader to deserialise from.
Vector3
The deserialised UnityEngine.Vector3.
Deserialises a UnityEngine.Quaternion.
public static Quaternion ReadQuaternion(BinaryReader reader)reader BinaryReader
The BinaryReader to deserialise from.
Quaternion
The deserialised UnityEngine.Quaternion.
Getting Started
Guides
- The Basics
- Packet Naming Conventions
- Defining Packets
- Registering Packet Listeners
- Sending Packets