Changed spawnedObjects counting code

This commit is contained in:
Albin Corén 2018-03-21 08:37:15 +01:00
parent 9b76a81f1f
commit 95082334af

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking; using UnityEngine.Networking;
using System.Linq;
namespace MLAPI namespace MLAPI
{ {
@ -1136,14 +1137,9 @@ namespace MLAPI
int sizeOfStream = 16 + ((connectedClients.Count - 1) * 4); int sizeOfStream = 16 + ((connectedClients.Count - 1) * 4);
int amountOfObjectsToSend = 0;
foreach (KeyValuePair<uint, NetworkedObject> pair in SpawnManager.spawnedObjects) int amountOfObjectsToSend = SpawnManager.spawnedObjects.Values.Count(x => x.ServerOnly == false);
{
if (pair.Value.ServerOnly)
continue;
else
amountOfObjectsToSend++;
}
if(NetworkConfig.HandleObjectSpawning) if(NetworkConfig.HandleObjectSpawning)
{ {
sizeOfStream += 4; sizeOfStream += 4;