Example #1
0
        public void Update(float deltaTime, EUpdatePriority startPriority, EUpdatePriority endPriority)
        {
            int startIndex = (int)startPriority;
            int endIndex   = (int)endPriority;

            for (int i = startIndex; i <= endIndex; ++i)
            {
                List <CUpdateScope> updates = m_priorityUpdateBuckets[i];
                for (int j = updates.Count - 1; j >= 0; --j)
                {
                    CUpdateScope update = updates[j];
                    if (update.IsConnected())
                    {
                        update.Callback(deltaTime);
                    }
                    else
                    {
                        // If the update was disconnected remove it from the list
                        ContainerUtilities.RemoveSwapAt(updates, j);
                    }
                }

                List <CUpdateScope> singleUpdates = m_oneTimeUpdateBucket[i];
                for (int j = 0; j < singleUpdates.Count; j++)
                {
                    CUpdateScope update = singleUpdates[j];
                    if (update.IsConnected())
                    {
                        update.Callback(deltaTime);
                    }
                    update.Disconnect();
                }
                singleUpdates.Clear();
            }
        }
Example #2
0
        /// <summary>
        /// Register a new UpdateCallback that is called one time
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="priority"></param>
        /// <returns></returns>
        public CUpdateScope ConnectOneTimeUpdate(UpdateCallback callback, EUpdatePriority priority)
        {
            CUpdateScope outScope = new CUpdateScope(callback);

            m_oneTimeUpdateBucket[(int)priority].Add(outScope);
            return(outScope);
        }
Example #3
0
        /// <summary>
        /// Register a new UpdateCallback that is called every frame until disconnected
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="priority"></param>
        /// <returns></returns>
        public CUpdateScope Connect(UpdateCallback callback, EUpdatePriority priority)
        {
            CUpdateScope outScope = new CUpdateScope(callback);

            // Add the scope to the priority bucket
            m_priorityUpdateBuckets[(int)priority].Add(outScope);

            return(outScope);
        }
Example #4
0
 public void Disconnect(CUpdateScope scope)
 {
     scope?.Disconnect();
 }