mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-05-24 23:07:02 -04:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
30 lines
787 B
C#
30 lines
787 B
C#
using System.IO;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using Sandbox.MovieMaker;
|
|
using Sandbox.Resources;
|
|
|
|
namespace Editor.MovieMaker;
|
|
|
|
#nullable enable
|
|
|
|
[ResourceIdentity( "movie" )]
|
|
public sealed class MovieCompiler : ResourceCompiler
|
|
{
|
|
protected override async Task<bool> Compile()
|
|
{
|
|
var source = await File.ReadAllTextAsync( Context.AbsolutePath );
|
|
|
|
source = Context.ScanJson( source );
|
|
|
|
var model = JsonSerializer.Deserialize<EmbeddedMovieResource>( source, EditorJsonOptions )!;
|
|
var compiled = model.EditorData?.Deserialize<MovieProject>( EditorJsonOptions )?.Compile() ?? model.Compiled;
|
|
|
|
model = new EmbeddedMovieResource { Compiled = compiled };
|
|
|
|
Context.Data.Write( JsonSerializer.Serialize( model, EditorJsonOptions ) );
|
|
|
|
return true;
|
|
}
|
|
}
|