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);
}