public new T Pop() { var item = base.Pop(); OnPop?.Invoke(item); return(item); }
public virtual T Pop() { T item = stack.Pop(); OnPop?.Invoke(item); return(item); }
void PushCommand(Command i) { Commands.Enqueue(i); CommandObjects.Enqueue(Instantiate(CommandPrefabs[(int)i], Container.transform, false)); if (Commands.Count > Length) { var v = Commands.Dequeue(); OnPop?.Invoke(v); Destroy(CommandObjects.Dequeue()); } RefreshSpacers(); }
/// <summary> /// Straight Up Queue.Dequeue /// </summary> /// <returns></returns> public T getNextObj() { if (avaliableItems.Count < 1) { Populate(5); OnPop.Invoke(avaliableItems.Peek()); return(avaliableItems.Dequeue()); } else { OnPop.Invoke(avaliableItems.Peek()); return(avaliableItems.Dequeue()); } }
public T Pop() { T t; if (Count == 0) { t = creator(); } else { t = buffer.Pop(); } onPop?.Invoke(t); return(t); }
/// <summary> /// Pop an instance from the pool /// </summary> /// <returns></returns> public T Pop() { T instanceToPop; //If pool is empty, create a new instance of the default prefab if (pool.Count == 0) { instanceToPop = CreateNew(Prefab); } //Pool has instances, pops the first item in the pool else { instanceToPop = pool.Pop(); } OnPop?.Invoke(instanceToPop); return(instanceToPop); }