Enhance graphics engine and code organization

Added `InternalsVisibleTo` attribute for "Ghost.Graphics" and "Ghost.Editor" in `AssemblyInfo.cs`.
Added a new `EngineAssemblyAttribute` in `EngineAssemblyAttribute.cs`.
Added a reference to `Misaki.HighPerformance.Unsafe` in `Ghost.Core.csproj`.
Added a new `Bounds` struct to represent axis-aligned bounding boxes in `Bounds.cs`.
Added new `Color32` and `Color128` structs for color representation in `Color.cs`.

Changed the namespace from `Ghost.Editor.Controls` to `Ghost.Editor.Core.Controls` in multiple files.
Changed the implicit conversion operator in `ConstPtr<T>` to use a more descriptive parameter name in `ConstPtr.cs`.
Changed the `Mesh` class to use `Color128` instead of `Color32` for color representation.

Enhanced the `TypeCache` class to load types from assemblies marked with `EngineAssemblyAttribute`.
Enhanced the `ProjectService` class to improve the `GetAllProjectAsync` method by filtering out bad projects.
Enhanced the `GraphicsPipeline` class to support both DX12 and D3D12 graphics APIs.
Enhanced the `Shader` class to include methods for compiling HLSL shaders and managing root signatures.
Enhanced the `MeshRenderPass` class to utilize the new shader compilation methods.

Refactored the `AppStateMachine` class to use private fields instead of static fields for state management.
Refactored the `ComponentDataView` class to use the new namespace and improve organization.
Refactored project references in `Ghost.Graphics.csproj` to include new dependencies and remove outdated ones.

Made various adjustments to ensure consistency and improve code quality across multiple files.
This commit is contained in:
2025-07-02 21:30:10 +09:00
parent 300ae7251b
commit 5ae4128baf
66 changed files with 2100 additions and 1632 deletions

View File

@@ -2,18 +2,18 @@
internal partial class AppStateMachine : IDisposable, IAsyncDisposable
{
private Dictionary<StateKey, Lazy<IAppState>> s_states = new();
private IAppState? s_current;
private Dictionary<StateKey, Lazy<IAppState>> _states = new();
private IAppState? _current;
public void RegisterState(StateKey key, Func<IAppState> stateFactory)
{
s_states[key] = new(stateFactory);
_states[key] = new(stateFactory);
}
public async Task TransitionToAsync(StateKey stateKey, object? parameter = null)
{
var previous = s_current;
if (!s_states.TryGetValue(stateKey, out var next))
var previous = _current;
if (!_states.TryGetValue(stateKey, out var next))
{
throw new InvalidOperationException($"State '{stateKey}' is not registered.");
}
@@ -32,24 +32,25 @@ internal partial class AppStateMachine : IDisposable, IAsyncDisposable
await next.Value.OnEnteredAsync(parameter);
s_current = next.Value;
_current = next.Value;
}
public void Dispose()
{
s_states.Clear();
_states.Clear();
s_current?.OnExitingAsync().GetAwaiter().GetResult();
s_current?.OnExitedAsync().GetAwaiter().GetResult();
_current?.OnExitingAsync().GetAwaiter().GetResult();
_current?.OnExitedAsync().GetAwaiter().GetResult();
_current = null;
}
public async ValueTask DisposeAsync()
{
s_states.Clear();
if (s_current != null)
_states.Clear();
if (_current != null)
{
await s_current.OnExitingAsync();
await s_current.OnExitedAsync();
await _current.OnExitingAsync();
await _current.OnExitedAsync();
}
}
}