mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-06 01:00:16 +00:00
add logs to GetPlayerId
This commit is contained in:
parent
2ed5e43db3
commit
d3f0af5d3c
@ -40,8 +40,33 @@ namespace QSB.Utility
|
||||
// QNET
|
||||
public static uint GetPlayerId(this QNetworkConnection connection)
|
||||
{
|
||||
var go = connection.PlayerControllers[0].Gameobject;
|
||||
if (connection == null)
|
||||
{
|
||||
DebugLog.DebugWrite($"Error - Trying to get player id of null QNetworkConnection.", MessageType.Error);
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
var playerController = connection.PlayerControllers[0];
|
||||
if (playerController == null)
|
||||
{
|
||||
DebugLog.DebugWrite($"Error - Player Controller of {connection.address} is null.", MessageType.Error);
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
var go = playerController.Gameobject;
|
||||
if (go == null)
|
||||
{
|
||||
DebugLog.DebugWrite($"Error - GameObject of {playerController.UnetView.NetId.Value} is null.", MessageType.Error);
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
var controller = go.GetComponent<PlayerTransformSync>();
|
||||
if (controller == null)
|
||||
{
|
||||
DebugLog.DebugWrite($"Error - No PlayerTransformSync found on {go.name}", MessageType.Error);
|
||||
return uint.MaxValue;
|
||||
}
|
||||
|
||||
return controller.NetId.Value;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user