-
Notifications
You must be signed in to change notification settings - Fork 459
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. |
{ | ||
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.
{ | ||
// 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
|
||
// 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) |
/// <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; |
// 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) |
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) |
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); |
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); |
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)) |
if (NetworkManager.Singleton != null && NetworkManager.Singleton.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); |
} | ||
|
||
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); |
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); |
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); |
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); |
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); |
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); |
{ | ||
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); |
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(); |
{ | ||
//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; |
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)) |
if (NetworkManager.Singleton.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); |
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)) |
if (NetworkManager.Singleton.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); |
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.
} | ||
|
||
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. |
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); |
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); |
{ | ||
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); |
{ | ||
// 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; |
{ | ||
// 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; |
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)) |
if (NetworkManager.Singleton.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; |
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)) |
if (NetworkManager.Singleton.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]; |
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)) |
if (NetworkManager.Singleton.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); |
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