remove QNetworkIdentity.PlayerIdentity

This commit is contained in:
JohnCorby 2021-12-27 20:11:52 -08:00
parent 62f7b4e1f1
commit d6c391d2ec
2 changed files with 7 additions and 6 deletions

View File

@ -17,7 +17,7 @@ namespace QSB.Syncs
public abstract class SyncBase<T> : QNetworkTransform where T : Component public abstract class SyncBase<T> : QNetworkTransform where T : Component
{ {
public uint PlayerId => IsPlayerObject ? NetIdentity.PlayerIdentity.NetId.Value : uint.MaxValue; public uint PlayerId { get; private set; } = uint.MaxValue;
public PlayerInfo Player => QSBPlayerManager.GetPlayer(PlayerId); public PlayerInfo Player => QSBPlayerManager.GetPlayer(PlayerId);
private bool _baseIsReady private bool _baseIsReady
@ -79,10 +79,12 @@ namespace QSB.Syncs
{ {
if (IsPlayerObject) if (IsPlayerObject)
{ {
var lowestBound = QSBWorldSync.GetUnityObjects<PlayerTransformSync>() // get player objects spawned before this object (or is this one)
.Where(x => x.NetId.Value <= NetId.Value) // and use the most recently spawned one
.OrderBy(x => x.NetId.Value).Last(); PlayerId = QSBWorldSync.GetUnityObjects<PlayerTransformSync>()
NetIdentity.PlayerIdentity = lowestBound.NetIdentity; .Select(x => x.NetId.Value)
.Where(x => x <= NetId.Value)
.Max();
} }
DontDestroyOnLoad(gameObject); DontDestroyOnLoad(gameObject);

View File

@ -21,7 +21,6 @@ namespace QuantumUNET.Components
public short PlayerControllerId { get; private set; } = -1; public short PlayerControllerId { get; private set; } = -1;
public QNetworkConnection ConnectionToServer { get; private set; } public QNetworkConnection ConnectionToServer { get; private set; }
public QNetworkConnection ConnectionToClient { get; private set; } public QNetworkConnection ConnectionToClient { get; private set; }
public QNetworkIdentity PlayerIdentity { get; set; }
public bool ServerOnly public bool ServerOnly
{ {