mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
Make SerializedFile.Metadata private
This commit is contained in:
parent
c9cb59e26a
commit
e84b296d6f
@ -77,9 +77,9 @@ public sealed class SerializedAssetCollection : AssetCollection
|
||||
|
||||
private static void ReadData(SerializedAssetCollection collection, SerializedFile file, AssetFactoryBase factory)
|
||||
{
|
||||
foreach (ObjectInfo objectInfo in file.Metadata.Object)
|
||||
foreach (ObjectInfo objectInfo in file.Objects)
|
||||
{
|
||||
SerializedType? type = objectInfo.GetSerializedType(file.Metadata.Types);
|
||||
SerializedType? type = objectInfo.GetSerializedType(file.Types);
|
||||
int classID = objectInfo.TypeID < 0 ? 114 : objectInfo.TypeID;
|
||||
AssetInfo assetInfo = new AssetInfo(collection, objectInfo.FileID, classID);
|
||||
IUnityObjectBase? asset = factory.ReadAsset(assetInfo, objectInfo.ObjectData, type);
|
||||
|
||||
@ -134,7 +134,7 @@ namespace AssetRipper.IO.Files.SerializedFiles.Parser
|
||||
return $"{ClassID}[{FileID}]";
|
||||
}
|
||||
|
||||
public SerializedType? GetSerializedType(SerializedType[] types)
|
||||
public SerializedType? GetSerializedType(ReadOnlySpan<SerializedType> types)
|
||||
{
|
||||
if (SerializedTypeIndex >= 0)
|
||||
{
|
||||
@ -146,11 +146,26 @@ namespace AssetRipper.IO.Files.SerializedFiles.Parser
|
||||
}
|
||||
else
|
||||
{
|
||||
return types.Single(t => t.TypeID == TypeID && t.IsStrippedType == Stripped);
|
||||
SerializedType? result = null;
|
||||
foreach (SerializedType type in types)
|
||||
{
|
||||
if (type.TypeID == TypeID && type.IsStrippedType == Stripped)
|
||||
{
|
||||
if (result is null)
|
||||
{
|
||||
result = type;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Multiple types with the same ID {TypeID} and stripped {Stripped} found");
|
||||
}
|
||||
}
|
||||
}
|
||||
return result ?? throw new Exception($"Type with ID {TypeID} and stripped {Stripped} not found");
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize(SerializedType[] types)
|
||||
public void Initialize(ReadOnlySpan<SerializedType> types)
|
||||
{
|
||||
if (SerializedTypeIndex >= 0)
|
||||
{
|
||||
|
||||
@ -13,20 +13,15 @@ namespace AssetRipper.IO.Files.SerializedFiles
|
||||
public sealed class SerializedFile : FileBase
|
||||
{
|
||||
private SerializedFileHeader Header { get; } = new();
|
||||
public SerializedFileMetadata Metadata { get; } = new();
|
||||
public UnityVersion Version
|
||||
{
|
||||
get => Metadata.UnityVersion;
|
||||
set => Metadata.UnityVersion = value;
|
||||
}
|
||||
public BuildTarget Platform
|
||||
{
|
||||
get => Metadata.TargetPlatform;
|
||||
set => Metadata.TargetPlatform = value;
|
||||
}
|
||||
private SerializedFileMetadata Metadata { get; } = new();
|
||||
public UnityVersion Version => Metadata.UnityVersion;
|
||||
public BuildTarget Platform => Metadata.TargetPlatform;
|
||||
public TransferInstructionFlags Flags => GetFlags(Header, Metadata, Name, FilePath);
|
||||
public EndianType EndianType => GetEndianType(Header, Metadata);
|
||||
public ReadOnlySpan<FileIdentifier> Dependencies => Metadata.Externals;
|
||||
public ReadOnlySpan<ObjectInfo> Objects => Metadata.Object;
|
||||
public ReadOnlySpan<SerializedType> Types => Metadata.Types;
|
||||
public bool HasTypeTree => Metadata.EnableTypeTree;
|
||||
|
||||
private static TransferInstructionFlags GetFlags(SerializedFileHeader header, SerializedFileMetadata metadata, string name, string filePath)
|
||||
{
|
||||
|
||||
@ -73,13 +73,13 @@ namespace AssetRipper.Tools.TypeTreeExtractor
|
||||
|
||||
private static void SaveTypeTrees(SerializedFile file)
|
||||
{
|
||||
if (!file.Metadata.EnableTypeTree)
|
||||
if (!file.HasTypeTree)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (SerializedType type in file.Metadata.Types.OrderBy(t => t.TypeID))
|
||||
StringBuilder sb = new();
|
||||
foreach (SerializedType type in file.Types.ToArray().OrderBy(t => t.TypeID))
|
||||
{
|
||||
Console.WriteLine($"\tType ID: {type.TypeID,-10} Script Index: {type.ScriptTypeIndex, -5} Node Count: {type.OldType?.Nodes?.Count ?? 0}");
|
||||
if (type.OldType is null)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user