浏览代码

Naming Convention

Renamed _available to Available in PoolSO
/main
Dave Rodriguez 4 年前
当前提交
07891a31
共有 1 个文件被更改,包括 5 次插入5 次删除
  1. 10
      UOP1_Project/Assets/Scripts/Pool/PoolSO.cs

10
UOP1_Project/Assets/Scripts/Pool/PoolSO.cs


/// <typeparam name="T">Specifies the type of elements to pool.</typeparam>
public abstract class PoolSO<T> : ScriptableObject, IPool<T>
{
protected readonly Stack<T> _available = new Stack<T>();
protected readonly Stack<T> Available = new Stack<T>();
public abstract IFactory<T> Factory { get; set; }
protected bool HasBeenPrewarmed { get; set; }

}
for (int i = 0; i < num; i++)
{
_available.Push(Create());
Available.Push(Create());
}
HasBeenPrewarmed = true;
}

return _available.Count > 0 ? _available.Pop() : Create();
return Available.Count > 0 ? Available.Pop() : Create();
}
public virtual IEnumerable<T> Request(int num = 1)

public virtual void Return(T member)
{
_available.Push(member);
Available.Push(member);
}
public virtual void Return(IEnumerable<T> members)

public virtual void OnDisable()
{
_available.Clear();
Available.Clear();
}
}
}
正在加载...
取消
保存