Skip to content

Commit 3cd7a35

Browse files
authored
AssetsTools update (#911)
* updated assetstools to v2019-2 * delete new text file * updated to assetstools v2 prerelease * assetstools nuget
1 parent 6e24b02 commit 3cd7a35

11 files changed

+40
-24
lines changed

NitroxServer-Subnautica/NitroxServer-Subnautica.csproj

+15-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
<SpecificVersion>False</SpecificVersion>
4545
<HintPath>$(SubnauticaManaged)\Assembly-CSharp-firstpass.dll</HintPath>
4646
</Reference>
47-
<Reference Include="AssetsTools.NET">
48-
<HintPath>..\lib\AssetsTools.NET.dll</HintPath>
47+
<Reference Include="AssetsTools.NET, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
48+
<HintPath>..\packages\AssetsTools.NET.2.0.0\lib\net35\AssetsTools.NET.dll</HintPath>
4949
</Reference>
5050
<Reference Include="Autofac, Version=2.6.3.862, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
5151
<SpecificVersion>False</SpecificVersion>
@@ -54,6 +54,18 @@
5454
<Reference Include="Autofac.Configuration">
5555
<HintPath>..\packages\Autofac.2.6.3.862\lib\NET35\Autofac.Configuration.dll</HintPath>
5656
</Reference>
57+
<Reference Include="Mono.Cecil, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
58+
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.dll</HintPath>
59+
</Reference>
60+
<Reference Include="Mono.Cecil.Mdb, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
61+
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
62+
</Reference>
63+
<Reference Include="Mono.Cecil.Pdb, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
64+
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
65+
</Reference>
66+
<Reference Include="Mono.Cecil.Rocks, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
67+
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
68+
</Reference>
5769
<Reference Include="protobuf-net">
5870
<HintPath>..\lib\protobuf-net.dll</HintPath>
5971
</Reference>
@@ -275,6 +287,7 @@
275287
</ItemGroup>
276288
<ItemGroup>
277289
<None Include="App.config" />
290+
<None Include="packages.config" />
278291
</ItemGroup>
279292
<ItemGroup>
280293
<ProjectReference Include="..\NitroxModel-Subnautica\NitroxModel-Subnautica.csproj">

NitroxServer-Subnautica/Serialization/Resources/Parsers/GameObjectAssetParser.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public override void Parse(AssetIdentifier identifier, AssetsFileReader reader,
1717

1818
for (int i = 0; i < componentCount; i++)
1919
{
20-
AssetIdentifier component = new AssetIdentifier((uint)reader.ReadInt32(), (ulong)reader.ReadInt64());
20+
AssetIdentifier component = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64());
2121
gameObjectAsset.Components.Add(component);
2222
}
2323

NitroxServer-Subnautica/Serialization/Resources/Parsers/MonobehaviourAssetParser.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ public override void Parse(AssetIdentifier identifier, AssetsFileReader reader,
2323
{
2424
MonobehaviourAsset monobehaviour = new MonobehaviourAsset();
2525

26-
monobehaviour.GameObjectIdentifier = new AssetIdentifier((uint)reader.ReadInt32(), (ulong)reader.ReadInt64());
27-
monobehaviour.Enabled = reader.ReadInt32(); // unknown but assume this is what it is
28-
monobehaviour.MonoscriptIdentifier = new AssetIdentifier((uint)reader.ReadInt32(), (ulong)reader.ReadInt64());
26+
monobehaviour.GameObjectIdentifier = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64());
27+
monobehaviour.Enabled = reader.ReadBoolean();
28+
reader.Align();
29+
monobehaviour.MonoscriptIdentifier = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64());
2930
monobehaviour.Name = reader.ReadCountStringInt32();
3031

3132
// Hack - If we have not yet loaded monoscripts then we are currently processing unit monobehaviours

NitroxServer-Subnautica/Serialization/Resources/Parsers/Monobehaviours/PrefabPlaceholdersGroupParser.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public override void Parse(AssetIdentifier identifier, AssetIdentifier gameObjec
1616

1717
for (int i = 0; i < placeholders; i++)
1818
{
19-
AssetIdentifier prefabPlaceholderId = new AssetIdentifier((uint)reader.ReadInt32(), (ulong)reader.ReadInt64());
19+
AssetIdentifier prefabPlaceholderId = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64());
2020
prefabPlaceholderIds.Add(prefabPlaceholderId);
2121
}
2222

NitroxServer-Subnautica/Serialization/Resources/Parsers/TransformAssetParser.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ public override void Parse(AssetIdentifier identifier, AssetsFileReader reader,
3838

3939
for (int i = 0; i < childrenCount; i++)
4040
{
41-
AssetIdentifier child = new AssetIdentifier((uint)reader.ReadInt32(), (ulong)reader.ReadInt64());
41+
AssetIdentifier child = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64());
4242
ChildrenIdToParentId.Add(child, identifier);
4343
}
4444

45-
transformAsset.ParentIdentifier = new AssetIdentifier((uint)reader.ReadInt32(), (ulong)reader.ReadInt64());
45+
transformAsset.ParentIdentifier = new AssetIdentifier(reader.ReadInt32(), reader.ReadInt64());
4646

4747
TransformsByAssetId.Add(identifier, transformAsset);
4848
}

