示例#1
0
        // update specific

        private void priorityIn(List <tListEntry> list, SelectorProtocol target, int nPriority, bool bPaused)
        {
            tListEntry listElement = new tListEntry();

            listElement.target            = target;
            listElement.priority          = nPriority;
            listElement.paused            = bPaused;
            listElement.markedForDeletion = false;

            // list will not be empty, because it is new in init()
            int index = 0;

            foreach (tListEntry element in list)
            {
                if (nPriority < element.priority)
                {
                    break;
                }

                ++index;
            }

            // Can not throw exception, because index in [0, count]
            list.Insert(index, listElement);

            // update hash entry for quick access
            tHashUpdateEntry hashElement = new tHashUpdateEntry();

            hashElement.target = target;
            hashElement.list   = list;
            hashElement.entry  = listElement;
            m_pHashForUpdates.Add(target, hashElement);
        }
示例#2
0
        private void priorityIn(List <tListEntry> list, SelectorProtocol target, int nPriority, bool bPaused)
        {
            tListEntry item = new tListEntry
            {
                target            = target,
                priority          = nPriority,
                paused            = bPaused,
                markedForDeletion = false
            };
            int index = 0;

            foreach (tListEntry entry2 in list)
            {
                if (nPriority < entry2.priority)
                {
                    break;
                }
                index++;
            }
            list.Insert(index, item);
            tHashUpdateEntry entry3 = new tHashUpdateEntry
            {
                target = target,
                list   = list,
                entry  = item
            };

            this.m_pHashForUpdates.Add(target, entry3);
        }
示例#3
0
        /** Schedules the 'update' selector for a given target with a given priority.
         *   The 'update' selector will be called every frame.
         *   The lower the priority, the earlier it is called.
         *   @since v0.99.3
         */
        public void scheduleUpdateForTarget(SelectorProtocol targt, int nPriority, bool bPaused)
        {
            tHashUpdateEntry hashElement = null;

            if (m_pHashForUpdates.ContainsKey(targt))
            {
                // TODO: check if priority has changed!

                hashElement = m_pHashForUpdates[targt];
                hashElement.entry.markedForDeletion = false;
            }

            // most of the updates are going to be 0, that's way there
            // is an special list for updates with priority 0
            if (nPriority == 0)
            {
                appendIn(m_pUpdates0List, targt, bPaused);
            }
            else if (nPriority < 0)
            {
                priorityIn(m_pUpdatesNegList, targt, nPriority, bPaused);
            }
            else
            {
                priorityIn(m_pUpdatesPosList, targt, nPriority, bPaused);
            }
        }
示例#4
0
 public void unscheduleUpdateForTarget(SelectorProtocol target)
 {
     if ((target != null) && this.m_pHashForUpdates.ContainsKey(target))
     {
         tHashUpdateEntry entry = this.m_pHashForUpdates[target];
         if (this.m_bUpdateHashLocked)
         {
             entry.entry.markedForDeletion = true;
         }
         else
         {
             this.removeUpdateFromHash(entry.entry);
         }
     }
 }
示例#5
0
 public void resumeTarget(SelectorProtocol target)
 {
     if (target != null)
     {
         if (this.m_pHashForSelectors.ContainsKey(target))
         {
             this.m_pHashForSelectors[target].paused = false;
         }
         if (this.m_pHashForUpdates.ContainsKey(target))
         {
             tHashUpdateEntry entry = this.m_pHashForUpdates[target];
             entry.entry.paused = false;
         }
     }
 }
示例#6
0
        private void appendIn(List <tListEntry> list, SelectorProtocol target, bool bPaused)
        {
            tListEntry listElement = new tListEntry();

            listElement.target            = target;
            listElement.paused            = bPaused;
            listElement.markedForDeletion = false;

            list.Add(listElement);

            // update hash entry for quicker access
            tHashUpdateEntry hashElement = new tHashUpdateEntry();

            hashElement.target = target;
            hashElement.list   = list;
            hashElement.entry  = listElement;
            m_pHashForUpdates.Add(target, hashElement);
        }
示例#7
0
        private void appendIn(List <tListEntry> list, SelectorProtocol target, bool bPaused)
        {
            tListEntry item = new tListEntry
            {
                target            = target,
                paused            = bPaused,
                markedForDeletion = false
            };

            list.Add(item);
            tHashUpdateEntry entry2 = new tHashUpdateEntry
            {
                target = target,
                list   = list,
                entry  = item
            };

            this.m_pHashForUpdates.Add(target, entry2);
        }
示例#8
0
 private void removeUpdateFromHash(tListEntry entry)
 {
     if (this.m_pHashForUpdates.ContainsKey(entry.target))
     {
         tHashUpdateEntry entry2 = this.m_pHashForUpdates[entry.target];
         entry2.list.Remove(entry);
         entry2.entry  = null;
         entry2.target = null;
         SelectorProtocol key = null;
         foreach (KeyValuePair <SelectorProtocol, tHashUpdateEntry> pair in this.m_pHashForUpdates)
         {
             if (entry2 == pair.Value)
             {
                 key = pair.Key;
                 break;
             }
         }
         this.m_pHashForUpdates.Remove(key);
     }
 }
