Esempio n. 1
0
        public static void Recycle(Errand <T> value, Type type)
        {
            var doesExist = _pool.TryGetValue(type, out var queue);

            if (!doesExist)
            {
                queue       = new Queue <Errand <T> >();
                _pool[type] = queue;
            }
            queue.Enqueue(value);
        }
Esempio n. 2
0
 public static ErrandStore Get(Errand <T> errand, Type type)
 {
     if (_queue.Count > 0)
     {
         var item = _queue.Dequeue();
         item.Errand = errand;
         item.Type   = type;
         return(item);
     }
     else
     {
         return(new ErrandStore(errand, type));
     }
 }
Esempio n. 3
0
 public void Draw(TimeSpan time, Errand <T> .DrawStatus drawStatus)
 {
     foreach (var errandType in _errands)
     {
         foreach (var errand in errandType.Value)
         {
             if (errand.DrawOrder == drawStatus)
             {
                 errand.Draw(time);
             }
         }
     }
     // Maybe I should just put CommitErrandChanges here for safety, but I
     // stubbornly refuse to enable future me to hack in a change to my errand
     // lists during a draw call. Take that, future Kyle!
 }
Esempio n. 4
0
 public void Remove(Errand <T> value, Type type)
 {
     _removeQueue.Add(ErrandStoreFactory.Get(value, type));
 }
Esempio n. 5
0
 public ErrandStore(Errand <T> errand, Type type)
 {
     Errand = errand;
     Type   = type;
 }