From 8c76f4f4d04cde00128f3de333827187d5ba2ac7 Mon Sep 17 00:00:00 2001 From: _nebula <41904486+misternebula@users.noreply.github.com> Date: Sun, 12 Nov 2023 15:13:25 +0000 Subject: [PATCH] Add GetPlayerPosition() and GetPlayerReady() to api --- QSB/API/IQSBAPI.cs | 13 +++++++++++++ QSB/API/QSBAPI.cs | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/QSB/API/IQSBAPI.cs b/QSB/API/IQSBAPI.cs index eadb98cea..a0e840308 100644 --- a/QSB/API/IQSBAPI.cs +++ b/QSB/API/IQSBAPI.cs @@ -37,6 +37,19 @@ public interface IQSBAPI /// The ID of the player you want the name of. string GetPlayerName(uint playerID); + /// + /// 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. + /// + /// The ID of the player you want the position of. + Vector3 GetPlayerPosition(uint playerID); + + /// + /// 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. + /// + /// The ID of the player. + bool GetPlayerReady(uint playerID); + /// /// Returns the list of IDs of all connected players. /// diff --git a/QSB/API/QSBAPI.cs b/QSB/API/QSBAPI.cs index 1430e1428..c979c92f6 100644 --- a/QSB/API/QSBAPI.cs +++ b/QSB/API/QSBAPI.cs @@ -25,6 +25,13 @@ public void RegisterRequiredForAllPlayers(IModBehaviour mod) 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 OnPlayerJoin() => QSBAPIEvents.OnPlayerJoinEvent;