Remove pending owner thing (#1018)

This commit is contained in:
Paul Pacheco 2019-08-11 11:28:39 -07:00 committed by vis2k
parent cd88c69df9
commit 75b4a276f8
2 changed files with 7 additions and 9 deletions

View File

@ -20,8 +20,6 @@ public static class ClientScene
{ {
static bool isSpawnFinished; static bool isSpawnFinished;
static HashSet<uint> pendingOwnerNetIds = new HashSet<uint>();
/// <summary> /// <summary>
/// NetworkIdentity of the localPlayer /// NetworkIdentity of the localPlayer
/// </summary> /// </summary>
@ -62,7 +60,6 @@ public static class ClientScene
internal static void Shutdown() internal static void Shutdown()
{ {
ClearSpawners(); ClearSpawners();
pendingOwnerNetIds.Clear();
spawnableObjects = null; spawnableObjects = null;
readyConnection = null; readyConnection = null;
ready = false; ready = false;
@ -502,6 +499,7 @@ internal static void OnSpawnPrefab(NetworkConnection conn, SpawnPrefabMessage ms
return; return;
} }
localObject.Reset(); localObject.Reset();
localObject.pendingOwner = msg.owner;
ApplySpawnPayload(localObject, msg.position, msg.rotation, msg.scale, msg.payload, msg.netId); ApplySpawnPayload(localObject, msg.position, msg.rotation, msg.scale, msg.payload, msg.netId);
} }
// lookup registered factory for type: // lookup registered factory for type:
@ -520,6 +518,7 @@ internal static void OnSpawnPrefab(NetworkConnection conn, SpawnPrefabMessage ms
return; return;
} }
localObject.Reset(); localObject.Reset();
localObject.pendingOwner = msg.owner;
localObject.assetId = msg.assetId; localObject.assetId = msg.assetId;
ApplySpawnPayload(localObject, msg.position, msg.rotation, msg.scale, msg.payload, msg.netId); ApplySpawnPayload(localObject, msg.position, msg.rotation, msg.scale, msg.payload, msg.netId);
} }
@ -564,6 +563,7 @@ internal static void OnSpawnSceneObject(NetworkConnection conn, SpawnSceneObject
if (LogFilter.Debug) Debug.Log("Client spawn for [netId:" + msg.netId + "] [sceneId:" + msg.sceneId + "] obj:" + spawnedId.gameObject.name); if (LogFilter.Debug) Debug.Log("Client spawn for [netId:" + msg.netId + "] [sceneId:" + msg.sceneId + "] obj:" + spawnedId.gameObject.name);
spawnedId.Reset(); spawnedId.Reset();
spawnedId.pendingOwner = msg.owner;
ApplySpawnPayload(spawnedId, msg.position, msg.rotation, msg.scale, msg.payload, msg.netId); ApplySpawnPayload(spawnedId, msg.position, msg.rotation, msg.scale, msg.payload, msg.netId);
} }
@ -733,15 +733,11 @@ internal static void OnSpawnMessageForOwner(uint netId)
localObject.SetLocalPlayer(); localObject.SetLocalPlayer();
InternalAddPlayer(localObject); InternalAddPlayer(localObject);
} }
else
{
pendingOwnerNetIds.Add(netId);
}
} }
static void CheckForOwner(NetworkIdentity identity) static void CheckForOwner(NetworkIdentity identity)
{ {
if (pendingOwnerNetIds.Contains(identity.netId)) if (identity.pendingOwner)
{ {
// found owner, turn into a local player // found owner, turn into a local player
@ -757,7 +753,7 @@ static void CheckForOwner(NetworkIdentity identity)
} }
InternalAddPlayer(identity); InternalAddPlayer(identity);
pendingOwnerNetIds.Remove(identity.netId); identity.pendingOwner = false;
} }
} }
} }

View File

@ -76,6 +76,8 @@ public bool isServer
/// </summary> /// </summary>
public bool isLocalPlayer { get; private set; } public bool isLocalPlayer { get; private set; }
internal bool pendingOwner { get; set; }
/// <summary> /// <summary>
/// This returns true if this object is the authoritative version of the object in the distributed network application. /// This returns true if this object is the authoritative version of the object in the distributed network application.
/// <para>This value is determined at runtime, as opposed to localPlayerAuthority which is set on the prefab. For most objects, authority is held by the server / host. For objects with localPlayerAuthority set, authority is held by the client of that player.</para> /// <para>This value is determined at runtime, as opposed to localPlayerAuthority which is set on the prefab. For most objects, authority is held by the server / host. For objects with localPlayerAuthority set, authority is held by the client of that player.</para>