Skip to content

Commit 76a0480

Browse files
committed
styling + is spawned check in internal has authory
1 parent 1495955 commit 76a0480

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ private void CheckForInScenePlaced()
390390
/// <param name="destroy">Defaults to true, determines whether the <see cref="NetworkObject"/> will be destroyed.</param>
391391
public void DeferDespawn(int tickOffset, bool destroy = true)
392392
{
393-
// Ensure we log the DAMode message first as locking ownership is not allowed if not DA so the DA message is the most relevant.
393+
// The DAMode message is logged first, as ownership locking isn’t allowed when not in DAMode, making it the most relevant message.
394394
if (!NetworkManager.DistributedAuthorityMode)
395395
{
396396
if (NetworkManager.LogLevel <= LogLevel.Error)
@@ -606,7 +606,7 @@ internal void RemoveOwnershipExtended(OwnershipStatusExtended extended)
606606
/// <returns>true or false depending upon lock operation's success</returns>
607607
public bool SetOwnershipLock(bool lockOwnership = true)
608608
{
609-
// Ensure we log the DAMode message first as locking ownership is not allowed if not DA so the DA message is the most relevant.
609+
// The DAMode message is logged first, as ownership locking isn’t allowed when not in DAMode, making it the most relevant message.
610610
if (!NetworkManager.DistributedAuthorityMode)
611611
{
612612
if (NetworkManager.LogLevel <= LogLevel.Error)
@@ -1154,8 +1154,11 @@ public bool HasOwnershipStatus(OwnershipStatus status)
11541154
[MethodImpl(MethodImplOptions.AggressiveInlining)]
11551155
private bool InternalHasAuthority()
11561156
{
1157-
var networkManager = NetworkManager;
1158-
return networkManager.DistributedAuthorityMode ? OwnerClientId == networkManager.LocalClientId : networkManager.IsServer;
1157+
if (!IsSpawned)
1158+
{
1159+
return false;
1160+
}
1161+
return NetworkManagerOwner.DistributedAuthorityMode ? OwnerClientId == NetworkManagerOwner.LocalClientId : NetworkManagerOwner.IsServer;
11591162
}
11601163

11611164
/// <summary>
@@ -3541,7 +3544,7 @@ internal void SceneChangedUpdate(Scene scene, bool notify = false)
35413544
OnMigratedToNewScene?.Invoke();
35423545

35433546
// Only the authority side will notify clients of non-parented NetworkObject scene changes
3544-
if (isAuthority && notify && !transform.parent)
3547+
if (isAuthority && notify && transform.parent == null)
35453548
{
35463549
NetworkManagerOwner.SceneManager.NotifyNetworkObjectSceneChanged(this);
35473550
}

0 commit comments

Comments
 (0)