remove SyncBase.PlayerId

This commit is contained in:
JohnCorby 2022-01-07 15:36:31 -08:00
parent 2d6133002b
commit b79cea5254
3 changed files with 11 additions and 8 deletions

View File

@ -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()

View File

@ -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;

View File

@ -16,8 +16,10 @@ namespace QSB.Syncs
public abstract class SyncBase<T> : QNetworkTransform where T : Component
{
/// <summary>
/// only valid for player objects
/// </summary>
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 : "<NonPlayer>")}.{NetId.Value}:{GetType().Name}";
protected virtual float DistanceLeeway { get; } = 5f;
private float _previousDistance;
protected const float SmoothTime = 0.1f;