NitroxServer-Subnautica/Serialization/Resources/ResourceAssetsParser.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static class ResourceAssetsParser
1515
{
1616
private static Dictionary<AssetIdentifier, uint> assetIdentifierToClassId = new Dictionary<AssetIdentifier, uint>();
1717

18-
private static Dictionary<string, uint> fileIdByResourcePath = new Dictionary<string, uint>();
18+
private static Dictionary<string, int> fileIdByResourcePath = new Dictionary<string, int>();
1919
private static HashSet<string> parsedManifests = new HashSet<string>();
2020

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

3939
CalculateDependencyFileIds(basePath, "resources.assets");
4040

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

4444
prefabPlaceholderExtractor.LoadInto(resourceAssets);
@@ -48,7 +48,7 @@ public static ResourceAssets Parse()
4848
return resourceAssets;
4949
}
5050

51-
private static void ParseAssetManifest(string basePath, string fileName, uint fileId, ResourceAssets resourceAssets)
51+
private static void ParseAssetManifest(string basePath, string fileName, int fileId, ResourceAssets resourceAssets)
5252
{
5353
if(parsedManifests.Contains(fileName))
5454
{
@@ -65,13 +65,13 @@ private static void ParseAssetManifest(string basePath, string fileName, uint fi
6565
AssetsFile file = new AssetsFile(reader);
6666
AssetsFileTable resourcesFileTable = new AssetsFileTable(file);
6767

68-
foreach (AssetsFileDependency dependency in file.dependencies.pDependencies)
68+
foreach (AssetsFileDependency dependency in file.dependencies.dependencies)
6969
{
70-
uint dependencyFileId = fileIdByResourcePath[dependency.assetPath];
70+
int dependencyFileId = fileIdByResourcePath[dependency.assetPath];
7171
ParseAssetManifest(basePath, dependency.assetPath, dependencyFileId, resourceAssets);
7272
}
7373

74-
foreach (AssetFileInfoEx assetFileInfo in resourcesFileTable.pAssetFileInfo)
74+
foreach (AssetFileInfoEx assetFileInfo in resourcesFileTable.assetFileInfo)
7575
{
7676
reader.Position = assetFileInfo.absoluteFilePos;
7777

@@ -102,9 +102,9 @@ private static void CalculateDependencyFileIds(string basePath, string fileName)
102102
AssetsFile file = new AssetsFile(reader);
103103
AssetsFileTable resourcesFileTable = new AssetsFileTable(file);
104104

105-
uint fileId = 1;
105+
int fileId = 1;
106106

107-
foreach (AssetsFileDependency dependency in file.dependencies.pDependencies)
107+
foreach (AssetsFileDependency dependency in file.dependencies.dependencies)
108108
{
109109
fileIdByResourcePath.Add(dependency.assetPath, fileId);
110110
fileId++;
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="AssetsTools.NET" version="2.0.0" targetFramework="net40" />
4+
<package id="Mono.Cecil" version="0.10.4" targetFramework="net40" />
5+
</packages>

NitroxServer/NitroxServer.csproj

-3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@
7373
<Reference Include="LitJson">
7474
<HintPath>$(SubnauticaManaged)\LitJson.dll</HintPath>
7575
</Reference>
76-
<Reference Include="AssetsTools.NET">
77-
<HintPath>..\lib\AssetsTools.NET.dll</HintPath>
78-
</Reference>
7976
<Reference Include="Microsoft.CSharp" />
8077
<Reference Include="protobuf-net">
8178
<HintPath>..\lib\protobuf-net.dll</HintPath>

NitroxServer/Serialization/Resources/Datastructures/AssetIdentifier.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
{
33
public class AssetIdentifier
44
{
5-
public uint FileId { get; }
6-
public ulong IndexId { get; }
5+
public int FileId { get; }
6+
public long IndexId { get; }
77

8-
public AssetIdentifier(uint fileId, ulong indexId)
8+
public AssetIdentifier(int fileId, long indexId)
99
{
1010
FileId = fileId;
1111
IndexId = indexId;

NitroxServer/Serialization/Resources/Datastructures/MonobehaviourAsset.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public class MonobehaviourAsset
55
public string Name { get; set; }
66
public string MonoscriptName { get; set; }
77
public AssetIdentifier GameObjectIdentifier { get; set; }
8-
public int Enabled { get; set; }
8+
public bool Enabled { get; set; }
99
public AssetIdentifier MonoscriptIdentifier { get; set; }
1010
}
1111
}

lib/AssetsTools.NET.dll

-78 KB
Binary file not shown.

0 commit comments

Comments
 (0)