public void Init(int count) { for (int i = 0; i < 10; i++) { NormalComponent component = ComponentIds.GetComponent(_componentId); if (component == null) { throw new Exception("需要获取的组件不存在"); } component.InstanceId = _componentList.Count; _componentList.Add(component); _indexQueue.Enqueue(i); } }
public NormalComponent Dequeue() { NormalComponent component = null; if (_indexQueue.Count > 0) { int index = _indexQueue.Dequeue(); component = _componentList[index]; _componentList[index] = null; return(component); } component = ComponentIds.GetComponent(_componentId); if (component == null) { throw new Exception("需要获取的组件不存在"); } component.InstanceId = _componentList.Count; _componentList.Add(null); return(component); }