forked from Unity-Technologies/com.unity.netcode.gameobjects
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathManagerExamples.cs
More file actions
42 lines (37 loc) · 1.15 KB
/
ManagerExamples.cs
File metadata and controls
42 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using MLAPI;
using MLAPI.Connection;
using MLAPI.Security;
using MLAPI.Spawning;
namespace MLAPI_Examples
{
// Features example calls for things often needed for things like Game managers
public class ManagerExamples : NetworkedBehaviour
{
public NetworkedObject GetPlayerGameObject(ulong clientId)
{
return SpawnManager.GetPlayerObject(clientId);
}
// Only runs on host and client
public NetworkedObject GetLocalPlayerObject()
{
return SpawnManager.GetLocalPlayerObject();
}
#if !DISABLE_CRYPTOGRAPHY
// Only runs on server
public byte[] GetAESKeyForClient(ulong clientId)
{
return CryptographyHelper.GetClientKey(clientId);
}
// Only runs on client
public byte[] GetAESKeyForServer()
{
return CryptographyHelper.GetServerKey();
}
#endif
// Contains player object, owned objects, cryptography keys and more
public NetworkedClient GetClient(ulong clientId)
{
return NetworkingManager.Singleton.ConnectedClients[clientId];
}
}
}