Ejemplo n.º 1
0
        public CombatEventTree FindInSiblings(CombatEvent evt)
        {
            if (m_parent == null)
            {
                return(null);
            }

            // speed up
            CombatEventTree found = null;

            if (s_nodeCache.TryGetValue(evt.GetHashCode(), out found))
            {
                if (found.IsAncestor(m_parent) && found != this)
                {
                    return(found);
                }
            }
            EB.Debug.LogWarning("CombatEventTree.FindInSiblings: cache miss");

            var iter = m_parent.GetChildrenNonAlloc();

            while (iter.MoveNext())
            {
                CombatEventTree sibling = iter.Current;

                if (sibling == this)
                {
                    continue;
                }

                if (sibling.Event.Equals(evt))
                {
                    iter.Dispose();
                    return(sibling);
                }
            }
            iter.Dispose();

            iter = m_parent.GetChildrenNonAlloc();
            while (iter.MoveNext())
            {
                CombatEventTree sibling = iter.Current;

                if (sibling == this)
                {
                    continue;
                }

                found = sibling.FindInChildren(evt);
                if (found != null)
                {
                    iter.Dispose();
                    return(found);
                }
            }
            iter.Dispose();

            return(null);
        }
Ejemplo n.º 2
0
        public CombatEventTree Find(CombatEvent evt)
        {
            // speed up
            CombatEventTree found = null;

            if (s_nodeCache.TryGetValue(evt.GetHashCode(), out found))
            {
                if (found == this || found.IsAncestor(this))
                {
                    return(found);
                }
            }

            if (m_event.Equals(evt))
            {
                return(this);
            }

            EB.Debug.LogWarning("CombatEventTree.Find: cache miss");

            var iter = m_children.GetEnumerator();

            while (iter.MoveNext())
            {
                var pair = iter.Current;
                List <CombatEventTree> tree_list = pair.Value;
                for (int i = 0, cnt = tree_list.Count; i < cnt; ++i)
                {
                    found = tree_list[i].Find(evt);
                    if (found != null)
                    {
                        iter.Dispose();
                        return(found);
                    }
                }
            }
            iter.Dispose();

            return(null);
        }
Ejemplo n.º 3
0
        public CombatEventTree FindInChildren(CombatEvent evt)
        {
            // speed up
            CombatEventTree found = null;

            if (s_nodeCache.TryGetValue(evt.GetHashCode(), out found))
            {
                if (found.IsAncestor(this))
                {
                    return(found);
                }
            }
            EB.Debug.LogWarning("CombatEventTree.FindInChildren: cache miss");

            var iter = GetChildrenNonAlloc();

            while (iter.MoveNext())
            {
                CombatEventTree child = iter.Current;

                if (child.Event.Equals(evt))
                {
                    iter.Dispose();
                    return(child);
                }

                found = child.FindInChildren(evt);
                if (found != null)
                {
                    iter.Dispose();
                    return(found);
                }
            }
            iter.Dispose();

            return(null);
        }