11using MLAPI . Data ;
22using MLAPI . MonoBehaviours . Core ;
3+ using MLAPI . NetworkingManagerComponents . Binary ;
34using System . Collections . Generic ;
45using System . IO ;
56using UnityEngine ;
@@ -134,23 +135,24 @@ private void Update()
134135 }
135136 }
136137
137- private void OnNavMeshStateUpdate ( uint clientId , byte [ ] data )
138+ private void OnNavMeshStateUpdate ( uint clientId , BitReader reader )
138139 {
140+ byte [ ] data = reader . ReadByteArray ( ) ;
139141 using ( MemoryStream stream = new MemoryStream ( data ) )
140142 {
141- using ( BinaryReader reader = new BinaryReader ( stream ) )
143+ using ( BinaryReader bReader = new BinaryReader ( stream ) )
142144 {
143- float xDestination = reader . ReadSingle ( ) ;
144- float yDestination = reader . ReadSingle ( ) ;
145- float zDestination = reader . ReadSingle ( ) ;
145+ float xDestination = bReader . ReadSingle ( ) ;
146+ float yDestination = bReader . ReadSingle ( ) ;
147+ float zDestination = bReader . ReadSingle ( ) ;
146148
147- float xVel = reader . ReadSingle ( ) ;
148- float yVel = reader . ReadSingle ( ) ;
149- float zVel = reader . ReadSingle ( ) ;
149+ float xVel = bReader . ReadSingle ( ) ;
150+ float yVel = bReader . ReadSingle ( ) ;
151+ float zVel = bReader . ReadSingle ( ) ;
150152
151- float xPos = reader . ReadSingle ( ) ;
152- float yPos = reader . ReadSingle ( ) ;
153- float zPos = reader . ReadSingle ( ) ;
153+ float xPos = bReader . ReadSingle ( ) ;
154+ float yPos = bReader . ReadSingle ( ) ;
155+ float zPos = bReader . ReadSingle ( ) ;
154156
155157 Vector3 destination = new Vector3 ( xDestination , yDestination , zDestination ) ;
156158 Vector3 velocity = new Vector3 ( xVel , yVel , zVel ) ;
@@ -166,19 +168,20 @@ private void OnNavMeshStateUpdate(uint clientId, byte[] data)
166168 }
167169 }
168170
169- private void OnNavMeshCorrectionUpdate ( uint clientId , byte [ ] data )
171+ private void OnNavMeshCorrectionUpdate ( uint clientId , BitReader reader )
170172 {
173+ byte [ ] data = reader . ReadByteArray ( ) ;
171174 using ( MemoryStream stream = new MemoryStream ( data ) )
172175 {
173- using ( BinaryReader reader = new BinaryReader ( stream ) )
176+ using ( BinaryReader bReader = new BinaryReader ( stream ) )
174177 {
175- float xVel = reader . ReadSingle ( ) ;
176- float yVel = reader . ReadSingle ( ) ;
177- float zVel = reader . ReadSingle ( ) ;
178+ float xVel = bReader . ReadSingle ( ) ;
179+ float yVel = bReader . ReadSingle ( ) ;
180+ float zVel = bReader . ReadSingle ( ) ;
178181
179- float xPos = reader . ReadSingle ( ) ;
180- float yPos = reader . ReadSingle ( ) ;
181- float zPos = reader . ReadSingle ( ) ;
182+ float xPos = bReader . ReadSingle ( ) ;
183+ float yPos = bReader . ReadSingle ( ) ;
184+ float zPos = bReader . ReadSingle ( ) ;
182185
183186 Vector3 velocity = new Vector3 ( xVel , yVel , zVel ) ;
184187 Vector3 position = new Vector3 ( xPos , yPos , zPos ) ;
0 commit comments