Skip to content

Commit dbc6ac1

Browse files
committed
Added ServerOnly option to NetworkedObject
1 parent 24c03f6 commit dbc6ac1

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

MLAPI/MonoBehaviours/Core/NetworkedObject.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ namespace MLAPI
66
//Will be used for objects which will be spawned automatically across clients
77
public class NetworkedObject : MonoBehaviour
88
{
9+
[HideInInspector]
910
public uint NetworkId;
11+
[HideInInspector]
1012
public int OwnerClientId = -1;
13+
[HideInInspector]
1114
public int SpawnablePrefabId;
12-
internal bool IsPlayerObject = false;
15+
[HideInInspector]
16+
public bool IsPlayerObject = false;
17+
public bool ServerOnly = false;
1318
public bool isLocalPlayer
1419
{
1520
get

MLAPI/MonoBehaviours/Core/NetworkingManager.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,9 +744,19 @@ private void HandleApproval(int clientId, bool approved)
744744
}
745745
if (NetworkConfig.HandleObjectSpawning)
746746
{
747-
writer.Write(spawnedObjectIds.Count);
747+
int amountOfObjectsToSend = 0;
748748
for (int i = 0; i < spawnedObjectIds.Count; i++)
749749
{
750+
if (spawnedObjects[spawnedObjectIds[i]].ServerOnly)
751+
continue;
752+
else
753+
amountOfObjectsToSend++;
754+
}
755+
writer.Write(amountOfObjectsToSend);
756+
for (int i = 0; i < spawnedObjectIds.Count; i++)
757+
{
758+
if (spawnedObjects[spawnedObjectIds[i]].ServerOnly)
759+
continue;
750760
writer.Write(spawnedObjects[spawnedObjectIds[i]].IsPlayerObject);
751761
writer.Write(spawnedObjects[spawnedObjectIds[i]].NetworkId);
752762
writer.Write(spawnedObjects[spawnedObjectIds[i]].OwnerClientId);

0 commit comments

Comments
 (0)