private UrlConfig GetConfig(UrlIdentifier id, int index) { if (index == id.UrlDepth) { int count = this._files.Count; for (int i = 0; i < count; i++) { UrlFile urlFile = this._files[i]; if (urlFile.Type == UrlFile.FileType.Config) { if (urlFile.ContainsConfig(id[index])) { return(urlFile.GetConfig(id[index])); } } } } else { int count2 = this._children.Count; for (int j = 0; j < count2; j++) { UrlDir urlDir = this._children[j]; if (urlDir.Name != string.Empty) { if (id[index] == urlDir.Name) { return(urlDir.GetConfig(id, index + 1)); } } else { UrlConfig config = urlDir.GetConfig(id, index); if (config != null) { return(config); } } } int count3 = this._files.Count; for (int k = 0; k < count3; k++) { UrlFile urlFile2 = this._files[k]; if (urlFile2.Type == UrlFile.FileType.Config) { if (id[index] == urlFile2.Name) { return(urlFile2.GetConfig(id[index + 1])); } } } } return(null); }
public static List <UrlConfig> CreateNodeList(UrlDir parentDir, UrlFile parent) { ConfigNode configNode = ConfigNode.Load(parent.FullPath); if (configNode == null) { Debug.LogWarning("Cannot create config from file '" + parent.FullPath + "'."); return(new List <UrlConfig>()); } if (!configNode.HasData()) { Debug.LogWarning("Config in file '" + parent.FullPath + "' contains no data."); return(new List <UrlConfig>()); } List <UrlConfig> list = new List <UrlConfig>(); if (configNode.HasValue()) { if (parentDir.Type == UrlDir.DirectoryType.Parts) { configNode.name = "PART"; list.Add(new UrlConfig(parent, configNode)); return(list); } } int count = configNode.Nodes.Count; for (int i = 0; i < count; i++) { ConfigNode configNode2 = configNode.Nodes[i]; if (configNode2.name == string.Empty) { if (parentDir.Type == UrlDir.DirectoryType.Parts) { configNode2.name = "PARTS"; } else { Debug.LogWarning("Config in file '" + parent.FullPath + "' contains an unnamed node. Skipping."); continue; } } list.Add(new UrlConfig(parent, configNode2)); } return(list); }
public UrlConfig(UrlFile parent, ConfigNode node) { this._type = node.name; this._parent = parent; if (node.name == string.Empty) { node.name = parent.Name; } if (node.HasValue("name")) { this._name = node.GetValue("name"); } else { this._name = node.name; } this._config = node; }