Add GetPlayerPosition() and GetPlayerReady() to api

This commit is contained in:
_nebula 2023-11-12 15:13:25 +00:00
parent 5f92d5d4bf
commit 8c76f4f4d0
2 changed files with 20 additions and 0 deletions

View File

@ -37,6 +37,19 @@ public interface IQSBAPI
/// <param name="playerID">The ID of the player you want the name of.</param>
string GetPlayerName(uint playerID);
/// <summary>
/// Returns the position of a given player.
/// This position is in world space, where (0, 0, 0) is roughly where the local player is located.
/// </summary>
/// <param name="playerID">The ID of the player you want the position of.</param>
Vector3 GetPlayerPosition(uint playerID);
/// <summary>
/// Returns true if a given player has fully loaded into the game. If the local player is still loading into the game, this will return false.
/// </summary>
/// <param name="playerID">The ID of the player.</param>
bool GetPlayerReady(uint playerID);
/// <summary>
/// Returns the list of IDs of all connected players.
///

View File

@ -25,6 +25,13 @@ public class QSBAPI : IQSBAPI
public uint GetLocalPlayerID() => QSBPlayerManager.LocalPlayerId;
public string GetPlayerName(uint playerId) => QSBPlayerManager.GetPlayer(playerId).Name;
public Vector3 GetPlayerPosition(uint playerId) => QSBPlayerManager.GetPlayer(playerId).Body.transform.position;
public bool GetPlayerReady(uint playerId)
{
var player = QSBPlayerManager.GetPlayer(playerId);
return player.IsReady && player.Body != null;
}
public uint[] GetPlayerIDs() => QSBPlayerManager.PlayerList.Select(x => x.PlayerId).ToArray();
public UnityEvent<uint> OnPlayerJoin() => QSBAPIEvents.OnPlayerJoinEvent;