コード例 #1
0
ファイル: NiwradMenu.cs プロジェクト: louis030195/niwrad
        public new T Pop()
        {
            var item = base.Pop();

            OnPop?.Invoke(item);
            return(item);
        }
コード例 #2
0
    public virtual T Pop()
    {
        T item = stack.Pop();

        OnPop?.Invoke(item);
        return(item);
    }
コード例 #3
0
 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();
 }
コード例 #4
0
 /// <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());
     }
 }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
 public ObjectPool(Creator creator, OnPush onPush = null, OnPop onPop = null)
 {
     this.creator = creator;
     this.onPop   = onPop;
     this.onPush  = onPush;
 }