private static void ExtractAnims(KWAD kwad, string outputBasePath, string texturesPath) { var animBundleList = (from aliasInfo in kwad.GetAliasInfoList() where kwad.GetResourceInfoList()[(int)aliasInfo.ResourceIdx].GetType().SequenceEqual(KLEIAnimation.KLEI_TYPE) select new { name = Path.GetFileNameWithoutExtension(aliasInfo.AliasPath.GetString()), path = Path.GetDirectoryName(aliasInfo.AliasPath.GetString()), //animDef = kwad.GetResourceAt<KLEIAnimation>((int)aliasInfo.ResourceIdx), animBld = kwad.GetResourceByAlias <KLEIBuild>(Path.ChangeExtension(aliasInfo.AliasPath.GetString(), ".abld")) //namedTextureList = (from innerAliasInfo in kwad.GetAliasInfoList() // where kwad.GetResourceInfoList()[(int) innerAliasInfo.ResourceIdx].GetType().SequenceEqual(KLEITexture.KLEI_TYPE) && // // ReSharper disable once PossibleNullReferenceException // Path.GetDirectoryName(innerAliasInfo.AliasPath.GetString()).Equals( // Path.GetDirectoryName(Path.Combine(Path.ChangeExtension(aliasInfo.AliasPath.GetString(), ".anim"), "dummy")), // //GetDirectoryName has a side effect of changing separator character. // //That is why it is used on a second path to effect both. // StringComparison.InvariantCultureIgnoreCase) // select new // { // name = Path.GetFileName(innerAliasInfo.AliasPath.GetString()), // texture = kwad.GetResourceAt<KLEITexture>((int) innerAliasInfo.ResourceIdx) // }).ToList() }).ToList(); Console.WriteLine("Extracting {0} animation bundles...", animBundleList.Count); foreach (var animBundle in animBundleList) { //TODO: log any issues for a current animBundle to a corresponding log.txt file in that animBundle directory var animBuildOutputPath = Path.Combine(outputBasePath, animBundle.path, animBundle.name + ".anim"); if (!string.IsNullOrWhiteSpace(animBuildOutputPath)) { Directory.CreateDirectory(animBuildOutputPath); } if (animBundle.animBld != null) { ExtractAnimationBuild(kwad, animBundle.animBld, animBuildOutputPath, texturesPath); //ZipFile.CreateFromDirectory(tempOutputPath, Path.Combine(Path.GetFullPath(outputPath), animBundle.path, animBundle.name + ".anmbdl")); } } }
private static void ExtractAnims(KWAD kwad, string outputBasePath, string texturesPath) { var animBundleList = (from aliasInfo in kwad.GetAliasInfoList() where kwad.GetResourceInfoList()[(int)aliasInfo.ResourceIdx].GetType().SequenceEqual(KLEIAnimation.KLEI_TYPE) select new { name = Path.GetFileNameWithoutExtension(aliasInfo.AliasPath.GetString()), path = Path.GetDirectoryName(aliasInfo.AliasPath.GetString()), animDef = kwad.GetResourceAt <KLEIAnimation>((int)aliasInfo.ResourceIdx), animBld = kwad.GetResourceByAlias <KLEIBuild>(Path.ChangeExtension(aliasInfo.AliasPath.GetString(), ".abld")) }).ToList(); Console.WriteLine("Extracting {0} animation bundles...", animBundleList.Count); int buildCount = 0; int animCount = 0; foreach (var animBundle in animBundleList) { if (animBundle.animBld != null) { buildCount++; } if (animBundle.animDef != null) { animCount++; } } Console.WriteLine("Extracting {0} animation builds...", buildCount); foreach (var animBundle in animBundleList) { //TODO: log any issues for a current animBundle to a corresponding log.txt file in that animBundle directory var animBuildOutputPath = Path.Combine(outputBasePath, animBundle.path, animBundle.name + ".anim"); if (!string.IsNullOrWhiteSpace(animBuildOutputPath)) { Directory.CreateDirectory(animBuildOutputPath); } if (animBundle.animBld != null) { ExtractAnimationBuild(kwad, animBundle.animBld, animBuildOutputPath, texturesPath); //ZipFile.CreateFromDirectory(tempOutputPath, Path.Combine(Path.GetFullPath(outputPath), animBundle.path, animBundle.name + ".anmbdl")); } } Console.WriteLine("Extracting {0} animation definitions...", animCount); foreach (var animBundle in animBundleList) { //TODO: log any issues for a current animBundle to a corresponding log.txt file in that animBundle directory var animBuildOutputPath = Path.Combine(outputBasePath, animBundle.path, animBundle.name + ".anim"); if (!string.IsNullOrWhiteSpace(animBuildOutputPath)) { Directory.CreateDirectory(animBuildOutputPath); } if (animBundle.animDef != null) { Console.WriteLine(string.Format("\tAnimation Def \"{0}\"", animBundle.name + ".anim")); ExtractAnimationDef(kwad, animBundle.animDef, animBuildOutputPath); } } }