示例#1
0
        public CGameplayTagNode(string InTag, CGameplayTagNode InParentNode)
        {
            Tag        = InTag;
            ParentNode = InParentNode;

            List <CGameplayTag> ParentCompleteTags = new List <CGameplayTag>();
            CGameplayTagNode    CurNode            = InParentNode;

            // 只要有父亲node
            while (CurNode.IsValid())
            {
                ParentCompleteTags.Add(CurNode.GetCompleteTag());
                CurNode = CurNode.GetParentTagNode();
            }

            //完整的tag名称
            string CompleteTagString = InTag;

            if (ParentCompleteTags.Count > 0)
            {
                CompleteTagString = string.Format("{0}.{1}", ParentCompleteTags[0].GetTagName(), InTag);
            }

            CGameplayTag tag = new CGameplayTag(CompleteTagString);

            CompleteTagWithParents.GameplayTags.Add(tag);
            CompleteTagWithParents.ParentTags.AddRange(ParentCompleteTags);
        }
示例#2
0
        /// <summary>
        /// 在node树中查找传入tag对应的container, 此container仅包含传入的tag
        /// </summary>
        public CGameplayTagContainer GetSingleTagContainer(CGameplayTag GameplayTag)
        {
            CGameplayTagNode node = FindTagNode(GameplayTag);

            if (node.IsValid())
            {
                return(node.GetSingleTagContainer());
            }

            return(null);
        }
示例#3
0
        /// <summary>
        /// 获取传入tag所有的子tag组成的container, 不包含传入tag
        /// 例如传入a.b, 则返回的conatiner包含a.b.c, a.b.d, a.b.c.e
        /// </summary>
        public CGameplayTagContainer RequestGameplayTagChildren(CGameplayTag GameplayTag)
        {
            CGameplayTagContainer TagContainer = new CGameplayTagContainer();

            CGameplayTagNode GameplayTagNode = FindTagNode(GameplayTag);

            if (GameplayTagNode.IsValid())
            {
                AddChildrenTags(TagContainer, GameplayTagNode, true, true);
            }
            return(TagContainer);
        }
示例#4
0
        /**
         * 返回直系的父亲
         * calling on x.y will return x
         */
        public CGameplayTag RequestGameplayTagDirectParent(CGameplayTag GameplayTag)
        {
            CGameplayTagNode GameplayTagNode = FindTagNode(GameplayTag);

            if (!GameplayTagNode.IsValid())
            {
                return(null);
            }

            var parent = GameplayTagNode.GetParentTagNode();

            if (parent.IsValid())
            {
                return(parent.GetCompleteTag());
            }
            return(null);
        }
示例#5
0
        /** 构建整个 tag 树*/
        public void ConstructGameplayTagTree()
        {
            if (!GameplayRootTag.IsValid())
            {
                return;
            }

            CGameplayTagNode currNode = GameplayRootTag;

            foreach (var item in GameplayTagTables)
            {
                var subTags = item.SubTags;
                for (int i = 0; i < subTags.Count; i++)
                {
                    List <CGameplayTagNode> childTags = currNode.GetChildTagNodes();
                    int insertIndex = InsertTagIntoNodeArray(subTags[i], currNode, childTags);
                    currNode = childTags[insertIndex];
                }
            }
        }
示例#6
0
        /// <summary>
        /// 将GameplayTagNode的children node对应的tag添加到TagContainer中去
        /// RecurseAll表示在树状节点中, 就添加一层child还是循环一直往下找
        /// </summary>
        private void AddChildrenTags(CGameplayTagContainer TagContainer, CGameplayTagNode GameplayTagNode,
                                     bool RecurseAll = true, bool OnlyIncludeDictionaryTags = false)
        {
            if (!GameplayTagNode.IsValid())
            {
                return;
            }

            var ChildrenNodes = GameplayTagNode.GetChildTagNodes();

            foreach (CGameplayTagNode ChildNode in ChildrenNodes)
            {
                if (!ChildNode.IsValid())
                {
                    continue;
                }

                TagContainer.AddTag(ChildNode.GetCompleteTag());
                if (RecurseAll)
                {
                    AddChildrenTags(TagContainer, ChildNode, true, OnlyIncludeDictionaryTags);
                }
            }
        }