first commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using System.IO;
|
||||
using AssetsTools.NET.Extra;
|
||||
using NitroxModel.Helper;
|
||||
using NitroxServer_Subnautica.Resources.Parsers.Helper;
|
||||
|
||||
namespace NitroxServer_Subnautica.Resources.Parsers;
|
||||
|
||||
public abstract class AssetParser
|
||||
{
|
||||
protected static readonly string rootPath;
|
||||
protected static readonly AssetsManager assetsManager;
|
||||
|
||||
private static readonly ThreadSafeMonoCecilTempGenerator monoGen;
|
||||
|
||||
static AssetParser()
|
||||
{
|
||||
rootPath = ResourceAssetsParser.FindDirectoryContainingResourceAssets();
|
||||
assetsManager = new AssetsManager();
|
||||
assetsManager.LoadClassPackage(Path.Combine(NitroxUser.AssetsPath, "Resources", "classdata.tpk"));
|
||||
assetsManager.LoadClassDatabaseFromPackage("2019.4.36f1");
|
||||
assetsManager.SetMonoTempGenerator(monoGen = new ThreadSafeMonoCecilTempGenerator(Path.Combine(rootPath, "Managed")));
|
||||
}
|
||||
|
||||
public static void Dispose()
|
||||
{
|
||||
assetsManager.UnloadAll(true);
|
||||
monoGen.Dispose();
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using AssetsTools.NET;
|
||||
using AssetsTools.NET.Extra;
|
||||
|
||||
namespace NitroxServer_Subnautica.Resources.Parsers.Abstract;
|
||||
|
||||
public abstract class BundleFileParser<T> : AssetParser
|
||||
{
|
||||
protected static AssetsFileInstance assetFileInst;
|
||||
protected static AssetsFile bundleFile;
|
||||
|
||||
protected BundleFileParser(string bundleName, int index)
|
||||
{
|
||||
string standaloneFolderName = "StandaloneWindows64";
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||
{
|
||||
standaloneFolderName = "StandaloneOSX";
|
||||
}
|
||||
string bundlePath = Path.Combine(ResourceAssetsParser.FindDirectoryContainingResourceAssets(), "StreamingAssets", "aa", standaloneFolderName, bundleName);
|
||||
BundleFileInstance bundleFileInst = assetsManager.LoadBundleFile(bundlePath);
|
||||
assetFileInst = assetsManager.LoadAssetsFileFromBundle(bundleFileInst, index, true);
|
||||
bundleFile = assetFileInst.file;
|
||||
}
|
||||
|
||||
public abstract T ParseFile();
|
||||
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
using System.IO;
|
||||
using AssetsTools.NET;
|
||||
using AssetsTools.NET.Extra;
|
||||
|
||||
namespace NitroxServer_Subnautica.Resources.Parsers.Abstract;
|
||||
|
||||
public abstract class ResourceFileParser<T> : AssetParser
|
||||
{
|
||||
protected static readonly AssetsFileInstance resourceInst;
|
||||
protected static readonly AssetsFile resourceFile;
|
||||
|
||||
static ResourceFileParser()
|
||||
{
|
||||
resourceInst = assetsManager.LoadAssetsFile(Path.Combine(rootPath, "resources.assets"), true);
|
||||
resourceFile = resourceInst.file;
|
||||
}
|
||||
public abstract T ParseFile();
|
||||
}
|
Reference in New Issue
Block a user