From b79cea5254296a4864af4982d24a920e2785fb46 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Fri, 7 Jan 2022 15:36:31 -0800 Subject: [PATCH] remove SyncBase.PlayerId --- QSB/Player/TransformSync/PlayerTransformSync.cs | 8 ++++---- QSB/Syncs/Sectored/BaseSectoredSync.cs | 5 +++-- QSB/Syncs/SyncBase.cs | 6 ++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/QSB/Player/TransformSync/PlayerTransformSync.cs b/QSB/Player/TransformSync/PlayerTransformSync.cs index b677aa2a..fb4529ac 100644 --- a/QSB/Player/TransformSync/PlayerTransformSync.cs +++ b/QSB/Player/TransformSync/PlayerTransformSync.cs @@ -50,8 +50,8 @@ namespace QSB.Player.TransformSync var player = new PlayerInfo(this); QSBPlayerManager.PlayerList.SafeAdd(player); base.Start(); - QSBPlayerManager.OnAddPlayer?.Invoke(PlayerId); - DebugLog.DebugWrite($"Create Player : id<{PlayerId}>", MessageType.Info); + QSBPlayerManager.OnAddPlayer?.Invoke(Player.PlayerId); + DebugLog.DebugWrite($"Create Player : id<{Player.PlayerId}>", MessageType.Info); } protected override void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool isInUniverse) @@ -87,11 +87,11 @@ namespace QSB.Player.TransformSync protected override void OnDestroy() { // TODO : Maybe move this to a leave event...? Would ensure everything could finish up before removing the player - QSBPlayerManager.OnRemovePlayer?.Invoke(PlayerId); + QSBPlayerManager.OnRemovePlayer?.Invoke(Player.PlayerId); base.OnDestroy(); Player.HudMarker?.Remove(); QSBPlayerManager.PlayerList.Remove(Player); - DebugLog.DebugWrite($"Remove Player : id<{PlayerId}>", MessageType.Info); + DebugLog.DebugWrite($"Remove Player : id<{Player.PlayerId}>", MessageType.Info); } protected override Transform InitLocalTransform() diff --git a/QSB/Syncs/Sectored/BaseSectoredSync.cs b/QSB/Syncs/Sectored/BaseSectoredSync.cs index d09b1a8c..8c3b7a8c 100644 --- a/QSB/Syncs/Sectored/BaseSectoredSync.cs +++ b/QSB/Syncs/Sectored/BaseSectoredSync.cs @@ -127,12 +127,13 @@ namespace QSB.Syncs.Sectored { if (IsPlayerObject) { - if (!QSBPlayerManager.PlayerExists(PlayerId)) + if (Player == null) { writer.Write(-1); return; } - else if (!Player.IsReady) + + if (!Player.IsReady) { writer.Write(-1); return; diff --git a/QSB/Syncs/SyncBase.cs b/QSB/Syncs/SyncBase.cs index 462a2405..96ebc309 100644 --- a/QSB/Syncs/SyncBase.cs +++ b/QSB/Syncs/SyncBase.cs @@ -16,8 +16,10 @@ namespace QSB.Syncs public abstract class SyncBase : QNetworkTransform where T : Component { + /// + /// only valid for player objects + /// public PlayerInfo Player { get; private set; } - protected uint PlayerId => Player.PlayerId; private bool _baseIsReady { @@ -60,7 +62,7 @@ namespace QSB.Syncs public T AttachedObject { get; set; } public Transform ReferenceTransform { get; set; } - public string LogName => $"{PlayerId}.{NetId.Value}:{GetType().Name}"; + public string LogName => $"{(IsPlayerObject ? Player.PlayerId : "")}.{NetId.Value}:{GetType().Name}"; protected virtual float DistanceLeeway { get; } = 5f; private float _previousDistance; protected const float SmoothTime = 0.1f;