-
Notifications
You must be signed in to change notification settings - Fork 450
refactor!: SpawnManager is no longer static #696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
BREAKING CHANGE: SpawnManager is no longer static. Access it with NetworkManager.Singleton.SpawnManager
First step towards singleton removal. Makes the SpawnManager instance based. |
@@ -508,7 +508,7 @@ internal static void NetworkBehaviourUpdate() | |||
for (int i = 0; i < NetworkManager.Singleton.ConnectedClientsList.Count; i++) | |||
{ | |||
var client = NetworkManager.Singleton.ConnectedClientsList[i]; | |||
var spawnedObjs = NetworkSpawnManager.SpawnedObjectsList; | |||
var spawnedObjs = NetworkManager.Singleton.SpawnManager.SpawnedObjectsList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var spawnedObjs = NetworkManager.Singleton.SpawnManager.SpawnedObjectsList; | |
var spawnedNetworkObjects = NetworkManager.SpawnManager.SpawnedObjectsList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree and disagree, but mostly disagree. The name change is maybe valid (though having small insignificant names for insignificant variables and vice versa is a style choice I actually prefer), but there's also the "when in Rome" principal where we want to make the PR as focused on the actual change at hand, not mix in some minor unrelated style edits to keep the signal / noise ratio high.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why you'd consider this change in a separate PR.
we're changing it from:
NetworkSpawnManager.SpawnedObjectsList
to
NetworkManager.Singleton.SpawnManager.SpawnedObjectsList
already.
my only suggestion here is to kill .Singleton
part as well
NetworkManager.SpawnManager.SpawnedObjectsList
because there is already NetworkBehaviour.NetworkManager
property available, so there is no need to access NetworkManager
over NetworkManager.Singleton
instead of NetworkBehaviour.NetworkManager
.
I do not think it should go under a separate PR — we are making a change there already, let's make it even better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will come in my next PR!
That's where I will convert the whole NetworkObject & Behaviour.
@@ -532,7 +532,7 @@ internal static void NetworkBehaviourUpdate() | |||
else | |||
{ | |||
// when client updates the sever, it tells it about all its objects | |||
foreach (var sobj in NetworkSpawnManager.SpawnedObjectsList) | |||
foreach (var sobj in NetworkManager.Singleton.SpawnManager.SpawnedObjectsList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foreach (var sobj in NetworkManager.Singleton.SpawnManager.SpawnedObjectsList) | |
var spawnedNetworkObjects = NetworkManager.SpawnManager.SpawnedObjectsList; | |
foreach (var networkObject in spawnedNetworkObjects) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto as above, actually making the induction variable longer doesn't to me improve readability
@@ -541,7 +541,7 @@ internal static void NetworkBehaviourUpdate() | |||
} | |||
|
|||
// Now, reset all the no-longer-dirty variables | |||
foreach (var sobj in NetworkSpawnManager.SpawnedObjectsList) | |||
foreach (var sobj in NetworkManager.Singleton.SpawnManager.SpawnedObjectsList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foreach (var sobj in NetworkManager.Singleton.SpawnManager.SpawnedObjectsList) | |
foreach (var networkObject in spawnedNetworkObjects) |
@@ -1006,6 +1006,6 @@ internal static void SetNetworkVariableData(List<INetworkVariable> networkVariab | |||
/// </summary> | |||
/// <param name="networkId"></param> | |||
/// <returns></returns> | |||
protected NetworkObject GetNetworkObject(ulong networkId) => NetworkSpawnManager.SpawnedObjects.ContainsKey(networkId) ? NetworkSpawnManager.SpawnedObjects[networkId] : null; | |||
protected NetworkObject GetNetworkObject(ulong networkId) => NetworkManager.Singleton.SpawnManager.SpawnedObjects.ContainsKey(networkId) ? NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkId] : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected NetworkObject GetNetworkObject(ulong networkId) => NetworkManager.Singleton.SpawnManager.SpawnedObjects.ContainsKey(networkId) ? NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkId] : null; | |
protected NetworkObject GetNetworkObject(ulong networkObjectId) => NetworkManager.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId) ? NetworkManager.SpawnManager.SpawnedObjects[networkObjectId] : null; |
@@ -1380,7 +1387,7 @@ internal void OnClientDisconnectFromServer(ulong clientId) | |||
|
|||
// TODO: Could(should?) be replaced with more memory per client, by storing the visiblity | |||
|
|||
foreach (var sobj in NetworkSpawnManager.SpawnedObjectsList) | |||
foreach (var sobj in SpawnManager.SpawnedObjectsList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foreach (var sobj in SpawnManager.SpawnedObjectsList) | |
foreach (var networkObject in SpawnManager.SpawnedObjectsList) |
|
||
ConnectedClients[ownerClientId].PlayerObject = networkObject; | ||
} | ||
|
||
m_ObservedObjects.Clear(); | ||
|
||
foreach (var sobj in NetworkSpawnManager.SpawnedObjectsList) | ||
foreach (var sobj in SpawnManager.SpawnedObjectsList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foreach (var sobj in SpawnManager.SpawnedObjectsList) | |
foreach (var networkObject in SpawnManager.SpawnedObjectsList) |
@@ -225,7 +225,7 @@ public void NetworkShow(ulong clientId, Stream payload = null) | |||
// Send spawn call | |||
Observers.Add(clientId); | |||
|
|||
NetworkSpawnManager.SendSpawnCallForObject(clientId, this, payload); | |||
NetworkManager.Singleton.SpawnManager.SendSpawnCallForObject(clientId, this, payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.SendSpawnCallForObject(clientId, this, payload); | |
NetworkManager.SpawnManager.SendSpawnCallForObject(clientId, this, payload); |
@@ -265,7 +265,7 @@ public static void NetworkShow(List<NetworkObject> networkObjects, ulong clientI | |||
// Send spawn call | |||
networkObjects[i].Observers.Add(clientId); | |||
|
|||
NetworkSpawnManager.WriteSpawnCallForObject(buffer, clientId, networkObjects[i], payload); | |||
NetworkManager.Singleton.SpawnManager.WriteSpawnCallForObject(buffer, clientId, networkObjects[i], payload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.WriteSpawnCallForObject(buffer, clientId, networkObjects[i], payload); | |
NetworkManager.SpawnManager.WriteSpawnCallForObject(buffer, clientId, networkObjects[i], payload); |
@@ -361,9 +361,9 @@ public static void NetworkHide(List<NetworkObject> networkObjects, ulong clientI | |||
|
|||
private void OnDestroy() | |||
{ | |||
if (NetworkManager.Singleton != null && NetworkSpawnManager.SpawnedObjects.ContainsKey(NetworkObjectId)) | |||
if (NetworkManager.Singleton != null && NetworkManager.Singleton.SpawnManager.SpawnedObjects.ContainsKey(NetworkObjectId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (NetworkManager.Singleton != null && NetworkManager.Singleton.SpawnManager.SpawnedObjects.ContainsKey(NetworkObjectId)) | |
if (NetworkManager.Singleton != null && NetworkManager.SpawnManager.SpawnedObjects.ContainsKey(NetworkObjectId)) |
{ | ||
NetworkSpawnManager.OnDestroyObject(NetworkObjectId, false); | ||
NetworkManager.Singleton.SpawnManager.OnDestroyObject(NetworkObjectId, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.OnDestroyObject(NetworkObjectId, false); | |
NetworkManager.SpawnManager.OnDestroyObject(NetworkObjectId, false); |
@@ -385,13 +385,13 @@ private void SpawnInternal(Stream spawnPayload, bool destroyWithScene, ulong? ow | |||
spawnPayload.Position = 0; | |||
} | |||
|
|||
NetworkSpawnManager.SpawnNetworkObjectLocally(this, NetworkSpawnManager.GetNetworkObjectId(), false, playerObject, ownerClientId, spawnPayload, spawnPayload != null, spawnPayload == null ? 0 : (int)spawnPayload.Length, false, destroyWithScene); | |||
NetworkManager.Singleton.SpawnManager.SpawnNetworkObjectLocally(this, NetworkManager.Singleton.SpawnManager.GetNetworkObjectId(), false, playerObject, ownerClientId, spawnPayload, spawnPayload != null, spawnPayload == null ? 0 : (int)spawnPayload.Length, false, destroyWithScene); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.SpawnNetworkObjectLocally(this, NetworkManager.Singleton.SpawnManager.GetNetworkObjectId(), false, playerObject, ownerClientId, spawnPayload, spawnPayload != null, spawnPayload == null ? 0 : (int)spawnPayload.Length, false, destroyWithScene); | |
NetworkManager.SpawnManager.SpawnNetworkObjectLocally(this, NetworkManager.SpawnManager.GetNetworkObjectId(), false, playerObject, ownerClientId, spawnPayload, spawnPayload != null, spawnPayload == null ? 0 : (int)spawnPayload.Length, false, destroyWithScene); |
|
||
for (int i = 0; i < NetworkManager.Singleton.ConnectedClientsList.Count; i++) | ||
{ | ||
if (Observers.Contains(NetworkManager.Singleton.ConnectedClientsList[i].ClientId)) | ||
{ | ||
NetworkSpawnManager.SendSpawnCallForObject(NetworkManager.Singleton.ConnectedClientsList[i].ClientId, this, spawnPayload); | ||
NetworkManager.Singleton.SpawnManager.SendSpawnCallForObject(NetworkManager.Singleton.ConnectedClientsList[i].ClientId, this, spawnPayload); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.SendSpawnCallForObject(NetworkManager.Singleton.ConnectedClientsList[i].ClientId, this, spawnPayload); | |
NetworkManager.SpawnManager.SendSpawnCallForObject(NetworkManager.Singleton.ConnectedClientsList[i].ClientId, this, spawnPayload); |
@@ -433,7 +433,7 @@ public void SpawnAsPlayerObject(ulong clientId, Stream spawnPayload = null, bool | |||
/// </summary> | |||
public void Despawn(bool destroy = false) | |||
{ | |||
NetworkSpawnManager.DespawnObject(this, destroy); | |||
NetworkManager.Singleton.SpawnManager.DespawnObject(this, destroy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.DespawnObject(this, destroy); | |
NetworkManager.SpawnManager.DespawnObject(this, destroy); |
@@ -442,7 +442,7 @@ public void Despawn(bool destroy = false) | |||
/// </summary> | |||
public void RemoveOwnership() | |||
{ | |||
NetworkSpawnManager.RemoveOwnership(this); | |||
NetworkManager.Singleton.SpawnManager.RemoveOwnership(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.RemoveOwnership(this); | |
NetworkManager.SpawnManager.RemoveOwnership(this); |
@@ -451,7 +451,7 @@ public void RemoveOwnership() | |||
/// <param name="newOwnerClientId">The new owner clientId</param> | |||
public void ChangeOwnership(ulong newOwnerClientId) | |||
{ | |||
NetworkSpawnManager.ChangeOwnership(this, newOwnerClientId); | |||
NetworkManager.Singleton.SpawnManager.ChangeOwnership(this, newOwnerClientId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.ChangeOwnership(this, newOwnerClientId); | |
NetworkManager.SpawnManager.ChangeOwnership(this, newOwnerClientId); |
@@ -111,11 +111,11 @@ void DelayedSpawnAction(Stream continuationStream) | |||
{ | |||
if (!NetworkManager.Singleton.NetworkConfig.EnableSceneManagement || NetworkManager.Singleton.NetworkConfig.UsePrefabSync) | |||
{ | |||
NetworkSpawnManager.DestroySceneObjects(); | |||
NetworkManager.Singleton.SpawnManager.DestroySceneObjects(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.DestroySceneObjects(); | |
NetworkManager.SpawnManager.DestroySceneObjects(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Come again?
} | ||
else | ||
{ | ||
NetworkSpawnManager.ClientCollectSoftSyncSceneObjectSweep(null); | ||
NetworkManager.Singleton.SpawnManager.ClientCollectSoftSyncSceneObjectSweep(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.ClientCollectSoftSyncSceneObjectSweep(null); | |
NetworkManager.SpawnManager.ClientCollectSoftSyncSceneObjectSweep(null); |
var networkObject = NetworkManager.Singleton.SpawnManager.CreateLocalNetworkObject(softSync, instanceId, prefabHash, ownerId, parentNetworkId, pos, rot); | ||
NetworkManager.Singleton.SpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, softSync, isPlayerObject, ownerId, continuationStream, false, 0, true, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var networkObject = NetworkManager.Singleton.SpawnManager.CreateLocalNetworkObject(softSync, instanceId, prefabHash, ownerId, parentNetworkId, pos, rot); | |
NetworkManager.Singleton.SpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, softSync, isPlayerObject, ownerId, continuationStream, false, 0, true, false); | |
var networkObject = NetworkManager.SpawnManager.CreateLocalNetworkObject(softSync, instanceId, prefabHash, ownerId, parentNetworkId, pos, rot); | |
NetworkManager.SpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, softSync, isPlayerObject, ownerId, continuationStream, false, 0, true, false); |
NetworkManager.Singleton.SpawnManager.CleanDiffedSceneObjects(); | ||
NetworkManager.Singleton.IsConnectedClient = true; | ||
NetworkManager.Singleton.InvokeOnClientConnectedCallback(NetworkManager.Singleton.LocalClientId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.CleanDiffedSceneObjects(); | |
NetworkManager.Singleton.IsConnectedClient = true; | |
NetworkManager.Singleton.InvokeOnClientConnectedCallback(NetworkManager.Singleton.LocalClientId); | |
NetworkManager.SpawnManager.CleanDiffedSceneObjects(); | |
NetworkManager.IsConnectedClient = true; | |
NetworkManager.InvokeOnClientConnectedCallback(NetworkManager.Singleton.LocalClientId); |
var networkObject = NetworkManager.Singleton.SpawnManager.CreateLocalNetworkObject(softSync, instanceId, prefabHash, ownerClientId, parentNetworkId, pos, rot); | ||
NetworkManager.Singleton.SpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, softSync, isPlayerObject, ownerClientId, stream, hasPayload, payLoadLength, true, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var networkObject = NetworkManager.Singleton.SpawnManager.CreateLocalNetworkObject(softSync, instanceId, prefabHash, ownerClientId, parentNetworkId, pos, rot); | |
NetworkManager.Singleton.SpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, softSync, isPlayerObject, ownerClientId, stream, hasPayload, payLoadLength, true, false); | |
var networkObject = NetworkManager.SpawnManager.CreateLocalNetworkObject(softSync, instanceId, prefabHash, ownerClientId, parentNetworkId, pos, rot); | |
NetworkManager.SpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, softSync, isPlayerObject, ownerClientId, stream, hasPayload, payLoadLength, true, false); |
@@ -302,7 +302,7 @@ internal static void HandleDestroyObject(ulong clientId, Stream stream) | |||
using (var reader = PooledNetworkReader.Get(stream)) | |||
{ | |||
ulong networkId = reader.ReadUInt64Packed(); | |||
NetworkSpawnManager.OnDestroyObject(networkId, true); | |||
NetworkManager.Singleton.SpawnManager.OnDestroyObject(networkId, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.OnDestroyObject(networkId, true); | |
NetworkManager.SpawnManager.OnDestroyObject(networkObjectId, true); |
@@ -354,19 +354,19 @@ internal static void HandleChangeOwner(ulong clientId, Stream stream) | |||
ulong networkId = reader.ReadUInt64Packed(); | |||
ulong ownerClientId = reader.ReadUInt64Packed(); | |||
|
|||
if (NetworkSpawnManager.SpawnedObjects[networkId].OwnerClientId == NetworkManager.Singleton.LocalClientId) | |||
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkId].OwnerClientId == NetworkManager.Singleton.LocalClientId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkId].OwnerClientId == NetworkManager.Singleton.LocalClientId) | |
if (NetworkManager.SpawnManager.SpawnedObjects[networkObjectId].OwnerClientId == NetworkManager.LocalClientId) |
{ | ||
//We are current owner. | ||
NetworkSpawnManager.SpawnedObjects[networkId].InvokeBehaviourOnLostOwnership(); | ||
NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkId].InvokeBehaviourOnLostOwnership(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkId].InvokeBehaviourOnLostOwnership(); | |
NetworkManager.SpawnManager.SpawnedObjects[networkObjectId].InvokeBehaviourOnLostOwnership(); |
} | ||
|
||
if (ownerClientId == NetworkManager.Singleton.LocalClientId) | ||
{ | ||
//We are new owner. | ||
NetworkSpawnManager.SpawnedObjects[networkId].InvokeBehaviourOnGainedOwnership(); | ||
NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkId].InvokeBehaviourOnGainedOwnership(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkId].InvokeBehaviourOnGainedOwnership(); | |
NetworkManager.SpawnManager.SpawnedObjects[networkObjectId].InvokeBehaviourOnGainedOwnership(); |
} | ||
|
||
NetworkSpawnManager.SpawnedObjects[networkId].OwnerClientId = ownerClientId; | ||
NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkId].OwnerClientId = ownerClientId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkId].OwnerClientId = ownerClientId; | |
NetworkManager.SpawnManager.SpawnedObjects[networkObjectId].OwnerClientId = ownerClientId; |
@@ -446,9 +446,9 @@ internal static void HandleNetworkVariableDelta(ulong clientId, Stream stream, A | |||
ulong networkObjectId = reader.ReadUInt64Packed(); | |||
ushort networkBehaviourIndex = reader.ReadUInt16Packed(); | |||
|
|||
if (NetworkSpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) | |||
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) | |
if (NetworkManager.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) |
{ | ||
NetworkBehaviour instance = NetworkSpawnManager.SpawnedObjects[networkObjectId].GetNetworkBehaviourAtOrderIndex(networkBehaviourIndex); | ||
NetworkBehaviour instance = NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkObjectId].GetNetworkBehaviourAtOrderIndex(networkBehaviourIndex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkBehaviour instance = NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkObjectId].GetNetworkBehaviourAtOrderIndex(networkBehaviourIndex); | |
var networkBehaviour = NetworkManager.SpawnManager.SpawnedObjects[networkObjectId].GetNetworkBehaviourAtOrderIndex(networkBehaviourIndex); |
@@ -504,9 +504,9 @@ internal static void HandleNetworkVariableUpdate(ulong clientId, Stream stream, | |||
ulong networkObjectId = reader.ReadUInt64Packed(); | |||
ushort networkBehaviourIndex = reader.ReadUInt16Packed(); | |||
|
|||
if (NetworkSpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) | |||
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) | |
if (NetworkManager.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) |
{ | ||
var networkBehaviour = NetworkSpawnManager.SpawnedObjects[networkObjectId].GetNetworkBehaviourAtOrderIndex(networkBehaviourIndex); | ||
var networkBehaviour = NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkObjectId].GetNetworkBehaviourAtOrderIndex(networkBehaviourIndex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var networkBehaviour = NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkObjectId].GetNetworkBehaviourAtOrderIndex(networkBehaviourIndex); | |
var networkBehaviour = NetworkManager.SpawnManager.SpawnedObjects[networkObjectId].GetNetworkBehaviourAtOrderIndex(networkBehaviourIndex); |
@@ -58,7 +58,7 @@ public void ProcessReceiveQueue(NetworkUpdateStage currentStage, bool isTesting) | |||
|
|||
if (!isTesting) | |||
{ | |||
NetworkManager.InvokeRpc(currentQueueItem); | |||
NetworkManager.Singleton.InvokeRpc(currentQueueItem); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.InvokeRpc(currentQueueItem); | |
NetworkManager.InvokeRpc(currentQueueItem); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not following how this would be valid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.InvokeRpc
is a static function.
@@ -118,7 +118,7 @@ public static SceneSwitchProgress SwitchScene(string sceneName) | |||
return null; | |||
} | |||
|
|||
NetworkSpawnManager.ServerDestroySpawnedSceneObjects(); //Destroy current scene objects before switching. | |||
NetworkManager.Singleton.SpawnManager.ServerDestroySpawnedSceneObjects(); //Destroy current scene objects before switching. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.ServerDestroySpawnedSceneObjects(); //Destroy current scene objects before switching. | |
NetworkManager.SpawnManager.ServerDestroySpawnedSceneObjects(); //Destroy current scene objects before switching. |
@@ -241,7 +241,7 @@ private static void OnSceneUnloadServer(Guid switchSceneGuid) | |||
{ | |||
if (networkObjects[i].IsSceneObject == null) | |||
{ | |||
NetworkSpawnManager.SpawnNetworkObjectLocally(networkObjects[i], NetworkSpawnManager.GetNetworkObjectId(), true, false, null, null, false, 0, false, true); | |||
NetworkManager.Singleton.SpawnManager.SpawnNetworkObjectLocally(networkObjects[i], NetworkManager.Singleton.SpawnManager.GetNetworkObjectId(), true, false, null, null, false, 0, false, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.SpawnNetworkObjectLocally(networkObjects[i], NetworkManager.Singleton.SpawnManager.GetNetworkObjectId(), true, false, null, null, false, 0, false, true); | |
NetworkManager.SpawnManager.SpawnNetworkObjectLocally(networkObjects[i], NetworkManager.SpawnManager.GetNetworkObjectId(), true, false, null, null, false, 0, false, true); |
@@ -337,7 +337,7 @@ private static void OnSceneUnloadClient(Guid switchSceneGuid, Stream objectStrea | |||
{ | |||
if (!NetworkManager.Singleton.NetworkConfig.EnableSceneManagement || NetworkManager.Singleton.NetworkConfig.UsePrefabSync) | |||
{ | |||
NetworkSpawnManager.DestroySceneObjects(); | |||
NetworkManager.Singleton.SpawnManager.DestroySceneObjects(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.DestroySceneObjects(); | |
NetworkManager.SpawnManager.DestroySceneObjects(); |
var networkObject = NetworkManager.Singleton.SpawnManager.CreateLocalNetworkObject(false, 0, prefabHash, ownerClientId, parentNetworkId, position, rotation); | ||
NetworkManager.Singleton.SpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, true, isPlayerObject, ownerClientId, objectStream, false, 0, true, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var networkObject = NetworkManager.Singleton.SpawnManager.CreateLocalNetworkObject(false, 0, prefabHash, ownerClientId, parentNetworkId, position, rotation); | |
NetworkManager.Singleton.SpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, true, isPlayerObject, ownerClientId, objectStream, false, 0, true, false); | |
var networkObject = NetworkManager.SpawnManager.CreateLocalNetworkObject(false, 0, prefabHash, ownerClientId, parentNetworkId, position, rotation); | |
NetworkManager.SpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, true, isPlayerObject, ownerClientId, objectStream, false, 0, true, false); |
@@ -387,7 +387,7 @@ private static void OnSceneUnloadClient(Guid switchSceneGuid, Stream objectStrea | |||
else | |||
{ | |||
var networkObjects = UnityEngine.Object.FindObjectsOfType<NetworkObject>(); | |||
NetworkSpawnManager.ClientCollectSoftSyncSceneObjectSweep(networkObjects); | |||
NetworkManager.Singleton.SpawnManager.ClientCollectSoftSyncSceneObjectSweep(networkObjects); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NetworkManager.Singleton.SpawnManager.ClientCollectSoftSyncSceneObjectSweep(networkObjects); | |
NetworkManager.SpawnManager.ClientCollectSoftSyncSceneObjectSweep(networkObjects); |
var networkObject = NetworkManager.Singleton.SpawnManager.CreateLocalNetworkObject(true, instanceId, 0, ownerClientId, parentNetworkId, null, null); | ||
NetworkManager.Singleton.SpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, true, isPlayerObject, ownerClientId, objectStream, false, 0, true, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var networkObject = NetworkManager.Singleton.SpawnManager.CreateLocalNetworkObject(true, instanceId, 0, ownerClientId, parentNetworkId, null, null); | |
NetworkManager.Singleton.SpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, true, isPlayerObject, ownerClientId, objectStream, false, 0, true, false); | |
var networkObject = NetworkManager.SpawnManager.CreateLocalNetworkObject(true, instanceId, 0, ownerClientId, parentNetworkId, null, null); | |
NetworkManager.SpawnManager.SpawnNetworkObjectLocally(networkObject, networkId, true, isPlayerObject, ownerClientId, objectStream, false, 0, true, false); |
@@ -470,7 +470,7 @@ internal static void RemoveClientFromSceneSwitchProgresses(ulong clientId) | |||
private static void MoveObjectsToDontDestroyOnLoad() | |||
{ | |||
// Move ALL NetworkObjects to the temp scene | |||
var objectsToKeep = NetworkSpawnManager.SpawnedObjectsList; | |||
var objectsToKeep = NetworkManager.Singleton.SpawnManager.SpawnedObjectsList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var objectsToKeep = NetworkManager.Singleton.SpawnManager.SpawnedObjectsList; | |
var objectsToKeep = NetworkManager.SpawnManager.SpawnedObjectsList; |
@@ -487,7 +487,7 @@ private static void MoveObjectsToDontDestroyOnLoad() | |||
private static void MoveObjectsToScene(Scene scene) | |||
{ | |||
// Move ALL NetworkObjects to the temp scene | |||
var objectsToKeep = NetworkSpawnManager.SpawnedObjectsList; | |||
var objectsToKeep = NetworkManager.Singleton.SpawnManager.SpawnedObjectsList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var objectsToKeep = NetworkManager.Singleton.SpawnManager.SpawnedObjectsList; | |
var objectsToKeep = NetworkManager.SpawnManager.SpawnedObjectsList; |
@@ -243,9 +243,9 @@ public object ReadObjectPacked(Type type) | |||
{ | |||
ulong networkObjectId = ReadUInt64Packed(); | |||
|
|||
if (NetworkSpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) | |||
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) | |
if (NetworkManager.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) |
{ | ||
return NetworkSpawnManager.SpawnedObjects[networkObjectId].gameObject; | ||
return NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkObjectId].gameObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkObjectId].gameObject; | |
return NetworkManager.SpawnManager.SpawnedObjects[networkObjectId].gameObject; |
@@ -260,9 +260,9 @@ public object ReadObjectPacked(Type type) | |||
{ | |||
ulong networkObjectId = ReadUInt64Packed(); | |||
|
|||
if (NetworkSpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) | |||
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) | |
if (NetworkManager.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) |
{ | ||
return NetworkSpawnManager.SpawnedObjects[networkObjectId]; | ||
return NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkObjectId]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkObjectId]; | |
return NetworkManager.SpawnManager.SpawnedObjects[networkObjectId]; |
@@ -277,9 +277,9 @@ public object ReadObjectPacked(Type type) | |||
{ | |||
ulong networkObjectId = ReadUInt64Packed(); | |||
ushort behaviourId = ReadUInt16Packed(); | |||
if (NetworkSpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) | |||
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) | |
if (NetworkManager.SpawnManager.SpawnedObjects.ContainsKey(networkObjectId)) |
{ | ||
return NetworkSpawnManager.SpawnedObjects[networkObjectId].GetNetworkBehaviourAtOrderIndex(behaviourId); | ||
return NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkObjectId].GetNetworkBehaviourAtOrderIndex(behaviourId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return NetworkManager.Singleton.SpawnManager.SpawnedObjects[networkObjectId].GetNetworkBehaviourAtOrderIndex(behaviourId); | |
return NetworkManager.SpawnManager.SpawnedObjects[networkObjectId].GetNetworkBehaviourAtOrderIndex(behaviourId); |
@@ -89,6 +89,11 @@ public class NetworkManager : MonoBehaviour, INetworkUpdateSystem, IProfilableTr | |||
/// </summary> | |||
public static NetworkManager Singleton { get; private set; } | |||
|
|||
/// <summary> | |||
/// Gets the SpawnManager for this NetworkManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Gets the SpawnManager for this NetworkManager | |
/// Gets the SpawnManager associated with this NetworkManager |
NetworkSpawnManager.SpawnedObjectsList.Clear(); | ||
NetworkSpawnManager.ReleasedNetworkObjectIds.Clear(); | ||
NetworkSpawnManager.PendingSoftSyncObjects.Clear(); | ||
// Create spawn manager instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Create spawn manager instance |
isn't it obvious already? 😛
what might be nicer is to use but all the suggested changes are optional, they're not showstoppers. |
84d35b1
to
96b9825
Compare
BREAKING CHANGE: SpawnManager is no longer static. Access it with NetworkManager.Singleton.SpawnManager