mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-06 00:39:55 +00:00
api regions
This commit is contained in:
parent
fb49c6e132
commit
c56e62e67b
@ -4,6 +4,8 @@ using UnityEngine.Events;
|
||||
|
||||
public interface IQSBAPI
|
||||
{
|
||||
#region General
|
||||
|
||||
/// <summary>
|
||||
/// If called, all players connected to YOUR hosted game must have this mod installed.
|
||||
/// </summary>
|
||||
@ -19,6 +21,20 @@ public interface IQSBAPI
|
||||
/// </summary>
|
||||
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>
|
||||
/// Returns the player ID of the current player.
|
||||
/// </summary>
|
||||
@ -69,16 +85,6 @@ public interface IQSBAPI
|
||||
/// </summary>
|
||||
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>
|
||||
/// Sets some arbitrary data for a given player.
|
||||
/// </summary>
|
||||
@ -97,6 +103,10 @@ public interface IQSBAPI
|
||||
/// <returns>The data requested. If key is not valid, returns default.</returns>
|
||||
T GetCustomData<T>(uint playerId, string key);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Messaging
|
||||
|
||||
/// <summary>
|
||||
/// 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="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);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ using UnityEngine.Events;
|
||||
|
||||
public interface IQSBAPI
|
||||
{
|
||||
#region General
|
||||
|
||||
/// <summary>
|
||||
/// If called, all players connected to YOUR hosted game must have this mod installed.
|
||||
/// </summary>
|
||||
@ -19,6 +21,20 @@ public interface IQSBAPI
|
||||
/// </summary>
|
||||
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>
|
||||
/// Returns the player ID of the current player.
|
||||
/// </summary>
|
||||
@ -69,16 +85,6 @@ public interface IQSBAPI
|
||||
/// </summary>
|
||||
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>
|
||||
/// Sets some arbitrary data for a given player.
|
||||
/// </summary>
|
||||
@ -97,6 +103,10 @@ public interface IQSBAPI
|
||||
/// <returns>The data requested. If key is not valid, returns default.</returns>
|
||||
T GetCustomData<T>(uint playerId, string key);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Messaging
|
||||
|
||||
/// <summary>
|
||||
/// 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="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);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
@ -19,6 +19,9 @@ public class QSBAPI : IQSBAPI
|
||||
public bool GetIsHost() => QSBCore.IsHost;
|
||||
public bool GetIsInMultiplayer() => QSBCore.IsInMultiplayer;
|
||||
|
||||
public UnityEvent OnStartHost() => QSBAPIEvents.OnStartHostEvent;
|
||||
public UnityEvent OnStopHost() => QSBAPIEvents.OnStopHostEvent;
|
||||
|
||||
public uint GetLocalPlayerID() => QSBPlayerManager.LocalPlayerId;
|
||||
public string GetPlayerName(uint playerId) => QSBPlayerManager.GetPlayer(playerId).Name;
|
||||
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> 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 T GetCustomData<T>(uint playerId, string key) => QSBPlayerManager.GetPlayer(playerId).GetCustomData<T>(key);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user