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:
@@ -4,7 +4,6 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Ghost.Engine.Components;
|
||||
|
||||
[SkipLocalsInit]
|
||||
[HideEditor]
|
||||
public struct Hierarchy : IComponent
|
||||
{
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using Ghost.Entities;
|
||||
using Misaki.HighPerformance.Mathematics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Ghost.Engine.Components;
|
||||
|
||||
[SkipLocalsInit]
|
||||
public struct LocalToWorld : IComponent
|
||||
{
|
||||
public float4x4 matrix;
|
||||
|
||||
@@ -40,8 +40,7 @@ public static partial class EngineCore
|
||||
{
|
||||
s_impl = new EngineCoreImpl();
|
||||
|
||||
ComponentRegistry.GetOrRegisterComponent<ManagedEntityRef>();
|
||||
RegisterIComponentTypes();
|
||||
ComponentRegistry.GetOrRegisterComponentID<ManagedEntityRef>();
|
||||
}
|
||||
|
||||
internal static void Init()
|
||||
|
||||
@@ -9,10 +9,12 @@
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<IsAotCompatible>True</IsAotCompatible>
|
||||
<IsTrimmable>True</IsTrimmable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<IsAotCompatible>True</IsAotCompatible>
|
||||
<IsTrimmable>True</IsTrimmable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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