RemoveFromVisList() private méthode

private RemoveFromVisList ( NetworkIdentity uv, bool isDestroyed ) : void
uv NetworkIdentity
isDestroyed bool
Résultat void
Exemple #1
0
 internal void RemoveObserver(NetworkConnection conn)
 {
     if (this.m_Observers != null)
     {
         this.m_Observers.Remove(conn);
         this.m_ObserverConnections.Remove(conn.connectionId);
         conn.RemoveFromVisList(this, false);
     }
 }
 internal void RemoveObserver(NetworkConnection conn)
 {
     if (m_Observers != null)
     {
         m_Observers.Remove(conn);
         m_ObserverConnections.Remove(conn.connectionId);
         conn.RemoveFromVisList(this, isDestroyed: false);
     }
 }
Exemple #3
0
        internal void RemoveObserver(NetworkConnection conn)
        {
            if (m_Observers == null)
            {
                return;
            }

            // NOTE this is linear performance now..
            m_Observers.Remove(conn);
            m_ObserverConnections.Remove(conn.connectionId);
            conn.RemoveFromVisList(this, false);
        }
 internal void ClearObservers()
 {
     if (m_Observers != null)
     {
         int count = m_Observers.Count;
         for (int i = 0; i < count; i++)
         {
             NetworkConnection networkConnection = m_Observers[i];
             networkConnection.RemoveFromVisList(this, isDestroyed: true);
         }
         m_Observers.Clear();
         m_ObserverConnections.Clear();
     }
 }
 internal void ClearObservers()
 {
     if (this.m_Observers != null)
     {
         int count = this.m_Observers.Count;
         for (int i = 0; i < count; i++)
         {
             NetworkConnection networkConnection = this.m_Observers[i];
             networkConnection.RemoveFromVisList(this, true);
         }
         this.m_Observers.Clear();
         this.m_ObserverConnections.Clear();
     }
 }
 internal void RemoveObserver(NetworkConnection conn)
 {
     if (this.m_Observers == null)
     return;
       this.m_Observers.Remove(conn);
       conn.RemoveFromVisList(this, false);
 }
 internal void RemoveObserver(NetworkConnection conn)
 {
     if (this.m_Observers != null)
     {
         this.m_Observers.Remove(conn);
         this.m_ObserverConnections.Remove(conn.connectionId);
         conn.RemoveFromVisList(this, false);
     }
 }
        /// <summary>
        ///   <para>This causes the set of players that can see this object to be rebuild. The OnRebuildObservers callback function will be invoked on each NetworkBehaviour.</para>
        /// </summary>
        /// <param name="initialize">True if this is the first time.</param>
        public void RebuildObservers(bool initialize)
        {
            if (this.m_Observers == null)
            {
                return;
            }
            bool flag1 = false;
            bool flag2 = false;
            HashSet <NetworkConnection> observers            = new HashSet <NetworkConnection>();
            HashSet <NetworkConnection> networkConnectionSet = new HashSet <NetworkConnection>((IEnumerable <NetworkConnection>) this.m_Observers);

            for (int index = 0; index < this.m_NetworkBehaviours.Length; ++index)
            {
                NetworkBehaviour networkBehaviour = this.m_NetworkBehaviours[index];
                flag2 |= networkBehaviour.OnRebuildObservers(observers, initialize);
            }
            if (!flag2)
            {
                if (!initialize)
                {
                    return;
                }
                foreach (NetworkConnection connection in NetworkServer.connections)
                {
                    if (connection != null && connection.isReady)
                    {
                        this.AddObserver(connection);
                    }
                }
                using (List <NetworkConnection> .Enumerator enumerator = NetworkServer.localConnections.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        NetworkConnection current = enumerator.Current;
                        if (current != null && current.isReady)
                        {
                            this.AddObserver(current);
                        }
                    }
                }
            }
            else
            {
                using (HashSet <NetworkConnection> .Enumerator enumerator = observers.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        NetworkConnection current = enumerator.Current;
                        if (current != null)
                        {
                            if (!current.isReady)
                            {
                                if (LogFilter.logWarn)
                                {
                                    Debug.LogWarning((object)("Observer is not ready for " + (object)this.gameObject + " " + (object)current));
                                }
                            }
                            else if (initialize || !networkConnectionSet.Contains(current))
                            {
                                current.AddToVisList(this);
                                if (LogFilter.logDebug)
                                {
                                    Debug.Log((object)("New Observer for " + (object)this.gameObject + " " + (object)current));
                                }
                                flag1 = true;
                            }
                        }
                    }
                }
                using (HashSet <NetworkConnection> .Enumerator enumerator = networkConnectionSet.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        NetworkConnection current = enumerator.Current;
                        if (!observers.Contains(current))
                        {
                            current.RemoveFromVisList(this, false);
                            if (LogFilter.logDebug)
                            {
                                Debug.Log((object)("Removed Observer for " + (object)this.gameObject + " " + (object)current));
                            }
                            flag1 = true;
                        }
                    }
                }
                if (initialize)
                {
                    using (List <NetworkConnection> .Enumerator enumerator = NetworkServer.localConnections.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            NetworkConnection current = enumerator.Current;
                            if (!observers.Contains(current))
                            {
                                this.OnSetLocalVisibility(false);
                            }
                        }
                    }
                }
                if (!flag1)
                {
                    return;
                }
                this.m_Observers = new List <NetworkConnection>((IEnumerable <NetworkConnection>)observers);
                this.m_ObserverConnections.Clear();
                using (List <NetworkConnection> .Enumerator enumerator = this.m_Observers.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        this.m_ObserverConnections.Add(enumerator.Current.connectionId);
                    }
                }
            }
        }