public static void DestroyPlayersForConnection(NetworkConnection conn)
{
if (conn.playerControllers.Count == 0)
{
if (LogFilter.logWarn)
{
Debug.LogWarning("Empty player list given to NetworkServer.Destroy(), nothing to do.");
}
}
else
{
if (conn.clientOwnedObjects != null)
{
HashSet<NetworkInstanceId> set = new HashSet<NetworkInstanceId>(conn.clientOwnedObjects);
foreach (NetworkInstanceId id in set)
{
GameObject obj2 = FindLocalObject(id);
if (obj2 != null)
{
DestroyObject(obj2);
}
}
}
for (int i = 0; i < conn.playerControllers.Count; i++)
{
PlayerController controller = conn.playerControllers[i];
if (controller.IsValid)
{
if (controller.unetView != null)
{
DestroyObject(controller.unetView, true);
}
controller.gameObject = null;
}
}
conn.playerControllers.Clear();
}
}