示例#9
0
        /** Unschedules the update selector for a given target
         *   @since v0.99.3
         */
        public void unscheduleUpdateForTarget(SelectorProtocol target)
        {
            if (target == null)
            {
                return;
            }

            if (m_pHashForUpdates.ContainsKey(target))
            {
                tHashUpdateEntry element = m_pHashForUpdates[target];
                if (m_bUpdateHashLocked)
                {
                    element.entry.markedForDeletion = true;
                }
                else
                {
                    removeUpdateFromHash(element.entry);
                }
            }
        }
示例#10
0
        /** Resumes the target.
         *   The 'target' will be unpaused, so all schedule selectors/update will be 'ticked' again.
         *   If the target is not present, nothing happens.
         *   @since v0.99.3
         */
        public void resumeTarget(SelectorProtocol target)
        {
            if (target == null)
            {
                return;
            }

            // custom selectors
            if (m_pHashForSelectors.ContainsKey(target))
            {
                m_pHashForSelectors[target].paused = false;
            }

            // Update selector
            if (m_pHashForUpdates.ContainsKey(target))
            {
                tHashUpdateEntry element = m_pHashForUpdates[target];
                Debug.Assert(element != null);
                element.entry.paused = false;
            }
        }
示例#11
0
        public void scheduleUpdateForTarget(SelectorProtocol targt, int nPriority, bool bPaused)
        {
            tHashUpdateEntry entry = null;

            if (this.m_pHashForUpdates.ContainsKey(targt))
            {
                entry = this.m_pHashForUpdates[targt];
                entry.entry.markedForDeletion = false;
            }
            if (nPriority == 0)
            {
                this.appendIn(this.m_pUpdates0List, targt, bPaused);
            }
            else if (nPriority < 0)
            {
                this.priorityIn(this.m_pUpdatesNegList, targt, nPriority, bPaused);
            }
            else
            {
                this.priorityIn(this.m_pUpdatesPosList, targt, nPriority, bPaused);
            }
        }
示例#12
0
        private void removeUpdateFromHash(tListEntry entry)
        {
            if (m_pHashForUpdates.ContainsKey(entry.target))
            {
                // list entry
                tHashUpdateEntry element = m_pHashForUpdates[entry.target];
                element.list.Remove(entry);
                element.entry = null;

                // hash entry
                element.target = null;
                SelectorProtocol target = null;
                foreach (KeyValuePair <SelectorProtocol, tHashUpdateEntry> kvp in m_pHashForUpdates)
                {
                    if (element == kvp.Value)
                    {
                        target = kvp.Key;
                        break;
                    }
                }
                m_pHashForUpdates.Remove(target);
            }
        }
示例#13
0
        /** Pauses the target.
         *   All scheduled selectors/update for a given target won't be 'ticked' until the target is resumed.
         *   If the target is not present, nothing happens.
         *   @since v0.99.3
         */
        public void pauseTarget(SelectorProtocol target)
        {
            if (target == null)
            {
                return;
            }

            // custom selectors
            if (m_pHashForSelectors.ContainsKey(target))
            {
                m_pHashForSelectors[target].paused = true;
            }

            // Update selector
            if (m_pHashForUpdates.ContainsKey(target))
            {
                tHashUpdateEntry element = m_pHashForUpdates[target];
                if (element != null)
                {
                    element.entry.paused = true;
                }
            }
        }
示例#14
0
        // update specific
        private void priorityIn(List<tListEntry> list, SelectorProtocol target, int nPriority, bool bPaused)
        {
            tListEntry listElement = new tListEntry();

            listElement.target = target;
            listElement.priority = nPriority;
            listElement.paused = bPaused;
            listElement.markedForDeletion = false;

            // list will not be empty, because it is new in init()
            int index = 0;
            foreach (tListEntry element in list)
            {
                if (nPriority < element.priority)
                {
                    break;
                }

                ++index;
            }

            // Can not throw exception, because index in [0, count]
            list.Insert(index, listElement);

            // update hash entry for quick access
            tHashUpdateEntry hashElement = new tHashUpdateEntry();
            hashElement.target = target;
            hashElement.list = list;
            hashElement.entry = listElement;
            m_pHashForUpdates.Add(target, hashElement);
        }
示例#15
0
        private void appendIn(List<tListEntry> list, SelectorProtocol target, bool bPaused)
        {
            tListEntry listElement = new tListEntry();

            listElement.target = target;
            listElement.paused = bPaused;
            listElement.markedForDeletion = false;

            list.Add(listElement);

            // update hash entry for quicker access
            tHashUpdateEntry hashElement = new tHashUpdateEntry();
            hashElement.target = target;
            hashElement.list = list;
            hashElement.entry = listElement;
            m_pHashForUpdates.Add(target, hashElement);
        }