mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-04 02:47:22 +00:00
get localplayer using transform sync
This commit is contained in:
parent
b8fd43fda2
commit
2d6133002b
@ -12,26 +12,26 @@ namespace QSB.Player
|
|||||||
{
|
{
|
||||||
public static class QSBPlayerManager
|
public static class QSBPlayerManager
|
||||||
{
|
{
|
||||||
public static uint LocalPlayerId
|
public static PlayerInfo LocalPlayer
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var localInstance = PlayerTransformSync.LocalInstance;
|
var localInstance = PlayerTransformSync.LocalInstance;
|
||||||
if (localInstance == null)
|
if (localInstance == null)
|
||||||
{
|
{
|
||||||
DebugLog.ToConsole($"Error - Trying to get LocalPlayerId when the local PlayerTransformSync instance is null." +
|
DebugLog.ToConsole("Error - Trying to get LocalPlayer when the local PlayerTransformSync instance is null." +
|
||||||
$"{Environment.NewLine} Stacktrace : {Environment.StackTrace} ", MessageType.Error);
|
$"{Environment.NewLine} Stacktrace : {Environment.StackTrace} ", MessageType.Error);
|
||||||
return uint.MaxValue;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return localInstance.NetIdentity.NetId.Value;
|
return localInstance.Player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static uint LocalPlayerId => LocalPlayer.PlayerId;
|
||||||
|
|
||||||
public static Action<uint> OnAddPlayer;
|
public static Action<uint> OnAddPlayer;
|
||||||
public static Action<uint> OnRemovePlayer;
|
public static Action<uint> OnRemovePlayer;
|
||||||
|
|
||||||
public static PlayerInfo LocalPlayer => GetPlayer(LocalPlayerId);
|
|
||||||
public static readonly List<PlayerInfo> PlayerList = new();
|
public static readonly List<PlayerInfo> PlayerList = new();
|
||||||
|
|
||||||
public static PlayerInfo GetPlayer(uint id)
|
public static PlayerInfo GetPlayer(uint id)
|
||||||
@ -58,8 +58,8 @@ namespace QSB.Player
|
|||||||
{
|
{
|
||||||
var cameraList = PlayerList.Where(x => x.Camera != null && x.PlayerId != LocalPlayerId).ToList();
|
var cameraList = PlayerList.Where(x => x.Camera != null && x.PlayerId != LocalPlayerId).ToList();
|
||||||
if (includeLocalCamera
|
if (includeLocalCamera
|
||||||
&& LocalPlayer != default
|
&& LocalPlayer != default
|
||||||
&& LocalPlayer.Camera != null)
|
&& LocalPlayer.Camera != null)
|
||||||
{
|
{
|
||||||
cameraList.Add(LocalPlayer);
|
cameraList.Add(LocalPlayer);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace QSB.Syncs
|
|||||||
|
|
||||||
public abstract class SyncBase<T> : QNetworkTransform where T : Component
|
public abstract class SyncBase<T> : QNetworkTransform where T : Component
|
||||||
{
|
{
|
||||||
protected PlayerInfo Player { get; private set; }
|
public PlayerInfo Player { get; private set; }
|
||||||
protected uint PlayerId => Player.PlayerId;
|
protected uint PlayerId => Player.PlayerId;
|
||||||
|
|
||||||
private bool _baseIsReady
|
private bool _baseIsReady
|
||||||
|
Loading…
Reference in New Issue
Block a user