Exemplo n.º 1
0
        public static Tag Parse(GameCache cache, string name)
        {
            if (name == "****" || name == "null")
            {
                return(Null);
            }

            if (name.Length < 4)
            {
                if (name.Length == 3)
                {
                    name = $"{name} ";
                }
                else if (name.Length == 2)
                {
                    name = $"{name}  ";
                }
            }

            if (TagDefinition.TryFind(name, out var type))
            {
                var attribute = TagStructure.GetTagStructureAttribute(type);
                return(new Tag(attribute.Tag));
            }

            foreach (var pair in TagGroup.Instances)
            {
                if (name == cache.StringTable.GetString(pair.Value.Name))
                {
                    return(pair.Value.Tag);
                }
            }

            return(Null);
        }
Exemplo n.º 2
0
        public static bool TryParseGroupTag(GameCache cache, string name, out Tag result)
        {
            if (TagDefinition.TryFind(name, out var type))
            {
                var attribute = TagStructure.GetTagStructureAttribute(type);
                result = new Tag(attribute.Tag);
                return(true);
            }

            foreach (var pair in TagGroup.Instances)
            {
                if (name == cache.StringTable.GetString(pair.Value.Name))
                {
                    result = pair.Value.Tag;
                    return(true);
                }
            }

            result = Tag.Null;
            return(name == "none" || name == "null");
        }