using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
namespace Sandbox;
///
/// A scene file contains a collection of GameObject with Components and their properties.
///
[AssetType( Name = "Scene", Extension = "scene", Category = "World", Flags = AssetTypeFlags.NoEmbedding )]
public partial class SceneFile : GameResource
{
[JsonPropertyName( "__guid" )]
public Guid Id { get; set; }
public JsonObject[] GameObjects { get; set; }
public JsonObject SceneProperties { get; set; }
public override int ResourceVersion => 3;
[Hide, JsonIgnore]
protected override Type ActionGraphTargetType => null;
[Hide, JsonIgnore]
protected override object ActionGraphTarget => null;
[System.Obsolete( "Use GetMetadata" )]
public string Title => GetMetadata( "Title" );
[System.Obsolete( "Use GetMetadata" )]
public string Description => GetMetadata( "Description" );
public string GetMetadata( string title, string defaultValue = null )
{
if ( SceneProperties is null ) return defaultValue;
if ( SceneProperties["Metadata"] is not JsonObject metadata ) return defaultValue;
return metadata.GetPropertyValue( title, defaultValue );
}
protected override Bitmap CreateAssetTypeIcon( int width, int height )
{
var svg = "";
return Bitmap.CreateFromSvgString( svg, width, height );
}
}