feat: add scene serialization (JSON + binary) with import pipeline

Implement scene save/load for editor and runtime.
Editor JSON (.gscene) uses Utf8JsonWriter for inline component objects.
Runtime binary (.imported) stores marshalled component data with
entity field offset metadata for AOT-safe remapping.

- SceneSerializationService: save from EditorWorld, load into EditorWorld
- SceneAsset + SceneAssetHandler: .gscene import/pack pipeline
- AssetManager.Scene + SceneLoader: runtime binary deserialization
- Scene: [JsonConstructor] + [JsonIgnore] for round-trip
- Component: GetComponentIDByName for editor-side type lookup
- 10 unit tests (save, load, round-trip, unknown comp, invalid version)

Also guard DSLShaderCompiler editor code with #if GHOST_EDITOR,
add GC.SuppressFinalize to EditorWorldService, and switch Archetype
debug fields from #if GHOST_EDITOR to #if DEBUG.
This commit is contained in:
2026-05-10 16:21:56 +09:00
parent 7e1db7b908
commit a95ff01366
12 changed files with 1540 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
using Ghost.Entities;
using Misaki.HighPerformance.LowLevel.Buffer;
using Misaki.HighPerformance.LowLevel.Collections;
using System.Text.Json.Serialization;
namespace Ghost.Engine.Core;
@@ -19,6 +20,7 @@ public readonly struct Scene : IEquatable<Scene>
/// <summary>
/// Gets whether this scene is valid.
/// </summary>
[JsonIgnore]
public bool IsValid => _id >= 0;
/// <summary>
@@ -26,7 +28,8 @@ public readonly struct Scene : IEquatable<Scene>
/// </summary>
public static Scene Invalid => new(-1);
internal Scene(short id)
[JsonConstructor]
public Scene(short id)
{
_id = id;
}