mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
Move AssetReader to the shader module
This commit is contained in:
parent
e272e6f9df
commit
b82be98c65
@ -1,31 +0,0 @@
|
||||
using AssetRipper.Assets.Collections;
|
||||
using AssetRipper.IO.Endian;
|
||||
|
||||
namespace AssetRipper.Assets.IO.Reading
|
||||
{
|
||||
public sealed class AssetReader : EndianReader
|
||||
{
|
||||
public AssetReader(Stream stream, AssetCollection assetCollection) : base(stream, assetCollection.EndianType, false)
|
||||
{
|
||||
AssetCollection = assetCollection;
|
||||
}
|
||||
|
||||
public override string ReadString()
|
||||
{
|
||||
int length = ReadInt32();
|
||||
|
||||
if (length == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
string ret = ReadString(length);
|
||||
AlignStream();
|
||||
//Strings have supposedly been aligned since 2.1.0,
|
||||
//which is earlier than the beginning of AssetRipper version support.
|
||||
return ret;
|
||||
}
|
||||
|
||||
public AssetCollection AssetCollection { get; }
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
using AssetRipper.IO.Endian;
|
||||
using AssetRipper.IO.Files.SerializedFiles;
|
||||
|
||||
namespace AssetRipper.Assets.IO.Reading;
|
||||
|
||||
public static class EndianSpanReadableExtensions
|
||||
{
|
||||
public static void Read(this IEndianSpanReadable asset, ref EndianSpanReader reader, TransferInstructionFlags flags)
|
||||
{
|
||||
if (flags.IsRelease())
|
||||
{
|
||||
asset.ReadRelease(ref reader);
|
||||
}
|
||||
else
|
||||
{
|
||||
asset.ReadEditor(ref reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
using AssetRipper.IO.Files.SerializedFiles;
|
||||
|
||||
namespace AssetRipper.Assets.IO.Reading
|
||||
{
|
||||
public interface IAssetReadable
|
||||
{
|
||||
void ReadEditor(AssetReader reader);
|
||||
void ReadRelease(AssetReader reader);
|
||||
}
|
||||
public static class AssetReadableExtensions
|
||||
{
|
||||
public static void Read(this IAssetReadable asset, AssetReader reader)
|
||||
{
|
||||
asset.Read(reader, reader.AssetCollection.Flags);
|
||||
}
|
||||
|
||||
public static void Read(this IAssetReadable asset, AssetReader reader, TransferInstructionFlags flags)
|
||||
{
|
||||
if (flags.IsRelease())
|
||||
{
|
||||
asset.ReadRelease(reader);
|
||||
}
|
||||
else
|
||||
{
|
||||
asset.ReadEditor(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ using AssetRipper.Assets.IO.Serialization;
|
||||
using AssetRipper.Assets.IO.Writing;
|
||||
using AssetRipper.Assets.Metadata;
|
||||
using AssetRipper.IO.Endian;
|
||||
using AssetRipper.IO.Files.SerializedFiles;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace AssetRipper.Assets;
|
||||
@ -33,3 +34,17 @@ public interface IUnityAssetBase : IEndianSpanReadable, IAssetWritable, IYamlExp
|
||||
JsonNode SerializeReleaseFields(IUnityAssetSerializer serializer, SerializationOptions options);
|
||||
IEnumerable<(string, PPtr)> FetchDependencies();
|
||||
}
|
||||
public static class UnityAssetBaseExtensions
|
||||
{
|
||||
public static void Read(this IUnityAssetBase asset, ref EndianSpanReader reader, TransferInstructionFlags flags)
|
||||
{
|
||||
if (flags.IsRelease())
|
||||
{
|
||||
asset.ReadRelease(ref reader);
|
||||
}
|
||||
else
|
||||
{
|
||||
asset.ReadEditor(ref reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using AssetRipper.Assets.Collections;
|
||||
using AssetRipper.Assets.Export;
|
||||
using AssetRipper.Assets.IO.Reading;
|
||||
using AssetRipper.Assets.Metadata;
|
||||
using AssetRipper.IO.Endian;
|
||||
using AssetRipper.Yaml;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using AssetRipper.Assets.Cloning;
|
||||
using AssetRipper.Assets.Export;
|
||||
using AssetRipper.Assets.IO.Reading;
|
||||
using AssetRipper.Assets.IO.Serialization;
|
||||
using AssetRipper.Assets.IO.Writing;
|
||||
using AssetRipper.Assets.Metadata;
|
||||
@ -14,12 +13,8 @@ namespace AssetRipper.Assets;
|
||||
/// <summary>
|
||||
/// The artificial base class for all generated Unity classes
|
||||
/// </summary>
|
||||
public abstract class UnityAssetBase : IUnityAssetBase, IAssetReadable
|
||||
public abstract class UnityAssetBase : IUnityAssetBase
|
||||
{
|
||||
public virtual void ReadEditor(AssetReader reader) => throw MethodNotSupported();
|
||||
|
||||
public virtual void ReadRelease(AssetReader reader) => throw MethodNotSupported();
|
||||
|
||||
public virtual void ReadEditor(ref EndianSpanReader reader) => throw MethodNotSupported();
|
||||
|
||||
public virtual void ReadRelease(ref EndianSpanReader reader) => throw MethodNotSupported();
|
||||
|
||||
30
Source/AssetRipper.Export.Modules.Shader/AssetReader.cs
Normal file
30
Source/AssetRipper.Export.Modules.Shader/AssetReader.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using AssetRipper.Assets.Collections;
|
||||
using AssetRipper.IO.Endian;
|
||||
|
||||
namespace AssetRipper.Export.Modules.Shaders;
|
||||
|
||||
public sealed class AssetReader : EndianReader
|
||||
{
|
||||
public AssetReader(Stream stream, AssetCollection assetCollection) : base(stream, assetCollection.EndianType, false)
|
||||
{
|
||||
AssetCollection = assetCollection;
|
||||
}
|
||||
|
||||
public override string ReadString()
|
||||
{
|
||||
int length = ReadInt32();
|
||||
|
||||
if (length == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
string ret = ReadString(length);
|
||||
AlignStream();
|
||||
//Strings have supposedly been aligned since 2.1.0,
|
||||
//which is earlier than the beginning of AssetRipper version support.
|
||||
return ret;
|
||||
}
|
||||
|
||||
public AssetCollection AssetCollection { get; }
|
||||
}
|
||||
@ -1,4 +1,3 @@
|
||||
using AssetRipper.Assets.IO.Reading;
|
||||
using AssetRipper.Assets.IO.Writing;
|
||||
using AssetRipper.Export.Modules.Shaders.ShaderBlob.Parameters;
|
||||
using AssetRipper.Primitives;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using AssetRipper.Assets.Collections;
|
||||
using AssetRipper.Assets.Generics;
|
||||
using AssetRipper.Assets.IO.Reading;
|
||||
using AssetRipper.Assets.IO.Writing;
|
||||
using K4os.Compression.LZ4;
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using AssetRipper.Assets.IO.Reading;
|
||||
using AssetRipper.Assets.IO.Writing;
|
||||
using AssetRipper.Assets.IO.Writing;
|
||||
using AssetRipper.Primitives;
|
||||
|
||||
namespace AssetRipper.Export.Modules.Shaders.ShaderBlob
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using AssetRipper.Assets;
|
||||
using AssetRipper.Assets.Generics;
|
||||
using AssetRipper.Assets.IO;
|
||||
using AssetRipper.Assets.IO.Reading;
|
||||
using AssetRipper.Assets.Metadata;
|
||||
using AssetRipper.Import.Logging;
|
||||
using AssetRipper.Import.Structure.Assembly.Managers;
|
||||
|
||||
@ -2,7 +2,6 @@ using AssetRipper.Assets;
|
||||
using AssetRipper.Assets.Cloning;
|
||||
using AssetRipper.Assets.Export;
|
||||
using AssetRipper.Assets.Export.Yaml;
|
||||
using AssetRipper.Assets.IO.Reading;
|
||||
using AssetRipper.Assets.IO.Writing;
|
||||
using AssetRipper.Assets.Metadata;
|
||||
using AssetRipper.IO.Endian;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user