Skip to content

Commit

Permalink
Refactor SerializableStructure.TryRead
Browse files Browse the repository at this point in the history
  • Loading branch information
ds5678 committed Feb 26, 2024
1 parent 1da1d23 commit e9d46bb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private static IMonoBehaviour ReadMonoBehaviour(IMonoBehaviour monoBehaviour, Re
if (type is not null && TypeTreeNodeStruct.TryMakeFromTypeTree(type.OldType, out TypeTreeNodeStruct rootNode))
{
structure = SerializableTreeType.FromRootNode(rootNode).CreateSerializableStructure();
if (structure.TryRead(ref reader, monoBehaviour.Collection.Version, monoBehaviour.Collection.Flags))
if (structure.TryRead(ref reader, monoBehaviour))
{
monoBehaviour.Structure = structure;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using AssetRipper.Import.Structure.Assembly.Mono;
using AssetRipper.IO.Endian;
using AssetRipper.IO.Files.SerializedFiles;
using AssetRipper.SourceGenerated.Classes.ClassID_114;
using AssetRipper.Yaml;

namespace AssetRipper.Import.Structure.Assembly.Serializable
Expand Down Expand Up @@ -142,11 +143,11 @@ private bool IsAvailable(in SerializableType.Field field)
return true;
}

public bool TryRead(ref EndianSpanReader reader, UnityVersion version, TransferInstructionFlags flags)
public bool TryRead(ref EndianSpanReader reader, IMonoBehaviour monoBehaviour)
{
try
{
Read(ref reader, version, flags);
Read(ref reader, monoBehaviour.Collection.Version, monoBehaviour.Collection.Flags);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void ThrowIfNotStructure()
if (structure is not null)
{
EndianSpanReader reader = new EndianSpanReader(structureData, monoBehaviour.Collection.EndianType);
if (structure.TryRead(ref reader, monoBehaviour.Collection.Version, monoBehaviour.Collection.Flags))
if (structure.TryRead(ref reader, monoBehaviour))
{
monoBehaviour.Structure = structure;
return structure;
Expand Down

0 comments on commit e9d46bb

Please sign in to comment.