protected void BuildSingleFileAssets(string dir, AssetTypeEnum assetType, AssetFileEnum fileType) { List<string> extensions = AssetFile.AllExtensionsForEnum(fileType); DirectoryInfo info = new DirectoryInfo(MakeRepositoryFilePath(dir)); FileInfo[] files = info.GetFiles(); foreach (FileInfo fileInfo in files) { string extension = fileInfo.Extension.ToLower(); if (extensions.IndexOf(extension) < 0) continue; string baseName = Path.GetFileNameWithoutExtension(fileInfo.Name) + "_" + AssetTypeDesc.AssetTypeEnumFileName(assetType); string defPath = MakeRepositoryFilePath("AssetDefinitions\\" + baseName + ".asset"); if (new FileInfo(defPath).Exists) { Warn("Skipping generated of asset definition '{0}', because it already exists", defPath); continue; } AssetFile file = new AssetFile(MakeFullFilePath(dir, fileInfo.Name), fileType); AssetDefinition def = new AssetDefinition(baseName, assetType, file); def.SetDescriptionFromName(); def.WriteXmlFile(defPath); } }
public void BuildPlantTypeAssets() { AssetTypeEnum assetType = AssetTypeEnum.PlantType; XmlDocument doc = new XmlDocument(); doc.Load(MakeRepositoryFilePath("Textures\\DetailVeg.imageset")); XmlElement root = doc.DocumentElement; XmlElement child = (XmlElement)root.FirstChild; while(child != null) { switch(child.LocalName) { case "ImageRect": string name = (string)child.Attributes[0].InnerText ; AssetFile file = new AssetFile("Textures\\DetailVeg.imageset", AssetFileEnum.ImageSet); AssetDefinition def = new AssetDefinition(name, AssetTypeEnum.PlantType, file); def.Files.Add(new AssetFile("AssetDefinitions\\DetailVeg_Material.asset", AssetFileEnum.AssetDef)); string baseName = name + "_" + AssetTypeDesc.AssetTypeEnumFileName(assetType); def.SetDescriptionFromName(); string defPath = "AssetDefinitions\\" + baseName + ".asset"; def.WriteXmlFile(MakeRepositoryFilePath(defPath)); break; default: break; } child = (XmlElement)child.NextSibling; } }
protected void BuildAllParticleScriptAssets() { AssetTypeEnum assetType = AssetTypeEnum.ParticleScript; AssetFileEnum fileType = AssetFileEnum.ParticleScript; List<string> extensions = AssetFile.AllExtensionsForEnum(fileType); string particleDir = AssetFile.DirectoryForFileEnum(assetType, true, fileType); DirectoryInfo info = new DirectoryInfo(MakeRepositoryFilePath(particleDir)); FileInfo[] files = info.GetFiles(); foreach (FileInfo fileInfo in files) { string extension = fileInfo.Extension.ToLower(); if (extensions.IndexOf(extension) < 0) continue; string baseName = Path.GetFileNameWithoutExtension(fileInfo.Name) + "_" + AssetTypeDesc.AssetTypeEnumFileName(assetType); string defPath = MakeRepositoryFilePath("AssetDefinitions\\" + baseName + ".asset"); if (new FileInfo(defPath).Exists) { Warn("Skipping generated of asset definition '{0}', because it already exists", defPath); continue; } AssetFile assetFile = new AssetFile(MakeFullFilePath(particleDir, fileInfo.Name), fileType); AssetDefinition def = new AssetDefinition(baseName, assetType, assetFile); // Add the textures Dictionary<string, List<string>> uses = ScriptParser.ParseParticleScript(fileInfo.FullName); List<string> references = new List<string>(); AddParsedReferences(def, fileInfo.FullName, references, uses, "material", assetType, AssetFileEnum.Material); def.SetDescriptionFromName(); def.WriteXmlFile(defPath); } }
public void BuildAllMeshAssets() { AssetTypeEnum assetType = AssetTypeEnum.Mesh; AssetFileEnum fileType = AssetFileEnum.Mesh; string meshDir = AssetFile.DirectoryForFileEnum(assetType, true, fileType); List<string> extensions = AssetFile.AllExtensionsForEnum(fileType); DirectoryInfo info = new DirectoryInfo(MakeRepositoryFilePath(meshDir)); FileInfo[] files = info.GetFiles(); foreach (FileInfo fileInfo in files) { string extension = fileInfo.Extension.ToLower(); if (extensions.IndexOf(extension) < 0) continue; string fileName = Path.GetFileNameWithoutExtension(fileInfo.Name); string baseName = fileName + "_" + AssetTypeDesc.AssetTypeEnumFileName(assetType); string meshFile = MakeFullFilePath(meshDir, fileInfo.Name); AssetFile file = new AssetFile(meshFile, fileType); AssetDefinition def = new AssetDefinition(baseName, assetType, file); // Find the corresponding material and physics files string materialFile = MakeFullFilePath(AssetFile.DirectoryForFileEnum(assetType, false, AssetFileEnum.Material), fileName + ".material"); if (File.Exists(MakeRepositoryFilePath(materialFile))) { string assetDir = AssetFile.DirectoryForFileEnum(AssetTypeEnum.Mesh, false, AssetFileEnum.AssetDef); string materialAsset = MakeFullFilePath(assetDir, fileName + "_Material.asset"); file = new AssetFile(materialAsset, AssetFileEnum.AssetDef); def.Files.Add(file); } else Warn("For mesh '{0}', didn't find material file '{1}'", meshFile, materialFile); string physicsFile = MakeFullFilePath(AssetFile.DirectoryForFileEnum(assetType, false, AssetFileEnum.Physics), fileName + ".physics"); if (File.Exists(MakeRepositoryFilePath(physicsFile))) { file = new AssetFile(physicsFile, AssetFileEnum.Physics); def.Files.Add(file); } else Warn("For mesh '{0}', didn't find physics file '{1}'", meshFile, physicsFile); // It's a long shot, and misleading in the case of the // rocketboxers, but see if there is a matching skeleton string skeletonFile = MakeFullFilePath(AssetFile.DirectoryForFileEnum(assetType, false, AssetFileEnum.Skeleton), fileName + ".skeleton"); if (File.Exists(MakeRepositoryFilePath(skeletonFile))) { file = new AssetFile(skeletonFile, AssetFileEnum.Skeleton); def.Files.Add(file); } else Warn("For mesh '{0}', didn't find skeleton file '{1}'", meshFile, skeletonFile); def.SetDescriptionFromName(); string defPath = MakeRepositoryFilePath("AssetDefinitions\\" + baseName + ".asset"); def.WriteXmlFile(defPath); } }