Esempio n. 1
0
        public bool AddChild(CombatEventTree sub_tree)
        {
            if (sub_tree.Parent != null)
            {
                EB.Debug.LogError("AddChild: parent is set");
                return(false);
            }

            eCombatEventTiming timing = sub_tree.Event.Timing;

            if (!HasChildren(timing))
            {
                m_children[timing] = new List <CombatEventTree>();
            }

            List <CombatEventTree> children = GetChildren(timing);

            if (ILRDefine.UNITY_EDITOR && children.Contains(sub_tree))
            {
                EB.Debug.LogError("AddChild: child exists");
                return(false);
            }

            sub_tree.Parent = this;
            children.Add(sub_tree);

            if (ILRDefine.UNITY_EDITOR && s_nodeCache.ContainsKey(sub_tree.GetHashCode()))
            {
                EB.Debug.LogError("AddChild: cache exists");
            }

            s_nodeCache[sub_tree.GetHashCode()] = sub_tree;

            if (ILRDefine.UNITY_EDITOR && timing == eCombatEventTiming.AUTO && children.Count > 1)
            {
                EB.Debug.LogError("AddChild: auto children great than one");
            }

            return(true);
        }
Esempio n. 2
0
        public bool RemoveChild(CombatEventTree sub_tree)
        {
            if (sub_tree.Parent != this)
            {
                EB.Debug.LogError("RemoveChild: parent not match, this = {0}, target = {1}", Event.GetLogId(), sub_tree.Parent != null ? sub_tree.Parent.Event.GetLogId() : null);
                return(false);
            }

            eCombatEventTiming     timing   = sub_tree.Event.Timing;
            List <CombatEventTree> children = GetChildren(timing);

            if (children == null)
            {
                EB.Debug.LogError("RemoveChild: timing not match, {0}", timing);
                return(false);
            }

            if (!children.Remove(sub_tree))
            {
                EB.Debug.LogError("RemoveChild: child not found, {0}", sub_tree.Event.GetLogId());
                return(false);
            }

            if (children.Count == 0 && !m_children.Remove(timing))
            {
                EB.Debug.LogError("RemoveChild: remove empty timing failed, {0}", timing);
                return(false);
            }

            sub_tree.Parent = null;
            if (ILRDefine.UNITY_EDITOR && !s_nodeCache.ContainsKey(sub_tree.GetHashCode()))
            {
                EB.Debug.LogError("RemoveChild: cache not exists");
            }
            s_nodeCache.Remove(sub_tree.GetHashCode());

            return(true);
        }
Esempio n. 3
0
        public bool RemoveChildren(eCombatEventTiming timing)
        {
            if (m_children.ContainsKey(timing))
            {
                List <CombatEventTree> children = GetChildren(timing);

                int len = children.Count;
                for (int i = 0; i < len; i++)
                {
                    CombatEventTree child = children[i];
                    child.Parent = null;
                    if (ILRDefine.UNITY_EDITOR && !s_nodeCache.ContainsKey(child.GetHashCode()))
                    {
                        EB.Debug.LogError("RemoveChildren: cache not exists");
                    }
                    s_nodeCache.Remove(child.GetHashCode());
                }
                //children.Clear();
                return(m_children.Remove(timing));
            }

            return(true);
        }