public void Destroy() { int maxCount = mObjPool.GetMaxCount(); for (int i = 0; i < maxCount; i++) { ObjectBase obj = mObjPool.Get(i) as ObjectBase; if (obj == null) { continue; } obj.Destroy(); } Clear(); }
public void Update(uint elapsed) { for (int i = 0; i < mWaitDestoryObjects.Count; ++i) { ObjectBase obj = mWaitDestoryObjects[i]; if (obj == null) { continue; } if (!obj.UpdateDestroy(elapsed)) { mWaitDestoryObjects.RemoveAt(i); mDestoryObjects.Add(obj); break; } } PoolSlot slot = mObjPool.UsedList(); while (slot != null) { ObjectBase obj = slot.Content as ObjectBase; if (obj == null) { slot = slot.NextSlot; continue; } if (!obj.Update(elapsed)) { if (obj.IsDestroyWaiting()) { mWaitDestoryObjects.Add(obj); } else { mDestoryObjects.Add(obj); } slot = slot.NextSlot; mObjPool.Remove((int)obj.InstanceID); continue; } slot = slot.NextSlot; } for (int i = 0; i < mDestoryObjects.Count; ++i) { ObjectBase obj = mDestoryObjects[i]; if (obj == null) { continue; } obj.Destroy(); } mDestoryObjects.Clear(); }