Пример #1
0
        public override void OnInitialized()
        {
            base.OnInitialized();

            ActiveRadiusComparer    = new WIRadiusComparer();
            VisibleRadiusComparer   = new WIRadiusComparer();
            InvisibleRadiusComparer = new WIRadiusComparer();
            LockedComparer          = new WIRadiusComparer();

            ActiveRadiusComparer.Locked    = false;
            VisibleRadiusComparer.Locked   = false;
            InvisibleRadiusComparer.Locked = false;
            LockedComparer.Locked          = true;

            ActiveRadiusComparer.State    = WIActiveState.Active;
            VisibleRadiusComparer.State   = WIActiveState.Visible;
            InvisibleRadiusComparer.State = WIActiveState.Invisible;
            LockedComparer.State          = WIActiveState.Any;

            ActiveWorldItems    = new HashSet <WorldItem> ();
            VisibleWorldItems   = new HashSet <WorldItem> ();
            InvisibleWorldItems = new HashSet <WorldItem> ();
            LockedWorldItems    = new HashSet <WorldItem> ();

            ActiveSet    = new List <WorldItem> ();
            VisibleSet   = new List <WorldItem> ();
            InvisibleSet = new List <WorldItem> ();
            LockedSet    = new List <WorldItem> ();
        }
Пример #2
0
        protected IEnumerator CheckIfDirty(List <WorldItem> listToCheck, HashSet <WorldItem> masterList, WIRadiusComparer sorter, int removalsPerFrame)
        {
            listToCheck.Sort(sorter);
            int       frame    = 0;
            int       removals = 0;
            WorldItem w        = null;

            for (int i = 0; i < listToCheck.Count; i++)
            {
                w = listToCheck [i];
                if (sorter.IsDirty(listToCheck [i]))
                {
                    //masterList.Remove (w);
                    //ItemsToSort.Add (w);
                    SendToStateList(w);
                    removals++;
                    if (removals > removalsPerFrame)
                    {
                        removals = 0;
                        yield return(null);
                    }
                }
                else
                {
                    break;
                }
            }
            listToCheck.Clear();
        }
Пример #3
0
        protected IEnumerator CleanWorldItemList(List <WorldItem> sortedList, HashSet <WorldItem> masterList, WIRadiusComparer sorter, int removalsPerFrame, int numToSortAtOnce)
        {
            sortedList.Clear();
            sortedList.AddRange(masterList);
            //if (sortedList.Count <= numToSortAtOnce) {
            //sort everything in one list
            var sortOneList = CheckIfDirty(sortedList, masterList, sorter, removalsPerFrame);

            while (sortOneList.MoveNext())
            {
                yield return(sortOneList.Current);
            }

            /*} else {
             *      //we need to do it in sections
             *      List <WorldItem> subList = new List<WorldItem> (numToSortAtOnce);
             *      int currentIndex = 0;
             *      while (currentIndex < numToSortAtOnce) {
             *              //sort everything bit by bit
             *              for (int i = 0; i < numToSortAtOnce; i++) {
             *                      subList.Add (sortedList [currentIndex]);
             *                      currentIndex++;
             *                      if (currentIndex >= sortedList.Count) {
             *                              break;
             *                      }
             *              }
             *              var sortMultipleLists = CheckIfDirty (subList, masterList, sorter, removalsPerFrame);
             *              while (sortMultipleLists.MoveNext ()) {
             *                      yield return sortMultipleLists.Current;
             *              }
             *              yield return null;
             *      }
             * }*/
            if (sortedList.Count > 0)
            {
                sortedList.Clear();
            }
            yield break;
        }