RemoveOwnedObject() private method

private RemoveOwnedObject ( NetworkIdentity obj ) : void
obj NetworkIdentity
return void
コード例 #1
0
        public bool RemoveClientAuthority(NetworkConnection conn)
        {
            if (!isServer)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("RemoveClientAuthority can only be call on the server for spawned objects.");
                }
                return(false);
            }

            if (connectionToClient != null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("RemoveClientAuthority cannot remove authority for a player object");
                }
                return(false);
            }

            if (m_ClientAuthorityOwner == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("RemoveClientAuthority for " + gameObject + " has no clientAuthority owner.");
                }
                return(false);
            }

            if (m_ClientAuthorityOwner != conn)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("RemoveClientAuthority for " + gameObject + " has different owner.");
                }
                return(false);
            }

            m_ClientAuthorityOwner.RemoveOwnedObject(this);
            m_ClientAuthorityOwner = null;

            // server now has authority (this is only called on server)
            ForceAuthority(true);

            // send msg to that client
            var msg = new ClientAuthorityMessage();

            msg.netId     = netId;
            msg.authority = false;
            conn.Send((short)MsgType.LocalClientAuthority, msg);

            if (clientAuthorityCallback != null)
            {
                clientAuthorityCallback(conn, this, false);
            }
            return(true);
        }
コード例 #2
0
ファイル: NetworkIdentity.cs プロジェクト: Hengle/JellyTerain
        public bool RemoveClientAuthority(NetworkConnection conn)
        {
            if (!isServer)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("RemoveClientAuthority can only be call on the server for spawned objects.");
                }
                return(false);
            }
            if (connectionToClient != null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("RemoveClientAuthority cannot remove authority for a player object");
                }
                return(false);
            }
            if (m_ClientAuthorityOwner == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("RemoveClientAuthority for " + base.gameObject + " has no clientAuthority owner.");
                }
                return(false);
            }
            if (m_ClientAuthorityOwner != conn)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("RemoveClientAuthority for " + base.gameObject + " has different owner.");
                }
                return(false);
            }
            m_ClientAuthorityOwner.RemoveOwnedObject(this);
            m_ClientAuthorityOwner = null;
            ForceAuthority(authority: true);
            ClientAuthorityMessage clientAuthorityMessage = new ClientAuthorityMessage();

            clientAuthorityMessage.netId     = netId;
            clientAuthorityMessage.authority = false;
            conn.Send(15, clientAuthorityMessage);
            if (clientAuthorityCallback != null)
            {
                clientAuthorityCallback(conn, this, authorityState: false);
            }
            return(true);
        }