예제 #1
0
파일: ECBehavior.cs 프로젝트: fengqk/Art
    public void CacheBehavior(ECBehavior beh)
    {
        beh.ECObj = null;
        beh.IsValid = true;
        LinkedList<ECBehavior> cache = m_cache[(int)beh.Type];

        if (cache.Count < MaxCacheNum[(int)beh.Type])
            cache.AddLast(beh);
    }
예제 #2
0
    public void AddBehavior(ECBehavior beh)
    {
        beh.ECObj = this;
        LinkedListNode<ECBehavior> pos = m_BehaviorList.First;

        while (pos != null)
        {
            ECBehavior b = pos.Value;

            if (b.Type == beh.Type)
            {
                if(b.IsValid)
                {
                    b.OnRemoved(true);
                    if (b.OnFinish != null)
                        b.OnFinish(0);
                }
                pos.Value = beh;

                ECBehaviorCache.Instance.CacheBehavior(b);
                return;
            }
            pos = pos.Next;
        }

        m_BehaviorList.AddLast(beh);
    }