NetworkScene.SetLocalObject removed. Moved code into ClientScene.SetLocalObject and NetworkServer.SetLocalObject instead.

This commit is contained in:
vis2k 2018-12-16 18:55:24 +01:00
parent 73bd9191d8
commit 7387b2a47a
3 changed files with 33 additions and 25 deletions

View File

@ -272,9 +272,25 @@ public static void DestroyAllClientObjects()
} }
public static void SetLocalObject(uint netId, NetworkIdentity ni) public static void SetLocalObject(uint netId, NetworkIdentity ni)
{
if (LogFilter.Debug) { Debug.Log("ClientScene.SetLocalObject " + netId + " " + ni); }
if (ni != null)
{ {
// if still receiving initial state, dont set isClient // if still receiving initial state, dont set isClient
s_NetworkScene.SetLocalObject(netId, ni, s_IsSpawnFinished, false); if (s_IsSpawnFinished) ni.EnableIsClient();
// !Contains check needed to avoid dictionary 'out of sync' error
// because SetLocalObject is called from a foreach loop
if (!NetworkIdentity.spawned.ContainsKey(netId))
{
NetworkIdentity.spawned[netId] = ni;
}
}
else
{
NetworkIdentity.spawned[netId] = null;
}
} }
public static GameObject FindLocalObject(uint netId) public static GameObject FindLocalObject(uint netId)

View File

@ -18,28 +18,6 @@ internal void Shutdown()
ClearSpawners(); ClearSpawners();
} }
internal void SetLocalObject(uint netId, NetworkIdentity ni, bool isClient, bool isServer)
{
if (LogFilter.Debug) { Debug.Log("SetLocalObject " + netId + " " + ni); }
if (ni != null)
{
if (isClient) ni.EnableIsClient();
if (isServer) ni.EnableIsServer();
// !Contains check needed to avoid dictionary 'out of sync' error
// because SetLocalObject is called from a foreach loop
if (!NetworkIdentity.spawned.ContainsKey(netId))
{
NetworkIdentity.spawned[netId] = ni;
}
}
else
{
NetworkIdentity.spawned[netId] = null;
}
}
internal static void RegisterPrefab(GameObject prefab, Guid newAssetId) internal static void RegisterPrefab(GameObject prefab, Guid newAssetId)
{ {
NetworkIdentity view = prefab.GetComponent<NetworkIdentity>(); NetworkIdentity view = prefab.GetComponent<NetworkIdentity>();

View File

@ -190,7 +190,21 @@ internal static void SetLocalObjectOnServer(uint netId, NetworkIdentity ni)
{ {
if (LogFilter.Debug) { Debug.Log("SetLocalObjectOnServer " + netId + " " + ni); } if (LogFilter.Debug) { Debug.Log("SetLocalObjectOnServer " + netId + " " + ni); }
s_NetworkScene.SetLocalObject(netId, ni, false, true); if (ni != null)
{
ni.EnableIsServer();
// !Contains check needed to avoid dictionary 'out of sync' error
// because SetLocalObject is called from a foreach loop
if (!NetworkIdentity.spawned.ContainsKey(netId))
{
NetworkIdentity.spawned[netId] = ni;
}
}
else
{
NetworkIdentity.spawned[netId] = null;
}
} }
internal static void ActivateLocalClientScene() internal static void ActivateLocalClientScene()