/// <summary> Working with a given connection, a List of all views, SliceSize and Position, /// the connection has its scope updated for the given position/slice of the provided list /// of views. If views.Count == 512, Position == 64, and slice size == 32, connection will /// have scope updated for views occupying index 64 through 96 of the views List only. </summary> internal void UpdateScopeRange(NetConnection connection, List <NetView> views) { if (Position >= views.Count) { Position = 0; } int count = SliceSize; NetScope scope = connection.Scope; for (int i = Position; i < views.Count; i++) { var view = views[i]; if (view != connection.View && view.Server == Socket.Self && connection.InGroup(view.Group) && view.CanInstantiateFor(connection) && UpdateScope(scope, view)) { if (scope.In(view.Id)) { view.SendInstantiateData(connection); } else { ViewManager.SendOutOfScope(view.Id, connection); } } count--; if (count == 0) { break; } } }
/// <summary> Calculates the scope for the supplied connection against the scope of every view. /// This is useful, for example, when a connection is first created and an immediate population /// of views is desired. This can be detrimental when there is so much instantiation data that /// sending it all at once would cause an immediate send window overflow. </summary> internal void FullScopeCalculation(NetConnection connection) { for (int i = 0; i < ViewManager.Views.Count; i++) { var view = ViewManager.Views[i]; if (view.Server != Socket.Self) continue; if (!connection.InGroup(view.Group) || !view.CanInstantiateFor(connection)) continue; if (!UpdateScope(connection.Scope, view) && !view.IsController(connection)) continue; view.SendInstantiateData(connection); } }
/// <summary> Working with a given connection, a List of all views, SliceSize and Position, /// the connection has its scope updated for the given position/slice of the provided list /// of views. If views.Count == 512, Position == 64, and slice size == 32, connection will /// have scope updated for views occupying index 64 through 96 of the views List only. </summary> internal void UpdateScopeRange(NetConnection connection, List<NetView> views) { if (Position >= views.Count) Position = 0; int count = SliceSize; NetScope scope = connection.Scope; for (int i = Position; i < views.Count; i++) { var view = views[i]; if (view != connection.View && view.Server == Socket.Self && connection.InGroup(view.Group) && view.CanInstantiateFor(connection) && UpdateScope(scope, view)) { if (scope.In(view.Id)) view.SendInstantiateData(connection); else ViewManager.SendOutOfScope(view.Id, connection); } count--; if (count == 0) break; } }
/// <summary> Calculates the scope for the supplied connection against the scope of every view. /// This is useful, for example, when a connection is first created and an immediate population /// of views is desired. This can be detrimental when there is so much instantiation data that /// sending it all at once would cause an immediate send window overflow. </summary> internal void FullScopeCalculation(NetConnection connection) { for (int i = 0; i < ViewManager.Views.Count; i++) { var view = ViewManager.Views[i]; if (view.Server != Socket.Self) { continue; } if (!connection.InGroup(view.Group) || !view.CanInstantiateFor(connection)) { continue; } if (!UpdateScope(connection.Scope, view) && !view.IsController(connection)) { continue; } view.SendInstantiateData(connection); } }
/// <summary> Calculates scope for every connection against the provided view's scope. /// This is useful, for example, when creating a new view so that it can be immediately /// instantiated since a delay may be undesireable. </summary> internal void FullScopeCalculation(NetView view) { if (view.Server != Socket.Self) { return; } for (int i = 0; i < Socket.Connections.Count; i++) { NetConnection connection = Socket.Connections[i]; if (connection.IsServer || !connection.HasScope) { continue; } if (view.IsController(connection)) { view.SendInstantiateData(connection); } else if (connection.InGroup(view.Group) && view.CanInstantiateFor(connection) && UpdateScope(connection.Scope, view)) { view.SendInstantiateData(connection); } } }