Esempio n. 1
0
        /**
         * Helper function to insert a tag into a tag node array
         *
         * @param Tag					Tag to insert
         * @param ParentNode			Parent node, if any, for the tag
         * @param NodeArray				Node array to insert the new node into, if necessary (if the tag already exists, no insertion will occur)
         * @return Index of the node of the tag
         */
        private int InsertTagIntoNodeArray(string Tag, CGameplayTagNode ParentNode, List <CGameplayTagNode> NodeArray)
        {
            int InsertionIdx  = -1;
            int WhereToInsert = -1;

            // See if the tag is already in the array
            for (int CurIdx = 0; CurIdx < NodeArray.Count; ++CurIdx)
            {
                var node = NodeArray[CurIdx];
                if (!node.IsValid())
                {
                    continue;
                }

                if (node.GetSimpleTagName() == Tag)
                {
                    InsertionIdx = CurIdx;
                    break;
                }

                if (WhereToInsert == -1)
                {
                    int v = string.CompareOrdinal(node.GetSimpleTagName(), Tag);
                    // Insert new node before this
                    if (v > 0)
                    {
                        WhereToInsert = CurIdx;
                    }
                }
            }

            if (InsertionIdx != -1)
            {
                return(InsertionIdx);
            }

            // Insert at end
            if (WhereToInsert == -1)
            {
                WhereToInsert = NodeArray.Count;
            }

            // Don't add the root node as parent
            CGameplayTagNode TagNode = new CGameplayTagNode(Tag, ParentNode != GameplayRootTag ? ParentNode : null);

            // Add at the sorted location
            NodeArray.Insert(WhereToInsert, TagNode);
            InsertionIdx = WhereToInsert;

            CGameplayTag GameplayTag = TagNode.GetCompleteTag();

            GameplayTagNodeMap.Add(GameplayTag.GetTagName(), TagNode);

            return(1);
        }
Esempio n. 2
0
        /// <summary>
        /// 将tag a.b.c 变成数组[a, b, c]
        /// </summary>
        public void SplitGameplayTagFName(CGameplayTag Tag, List <string> OutNames)
        {
            var list = Tag.GetTagName().Split('.');

            OutNames.AddRange(list);
        }
Esempio n. 3
0
        /// <summary>
        /// 找到tag对应的node
        /// </summary>
        public CGameplayTagNode FindTagNode(CGameplayTag GameplayTag)
        {
            CGameplayTagNode Node = GameplayTagNodeMap[GameplayTag.GetTagName()];

            return(Node);
        }