feat: exporting

This commit is contained in:
TrèsAbhi committed 2026-02-02 19:04:54 -06:00
1 parent d4f11fc52a
commit 99f41b9805
4 files changed
+35 -96

No files matched your search

+12 -48
View File
@@ -1,6 +1,8 @@
using System.Runtime.InteropServices;
using BlitzKit.Game.Models;
using CUE4Parse.Compression;
using BlitzKit.Game.Models;
using CUE4Parse_Conversion.Textures;
using CUE4Parse.UE4.Assets.Exports.Texture;
using CUE4Parse.UE4.Objects.Engine;
using CUE4Parse.UE4.Objects.UObject;
using Microsoft.JavaScript.NodeApi;
namespace BlitzKit.Game.JSExport;
@@ -17,40 +19,6 @@ public class GameInterface
{
provider = new(directory);
provider.Initialize();
provider.Mount();
Console.WriteLine("Mounted VFS:");
Console.WriteLine(provider.MountedVfs.Count);
foreach (var vfs in provider.MountedVfs)
{
Console.WriteLine(vfs.Path);
}
Console.WriteLine("Unloaded VFS:");
Console.WriteLine(provider.UnloadedVfs.Count);
foreach (var vfs in provider.UnloadedVfs)
{
Console.WriteLine(vfs.Path);
}
string libraryExtension;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
libraryExtension = "dll";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
libraryExtension = "so";
}
else
{
throw new Exception("Unsupported OS");
}
OodleHelper.DownloadOodleDll($"../../temp/oodle.{libraryExtension}");
OodleHelper.Initialize($"../../temp/oodle.{libraryExtension}");
files = [.. provider.Files.Keys];
var tanksBase = "Blitz/Content/Tanks/";
@@ -63,12 +31,6 @@ public class GameInterface
.Where(nation => !nation.EndsWith(".uasset") && nation != "TankStub")
.Distinct(),
];
var pda = provider.LoadPackageObject(
"Blitz/Content/Tanks/USA/A97_M41_Bulldog/PDA_A97_M41_Bulldog.PDA_A97_M41_Bulldog"
);
Console.WriteLine(pda);
}
public string[] Files => files;
@@ -80,12 +42,14 @@ public class GameInterface
{
var path = $"Blitz/Content/Tanks/{nation}/{tankId}/{pdaName}.{pdaName}";
Console.WriteLine(path);
if (provider.TryLoadPackageObject(path, out var pda))
if (provider.TryLoadPackageObject<UPrimaryDataAsset>(path, out var pda))
{
Console.WriteLine(pda);
Console.WriteLine(pda.GetType());
var bigIcon = pda.Get<FSoftObjectPath>("BigIcon").Load<UTexture2D>();
Console.WriteLine(bigIcon.Format);
Console.WriteLine(bigIcon.GetType());
bigIcon.Decode(ETexturePlatform.DesktopMobile);
return [];
}
+22
View File
@@ -1,3 +1,5 @@
using System.Runtime.InteropServices;
using CUE4Parse.Compression;
using CUE4Parse.FileProvider;
using CUE4Parse.MappingsProvider;
using CUE4Parse.UE4.Versions;
@@ -15,5 +17,25 @@ public class BlitzFileProvider : DefaultFileProvider
)
{
MappingsContainer = new FileUsmapTypeMappingsProvider("../../packages/closed/blitz.usmap");
Initialize();
Mount();
string libraryExtension;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
libraryExtension = "dll";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
libraryExtension = "so";
}
else
{
throw new Exception("Unsupported OS");
}
OodleHelper.DownloadOodleDll($"../../temp/oodle.{libraryExtension}");
OodleHelper.Initialize($"../../temp/oodle.{libraryExtension}");
}
}
-48
View File
@@ -1,48 +0,0 @@
using CUE4Parse.FileProvider;
using CUE4Parse.UE4.Exceptions;
using CUE4Parse.UE4.Versions;
using CUE4Parse.Utils;
namespace BlitzKit.Game.Synchronous;
public class SynchronousFileProvider(
string directory,
SearchOption searchOption,
VersionContainer? versions = null,
StringComparer? pathComparer = null
) : DefaultFileProvider(directory, searchOption, versions, pathComparer)
{
public new int Mount()
{
var countNewMounts = 0;
foreach (var reader in _unloadedVfs.Keys)
{
// VerifyGlobalData(reader);
if (reader.IsEncrypted && CustomEncryption == null || !reader.HasDirectoryIndex)
continue;
try
{
reader.MountTo(Files, PathComparer);
_unloadedVfs.TryRemove(reader, out _);
_mountedVfs[reader] = null;
Interlocked.Increment(ref countNewMounts);
// return reader;
}
catch (InvalidAesKeyException)
{
// Ignore this
}
catch (Exception e)
{
Log.Warning(
e,
$"Uncaught exception while loading file {reader.Path.SubstringAfterLast('/')}"
);
}
}
return countNewMounts;
}
}
+1
View File
@@ -9,6 +9,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../cue4parse/CUE4Parse/CUE4Parse.csproj" />
<ProjectReference Include="../cue4parse/CUE4Parse-Conversion/CUE4Parse-Conversion.csproj" />
<PackageReference Include="Microsoft.JavaScript.NodeApi" Version="0.9.19" />
<PackageReference Include="Microsoft.JavaScript.NodeApi.Generator" Version="0.9.19" />
</ItemGroup>