mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: some cleanup
This commit is contained in:
1 parent
98e7760142
commit
204fbbff59
4 files changed
+7
-2
No files matched your search
@@ -1,18 +0,0 @@
|
||||
using CUE4Parse.MappingsProvider;
|
||||
using CUE4Parse.UE4.Versions;
|
||||
|
||||
namespace game.src.classes;
|
||||
|
||||
public class BlitzFileProvider : SynchronousFileProvider
|
||||
{
|
||||
public BlitzFileProvider(string directory)
|
||||
: base(
|
||||
directory: directory,
|
||||
searchOption: SearchOption.AllDirectories,
|
||||
versions: new(EGame.GAME_UE5_5),
|
||||
pathComparer: StringComparer.OrdinalIgnoreCase
|
||||
)
|
||||
{
|
||||
MappingsContainer = new FileUsmapTypeMappingsProvider("../../packages/closed/blitz.usmap");
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using CUE4Parse.Compression;
|
||||
using Microsoft.JavaScript.NodeApi;
|
||||
|
||||
namespace game.src.classes;
|
||||
|
||||
[JSExport]
|
||||
public class GameInterface
|
||||
{
|
||||
private readonly BlitzFileProvider provider;
|
||||
|
||||
public string[] files;
|
||||
public string[] tanksDirectoryNations;
|
||||
|
||||
public GameInterface(string directory)
|
||||
{
|
||||
provider = new(directory);
|
||||
|
||||
provider.Initialize();
|
||||
provider.Mount();
|
||||
|
||||
string libraryExtension;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
libraryExtension = "dll";
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
libraryExtension = "so";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unsupported OS");
|
||||
}
|
||||
|
||||
Directory.CreateDirectory("../../temp");
|
||||
Console.WriteLine($"../..temp/oodle.{libraryExtension}");
|
||||
var bool1 = OodleHelper.DownloadOodleDll($"../..temp/oodle.{libraryExtension}");
|
||||
Console.WriteLine(bool1);
|
||||
OodleHelper.Initialize($"../..temp/oodle.{libraryExtension}");
|
||||
|
||||
files = [.. provider.Files.Keys];
|
||||
|
||||
var tanksBase = "Blitz/Content/Tanks/";
|
||||
tanksDirectoryNations =
|
||||
[
|
||||
.. files
|
||||
.Where(path => path.StartsWith(tanksBase))
|
||||
.Select(path => path[tanksBase.Length..])
|
||||
.Select(path => path.Split('/')[0])
|
||||
.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;
|
||||
public string[] TanksDirectoryNations => tanksDirectoryNations;
|
||||
|
||||
public byte[] TankBigIcon(string tankId, string pdaName)
|
||||
{
|
||||
foreach (var nation in tanksDirectoryNations)
|
||||
{
|
||||
var path = $"Blitz/Content/Tanks/{nation}/{tankId}/{pdaName}.{pdaName}";
|
||||
|
||||
Console.WriteLine(path);
|
||||
|
||||
if (provider.TryLoadPackageObject(path, out var pda))
|
||||
{
|
||||
Console.WriteLine(pda);
|
||||
Console.WriteLine(pda.GetType());
|
||||
|
||||
return [];
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
throw new FileNotFoundException($"Tank {tankId}/{pdaName} not found in any nation");
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
using CUE4Parse.FileProvider;
|
||||
using CUE4Parse.UE4.Exceptions;
|
||||
using CUE4Parse.UE4.Versions;
|
||||
using CUE4Parse.Utils;
|
||||
|
||||
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)
|
||||
{
|
||||
if (reader.IsEncrypted && CustomEncryption == null || !reader.HasDirectoryIndex)
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
reader.MountTo(Files, PathComparer);
|
||||
_unloadedVfs.TryRemove(reader, out _);
|
||||
countNewMounts++;
|
||||
}
|
||||
catch (InvalidAesKeyException) { }
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Warning(
|
||||
e,
|
||||
$"Uncaught exception while loading file {reader.Path.SubstringAfterLast('/')}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return countNewMounts;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user