internal void OnStartServer(bool allowNonZeroNetId)
{
if (!this.m_IsServer)
{
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 = GetNextNetworkId();
}
else if (!allowNonZeroNetId)
{
if (LogFilter.logError)
{
Debug.LogError(string.Concat(new object[] { "Object has non-zero netId ", this.netId, " for ", base.gameObject }));
}
return;
}
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 behaviour = this.m_NetworkBehaviours[i];
try
{
behaviour.OnStartServer();
}
catch (Exception exception)
{
Debug.LogError("Exception in OnStartServer:" + exception.Message + " " + exception.StackTrace);
}
}
if (NetworkClient.active && NetworkServer.localClientActive)
{
ClientScene.SetLocalObject(this.netId, base.gameObject);
this.OnStartClient();
}
if (this.m_HasAuthority)
{
this.OnStartAuthority();
}
}
}