Beispiel #1
0
 public virtual void Destroy()
 {
     while (mCircleCaches.Count > 0)
     {
         ObjectBase circle = mCircleCaches.First.Value;
         mCircleCaches.RemoveFirst();
         circle.Destroy();
     }
     mCircleCaches.Clear();
 }
Beispiel #2
0
        public void Release(ObjectBase obj)
        {
            if (obj == null)
            {
                return;
            }
            Type type = obj.GetType();

            DebugUtils.Assert(type.IsSubclassOf(typeof(ObjectBase)), "wrong type");
            if (mPools.ContainsKey(type))
            {
                mPools[type].Release(obj);
            }
            else
            {
                // 释放调用 Destroy,比Release要强
                obj.Destroy();
            }
        }
Beispiel #3
0
        public void RemoveExpired(int lifeSeconds)
        {
            float timeStamp = DateTimeUtils.GetTimeStampSeconds();
            int   cnt       = mCircleCaches.Count;
            int   i         = 0;

            while (i < cnt)
            {
                ObjectBase circle = mCircleCaches.First.Value;
                mCircleCaches.RemoveFirst();
                if (!circle.IsExpired(mLifeTimeSecond))
                {
                    mCircleCaches.AddLast(circle);
                }
                else
                {
                    circle.Destroy();
                }
            }
        }