GetNextNetworkId() static private method

static private GetNextNetworkId ( ) : NetworkInstanceId
return NetworkInstanceId
コード例 #1
0
 internal void OnStartServer(bool allowNonZeroNetId)
 {
     if (this.m_IsServer)
     {
         return;
     }
     this.m_IsServer            = true;
     this.m_HasAuthority        = !this.m_LocalPlayerAuthority;
     this.m_Observers           = new List <NetworkConnection>();
     this.m_ObserverConnections = new HashSet <int>();
     this.CacheBehaviours();
     if (this.netId.IsEmpty())
     {
         this.m_NetId = NetworkIdentity.GetNextNetworkId();
     }
     else if (!allowNonZeroNetId)
     {
         if (!LogFilter.logError)
         {
             return;
         }
         Debug.LogError((object)("Object has non-zero netId " + (object)this.netId + " for " + (object)this.gameObject));
         return;
     }
     if (LogFilter.logDev)
     {
         Debug.Log((object)("OnStartServer " + (object)this.gameObject + " GUID:" + (object)this.netId));
     }
     NetworkServer.instance.SetLocalObjectOnServer(this.netId, this.gameObject);
     for (int index = 0; index < this.m_NetworkBehaviours.Length; ++index)
     {
         NetworkBehaviour networkBehaviour = this.m_NetworkBehaviours[index];
         try
         {
             networkBehaviour.OnStartServer();
         }
         catch (Exception ex)
         {
             Debug.LogError((object)("Exception in OnStartServer:" + ex.Message + " " + ex.StackTrace));
         }
     }
     if (NetworkClient.active && NetworkServer.localClientActive)
     {
         ClientScene.SetLocalObject(this.netId, this.gameObject);
         this.OnStartClient();
     }
     if (!this.m_HasAuthority)
     {
         return;
     }
     this.OnStartAuthority();
 }
コード例 #2
0
 internal void OnStartServer()
 {
     if (this.m_IsServer)
     {
         return;
     }
     this.m_IsServer = true;
     if (this.m_LocalPlayerAuthority)
     {
         this.m_HasAuthority = false;
     }
     else
     {
         this.m_HasAuthority = true;
     }
     this.m_Observers           = new List <NetworkConnection>();
     this.m_ObserverConnections = new HashSet <int>();
     this.CacheBehaviours();
     if (this.netId.IsEmpty())
     {
         this.m_NetId = NetworkIdentity.GetNextNetworkId();
         if (LogFilter.logDev)
         {
             Debug.Log(string.Concat(new object[]
             {
                 "OnStartServer ",
                 base.gameObject,
                 " GUID:",
                 this.netId
             }));
         }
         NetworkServer.instance.SetLocalObjectOnServer(this.netId, base.gameObject);
         for (int i = 0; i < this.m_NetworkBehaviours.Length; i++)
         {
             NetworkBehaviour networkBehaviour = this.m_NetworkBehaviours[i];
             try
             {
                 networkBehaviour.OnStartServer();
             }
             catch (Exception ex)
             {
                 Debug.LogError("Exception in OnStartServer:" + ex.Message + " " + ex.StackTrace);
             }
         }
         if (NetworkClient.active && NetworkServer.localClientActive)
         {
             ClientScene.SetLocalObject(this.netId, base.gameObject);
             this.OnStartClient();
         }
         if (this.m_HasAuthority)
         {
             this.OnStartAuthority();
         }
         return;
     }
     if (LogFilter.logError)
     {
         Debug.LogError(string.Concat(new object[]
         {
             "Object has non-zero netId ",
             this.netId,
             " for ",
             base.gameObject,
             " !!1"
         }));
     }
 }