Exemplo n.º 1
0
        /// <summary> Adds an element. </summary>
        public void Add(PhysicsTask t)
        {
            int me = _free++;

            if (_heap.Count > me)
            {
                _heap[me] = t;
            }
            else
            {
                _heap.Add(t);
            }

            long myKey = t.GetHeapKey();

            while (me > 0)
            {
                int parent = ParentIdx(me);
                if (_heap[parent].GetHeapKey() < myKey)
                {
                    break;
                }
                Swap(me, parent);
                me = parent;
            }
        }
Exemplo n.º 2
0
        void Swap(int i1, int i2)
        {
            PhysicsTask t = _heap[i1];

            _heap[i1] = _heap[i2];
            _heap[i2] = t;
        }
Exemplo n.º 3
0
 public void AddTask(PhysicsTask task, int delay)
 {
     task.DueTime = _watch.ElapsedMilliseconds + delay;
     lock ( _tasks ) {
         _tasks.Add(task);
     }
     _continue.Set();
 }
Exemplo n.º 4
0
 internal void AddPhysicsTask(PhysicsTask task, int Delay)
 {
     _physSchedulers[(int)TaskCategory.Physics].AddTask(task, Delay);
 }
Exemplo n.º 5
0
 internal void AddTask(TaskCategory cat, PhysicsTask task, int Delay)
 {
     _physSchedulers[(int)cat].AddTask(task, Delay);
 }