示例#1
0
    public void SortBehaviours()
    {
        if (!NeedsSorting)
        {
            return;
        }

#if UNITY_EDITOR
        Profiler.BeginSample("Entres Sorting");
#endif

        NeedsSorting = false;

        for (int i = LowerBound + 1; i < UpperBound; i++)
        {
            CoreMonoBeh temp = queue[i];
            int         j    = i - 1;

            while (j >= 0 && GetLoopSettings(queue[j]).UpdateOrder > GetLoopSettings(temp).UpdateOrder)
            {
                queue[j + 1] = queue[j];
                j--;
            }

            queue[j + 1] = temp;
        }

#if UNITY_EDITOR
        Profiler.EndSample();
#endif
    }
    private void ProcessAdditions()
    {
        if (additionQueue.HasEntries)
        {
#if UNITY_EDITOR
            Profiler.BeginSample("Entries Additions");
#endif

            for (int i = additionQueue.LowerBound + 1; i < additionQueue.UpperBound; i++)
            {
                CoreMonoBeh workerBeh = additionQueue.queue[i];

                for (int j = 0; j < behaviourQueues.Count; j++)
                {
                    if (behaviourQueues[j].GetLoopSettings(workerBeh).isInited)
                    {
                        behaviourQueues[j].AddBehaviourAndSort(workerBeh);
                    }
                }
            }

            additionQueue.WipeQueue();

#if UNITY_EDITOR
            Profiler.EndSample();
#endif
        }
    }
示例#3
0
    public void RemoveBehaviourSingular(CoreMonoBeh beh)
    {
        int  j        = 0;
        int  cnt      = m_UpperBound;
        bool foundOne = false;

        for (int i = m_LowerBound + 1; i < m_UpperBound; i++)
        {
            if (queue[i] == beh)
            {
                j++;
                m_UpperBound--;
                foundOne = true;
            }

            queue[i] = queue[i + j];
        }

        if (foundOne)
        {
            queue[m_UpperBound] = null;

            if (m_LowerBound + 1 >= m_UpperBound)
            {
                m_LowerBound = -1;
                m_UpperBound = 0;
                m_HasEntries = false;
            }
            else
            {
                m_UpperUpdateQueueBound = GetLoopSettings(queue[m_UpperBound - 1]).UpdateOrder;
            }
        }
    }
示例#4
0
    public void AddBehaviourOnTop(CoreMonoBeh beh)
    {
        //Safety check for overflow
        CheckForOverflowAndExpand();

        queue[m_UpperBound] = beh;
        m_UpperBound++;

        if (!HasEntries)
        {
            m_LowerUpdateQueueBound = m_UpperUpdateQueueBound;
            m_HasEntries            = true;
        }
    }
示例#5
0
    public void AddBehaviourAndSort(CoreMonoBeh beh)
    {
        //Safety check for overflow
        CheckForOverflowAndExpand();

        LoopUpdateSettings settings = GetLoopSettings(beh);

        //Just throw it somewhere if the queue is already marked for sorting.
        //A nice early-out for batched additions.
        if (NeedsSorting)
        {
            queue[m_UpperBound] = beh;
            m_UpperBound++;
            return;
        }
        else if (settings.UpdateOrder >= UpperUpdateQueueBound)
        {
            queue[m_UpperBound] = beh;
            m_UpperBound++;
            m_UpperUpdateQueueBound = settings.UpdateOrder;
        }
        else if (settings.UpdateOrder <= LowerUpdateQueueBound && m_LowerBound > -1)
        {
            queue[m_LowerBound] = beh;
            m_LowerBound--;
            m_LowerUpdateQueueBound = settings.UpdateOrder;
        }
        //It's somewhere inbetween or where we can't place legally. Mark it for sorting.
        else
        {
            queue[m_UpperBound] = beh;
            m_UpperBound++;
            NeedsSorting = true;
        }

        if (!HasEntries)
        {
            m_LowerUpdateQueueBound = m_UpperUpdateQueueBound;
            m_HasEntries            = true;
        }
    }
示例#6
0
    public void AddBehaviour(CoreMonoBeh beh)
    {
        //Safety check for overflow
        CheckForOverflowAndExpand();

        //Lower empty fields take priority
        if (LowerBound > -1)
        {
            queue[LowerBound] = beh;
            m_LowerBound--;
        }
        else
        {
            queue[UpperBound] = beh;
            m_UpperBound++;
        }

        if (!HasEntries)
        {
            m_LowerUpdateQueueBound = m_UpperUpdateQueueBound;
            m_HasEntries            = true;
        }
    }
 public override void WriteLoopSettings(CoreMonoBeh beh, LoopUpdateSettings set)
 {
     beh.UM_SETTINGS_GAMEPLAYUPDATE = set;
 }
 public override LoopUpdateSettings GetLoopSettings(CoreMonoBeh beh)
 {
     return(beh.UM_SETTINGS_GAMEPLAYUPDATE);
 }
 public static void ScheduleBehaviourRemoval(CoreMonoBeh beh)
 {
     instance.removalsRequired = true;
 }
 public static void ScheduleBehaviourRegister(CoreMonoBeh beh)
 {
     Init();
     additionQueue.AddBehaviourOnTop(beh);
 }
示例#11
0
 public sealed override void WriteLoopSettings(CoreMonoBeh beh, LoopUpdateSettings set)
 {
     throw new Exception("A WorkerLoop abstract method has been called! You should not inherit from it!");
 }
示例#12
0
 public abstract void WriteLoopSettings(CoreMonoBeh beh, LoopUpdateSettings set);
示例#13
0
 public abstract LoopUpdateSettings GetLoopSettings(CoreMonoBeh beh);