@@ -17,7 +17,14 @@ public class NetworkingManager : MonoBehaviour
17
17
/// <summary>
18
18
/// A syncronized time, represents the time in seconds since the server application started. Is replicated across all clients
19
19
/// </summary>
20
- public static float NetworkTime ;
20
+ public float NetworkTime
21
+ {
22
+ get
23
+ {
24
+ return networkTime ;
25
+ }
26
+ }
27
+ internal float networkTime ;
21
28
/// <summary>
22
29
/// Gets or sets if the NetworkingManager should be marked as DontDestroyOnLoad
23
30
/// </summary>
@@ -37,12 +44,26 @@ public class NetworkingManager : MonoBehaviour
37
44
/// <summary>
38
45
/// The singleton instance of the NetworkingManager
39
46
/// </summary>
40
- public static NetworkingManager singleton ;
47
+ public static NetworkingManager singleton
48
+ {
49
+ get
50
+ {
51
+ return _singleton ;
52
+ }
53
+ }
54
+ private static NetworkingManager _singleton ;
41
55
/// <summary>
42
56
/// The clientId the server calls the local client by, only valid for clients
43
57
/// </summary>
44
58
[ HideInInspector ]
45
- public int MyClientId ;
59
+ public int MyClientId
60
+ {
61
+ get
62
+ {
63
+ return myClientId ;
64
+ }
65
+ }
66
+ internal int myClientId ;
46
67
internal Dictionary < int , NetworkedClient > connectedClients ;
47
68
/// <summary>
48
69
/// Gets a dictionary of connected clients
@@ -74,7 +95,14 @@ public bool isHost
74
95
/// Gets if we are connected as a client
75
96
/// </summary>
76
97
[ HideInInspector ]
77
- public bool IsClientConnected ;
98
+ public bool IsClientConnected
99
+ {
100
+ get
101
+ {
102
+ return _isClientConnected ;
103
+ }
104
+ }
105
+ internal bool _isClientConnected ;
78
106
/// <summary>
79
107
/// The callback to invoke once a client connects
80
108
/// </summary>
@@ -110,7 +138,7 @@ private void OnValidate()
110
138
Debug . LogWarning ( "MLAPI: All SpawnablePrefabs need a NetworkedObject component. Please add one to the prefab " + SpawnablePrefabs [ i ] . gameObject . name ) ;
111
139
continue ;
112
140
}
113
- netObject . SpawnablePrefabIndex = i ;
141
+ netObject . spawnablePrefabIndex = i ;
114
142
}
115
143
}
116
144
if ( DefaultPlayerPrefab != null )
@@ -126,7 +154,7 @@ private void OnValidate()
126
154
private ConnectionConfig Init ( NetworkingConfiguration netConfig )
127
155
{
128
156
NetworkConfig = netConfig ;
129
- NetworkTime = 0f ;
157
+ networkTime = 0f ;
130
158
lastSendTickTime = 0 ;
131
159
lastEventTickTime = 0 ;
132
160
lastReceiveTickTime = 0 ;
@@ -360,7 +388,7 @@ private void OnEnable()
360
388
Destroy ( this ) ;
361
389
return ;
362
390
}
363
- singleton = this ;
391
+ _singleton = this ;
364
392
if ( DontDestroy )
365
393
DontDestroyOnLoad ( gameObject ) ;
366
394
if ( RunInBackground )
@@ -369,7 +397,7 @@ private void OnEnable()
369
397
370
398
private void OnDestroy ( )
371
399
{
372
- singleton = null ;
400
+ _singleton = null ;
373
401
Shutdown ( ) ;
374
402
}
375
403
@@ -420,7 +448,7 @@ private void Update()
420
448
return ;
421
449
}
422
450
else
423
- IsClientConnected = false ;
451
+ _isClientConnected = false ;
424
452
425
453
if ( OnClientDisconnectCallback != null )
426
454
OnClientDisconnectCallback . Invoke ( clientId ) ;
@@ -481,7 +509,7 @@ private void Update()
481
509
if ( isServer )
482
510
OnClientDisconnect ( clientId ) ;
483
511
else
484
- IsClientConnected = false ;
512
+ _isClientConnected = false ;
485
513
486
514
if ( OnClientDisconnectCallback != null )
487
515
OnClientDisconnectCallback . Invoke ( clientId ) ;
@@ -497,7 +525,7 @@ private void Update()
497
525
NetworkedObject . InvokeSyncvarUpdate ( ) ;
498
526
lastEventTickTime = Time . time ;
499
527
}
500
- NetworkTime += Time . deltaTime ;
528
+ networkTime += Time . deltaTime ;
501
529
}
502
530
}
503
531
@@ -673,7 +701,7 @@ private void HandleIncomingData(int clientId, byte[] data, int channelId)
673
701
{
674
702
using ( BinaryReader messageReader = new BinaryReader ( messageReadStream ) )
675
703
{
676
- MyClientId = messageReader . ReadInt32 ( ) ;
704
+ myClientId = messageReader . ReadInt32 ( ) ;
677
705
uint sceneIndex = 0 ;
678
706
if ( NetworkConfig . EnableSceneSwitching )
679
707
{
@@ -709,7 +737,7 @@ private void HandleIncomingData(int clientId, byte[] data, int channelId)
709
737
int msDelay = NetworkTransport . GetRemoteDelayTimeMS ( hostId , clientId , remoteStamp , out error ) ;
710
738
if ( ( NetworkError ) error != NetworkError . Ok )
711
739
msDelay = 0 ;
712
- NetworkTime = netTime + ( msDelay / 1000f ) ;
740
+ networkTime = netTime + ( msDelay / 1000f ) ;
713
741
714
742
connectedClients . Add ( MyClientId , new NetworkedClient ( ) { ClientId = MyClientId } ) ;
715
743
int clientCount = messageReader . ReadInt32 ( ) ;
@@ -745,7 +773,7 @@ private void HandleIncomingData(int clientId, byte[] data, int channelId)
745
773
}
746
774
}
747
775
}
748
- IsClientConnected = true ;
776
+ _isClientConnected = true ;
749
777
if ( OnClientConnectedCallback != null )
750
778
OnClientConnectedCallback . Invoke ( clientId ) ;
751
779
}
@@ -879,7 +907,7 @@ private void HandleIncomingData(int clientId, byte[] data, int channelId)
879
907
//We are new owner.
880
908
SpawnManager . spawnedObjects [ netId ] . InvokeBehaviourOnGainedOwnership ( ) ;
881
909
}
882
- SpawnManager . spawnedObjects [ netId ] . OwnerClientId = ownerClientId ;
910
+ SpawnManager . spawnedObjects [ netId ] . ownerClientId = ownerClientId ;
883
911
}
884
912
}
885
913
}
0 commit comments