mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-11 06:40:39 +00:00
api regions
This commit is contained in:
parent
fb49c6e132
commit
c56e62e67b
@ -4,6 +4,8 @@ using UnityEngine.Events;
|
|||||||
|
|
||||||
public interface IQSBAPI
|
public interface IQSBAPI
|
||||||
{
|
{
|
||||||
|
#region General
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If called, all players connected to YOUR hosted game must have this mod installed.
|
/// If called, all players connected to YOUR hosted game must have this mod installed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -19,6 +21,20 @@ public interface IQSBAPI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
bool GetIsInMultiplayer();
|
bool GetIsInMultiplayer();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked on the host when the server is first started.
|
||||||
|
/// </summary>
|
||||||
|
UnityEvent OnStartHost();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked on the host when the server is closed.
|
||||||
|
/// </summary>
|
||||||
|
UnityEvent OnStopHost();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Player
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the player ID of the current player.
|
/// Returns the player ID of the current player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -69,16 +85,6 @@ public interface IQSBAPI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
UnityEvent<uint> OnPeerLeave();
|
UnityEvent<uint> OnPeerLeave();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invoked on the host when the server is first started.
|
|
||||||
/// </summary>
|
|
||||||
UnityEvent OnStartHost();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invoked on the host when the server is closed.
|
|
||||||
/// </summary>
|
|
||||||
UnityEvent OnStopHost();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets some arbitrary data for a given player.
|
/// Sets some arbitrary data for a given player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -97,6 +103,10 @@ public interface IQSBAPI
|
|||||||
/// <returns>The data requested. If key is not valid, returns default.</returns>
|
/// <returns>The data requested. If key is not valid, returns default.</returns>
|
||||||
T GetCustomData<T>(uint playerId, string key);
|
T GetCustomData<T>(uint playerId, string key);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Messaging
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a message containing arbitrary data to every player.
|
/// Sends a message containing arbitrary data to every player.
|
||||||
///
|
///
|
||||||
@ -116,4 +126,6 @@ public interface IQSBAPI
|
|||||||
/// <param name="messageType">The unique key of the message.</param>
|
/// <param name="messageType">The unique key of the message.</param>
|
||||||
/// <param name="handler">The action to be ran when the message is received. The uint is the player ID that sent the messsage.</param>
|
/// <param name="handler">The action to be ran when the message is received. The uint is the player ID that sent the messsage.</param>
|
||||||
void RegisterHandler<T>(string messageType, Action<uint, T> handler);
|
void RegisterHandler<T>(string messageType, Action<uint, T> handler);
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ using UnityEngine.Events;
|
|||||||
|
|
||||||
public interface IQSBAPI
|
public interface IQSBAPI
|
||||||
{
|
{
|
||||||
|
#region General
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If called, all players connected to YOUR hosted game must have this mod installed.
|
/// If called, all players connected to YOUR hosted game must have this mod installed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -19,6 +21,20 @@ public interface IQSBAPI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
bool GetIsInMultiplayer();
|
bool GetIsInMultiplayer();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked on the host when the server is first started.
|
||||||
|
/// </summary>
|
||||||
|
UnityEvent OnStartHost();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked on the host when the server is closed.
|
||||||
|
/// </summary>
|
||||||
|
UnityEvent OnStopHost();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Player
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the player ID of the current player.
|
/// Returns the player ID of the current player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -69,16 +85,6 @@ public interface IQSBAPI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
UnityEvent<uint> OnPeerLeave();
|
UnityEvent<uint> OnPeerLeave();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invoked on the host when the server is first started.
|
|
||||||
/// </summary>
|
|
||||||
UnityEvent OnStartHost();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invoked on the host when the server is closed.
|
|
||||||
/// </summary>
|
|
||||||
UnityEvent OnStopHost();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets some arbitrary data for a given player.
|
/// Sets some arbitrary data for a given player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -97,6 +103,10 @@ public interface IQSBAPI
|
|||||||
/// <returns>The data requested. If key is not valid, returns default.</returns>
|
/// <returns>The data requested. If key is not valid, returns default.</returns>
|
||||||
T GetCustomData<T>(uint playerId, string key);
|
T GetCustomData<T>(uint playerId, string key);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Messaging
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a message containing arbitrary data to every player.
|
/// Sends a message containing arbitrary data to every player.
|
||||||
///
|
///
|
||||||
@ -116,4 +126,6 @@ public interface IQSBAPI
|
|||||||
/// <param name="messageType">The unique key of the message.</param>
|
/// <param name="messageType">The unique key of the message.</param>
|
||||||
/// <param name="handler">The action to be ran when the message is received. The uint is the player ID that sent the messsage.</param>
|
/// <param name="handler">The action to be ran when the message is received. The uint is the player ID that sent the messsage.</param>
|
||||||
void RegisterHandler<T>(string messageType, Action<uint, T> handler);
|
void RegisterHandler<T>(string messageType, Action<uint, T> handler);
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,9 @@ public class QSBAPI : IQSBAPI
|
|||||||
public bool GetIsHost() => QSBCore.IsHost;
|
public bool GetIsHost() => QSBCore.IsHost;
|
||||||
public bool GetIsInMultiplayer() => QSBCore.IsInMultiplayer;
|
public bool GetIsInMultiplayer() => QSBCore.IsInMultiplayer;
|
||||||
|
|
||||||
|
public UnityEvent OnStartHost() => QSBAPIEvents.OnStartHostEvent;
|
||||||
|
public UnityEvent OnStopHost() => QSBAPIEvents.OnStopHostEvent;
|
||||||
|
|
||||||
public uint GetLocalPlayerID() => QSBPlayerManager.LocalPlayerId;
|
public uint GetLocalPlayerID() => QSBPlayerManager.LocalPlayerId;
|
||||||
public string GetPlayerName(uint playerId) => QSBPlayerManager.GetPlayer(playerId).Name;
|
public string GetPlayerName(uint playerId) => QSBPlayerManager.GetPlayer(playerId).Name;
|
||||||
public uint[] GetPlayerIDs() => QSBPlayerManager.PlayerList.Select(x => x.PlayerId).ToArray();
|
public uint[] GetPlayerIDs() => QSBPlayerManager.PlayerList.Select(x => x.PlayerId).ToArray();
|
||||||
@ -32,9 +35,6 @@ public class QSBAPI : IQSBAPI
|
|||||||
public UnityEvent<uint> OnPeerJoin() => QSBAPIEvents.OnPeerJoinEvent;
|
public UnityEvent<uint> OnPeerJoin() => QSBAPIEvents.OnPeerJoinEvent;
|
||||||
public UnityEvent<uint> OnPeerLeave() => QSBAPIEvents.OnPeerLeaveEvent;
|
public UnityEvent<uint> OnPeerLeave() => QSBAPIEvents.OnPeerLeaveEvent;
|
||||||
|
|
||||||
public UnityEvent OnStartHost() => QSBAPIEvents.OnStartHostEvent;
|
|
||||||
public UnityEvent OnStopHost() => QSBAPIEvents.OnStopHostEvent;
|
|
||||||
|
|
||||||
public void SetCustomData<T>(uint playerId, string key, T data) => QSBPlayerManager.GetPlayer(playerId).SetCustomData(key, data);
|
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 T GetCustomData<T>(uint playerId, string key) => QSBPlayerManager.GetPlayer(playerId).GetCustomData<T>(key);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user