diff --git a/Basis/Packages/com.basis.framework/Networking/BasisNetworkBehaviour/BasisNetworkBehaviour.cs b/Basis/Packages/com.basis.framework/Networking/BasisNetworkBehaviour/BasisNetworkBehaviour.cs index 6854efcfcf..6861f5dea7 100644 --- a/Basis/Packages/com.basis.framework/Networking/BasisNetworkBehaviour/BasisNetworkBehaviour.cs +++ b/Basis/Packages/com.basis.framework/Networking/BasisNetworkBehaviour/BasisNetworkBehaviour.cs @@ -30,6 +30,8 @@ public ushort NetworkID public ushort CurrentOwnerId; public BasisNetworkPlayer currentOwnedPlayer; + public DateTime RemoteUtcTime => BasisNetworkManagement.RemoteUtcTime(); + public long RemoteDeltaTime => BasisNetworkManagement.RemoteTimeDelta(); /// /// the reason its start instead of awake is to make sure progation occurs to everything no matter the net connect /// @@ -122,6 +124,8 @@ private void LowLevelOwnershipReleased(string uniqueEntityID) { if (uniqueEntityID == clientIdentifier) { + IsOwnedLocallyOnServer = false; + IsOwnedLocallyOnClient = false; OnServerOwnershipDestroyed(); } } @@ -142,6 +146,7 @@ private void LowLevelOwnershipTransfer(string uniqueEntityID, ushort NetIdNewOwn BasisUnInitalizedPlayer UnInitalizedPlayer = new BasisUnInitalizedPlayer(CurrentOwnerId); BasisDebug.LogError($"No Owner for Id {CurrentOwnerId} Creating Fake {nameof(BasisUnInitalizedPlayer)} this should only occur rarely"); UnInitalizedPlayer.Initialize(); + currentOwnedPlayer = UnInitalizedPlayer; OnOwnershipTransfer(UnInitalizedPlayer); } } @@ -302,6 +307,20 @@ public async Task RequestWhoIsOwnershipAsync(int Timout = BasisOwnershipResult Result = await BasisNetworkOwnership.RequestCurrentOwnershipAsync(clientIdentifier, Timout); return Result; } + + public bool TryGetOwnerId(out ushort OwnerId) + { + if (currentOwnedPlayer != null && currentOwnedPlayer.IsOwnerCached(clientIdentifier)) + { + OwnerId = currentOwnedPlayer.playerId; + return true; + } + OwnerId = 0; + // if we dont have it cached locally we can ask the server to give it to us to cache and invoke any ownershipTransfer events. + RequestWhoIsOwnershipAsync(); + return false; + } + public virtual void OnNetworkReady() {