ECS refactor: new ComponentSet, serialization, generators

Major ECS API overhaul: added ComponentSet, refactored ComponentRegistry, and updated all entity/component creation methods. Introduced robust custom serialization infrastructure and per-component source generators for registration and (de)serialization. Updated editor, engine, and test code to use new APIs. Improved code quality, naming, and performance throughout. Removed obsolete code and updated dependencies.
This commit is contained in:
2025-12-20 20:41:40 +09:00
parent 3118021272
commit 00b4e82ded
60 changed files with 1216 additions and 814 deletions

View File

@@ -11,7 +11,7 @@ public static partial class AssetDatabase
private static void InitializeMetaData()
{
if (_watcher == null)
if (s_watcher == null)
{
throw new InvalidOperationException("AssetDatabase is not initialized. Ensure that Initialize() is called before registering asset importers.");
}
@@ -26,24 +26,24 @@ public static partial class AssetDatabase
}
}
_watcher.Created += OnAssetCreated;
_watcher.Deleted += OnAssetDeleted;
_watcher.Renamed += OnAssetRenamed;
s_watcher.Created += OnAssetCreated;
s_watcher.Deleted += OnAssetDeleted;
s_watcher.Renamed += OnAssetRenamed;
}
private static Result<string> GetMetaFilePath(string assetPath)
private static Result<string, ErrorStatus> GetMetaFilePath(string assetPath)
{
if (Directory.Exists(assetPath))
{
return Result<string>.Failure("Folder does not have meta data");
return ErrorStatus.NotFound;
}
if (Path.GetExtension(assetPath).Equals(".meta", StringComparison.OrdinalIgnoreCase))
{
return Result<string>.Failure("Asset path cannot be a meta file");
return ErrorStatus.InvalidState;
}
return Result<string>.Success(assetPath + ".meta");
return assetPath + ".meta";
}
private static ImporterSettings? GetDefaultSettingsForAsset(string assetPath)
@@ -83,7 +83,7 @@ public static partial class AssetDatabase
var metaFileResult = GetMetaFilePath(assetPath);
if (!metaFileResult.IsSuccess)
{
return Result.Failure(metaFileResult.Message);
return Result.Failure(metaFileResult.Error.ToString());
}
if (File.Exists(metaFileResult.Value))

View File

@@ -1,3 +1,4 @@
using Ghost.Editor.Core.Utilities;
using System.Diagnostics;
using System.Reflection;
@@ -9,8 +10,7 @@ public static partial class AssetDatabase
private static void InitializeAssetHandle()
{
var methods = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(a => a.GetTypes())
var methods = TypeCache.GetTypes()
.SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
.Where(m => m.GetCustomAttribute<AssetOpenHandlerAttribute>() != null &&
m.GetParameters().Length == 1 &&

View File

@@ -4,7 +4,7 @@ namespace Ghost.Editor.Core.AssetHandle;
public static partial class AssetDatabase
{
private static FileSystemWatcher? _watcher;
private static FileSystemWatcher? s_watcher;
private static readonly Dictionary<Guid, string> s_assetPathLookup = new();
@@ -22,7 +22,7 @@ public static partial class AssetDatabase
}
AssetsDirectory = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(ProjectService.CurrentProject.Path)!, ProjectService.ASSETS_FOLDER));
_watcher = new FileSystemWatcher
s_watcher = new FileSystemWatcher
{
Path = AssetsDirectory.FullName,
IncludeSubdirectories = true,