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);
this.ForceAuthority(false);
ClientAuthorityMessage msg = new ClientAuthorityMessage {
netId = this.netId,
authority = true
};
conn.Send(15, msg);
if (clientAuthorityCallback != null)
{
clientAuthorityCallback(conn, this, true);
}
return true;
}