AddToVisList() private méthode

private AddToVisList ( NetworkIdentity uv ) : void
uv NetworkIdentity
Résultat void
 internal void AddObserver(NetworkConnection conn)
 {
     if (m_Observers == null)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("AddObserver for " + base.gameObject + " observer list is null");
         }
         return;
     }
     if (m_ObserverConnections.Contains(conn.connectionId))
     {
         if (LogFilter.logDebug)
         {
             Debug.Log("Duplicate observer " + conn.address + " added for " + base.gameObject);
         }
         return;
     }
     if (LogFilter.logDev)
     {
         Debug.Log("Added observer " + conn.address + " added for " + base.gameObject);
     }
     m_Observers.Add(conn);
     m_ObserverConnections.Add(conn.connectionId);
     conn.AddToVisList(this);
 }
Exemple #2
0
        internal void AddObserver(NetworkConnection conn)
        {
            if (m_Observers == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("AddObserver for " + gameObject + " observer list is null");
                }
                return;
            }

            // uses hashset for better-than-list-iteration lookup performance.
            if (m_ObserverConnections.Contains(conn.connectionId))
            {
                // if we try to add a connectionId that was already added, then
                // we may have generated one that was already in use. this is
                // not good and there should be a notification.
                if (LogFilter.logWarn)
                {
                    Debug.LogWarning("AddObserver: connectionId=" + conn.connectionId + " already added for " + name + ". Maybe this function was called twice. Or maybe the transport layer generated the same connectionId twice, which would be a huge problem.");
                }
                return;
            }

            if (LogFilter.logDev)
            {
                Debug.Log("Added observer " + conn.address + " added for " + gameObject);
            }

            m_Observers.Add(conn);
            m_ObserverConnections.Add(conn.connectionId);
            conn.AddToVisList(this);
        }
Exemple #3
0
 internal void AddObserver(NetworkConnection conn)
 {
     if (this.m_Observers == null)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("AddObserver for " + base.gameObject + " observer list is null");
         }
     }
     else if (this.m_ObserverConnections.Contains(conn.connectionId))
     {
         if (LogFilter.logDebug)
         {
             Debug.Log(string.Concat(new object[] { "Duplicate observer ", conn.address, " added for ", base.gameObject }));
         }
     }
     else
     {
         if (LogFilter.logDev)
         {
             Debug.Log(string.Concat(new object[] { "Added observer ", conn.address, " added for ", base.gameObject }));
         }
         this.m_Observers.Add(conn);
         this.m_ObserverConnections.Add(conn.connectionId);
         conn.AddToVisList(this);
     }
 }
Exemple #4
0
        internal void AddObserver(NetworkConnection conn)
        {
            if (m_Observers == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("AddObserver for " + gameObject + " observer list is null");
                }
                return;
            }

            // uses hashset for better-than-list-iteration lookup performance.
            if (m_ObserverConnections.Contains(conn.connectionId))
            {
                if (LogFilter.logDebug)
                {
                    Debug.Log("Duplicate observer " + conn.address + " added for " + gameObject);
                }
                return;
            }

            if (LogFilter.logDev)
            {
                Debug.Log("Added observer " + conn.address + " added for " + gameObject);
            }

            m_Observers.Add(conn);
            m_ObserverConnections.Add(conn.connectionId);
            conn.AddToVisList(this);
        }
 internal void AddObserver(NetworkConnection conn)
 {
     if (this.m_Observers == null)
     {
         if (!LogFilter.logError)
         {
             return;
         }
         Debug.LogError((object)("AddObserver for " + (object)this.gameObject + " observer list is null"));
     }
     else if (this.m_ObserverConnections.Contains(conn.connectionId))
     {
         if (!LogFilter.logDebug)
         {
             return;
         }
         Debug.Log((object)("Duplicate observer " + conn.address + " added for " + (object)this.gameObject));
     }
     else
     {
         if (LogFilter.logDev)
         {
             Debug.Log((object)("Added observer " + conn.address + " added for " + (object)this.gameObject));
         }
         this.m_Observers.Add(conn);
         this.m_ObserverConnections.Add(conn.connectionId);
         conn.AddToVisList(this);
     }
 }
 internal void AddObserver(NetworkConnection conn)
 {
     if (this.m_Observers == null)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("AddObserver for " + base.gameObject + " observer list is null");
         }
     }
     else if (this.m_ObserverConnections.Contains(conn.connectionId))
     {
         if (LogFilter.logDebug)
         {
             Debug.Log(string.Concat(new object[] { "Duplicate observer ", conn.address, " added for ", base.gameObject }));
         }
     }
     else
     {
         if (LogFilter.logDev)
         {
             Debug.Log(string.Concat(new object[] { "Added observer ", conn.address, " added for ", base.gameObject }));
         }
         this.m_Observers.Add(conn);
         this.m_ObserverConnections.Add(conn.connectionId);
         conn.AddToVisList(this);
     }
 }
 internal void AddObserver(NetworkConnection conn)
 {
     if (this.m_Observers == null)
     return;
       if (this.m_Observers.Contains(conn))
       {
     if (!LogFilter.logWarn)
       return;
     object[] objArray = new object[4];
     int index1 = 0;
     string str1 = "Duplicate observer ";
     objArray[index1] = (object) str1;
     int index2 = 1;
     string str2 = conn.address;
     objArray[index2] = (object) str2;
     int index3 = 2;
     string str3 = " added for ";
     objArray[index3] = (object) str3;
     int index4 = 3;
     GameObject gameObject = this.gameObject;
     objArray[index4] = (object) gameObject;
     Debug.LogWarning((object) string.Concat(objArray));
       }
       else
       {
     if (LogFilter.logDev)
     {
       object[] objArray = new object[4];
       int index1 = 0;
       string str1 = "Added observer ";
       objArray[index1] = (object) str1;
       int index2 = 1;
       string str2 = conn.address;
       objArray[index2] = (object) str2;
       int index3 = 2;
       string str3 = " added for ";
       objArray[index3] = (object) str3;
       int index4 = 3;
       GameObject gameObject = this.gameObject;
       objArray[index4] = (object) gameObject;
       Debug.Log((object) string.Concat(objArray));
     }
     this.m_Observers.Add(conn);
     conn.AddToVisList(this);
       }
 }
        /// <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);
                    }
                }
            }
        }
 internal void AddObserver(NetworkConnection conn)
 {
   if (this.m_Observers == null)
   {
     if (!LogFilter.logError)
       return;
     Debug.LogError((object) ("AddObserver for " + (object) this.gameObject + " observer list is null"));
   }
   else if (this.m_ObserverConnections.Contains(conn.connectionId))
   {
     if (!LogFilter.logDebug)
       return;
     Debug.Log((object) ("Duplicate observer " + conn.address + " added for " + (object) this.gameObject));
   }
   else
   {
     if (LogFilter.logDev)
       Debug.Log((object) ("Added observer " + conn.address + " added for " + (object) this.gameObject));
     this.m_Observers.Add(conn);
     this.m_ObserverConnections.Add(conn.connectionId);
     conn.AddToVisList(this);
   }
 }