Skip to content

Commit

Permalink
AssetsTools update (#911)
Browse files Browse the repository at this point in the history
* updated assetstools to v2019-2

* delete new text file

* updated to assetstools v2 prerelease

* assetstools nuget
  • Loading branch information
nesrak1 authored Mar 8, 2020
1 parent 6e24b02 commit 3cd7a35
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 24 deletions.
17 changes: 15 additions & 2 deletions NitroxServer-Subnautica/NitroxServer-Subnautica.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SubnauticaManaged)\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="AssetsTools.NET">
<HintPath>..\lib\AssetsTools.NET.dll</HintPath>
<Reference Include="AssetsTools.NET, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\AssetsTools.NET.2.0.0\lib\net35\AssetsTools.NET.dll</HintPath>
</Reference>
<Reference Include="Autofac, Version=2.6.3.862, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand All @@ -54,6 +54,18 @@
<Reference Include="Autofac.Configuration">
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET35\Autofac.Configuration.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
<Reference Include="protobuf-net">
<HintPath>..\lib\protobuf-net.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -275,6 +287,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NitroxModel-Subnautica\NitroxModel-Subnautica.csproj">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public override void Parse(AssetIdentifier identifier, AssetsFileReader reader,

for (int i = 0; i < componentCount; i++)
{
AssetIdentifier component = new AssetIdentifier((uint)reader.ReadInt32(), (ulong)reader.ReadInt64());
AssetIdentifier component = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64());
gameObjectAsset.Components.Add(component);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ public override void Parse(AssetIdentifier identifier, AssetsFileReader reader,
{
MonobehaviourAsset monobehaviour = new MonobehaviourAsset();

monobehaviour.GameObjectIdentifier = new AssetIdentifier((uint)reader.ReadInt32(), (ulong)reader.ReadInt64());
monobehaviour.Enabled = reader.ReadInt32(); // unknown but assume this is what it is
monobehaviour.MonoscriptIdentifier = new AssetIdentifier((uint)reader.ReadInt32(), (ulong)reader.ReadInt64());
monobehaviour.GameObjectIdentifier = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64());
monobehaviour.Enabled = reader.ReadBoolean();
reader.Align();
monobehaviour.MonoscriptIdentifier = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64());
monobehaviour.Name = reader.ReadCountStringInt32();

// Hack - If we have not yet loaded monoscripts then we are currently processing unit monobehaviours
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public override void Parse(AssetIdentifier identifier, AssetIdentifier gameObjec

for (int i = 0; i < placeholders; i++)
{
AssetIdentifier prefabPlaceholderId = new AssetIdentifier((uint)reader.ReadInt32(), (ulong)reader.ReadInt64());
AssetIdentifier prefabPlaceholderId = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64());
prefabPlaceholderIds.Add(prefabPlaceholderId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public override void Parse(AssetIdentifier identifier, AssetsFileReader reader,

for (int i = 0; i < childrenCount; i++)
{
AssetIdentifier child = new AssetIdentifier((uint)reader.ReadInt32(), (ulong)reader.ReadInt64());
AssetIdentifier child = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64());
ChildrenIdToParentId.Add(child, identifier);
}

transformAsset.ParentIdentifier = new AssetIdentifier((uint)reader.ReadInt32(), (ulong)reader.ReadInt64());
transformAsset.ParentIdentifier = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64());

TransformsByAssetId.Add(identifier, transformAsset);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class ResourceAssetsParser
{
private static Dictionary<AssetIdentifier, uint> assetIdentifierToClassId = new Dictionary<AssetIdentifier, uint>();

private static Dictionary<string, uint> fileIdByResourcePath = new Dictionary<string, uint>();
private static Dictionary<string, int> fileIdByResourcePath = new Dictionary<string, int>();
private static HashSet<string> parsedManifests = new HashSet<string>();

private static PrefabPlaceholderExtractor prefabPlaceholderExtractor = new PrefabPlaceholderExtractor();
Expand All @@ -38,7 +38,7 @@ public static ResourceAssets Parse()

CalculateDependencyFileIds(basePath, "resources.assets");

uint rootAssetId = 0; // resources.assets is always considered to be the top level '0'
int rootAssetId = 0; // resources.assets is always considered to be the top level '0'
ParseAssetManifest(basePath, "resources.assets", rootAssetId, resourceAssets);

prefabPlaceholderExtractor.LoadInto(resourceAssets);
Expand All @@ -48,7 +48,7 @@ public static ResourceAssets Parse()
return resourceAssets;
}

private static void ParseAssetManifest(string basePath, string fileName, uint fileId, ResourceAssets resourceAssets)
private static void ParseAssetManifest(string basePath, string fileName, int fileId, ResourceAssets resourceAssets)
{
if(parsedManifests.Contains(fileName))
{
Expand All @@ -65,13 +65,13 @@ private static void ParseAssetManifest(string basePath, string fileName, uint fi
AssetsFile file = new AssetsFile(reader);
AssetsFileTable resourcesFileTable = new AssetsFileTable(file);

foreach (AssetsFileDependency dependency in file.dependencies.pDependencies)
foreach (AssetsFileDependency dependency in file.dependencies.dependencies)
{
uint dependencyFileId = fileIdByResourcePath[dependency.assetPath];
int dependencyFileId = fileIdByResourcePath[dependency.assetPath];
ParseAssetManifest(basePath, dependency.assetPath, dependencyFileId, resourceAssets);
}

foreach (AssetFileInfoEx assetFileInfo in resourcesFileTable.pAssetFileInfo)
foreach (AssetFileInfoEx assetFileInfo in resourcesFileTable.assetFileInfo)
{
reader.Position = assetFileInfo.absoluteFilePos;

Expand Down Expand Up @@ -102,9 +102,9 @@ private static void CalculateDependencyFileIds(string basePath, string fileName)
AssetsFile file = new AssetsFile(reader);
AssetsFileTable resourcesFileTable = new AssetsFileTable(file);

uint fileId = 1;
int fileId = 1;

foreach (AssetsFileDependency dependency in file.dependencies.pDependencies)
foreach (AssetsFileDependency dependency in file.dependencies.dependencies)
{
fileIdByResourcePath.Add(dependency.assetPath, fileId);
fileId++;
Expand Down
5 changes: 5 additions & 0 deletions NitroxServer-Subnautica/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AssetsTools.NET" version="2.0.0" targetFramework="net40" />
<package id="Mono.Cecil" version="0.10.4" targetFramework="net40" />
</packages>
3 changes: 0 additions & 3 deletions NitroxServer/NitroxServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@
<Reference Include="LitJson">
<HintPath>$(SubnauticaManaged)\LitJson.dll</HintPath>
</Reference>
<Reference Include="AssetsTools.NET">
<HintPath>..\lib\AssetsTools.NET.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="protobuf-net">
<HintPath>..\lib\protobuf-net.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
{
public class AssetIdentifier
{
public uint FileId { get; }
public ulong IndexId { get; }
public int FileId { get; }
public long IndexId { get; }

public AssetIdentifier(uint fileId, ulong indexId)
public AssetIdentifier(int fileId, long indexId)
{
FileId = fileId;
IndexId = indexId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class MonobehaviourAsset
public string Name { get; set; }
public string MonoscriptName { get; set; }
public AssetIdentifier GameObjectIdentifier { get; set; }
public int Enabled { get; set; }
public bool Enabled { get; set; }
public AssetIdentifier MonoscriptIdentifier { get; set; }
}
}
Binary file removed lib/AssetsTools.NET.dll
Binary file not shown.

0 comments on commit 3cd7a35

Please sign in to comment.