mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
add To
to api messages
This commit is contained in:
parent
b2962e19ca
commit
ad218e82e2
@ -52,15 +52,16 @@ public interface IQSBAPI
|
||||
/// <param name="key">The unique key of the data you want to access.</param>
|
||||
/// <returns>The data requested. If key is not valid, returns default.</returns>
|
||||
T GetCustomData<T>(uint playerId, string key);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sends a message containing arbitrary data to every player.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the data being sent. This type must be serializable.</typeparam>
|
||||
/// <param name="messageType">The unique key of the message.</param>
|
||||
/// <param name="data">The data to send.</param>
|
||||
/// <param name="to">The player to send this message to. (0 is the host, uint.MaxValue means every player)</param>
|
||||
/// <param name="receiveLocally">If true, the action given to <see cref="RegisterHandler{T}"/> will also be called on the same client that is sending the message.</param>
|
||||
void SendMessage<T>(string messageType, T data, bool receiveLocally = false);
|
||||
void SendMessage<T>(string messageType, T data, uint to = uint.MaxValue, bool receiveLocally = false);
|
||||
|
||||
/// <summary>
|
||||
/// Registers an action to be called when a message is received.
|
||||
|
@ -27,8 +27,8 @@ public class QSBAPI : IQSBAPI
|
||||
public void SetCustomData<T>(uint playerId, string key, T data) => QSBPlayerManager.GetPlayer(playerId).SetCustomData(key, data);
|
||||
public T GetCustomData<T>(uint playerId, string key) => QSBPlayerManager.GetPlayer(playerId).GetCustomData<T>(key);
|
||||
|
||||
public void SendMessage<T>(string messageType, T data, bool receiveLocally = false)
|
||||
=> new AddonDataMessage(messageType, data, receiveLocally).Send();
|
||||
public void SendMessage<T>(string messageType, T data, uint to = uint.MaxValue, bool receiveLocally = false)
|
||||
=> new AddonDataMessage(messageType, data, receiveLocally) {To = to} .Send();
|
||||
|
||||
public void RegisterHandler<T>(string messageType, Action<uint, T> handler)
|
||||
=> AddonDataManager.RegisterHandler(messageType, handler);
|
||||
|
Loading…
Reference in New Issue
Block a user