Inheritance: UnityEngine.Networking.MessageBase
Beispiel #1
0
 public bool AssignClientAuthority(NetworkConnection conn)
 {
     if (!this.isServer)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("AssignClientAuthority can only be call on the server for spawned objects.");
         }
         return false;
     }
     if (!this.localPlayerAuthority)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("AssignClientAuthority can only be used for NetworkIdentity component with LocalPlayerAuthority set.");
         }
         return false;
     }
     if ((this.m_ClientAuthorityOwner != null) && (conn != this.m_ClientAuthorityOwner))
     {
         if (LogFilter.logError)
         {
             Debug.LogError("AssignClientAuthority for " + base.gameObject + " already has an owner. Use RemoveClientAuthority() first.");
         }
         return false;
     }
     if (conn == null)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("AssignClientAuthority for " + base.gameObject + " owner cannot be null. Use RemoveClientAuthority() instead.");
         }
         return false;
     }
     this.m_ClientAuthorityOwner = conn;
     this.m_ClientAuthorityOwner.AddOwnedObject(this);
     ClientAuthorityMessage msg = new ClientAuthorityMessage {
         netId = this.netId,
         authority = true
     };
     conn.Send(15, msg);
     return true;
 }
Beispiel #2
0
 public bool RemoveClientAuthority(NetworkConnection conn)
 {
     if (!this.isServer)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("RemoveClientAuthority can only be call on the server for spawned objects.");
         }
         return false;
     }
     if (this.connectionToClient != null)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("RemoveClientAuthority cannot remove authority for a player object");
         }
         return false;
     }
     if (this.m_ClientAuthorityOwner == null)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("RemoveClientAuthority for " + base.gameObject + " has no clientAuthority owner.");
         }
         return false;
     }
     if (this.m_ClientAuthorityOwner != conn)
     {
         if (LogFilter.logError)
         {
             Debug.LogError("RemoveClientAuthority for " + base.gameObject + " has different owner.");
         }
         return false;
     }
     this.m_ClientAuthorityOwner.RemoveOwnedObject(this);
     this.m_ClientAuthorityOwner = null;
     ClientAuthorityMessage msg = new ClientAuthorityMessage {
         netId = this.netId,
         authority = false
     };
     conn.Send(15, msg);
     return true;
 }