@@ -71,7 +71,7 @@ public static SwitchSceneProgress SwitchScene(string sceneName)
7171 nextScene = SceneManager . GetSceneByName ( sceneName ) ;
7272 sceneLoad . completed += ( AsyncOperation AsyncOp ) => { OnSceneLoaded ( AsyncOp , switchSceneProgress . guid ) ; } ;
7373
74- switchSceneProgress . setSceneLoadOperation ( sceneLoad ) ;
74+ switchSceneProgress . SetSceneLoadOperation ( sceneLoad ) ;
7575
7676 using ( PooledBitStream stream = PooledBitStream . Get ( ) )
7777 {
@@ -206,14 +206,14 @@ internal static void OnClientSwitchSceneCompleted(uint clientId, Guid switchScen
206206 return ;
207207 }
208208
209- switchSceneProgresses [ switchSceneGuid ] . addClientAsDone ( clientId ) ;
209+ switchSceneProgresses [ switchSceneGuid ] . AddClientAsDone ( clientId ) ;
210210 }
211211
212212
213213 internal static void removeClientFromSceneSwitchProgresses ( uint clientId )
214214 {
215215 foreach ( SwitchSceneProgress switchSceneProgress in switchSceneProgresses . Values )
216- switchSceneProgress . removeClientAsDone ( clientId ) ;
216+ switchSceneProgress . RemoveClientAsDone ( clientId ) ;
217217 }
218218 }
219219
@@ -222,46 +222,30 @@ internal static void removeClientFromSceneSwitchProgresses(uint clientId)
222222 /// </summary>
223223 public class SwitchSceneProgress
224224 {
225-
226- internal SwitchSceneProgress ( )
227- {
228- timeOutCoroutine = NetworkingManager . singleton . StartCoroutine ( NetworkingManager . singleton . TimeOutSwitchSceneProgress ( this ) ) ;
229- }
230-
231- private Coroutine timeOutCoroutine ;
232- private Guid _guid = Guid . NewGuid ( ) ;
233- internal Guid guid => _guid ;
234-
235- private AsyncOperation sceneLoadOperation ;
236-
237225 /// <summary>
238- /// Array of clientIds of those clients that is done loading the scene.
226+ /// List of clientIds of those clients that is done loading the scene.
239227 /// </summary>
240- public uint [ ] doneClients => _doneClients . ToArray ( ) ;
241- private List < uint > _doneClients = new List < uint > ( ) ;
228+ public List < uint > DoneClients { get ; } = new List < uint > ( ) ;
242229 /// <summary>
243230 /// The NetworkTime time at the moment the scene switch was initiated by the server.
244231 /// </summary>
245- public float timeAtInitiation => _timeAtInitiation ;
246- private float _timeAtInitiation = NetworkingManager . singleton . NetworkTime ;
232+ public float TimeAtInitiation { get ; } = NetworkingManager . singleton . NetworkTime ;
247233 /// <summary>
248234 /// Delegate type for when the switch scene progress is completed. Either by all clients done loading the scene or by time out.
249235 /// </summary>
250236 public delegate void OnCompletedDelegate ( bool timedOut ) ;
251237 /// <summary>
252238 /// The callback invoked when the switch scene progress is completed. Either by all clients done loading the scene or by time out.
253239 /// </summary>
254- public event OnCompletedDelegate onCompleted ;
240+ public event OnCompletedDelegate OnComplete ;
255241 /// <summary>
256242 /// Is this scene switch progresses completed, all clients are done loading the scene or a timeout has occured.
257243 /// </summary>
258- public bool isCompleted => completed ;
259- private bool completed = false ;
244+ public bool isCompleted { get ; private set ; }
260245 /// <summary>
261246 /// If all clients are done loading the scene, at the moment of completed.
262247 /// </summary>
263- public bool isAllClientsDoneLoading => allClientsDoneLoading ;
264- private bool allClientsDoneLoading = false ;
248+ public bool isAllClientsDoneLoading { get ; private set ; }
265249 /// <summary>
266250 /// Delegate type for when a client is done loading the scene.
267251 /// </summary>
@@ -271,44 +255,58 @@ internal SwitchSceneProgress()
271255 /// </summary>
272256 public event OnClientLoadedSceneDelegate OnClientLoadedScene ;
273257
274- internal void addClientAsDone ( uint clientId )
258+ internal Guid guid { get ; } = Guid . NewGuid ( ) ;
259+
260+ private Coroutine timeOutCoroutine ;
261+ private AsyncOperation sceneLoadOperation ;
262+
263+ internal SwitchSceneProgress ( )
275264 {
276- _doneClients . Add ( clientId ) ;
265+ timeOutCoroutine = NetworkingManager . singleton . StartCoroutine ( NetworkingManager . singleton . TimeOutSwitchSceneProgress ( this ) ) ;
266+ }
267+
268+ internal void AddClientAsDone ( uint clientId )
269+ {
270+ DoneClients . Add ( clientId ) ;
277271 if ( OnClientLoadedScene != null )
278272 OnClientLoadedScene . Invoke ( clientId ) ;
279- checkCompletion ( ) ;
273+ CheckCompletion ( ) ;
280274 }
281- internal void removeClientAsDone ( uint clientId )
275+
276+ internal void RemoveClientAsDone ( uint clientId )
282277 {
283- _doneClients . Remove ( clientId ) ;
284- checkCompletion ( ) ;
278+ DoneClients . Remove ( clientId ) ;
279+ CheckCompletion ( ) ;
285280 }
286- internal void setSceneLoadOperation ( AsyncOperation sceneLoadOperation )
281+
282+ internal void SetSceneLoadOperation ( AsyncOperation sceneLoadOperation )
287283 {
288284 this . sceneLoadOperation = sceneLoadOperation ;
289- this . sceneLoadOperation . completed += ( AsyncOperation operation ) => { checkCompletion ( ) ; } ;
285+ this . sceneLoadOperation . completed += ( AsyncOperation operation ) => { CheckCompletion ( ) ; } ;
290286 }
291- internal void checkCompletion ( )
287+
288+ internal void CheckCompletion ( )
292289 {
293- if ( ! completed && _doneClients . Count == NetworkingManager . singleton . ConnectedClientsList . Count && sceneLoadOperation . isDone )
290+ if ( ! isCompleted && DoneClients . Count == NetworkingManager . singleton . ConnectedClientsList . Count && sceneLoadOperation . isDone )
294291 {
295- completed = true ;
296- allClientsDoneLoading = true ;
297- NetworkSceneManager . switchSceneProgresses . Remove ( _guid ) ;
298- if ( onCompleted != null )
299- onCompleted . Invoke ( false ) ;
292+ isCompleted = true ;
293+ isAllClientsDoneLoading = true ;
294+ NetworkSceneManager . switchSceneProgresses . Remove ( guid ) ;
295+ if ( OnComplete != null )
296+ OnComplete . Invoke ( false ) ;
300297
301298 NetworkingManager . singleton . StopCoroutine ( timeOutCoroutine ) ;
302299 }
303300 }
304- internal void setTimedOut ( )
301+
302+ internal void SetTimedOut ( )
305303 {
306- if ( ! completed )
304+ if ( ! isCompleted )
307305 {
308- completed = true ;
309- NetworkSceneManager . switchSceneProgresses . Remove ( _guid ) ;
310- if ( onCompleted != null )
311- onCompleted . Invoke ( true ) ;
306+ isCompleted = true ;
307+ NetworkSceneManager . switchSceneProgresses . Remove ( guid ) ;
308+ if ( OnComplete != null )
309+ OnComplete . Invoke ( true ) ;
312310 }
313311 }
314312
0 commit comments