示例#1
0
 private IEnumerable <ApiWorldInstance> GetViableInstances(string forUserId, List <string> instanceIdsToIgnore = null, bool excludePublicInstances = false, bool includePublicInstancesOnly = false)
 {
     if (instanceIdsToIgnore == null)
     {
         instanceIdsToIgnore = new List <string>();
     }
     if (worldInstances != null)
     {
         List <ApiWorldInstance> list = new List <ApiWorldInstance>();
         for (int i = 0; i < worldInstances.Count; i++)
         {
             ApiWorldInstance apiWorldInstance = worldInstances[i];
             int num = Mathf.Min(capacity, Mathf.Max(6, Mathf.FloorToInt((float)capacity * 0.66f)));
             ApiWorldInstance.AccessType accessType = apiWorldInstance.GetAccessType();
             string instanceCreator = apiWorldInstance.GetInstanceCreator();
             bool   flag            = accessType == ApiWorldInstance.AccessType.Public || accessType == ApiWorldInstance.AccessType.FriendsOfGuests;
             if (apiWorldInstance.count < capacity && apiWorldInstance.count < num && !instanceIdsToIgnore.Contains(apiWorldInstance.idWithTags) && !instanceIdsToIgnore.Contains(apiWorldInstance.idOnly) && accessType != ApiWorldInstance.AccessType.InviteOnly && accessType != ApiWorldInstance.AccessType.InvitePlus && (flag || !includePublicInstancesOnly) && (!excludePublicInstances || !flag) && (accessType != ApiWorldInstance.AccessType.FriendsOnly || APIUser.IsFriendsWith(instanceCreator)) && (accessType != ApiWorldInstance.AccessType.FriendsOfGuests || (instanceCreator != null && !(instanceCreator != forUserId))))
             {
                 list.Add(apiWorldInstance);
             }
         }
         return(from instance in list
                orderby instance.count descending
                select instance);
     }
     return(new ApiWorldInstance[0]);
 }