コード例 #1
0
        public void Recycle(Entity obj)
        {
            Type           type = obj.GetType();
            ComponentQueue queue;

            if (!this.dictionary.TryGetValue(type, out queue))
            {
                queue = new ComponentQueue(type.Name);

#if !SERVER
                if (queue.ViewGO != null)
                {
                    queue.ViewGO.transform.SetParent(this.ViewGO.transform);
                    queue.ViewGO.name = $"{type.Name}s";
                }
#endif
                this.dictionary.Add(type, queue);
            }

#if !SERVER
            if (obj.ViewGO != null)
            {
                obj.ViewGO.transform.SetParent(queue.ViewGO.transform);
            }
#endif
            obj.Id = 0;
            queue.Enqueue(obj);
        }
コード例 #2
0
        public void Recycle(Component obj)
        {
            obj.Parent = this;
            Type           type = obj.GetType();
            ComponentQueue queue;

            if (!this.dictionary.TryGetValue(type, out queue))
            {
                queue        = new ComponentQueue(type.Name);
                queue.Parent = this;
                this.dictionary.Add(type, queue);
            }
            queue.Enqueue(obj);
        }
コード例 #3
0
ファイル: ObjectPool.cs プロジェクト: robinch-top/ET-Tank
        public void Recycle(Component obj)
        {
            obj.Parent = this;
            Type           type = obj.GetType();
            ComponentQueue queue;

            if (!this.dictionary.TryGetValue(type, out queue))
            {
                queue        = new ComponentQueue(type.Name);
                queue.Parent = this;
#if !SERVER
                queue.GameObject.name = $"{type.Name}s";
#endif
                this.dictionary.Add(type, queue);
            }
            queue.Enqueue(obj);
        }