//        public static bool AddVisitorToLittleZooApply(
//            EntityVisitor entity, bool isFirstApply, Dictionary<int, LittleZoo> littleZooMap,
//            ref int groupID, ref int littleZooID, ref bool isCrossGroup, List<int> openedLittleZooIDs,
//            List<int> freeLittleZooIDs, List<int> wouldGotoLittleZooIDs,
//            List<int> wouldGotoWeights, List<int> crossGroupIDs)
//        {
//            bool applyResult = false;
//            int nextGroupID = Const.Invalid_Int;
//            if (isFirstApply)
//            {
//                groupID = GlobalDataManager.GetInstance().logicTableGroup.sortedGroupID[0];
//                if (!crossGroupIDs.Contains(groupID))
//                {
//                    crossGroupIDs.Add(groupID);
//                }
//            }

//            //判定goto概率
//            applyResult = WouldGotoGroupByGotoweight(groupID);
//            if (!applyResult)
//            {
//                return applyResult;
//            }

//            //获得这组开放的动物栏
//            applyResult = GetOpenedLittleZooIDs(groupID, openedLittleZooIDs);
//            if (!applyResult)
//            {
//                return applyResult;
//            }

//            applyResult = GetFreeLittleZooIDs(openedLittleZooIDs, littleZooMap, freeLittleZooIDs);
//            if (!applyResult)
//            {
//                applyResult = GlobalDataManager.GetInstance().logicTableGroup.GetNextGroupID(groupID, ref nextGroupID);
//                isCrossGroup = true;
//                groupID = nextGroupID;

//                if (!applyResult)
//                {
//                    return applyResult;
//                }

//                if (!crossGroupIDs.Contains(groupID))
//                {
//                    crossGroupIDs.Add(groupID);
//                }

//                if (!crossGroupIDs.Contains(nextGroupID))
//                {
//                    crossGroupIDs.Add(nextGroupID);
//                }

//                return AddVisitorToLittleZooApply(entity, false, littleZooMap, ref groupID,
//                    ref littleZooID, ref isCrossGroup, openedLittleZooIDs, freeLittleZooIDs, wouldGotoLittleZooIDs,
//                    wouldGotoWeights, crossGroupIDs);
//            }

//            //从有空位的中筛选出没有浏览过的
//            applyResult = GetWouldGotoLittleZooIDs(entity, groupID, freeLittleZooIDs, wouldGotoLittleZooIDs);
//            if (!applyResult)
//            {
//                applyResult = GlobalDataManager.GetInstance().logicTableGroup.GetNextGroupID(groupID, ref nextGroupID);
//                isCrossGroup = true;
//                groupID = nextGroupID;

//                if (!applyResult)
//                {
//                    return applyResult;
//                }

//                if (!crossGroupIDs.Contains(groupID))
//                {
//                    crossGroupIDs.Add(groupID);
//                }

//                if (!crossGroupIDs.Contains(nextGroupID))
//                {
//                    crossGroupIDs.Add(nextGroupID);
//                }

//                return AddVisitorToLittleZooApply(entity, false, littleZooMap, ref groupID,
//                    ref littleZooID, ref isCrossGroup, openedLittleZooIDs, freeLittleZooIDs, wouldGotoLittleZooIDs,
//                    wouldGotoWeights, crossGroupIDs);
//            }

//            applyResult = GetWouldGotoWeights(groupID, wouldGotoLittleZooIDs, wouldGotoWeights);
//#if UNITY_EDITOR
//            if (!applyResult)
//            {
//                string e = string.Format("{0} GetWouldGotoWeights 异常", entity.entityID);
//                throw new System.Exception(e);
//            }
//#endif
//            int idx = Const.Invalid_Int;
//            Math_F.TableProbability(wouldGotoWeights, ref idx);

//            littleZooID = wouldGotoLittleZooIDs[idx];
//            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} TableProbability group={1}, nextgroup={2} littlezoo={3}",
//                entity.entityID, groupID, nextGroupID, littleZooID);
//            return true;
//        }

        /// <summary>
        /// 从空闲列表中剔除浏览过的
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="groupID"></param>
        /// <param name="freeLittleZooIDs"></param>
        /// <param name="wouldGotoLittleZooIDs"></param>
        /// <returns></returns>
        public static bool GetWouldGotoLittleZooIDs(EntityVisitor entity, int groupID, List <int> freeLittleZooIDs, List <int> wouldGotoLittleZooIDs)
        {
            wouldGotoLittleZooIDs.Clear();

            var visitedLittleZooIDs = EntityVisitor.GetVisitedLittleZooIDs(entity, groupID);
            int freeLittleZooID     = Const.Invalid_Int;

            for (int i = 0; i < freeLittleZooIDs.Count; i++)
            {
                freeLittleZooID = freeLittleZooIDs[i];
                if (visitedLittleZooIDs == null ||
                    visitedLittleZooIDs.Count == 0 ||
                    visitedLittleZooIDs.IndexOf(freeLittleZooID) < 0)
                {
                    //没有浏览过
                    wouldGotoLittleZooIDs.Add(freeLittleZooID);
                }
            }

            return(wouldGotoLittleZooIDs.Count > 0);
        }