public T Pop <T>() where T : GPoolObject, new() { Type type = typeof(T); if (!this._typeToObjects.TryGetValue(type, out Queue <GPoolObject> objs)) { objs = new Queue <GPoolObject>(); this._typeToObjects[type] = objs; } GPoolObject obj = objs.Count == 0 ? new T() : objs.Dequeue(); return(( T )obj); }
public void Push(GPoolObject obj) { this._typeToObjects[obj.GetType()].Enqueue(obj); }