Refactor component registration, update deps, improve JSON
- Updated Misaki.HighPerformance package versions in Core and Graphics projects. - Added IsTrimmable to Ghost.Engine.csproj for trimming support. - Renamed GetOrRegisterComponent to GetOrRegisterComponentID and updated all usages. - Component registration codegen now uses a static class with [ModuleInitializer], no longer requires [EngineEntry]. - Improved JSON serialization: added string support, introduced Utf8JsonObjectScope/ArrayScope, and new extension methods for cleaner JSON writing. - Removed [SkipLocalsInit] from Hierarchy and LocalToWorld. - Fixed Entity.Invalid to use INVALID_ID for both fields. - Minor cleanup: clarified comments, reorganized Ghost.Generator in solution, and disabled component serialization generator.
This commit is contained in:
@@ -2,6 +2,34 @@ using System.Text.Json;
|
||||
|
||||
namespace Ghost.Engine.Utilities;
|
||||
|
||||
public readonly ref struct Utf8JsonObjectScope : IDisposable
|
||||
{
|
||||
private readonly Utf8JsonWriter _writer;
|
||||
public Utf8JsonObjectScope(Utf8JsonWriter writer)
|
||||
{
|
||||
_writer = writer;
|
||||
_writer.WriteStartObject();
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_writer.WriteEndObject();
|
||||
}
|
||||
}
|
||||
|
||||
public readonly ref struct Utf8JsonArrayScope : IDisposable
|
||||
{
|
||||
private readonly Utf8JsonWriter _writer;
|
||||
public Utf8JsonArrayScope(Utf8JsonWriter writer)
|
||||
{
|
||||
_writer = writer;
|
||||
_writer.WriteStartArray();
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
_writer.WriteEndArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Utf8JsonWriterExtension
|
||||
{
|
||||
public static void WriteArray<T>(this Utf8JsonWriter writer, ReadOnlySpan<char> name, IEnumerable<T> source, Action<T> writeAction)
|
||||
@@ -37,4 +65,14 @@ public static class Utf8JsonWriterExtension
|
||||
writeAction();
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
public static Utf8JsonObjectScope StartObjectScope(this Utf8JsonWriter writer)
|
||||
{
|
||||
return new Utf8JsonObjectScope(writer);
|
||||
}
|
||||
|
||||
public static Utf8JsonArrayScope StartArrayScope(this Utf8JsonWriter writer)
|
||||
{
|
||||
return new Utf8JsonArrayScope(writer);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user