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); }
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)); } }
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! }
public void Remove(Errand <T> value, Type type) { _removeQueue.Add(ErrandStoreFactory.Get(value, type)); }
public ErrandStore(Errand <T> errand, Type type) { Errand = errand; Type = type; }