public static bool IsMatchingPathConstraints(AssetFile file, AssetTypeValueField baseField, IEnumerable <string> pathConstraints)
 {
     return(pathConstraints.All(path => GetFieldAtPath(file, baseField, path.Split(':')).Count > 0));
 }
        public static List <AssetTypeValueField> GetFieldAtPath(AssetFile file, AssetTypeValueField baseField, IEnumerable <string> customPaths)
        {
            List <AssetTypeValueField> currentScope = new List <AssetTypeValueField> {
                baseField
            };

            foreach (string customPath in customPaths)
            {
                if (customPath.Contains('/'))
                {
                    string[] referencePaths = customPath.Split('/');
                    for (int i = 0; i < referencePaths.Length; i++)
                    {
                        List <AssetTypeValueField> found = new List <AssetTypeValueField>();
                        if (i == 0)
                        {
                            foreach (AssetTypeValueField field in currentScope.Where(field => field.GetChildrenCount() > 0))
                            {
                                found.AddRange(field.GetChildrenList().Where(child => child.GetName() == referencePaths[i].Split('=')[0]));
                            }
                        }
                        else
                        {
                            foreach (AssetTypeValueField field in currentScope.Where(field => field.GetValue() != null))
                            {
                                AssetFileInfoEx referenceInfo = file.fileInstance.table.GetAssetInfo(field.GetValue().AsInt64());
                                if (referenceInfo == null)
                                {
                                    Console.WriteLine("could not find referenceInfo for pathID = (" + field.GetValue().AsInt64() +
                                                      "), that's probably bad, skipping");
                                    continue;
                                }

                                found.AddRange(GetATI(file, referenceInfo).baseFields.Where(referenceField => referenceField.GetName() == referencePaths[i].Split('=')[0]));
                            }
                        }

                        if (customPath.Contains('='))
                        {
                            string targetValue = customPath.Split('=')[1];
                            found.RemoveAll(field => field.GetValue()?.AsString() != targetValue);
                        }
                        currentScope = found;
                    }
                }
                else
                {
                    List <AssetTypeValueField> found = new List <AssetTypeValueField>();
                    foreach (AssetTypeValueField field in currentScope.Where(field => field.GetChildrenCount() > 0))
                    {
                        found.AddRange(field.GetChildrenList().Where(child => child.GetName() == customPath.Split('=')[0]));
                    }

                    if (customPath.Contains('='))
                    {
                        string targetValue = customPath.Split('=')[1];
                        found.RemoveAll(field => field.GetValue()?.AsString() != targetValue);
                    }
                    currentScope = found;
                }
            }

            return(currentScope);
        }
 public static bool IsMatchingPathConstraints(AssetFile file, AssetTypeValueField baseField, string pathConstraint)
 {
     return(IsMatchingPathConstraints(file, baseField, new[] { pathConstraint }));
 }
 public static List <AssetTypeValueField> GetFieldAtPath(AssetFile file, AssetTypeValueField baseField, string customPath)
 {
     return(GetFieldAtPath(file, baseField, new[] { customPath }));
 }