From dbc6ac13700498017a7e571d21c5eed383ce3bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20Cor=C3=A9n?= <2108U9@gmail.com> Date: Sun, 7 Jan 2018 05:32:39 +0100 Subject: [PATCH] Added ServerOnly option to NetworkedObject --- MLAPI/MonoBehaviours/Core/NetworkedObject.cs | 7 ++++++- MLAPI/MonoBehaviours/Core/NetworkingManager.cs | 12 +++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/MLAPI/MonoBehaviours/Core/NetworkedObject.cs b/MLAPI/MonoBehaviours/Core/NetworkedObject.cs index ce4c7064c..323c0b948 100644 --- a/MLAPI/MonoBehaviours/Core/NetworkedObject.cs +++ b/MLAPI/MonoBehaviours/Core/NetworkedObject.cs @@ -6,10 +6,15 @@ namespace MLAPI //Will be used for objects which will be spawned automatically across clients public class NetworkedObject : MonoBehaviour { + [HideInInspector] public uint NetworkId; + [HideInInspector] public int OwnerClientId = -1; + [HideInInspector] public int SpawnablePrefabId; - internal bool IsPlayerObject = false; + [HideInInspector] + public bool IsPlayerObject = false; + public bool ServerOnly = false; public bool isLocalPlayer { get diff --git a/MLAPI/MonoBehaviours/Core/NetworkingManager.cs b/MLAPI/MonoBehaviours/Core/NetworkingManager.cs index a20fb2add..c8c4fd542 100644 --- a/MLAPI/MonoBehaviours/Core/NetworkingManager.cs +++ b/MLAPI/MonoBehaviours/Core/NetworkingManager.cs @@ -744,9 +744,19 @@ namespace MLAPI } if (NetworkConfig.HandleObjectSpawning) { - writer.Write(spawnedObjectIds.Count); + int amountOfObjectsToSend = 0; for (int i = 0; i < spawnedObjectIds.Count; i++) { + if (spawnedObjects[spawnedObjectIds[i]].ServerOnly) + continue; + else + amountOfObjectsToSend++; + } + writer.Write(amountOfObjectsToSend); + for (int i = 0; i < spawnedObjectIds.Count; i++) + { + if (spawnedObjects[spawnedObjectIds[i]].ServerOnly) + continue; writer.Write(spawnedObjects[spawnedObjectIds[i]].IsPlayerObject); writer.Write(spawnedObjects[spawnedObjectIds[i]].NetworkId); writer.Write(spawnedObjects[spawnedObjectIds[i]].OwnerClientId);