diff --git a/Ghost.InternalEditor/ActivationHandler.cs b/Ghost.App/ActivationHandler.cs similarity index 99% rename from Ghost.InternalEditor/ActivationHandler.cs rename to Ghost.App/ActivationHandler.cs index eab296a..a9343ec 100644 --- a/Ghost.InternalEditor/ActivationHandler.cs +++ b/Ghost.App/ActivationHandler.cs @@ -25,4 +25,4 @@ internal static class ActivationHandler FolderInitialization(); ProjectService.EnsureDefaultTemplate(); } -} \ No newline at end of file +} diff --git a/Ghost.InternalEditor/App.xaml b/Ghost.App/App.xaml similarity index 100% rename from Ghost.InternalEditor/App.xaml rename to Ghost.App/App.xaml diff --git a/Ghost.InternalEditor/App.xaml.cs b/Ghost.App/App.xaml.cs similarity index 91% rename from Ghost.InternalEditor/App.xaml.cs rename to Ghost.App/App.xaml.cs index e4686d9..e338d7a 100644 --- a/Ghost.InternalEditor/App.xaml.cs +++ b/Ghost.App/App.xaml.cs @@ -1,6 +1,8 @@ using Ghost.App.Infrastructures.AppState; using Ghost.App.Services; using Ghost.App.Utilities; +using Ghost.Editor.Services.Contracts; +using Ghost.Engine.Services; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.UI.Xaml; @@ -52,7 +54,8 @@ public partial class GhostApplication : Application HostHelper.AddEngineScope(context, services); services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); }) .Build(); @@ -82,9 +85,8 @@ public partial class GhostApplication : Application { base.OnLaunched(args); - ActivationHandler.Handle(args); - Host.Start(); + ActivationHandler.Handle(args); var stateMachine = GetService(); stateMachine.RegisterState(StateKey.Landing, () => new LandingState()); @@ -95,7 +97,6 @@ public partial class GhostApplication : Application private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) { - // TODO: Log and handle exceptions as appropriate. - // https://docs.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.application.unhandledexception. + Logger.LogError(e.Exception); } } \ No newline at end of file diff --git a/Ghost.InternalEditor/Assets/Icon.altform-lightunplated_targetsize-16.png b/Ghost.App/Assets/Icon.altform-lightunplated_targetsize-16.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.altform-lightunplated_targetsize-16.png rename to Ghost.App/Assets/Icon.altform-lightunplated_targetsize-16.png diff --git a/Ghost.InternalEditor/Assets/Icon.altform-lightunplated_targetsize-24.png b/Ghost.App/Assets/Icon.altform-lightunplated_targetsize-24.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.altform-lightunplated_targetsize-24.png rename to Ghost.App/Assets/Icon.altform-lightunplated_targetsize-24.png diff --git a/Ghost.InternalEditor/Assets/Icon.altform-lightunplated_targetsize-256.png b/Ghost.App/Assets/Icon.altform-lightunplated_targetsize-256.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.altform-lightunplated_targetsize-256.png rename to Ghost.App/Assets/Icon.altform-lightunplated_targetsize-256.png diff --git a/Ghost.InternalEditor/Assets/Icon.altform-lightunplated_targetsize-32.png b/Ghost.App/Assets/Icon.altform-lightunplated_targetsize-32.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.altform-lightunplated_targetsize-32.png rename to Ghost.App/Assets/Icon.altform-lightunplated_targetsize-32.png diff --git a/Ghost.InternalEditor/Assets/Icon.altform-lightunplated_targetsize-48.png b/Ghost.App/Assets/Icon.altform-lightunplated_targetsize-48.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.altform-lightunplated_targetsize-48.png rename to Ghost.App/Assets/Icon.altform-lightunplated_targetsize-48.png diff --git a/Ghost.InternalEditor/Assets/Icon.altform-unplated_targetsize-16.png b/Ghost.App/Assets/Icon.altform-unplated_targetsize-16.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.altform-unplated_targetsize-16.png rename to Ghost.App/Assets/Icon.altform-unplated_targetsize-16.png diff --git a/Ghost.InternalEditor/Assets/Icon.altform-unplated_targetsize-24.png b/Ghost.App/Assets/Icon.altform-unplated_targetsize-24.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.altform-unplated_targetsize-24.png rename to Ghost.App/Assets/Icon.altform-unplated_targetsize-24.png diff --git a/Ghost.InternalEditor/Assets/Icon.altform-unplated_targetsize-256.png b/Ghost.App/Assets/Icon.altform-unplated_targetsize-256.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.altform-unplated_targetsize-256.png rename to Ghost.App/Assets/Icon.altform-unplated_targetsize-256.png diff --git a/Ghost.InternalEditor/Assets/Icon.altform-unplated_targetsize-32.png b/Ghost.App/Assets/Icon.altform-unplated_targetsize-32.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.altform-unplated_targetsize-32.png rename to Ghost.App/Assets/Icon.altform-unplated_targetsize-32.png diff --git a/Ghost.InternalEditor/Assets/Icon.altform-unplated_targetsize-48.png b/Ghost.App/Assets/Icon.altform-unplated_targetsize-48.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.altform-unplated_targetsize-48.png rename to Ghost.App/Assets/Icon.altform-unplated_targetsize-48.png diff --git a/Ghost.InternalEditor/Assets/Icon.scale-100.png b/Ghost.App/Assets/Icon.scale-100.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.scale-100.png rename to Ghost.App/Assets/Icon.scale-100.png diff --git a/Ghost.InternalEditor/Assets/Icon.scale-125.png b/Ghost.App/Assets/Icon.scale-125.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.scale-125.png rename to Ghost.App/Assets/Icon.scale-125.png diff --git a/Ghost.InternalEditor/Assets/Icon.scale-150.png b/Ghost.App/Assets/Icon.scale-150.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.scale-150.png rename to Ghost.App/Assets/Icon.scale-150.png diff --git a/Ghost.InternalEditor/Assets/Icon.scale-200.png b/Ghost.App/Assets/Icon.scale-200.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.scale-200.png rename to Ghost.App/Assets/Icon.scale-200.png diff --git a/Ghost.InternalEditor/Assets/Icon.scale-400.png b/Ghost.App/Assets/Icon.scale-400.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.scale-400.png rename to Ghost.App/Assets/Icon.scale-400.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-16.png b/Ghost.App/Assets/Icon.targetsize-16.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-16.png rename to Ghost.App/Assets/Icon.targetsize-16.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-16_altform-lightunplated.png b/Ghost.App/Assets/Icon.targetsize-16_altform-lightunplated.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-16_altform-lightunplated.png rename to Ghost.App/Assets/Icon.targetsize-16_altform-lightunplated.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-16_altform-unplated.png b/Ghost.App/Assets/Icon.targetsize-16_altform-unplated.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-16_altform-unplated.png rename to Ghost.App/Assets/Icon.targetsize-16_altform-unplated.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-24.png b/Ghost.App/Assets/Icon.targetsize-24.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-24.png rename to Ghost.App/Assets/Icon.targetsize-24.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-24_altform-lightunplated.png b/Ghost.App/Assets/Icon.targetsize-24_altform-lightunplated.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-24_altform-lightunplated.png rename to Ghost.App/Assets/Icon.targetsize-24_altform-lightunplated.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-24_altform-unplated.png b/Ghost.App/Assets/Icon.targetsize-24_altform-unplated.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-24_altform-unplated.png rename to Ghost.App/Assets/Icon.targetsize-24_altform-unplated.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-256.png b/Ghost.App/Assets/Icon.targetsize-256.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-256.png rename to Ghost.App/Assets/Icon.targetsize-256.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-256_altform-lightunplated.png b/Ghost.App/Assets/Icon.targetsize-256_altform-lightunplated.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-256_altform-lightunplated.png rename to Ghost.App/Assets/Icon.targetsize-256_altform-lightunplated.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-256_altform-unplated.png b/Ghost.App/Assets/Icon.targetsize-256_altform-unplated.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-256_altform-unplated.png rename to Ghost.App/Assets/Icon.targetsize-256_altform-unplated.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-32.png b/Ghost.App/Assets/Icon.targetsize-32.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-32.png rename to Ghost.App/Assets/Icon.targetsize-32.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-32_altform-lightunplated.png b/Ghost.App/Assets/Icon.targetsize-32_altform-lightunplated.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-32_altform-lightunplated.png rename to Ghost.App/Assets/Icon.targetsize-32_altform-lightunplated.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-32_altform-unplated.png b/Ghost.App/Assets/Icon.targetsize-32_altform-unplated.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-32_altform-unplated.png rename to Ghost.App/Assets/Icon.targetsize-32_altform-unplated.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-48.png b/Ghost.App/Assets/Icon.targetsize-48.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-48.png rename to Ghost.App/Assets/Icon.targetsize-48.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-48_altform-lightunplated.png b/Ghost.App/Assets/Icon.targetsize-48_altform-lightunplated.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-48_altform-lightunplated.png rename to Ghost.App/Assets/Icon.targetsize-48_altform-lightunplated.png diff --git a/Ghost.InternalEditor/Assets/Icon.targetsize-48_altform-unplated.png b/Ghost.App/Assets/Icon.targetsize-48_altform-unplated.png similarity index 100% rename from Ghost.InternalEditor/Assets/Icon.targetsize-48_altform-unplated.png rename to Ghost.App/Assets/Icon.targetsize-48_altform-unplated.png diff --git a/Ghost.InternalEditor/Assets/LockScreenLogo.scale-200.png b/Ghost.App/Assets/LockScreenLogo.scale-200.png similarity index 100% rename from Ghost.InternalEditor/Assets/LockScreenLogo.scale-200.png rename to Ghost.App/Assets/LockScreenLogo.scale-200.png diff --git a/Ghost.InternalEditor/Assets/SplashScreen.scale-200.png b/Ghost.App/Assets/SplashScreen.scale-200.png similarity index 100% rename from Ghost.InternalEditor/Assets/SplashScreen.scale-200.png rename to Ghost.App/Assets/SplashScreen.scale-200.png diff --git a/Ghost.InternalEditor/Assets/Square150x150Logo.scale-200.png b/Ghost.App/Assets/Square150x150Logo.scale-200.png similarity index 100% rename from Ghost.InternalEditor/Assets/Square150x150Logo.scale-200.png rename to Ghost.App/Assets/Square150x150Logo.scale-200.png diff --git a/Ghost.InternalEditor/Assets/StoreLogo.png b/Ghost.App/Assets/StoreLogo.png similarity index 100% rename from Ghost.InternalEditor/Assets/StoreLogo.png rename to Ghost.App/Assets/StoreLogo.png diff --git a/Ghost.InternalEditor/Assets/Wide310x150Logo.scale-200.png b/Ghost.App/Assets/Wide310x150Logo.scale-200.png similarity index 100% rename from Ghost.InternalEditor/Assets/Wide310x150Logo.scale-200.png rename to Ghost.App/Assets/Wide310x150Logo.scale-200.png diff --git a/Ghost.InternalEditor/Assets/icon-256.ico b/Ghost.App/Assets/icon-256.ico similarity index 100% rename from Ghost.InternalEditor/Assets/icon-256.ico rename to Ghost.App/Assets/icon-256.ico diff --git a/Ghost.InternalEditor/Assets/icon-256.png b/Ghost.App/Assets/icon-256.png similarity index 100% rename from Ghost.InternalEditor/Assets/icon-256.png rename to Ghost.App/Assets/icon-256.png diff --git a/Ghost.InternalEditor/Contracts/INavigationAware.cs b/Ghost.App/Contracts/INavigationAware.cs similarity index 76% rename from Ghost.InternalEditor/Contracts/INavigationAware.cs rename to Ghost.App/Contracts/INavigationAware.cs index 62fe65f..51349ab 100644 --- a/Ghost.InternalEditor/Contracts/INavigationAware.cs +++ b/Ghost.App/Contracts/INavigationAware.cs @@ -1,6 +1,6 @@ namespace Ghost.App.Contracts; -internal interface INavigationAware +public interface INavigationAware { public void OnNavigatedTo(object? parameter); public void OnNavigatedFrom(); diff --git a/Ghost.InternalEditor/Controls/BasicInput/PropertyField.cs b/Ghost.App/Controls/BasicInput/PropertyField.cs similarity index 100% rename from Ghost.InternalEditor/Controls/BasicInput/PropertyField.cs rename to Ghost.App/Controls/BasicInput/PropertyField.cs diff --git a/Ghost.InternalEditor/Controls/BasicInput/PropertyField.xaml b/Ghost.App/Controls/BasicInput/PropertyField.xaml similarity index 100% rename from Ghost.InternalEditor/Controls/BasicInput/PropertyField.xaml rename to Ghost.App/Controls/BasicInput/PropertyField.xaml diff --git a/Ghost.InternalEditor/Controls/EditorControls.xaml b/Ghost.App/Controls/EditorControls.xaml similarity index 100% rename from Ghost.InternalEditor/Controls/EditorControls.xaml rename to Ghost.App/Controls/EditorControls.xaml diff --git a/Ghost.InternalEditor/Controls/Internal/InspectorView.cs b/Ghost.App/Controls/Internal/InspectorView.cs similarity index 100% rename from Ghost.InternalEditor/Controls/Internal/InspectorView.cs rename to Ghost.App/Controls/Internal/InspectorView.cs diff --git a/Ghost.InternalEditor/Controls/Internal/InspectorView.xaml b/Ghost.App/Controls/Internal/InspectorView.xaml similarity index 100% rename from Ghost.InternalEditor/Controls/Internal/InspectorView.xaml rename to Ghost.App/Controls/Internal/InspectorView.xaml diff --git a/Ghost.InternalEditor/Controls/Internal/InternalControls.xaml b/Ghost.App/Controls/Internal/InternalControls.xaml similarity index 100% rename from Ghost.InternalEditor/Controls/Internal/InternalControls.xaml rename to Ghost.App/Controls/Internal/InternalControls.xaml diff --git a/Ghost.InternalEditor/Controls/ViewModelPage.cs b/Ghost.App/Controls/ViewModelPage.cs similarity index 100% rename from Ghost.InternalEditor/Controls/ViewModelPage.cs rename to Ghost.App/Controls/ViewModelPage.cs diff --git a/Ghost.InternalEditor/Ghost.App.csproj b/Ghost.App/Ghost.App.csproj similarity index 100% rename from Ghost.InternalEditor/Ghost.App.csproj rename to Ghost.App/Ghost.App.csproj diff --git a/Ghost.InternalEditor/Infrastructures/AppState/AppStateMachine.cs b/Ghost.App/Infrastructures/AppState/AppStateMachine.cs similarity index 100% rename from Ghost.InternalEditor/Infrastructures/AppState/AppStateMachine.cs rename to Ghost.App/Infrastructures/AppState/AppStateMachine.cs diff --git a/Ghost.InternalEditor/Infrastructures/AppState/EditorState.cs b/Ghost.App/Infrastructures/AppState/EditorState.cs similarity index 91% rename from Ghost.InternalEditor/Infrastructures/AppState/EditorState.cs rename to Ghost.App/Infrastructures/AppState/EditorState.cs index e647ce6..de9d32c 100644 --- a/Ghost.InternalEditor/Infrastructures/AppState/EditorState.cs +++ b/Ghost.App/Infrastructures/AppState/EditorState.cs @@ -1,7 +1,9 @@ using Ghost.App.View.Windows; using Ghost.Data.Models; using Ghost.Data.Services; +using Ghost.Editor; using Ghost.Engine; +using Microsoft.UI.Xaml; using System; using System.Threading.Tasks; @@ -57,6 +59,7 @@ internal class EditorState : IAppState public Task OnEnteredAsync(object? parameter) { + EditorApplication.Activate(parameter, ((GhostApplication)(Application.Current)).Host.Services); return Task.CompletedTask; } } \ No newline at end of file diff --git a/Ghost.InternalEditor/Infrastructures/AppState/IAppState.cs b/Ghost.App/Infrastructures/AppState/IAppState.cs similarity index 100% rename from Ghost.InternalEditor/Infrastructures/AppState/IAppState.cs rename to Ghost.App/Infrastructures/AppState/IAppState.cs diff --git a/Ghost.InternalEditor/Infrastructures/AppState/LandingState.cs b/Ghost.App/Infrastructures/AppState/LandingState.cs similarity index 100% rename from Ghost.InternalEditor/Infrastructures/AppState/LandingState.cs rename to Ghost.App/Infrastructures/AppState/LandingState.cs diff --git a/Ghost.InternalEditor/Infrastructures/AppState/StateKey.cs b/Ghost.App/Infrastructures/AppState/StateKey.cs similarity index 100% rename from Ghost.InternalEditor/Infrastructures/AppState/StateKey.cs rename to Ghost.App/Infrastructures/AppState/StateKey.cs diff --git a/Ghost.InternalEditor/Models/AssetItem.cs b/Ghost.App/Models/AssetItem.cs similarity index 80% rename from Ghost.InternalEditor/Models/AssetItem.cs rename to Ghost.App/Models/AssetItem.cs index c80d179..85a890e 100644 --- a/Ghost.InternalEditor/Models/AssetItem.cs +++ b/Ghost.App/Models/AssetItem.cs @@ -2,12 +2,12 @@ internal struct AssetItem() { - public string AssetPath + public string Name { get; set; } = string.Empty; - public string AssetName + public string FullNam { get; set; } = string.Empty; diff --git a/Ghost.InternalEditor/Models/ExplorerItem.cs b/Ghost.App/Models/ExplorerItem.cs similarity index 93% rename from Ghost.InternalEditor/Models/ExplorerItem.cs rename to Ghost.App/Models/ExplorerItem.cs index bfe37f3..2921083 100644 --- a/Ghost.InternalEditor/Models/ExplorerItem.cs +++ b/Ghost.App/Models/ExplorerItem.cs @@ -9,7 +9,7 @@ internal class ExplorerItem(string name, string path, bool isDirectory) get; } = name; - public string Path + public string FullName { get; } = path; diff --git a/Ghost.InternalEditor/Package.appxmanifest b/Ghost.App/Package.appxmanifest similarity index 100% rename from Ghost.InternalEditor/Package.appxmanifest rename to Ghost.App/Package.appxmanifest diff --git a/Ghost.InternalEditor/Properties/launchSettings.json b/Ghost.App/Properties/launchSettings.json similarity index 100% rename from Ghost.InternalEditor/Properties/launchSettings.json rename to Ghost.App/Properties/launchSettings.json diff --git a/Ghost.InternalEditor/Services/StackedNotificationService.cs b/Ghost.App/Services/NotificationService.cs similarity index 78% rename from Ghost.InternalEditor/Services/StackedNotificationService.cs rename to Ghost.App/Services/NotificationService.cs index 49ed3d7..0e0875f 100644 --- a/Ghost.InternalEditor/Services/StackedNotificationService.cs +++ b/Ghost.App/Services/NotificationService.cs @@ -1,10 +1,12 @@ using CommunityToolkit.WinUI.Behaviors; +using Ghost.Editor.Models; +using Ghost.Editor.Services.Contracts; using Microsoft.UI.Xaml.Controls; using System; namespace Ghost.App.Services; -public class StackedNotificationService +public class NotificationService : INotificationService { private InfoBar? _infoBar; private StackedNotificationsBehavior? _notificationQueue; @@ -15,17 +17,7 @@ public class StackedNotificationService _notificationQueue = notificationQueue; } - internal void ClearReference() - { - if (_infoBar != null) - { - _infoBar.IsOpen = false; - } - _infoBar = null; - _notificationQueue = null; - } - - public void ShowNotification(string? message, InfoBarSeverity severity, int duration = 5, string? title = null) + public void ShowNotification(string? message, MessageType type, int duration = 5, string? title = null) { if (string.IsNullOrWhiteSpace(message)) { @@ -35,7 +27,7 @@ public class StackedNotificationService var notification = new Notification { Message = message, - Severity = severity, + Severity = (InfoBarSeverity)type, Duration = TimeSpan.FromSeconds(duration), Title = title }; @@ -47,4 +39,14 @@ public class StackedNotificationService { _notificationQueue?.Show(notification); } + + internal void ClearReference() + { + if (_infoBar != null) + { + _infoBar.IsOpen = false; + } + _infoBar = null; + _notificationQueue = null; + } } \ No newline at end of file diff --git a/Ghost.App/Services/ProgressService.cs b/Ghost.App/Services/ProgressService.cs new file mode 100644 index 0000000..3c16556 --- /dev/null +++ b/Ghost.App/Services/ProgressService.cs @@ -0,0 +1,75 @@ +using CommunityToolkit.WinUI; +using Ghost.Editor.Services.Contracts; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using System.Runtime.CompilerServices; + +namespace Ghost.App.Services; + +public class ProgressService : IProgressService +{ + private Grid? _progressBarContainer; + private TextBlock? _progressMessage; + private ProgressBar? _progressBar; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private bool IsInitialized() + { + return _progressBarContainer != null && _progressMessage != null && _progressBar != null; + } + + internal void SetReference(Grid progressBarContainer) + { + _progressBarContainer = progressBarContainer; + _progressMessage = _progressBarContainer.FindChild(); + _progressBar = _progressBarContainer.FindChild(); + } + + public void ShowProgress(string message, double progress = 0.0) + { + if (!IsInitialized()) + { + return; + } + + _progressBarContainer!.Visibility = Visibility.Visible; + _progressMessage!.Text = message; + _progressBar!.Value = progress; + } + + public void ShowIndeterminateProgress(string message) + { + if (!IsInitialized()) + { + return; + } + + _progressBarContainer!.Visibility = Visibility.Visible; + _progressMessage!.Text = message; + _progressBar!.IsIndeterminate = true; + } + + public void SetProgress(double progress) + { + _progressBar!.Value = progress; + } + + public void HideProgress() + { + if (!IsInitialized()) + { + return; + } + + _progressBarContainer!.Visibility = Visibility.Collapsed; + _progressMessage!.Text = string.Empty; + _progressBar!.Value = 0.0; + } + + internal void ClearReference() + { + _progressBarContainer = null; + _progressMessage = null; + _progressBar = null; + } +} \ No newline at end of file diff --git a/Ghost.InternalEditor/Themes/Override.xaml b/Ghost.App/Themes/Override.xaml similarity index 100% rename from Ghost.InternalEditor/Themes/Override.xaml rename to Ghost.App/Themes/Override.xaml diff --git a/Ghost.InternalEditor/Utilities/ComponentTypeCache.cs b/Ghost.App/Utilities/ComponentTypeCache.cs similarity index 100% rename from Ghost.InternalEditor/Utilities/ComponentTypeCache.cs rename to Ghost.App/Utilities/ComponentTypeCache.cs diff --git a/Ghost.InternalEditor/Utilities/Converters/AssetPathToGlyphConverter.cs b/Ghost.App/Utilities/Converters/AssetPathToGlyphConverter.cs similarity index 73% rename from Ghost.InternalEditor/Utilities/Converters/AssetPathToGlyphConverter.cs rename to Ghost.App/Utilities/Converters/AssetPathToGlyphConverter.cs index 75857c5..cd45bd3 100644 --- a/Ghost.InternalEditor/Utilities/Converters/AssetPathToGlyphConverter.cs +++ b/Ghost.App/Utilities/Converters/AssetPathToGlyphConverter.cs @@ -23,13 +23,14 @@ public partial class AssetPathToGlyphConverter : IValueConverter // TODO: Use resource dictionary for icons. return extension switch { + ".ghostscene" => "\uF159", ".fbx" or ".obj" => "\uF158", - ".png" or ".jpg" or ".jpeg" or ".gif" or ".bmp" => "\uE91B", // Image icon - ".mp3" or ".wav" or ".ogg" => "\uE767", // Audio icon - ".mp4" or ".avi" or ".mkv" => "\uE714", // Video icon - ".txt" or ".md" => "\uF000", // Text file icon - ".cs" or ".hlsl" => "\uE943", // Code file icon - _ => "\uE8A5", // Default file icon + ".png" or ".jpg" or ".jpeg" or ".gif" or ".bmp" => "\uE91B", + ".mp3" or ".wav" or ".ogg" => "\uE767", + ".mp4" or ".avi" or ".mkv" => "\uE714", + ".txt" or ".md" => "\uF000", + ".cs" or ".hlsl" => "\uE943", + _ => "\uE8A5", }; } diff --git a/Ghost.InternalEditor/Utilities/Converters/GetDirectoryNameConverter .cs b/Ghost.App/Utilities/Converters/GetDirectoryNameConverter .cs similarity index 100% rename from Ghost.InternalEditor/Utilities/Converters/GetDirectoryNameConverter .cs rename to Ghost.App/Utilities/Converters/GetDirectoryNameConverter .cs diff --git a/Ghost.InternalEditor/Utilities/HostHelpers.Page.cs b/Ghost.App/Utilities/HostHelpers.Page.cs similarity index 100% rename from Ghost.InternalEditor/Utilities/HostHelpers.Page.cs rename to Ghost.App/Utilities/HostHelpers.Page.cs diff --git a/Ghost.InternalEditor/Utilities/SystemUtilities.cs b/Ghost.App/Utilities/SystemUtilities.cs similarity index 100% rename from Ghost.InternalEditor/Utilities/SystemUtilities.cs rename to Ghost.App/Utilities/SystemUtilities.cs diff --git a/Ghost.InternalEditor/View/Pages/EngineEditor/ConsolePage.xaml b/Ghost.App/View/Pages/EngineEditor/ConsolePage.xaml similarity index 100% rename from Ghost.InternalEditor/View/Pages/EngineEditor/ConsolePage.xaml rename to Ghost.App/View/Pages/EngineEditor/ConsolePage.xaml diff --git a/Ghost.InternalEditor/View/Pages/EngineEditor/ConsolePage.xaml.cs b/Ghost.App/View/Pages/EngineEditor/ConsolePage.xaml.cs similarity index 100% rename from Ghost.InternalEditor/View/Pages/EngineEditor/ConsolePage.xaml.cs rename to Ghost.App/View/Pages/EngineEditor/ConsolePage.xaml.cs diff --git a/Ghost.InternalEditor/View/Pages/EngineEditor/HierarchyPage.xaml b/Ghost.App/View/Pages/EngineEditor/HierarchyPage.xaml similarity index 100% rename from Ghost.InternalEditor/View/Pages/EngineEditor/HierarchyPage.xaml rename to Ghost.App/View/Pages/EngineEditor/HierarchyPage.xaml diff --git a/Ghost.InternalEditor/View/Pages/EngineEditor/HierarchyPage.xaml.cs b/Ghost.App/View/Pages/EngineEditor/HierarchyPage.xaml.cs similarity index 100% rename from Ghost.InternalEditor/View/Pages/EngineEditor/HierarchyPage.xaml.cs rename to Ghost.App/View/Pages/EngineEditor/HierarchyPage.xaml.cs diff --git a/Ghost.InternalEditor/View/Pages/EngineEditor/ProjectPage.xaml b/Ghost.App/View/Pages/EngineEditor/ProjectPage.xaml similarity index 97% rename from Ghost.InternalEditor/View/Pages/EngineEditor/ProjectPage.xaml rename to Ghost.App/View/Pages/EngineEditor/ProjectPage.xaml index 9255457..8bedf5c 100644 --- a/Ghost.InternalEditor/View/Pages/EngineEditor/ProjectPage.xaml +++ b/Ghost.App/View/Pages/EngineEditor/ProjectPage.xaml @@ -105,7 +105,7 @@ - + diff --git a/Ghost.InternalEditor/View/Pages/EngineEditor/ProjectPage.xaml.cs b/Ghost.App/View/Pages/EngineEditor/ProjectPage.xaml.cs similarity index 75% rename from Ghost.InternalEditor/View/Pages/EngineEditor/ProjectPage.xaml.cs rename to Ghost.App/View/Pages/EngineEditor/ProjectPage.xaml.cs index 280c80a..ab7d437 100644 --- a/Ghost.InternalEditor/View/Pages/EngineEditor/ProjectPage.xaml.cs +++ b/Ghost.App/View/Pages/EngineEditor/ProjectPage.xaml.cs @@ -18,8 +18,8 @@ internal sealed partial class ProjectPage : Page InitializeComponent(); } - private void GridViewItem_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) + private async void GridViewItem_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e) { - ViewModel.NavigateToSelected(); + await ViewModel.OpenSelected(); } -} +} \ No newline at end of file diff --git a/Ghost.InternalEditor/View/Pages/Landing/CreateProjectPage.xaml b/Ghost.App/View/Pages/Landing/CreateProjectPage.xaml similarity index 100% rename from Ghost.InternalEditor/View/Pages/Landing/CreateProjectPage.xaml rename to Ghost.App/View/Pages/Landing/CreateProjectPage.xaml diff --git a/Ghost.InternalEditor/View/Pages/Landing/CreateProjectPage.xaml.cs b/Ghost.App/View/Pages/Landing/CreateProjectPage.xaml.cs similarity index 100% rename from Ghost.InternalEditor/View/Pages/Landing/CreateProjectPage.xaml.cs rename to Ghost.App/View/Pages/Landing/CreateProjectPage.xaml.cs diff --git a/Ghost.InternalEditor/View/Pages/Landing/OpenProjectPage.xaml b/Ghost.App/View/Pages/Landing/OpenProjectPage.xaml similarity index 100% rename from Ghost.InternalEditor/View/Pages/Landing/OpenProjectPage.xaml rename to Ghost.App/View/Pages/Landing/OpenProjectPage.xaml diff --git a/Ghost.InternalEditor/View/Pages/Landing/OpenProjectPage.xaml.cs b/Ghost.App/View/Pages/Landing/OpenProjectPage.xaml.cs similarity index 100% rename from Ghost.InternalEditor/View/Pages/Landing/OpenProjectPage.xaml.cs rename to Ghost.App/View/Pages/Landing/OpenProjectPage.xaml.cs diff --git a/Ghost.InternalEditor/View/Windows/EngineEditorWindow.xaml b/Ghost.App/View/Windows/EngineEditorWindow.xaml similarity index 79% rename from Ghost.InternalEditor/View/Windows/EngineEditorWindow.xaml rename to Ghost.App/View/Windows/EngineEditorWindow.xaml index 24f2139..0eb4763 100644 --- a/Ghost.InternalEditor/View/Windows/EngineEditorWindow.xaml +++ b/Ghost.App/View/Windows/EngineEditorWindow.xaml @@ -3,13 +3,16 @@ x:Class="Ghost.App.View.Windows.EngineEditorWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors" xmlns:controls="using:CommunityToolkit.WinUI.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:ee="using:Ghost.App.View.Pages.EngineEditor" + xmlns:interactivity="using:Microsoft.Xaml.Interactivity" xmlns:local="using:Ghost.App.View.Windows" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:winex="using:WinUIEx" Activated="WindowEx_Activated" + Closed="WindowEx_Closed" mc:Ignorable="d"> @@ -192,5 +195,50 @@ + + + + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/Ghost.InternalEditor/View/Windows/EngineEditorWindow.xaml.cs b/Ghost.App/View/Windows/EngineEditorWindow.xaml.cs similarity index 50% rename from Ghost.InternalEditor/View/Windows/EngineEditorWindow.xaml.cs rename to Ghost.App/View/Windows/EngineEditorWindow.xaml.cs index 4714666..5770242 100644 --- a/Ghost.InternalEditor/View/Windows/EngineEditorWindow.xaml.cs +++ b/Ghost.App/View/Windows/EngineEditorWindow.xaml.cs @@ -1,6 +1,9 @@ -using Ghost.Data.Resources; +using Ghost.App.Services; +using Ghost.Data.Resources; +using Ghost.Editor.Services.Contracts; using Ghost.Editor.ViewModels.Windows; using Ghost.Engine.Resources; +using Microsoft.Extensions.DependencyInjection; using WinUIEx; // To learn more about WinUI, the WinUI project structure, @@ -12,6 +15,11 @@ namespace Ghost.App.View.Windows; /// internal sealed partial class EngineEditorWindow : WindowEx { + private IServiceScope? _editorScope; + + private readonly NotificationService _notificationService; + private readonly ProgressService _progressService; + public EngineEditorViewModel ViewModel { get; @@ -21,6 +29,9 @@ internal sealed partial class EngineEditorWindow : WindowEx { ViewModel = GhostApplication.GetService(); + _notificationService = (NotificationService)GhostApplication.GetService(); + _progressService = (ProgressService)GhostApplication.GetService(); + AppWindow.SetIcon(AssetsPath.s_appIconPath); Title = EngineData.ENGINE_NAME; ExtendsContentIntoTitleBar = true; @@ -33,5 +44,19 @@ internal sealed partial class EngineEditorWindow : WindowEx private void WindowEx_Activated(object sender, Microsoft.UI.Xaml.WindowActivatedEventArgs args) { Bindings.Update(); + + _editorScope?.Dispose(); + _editorScope = GhostApplication.CreateScope(); + + _notificationService.SetReference(InfoBar, NotificationQueue); + _progressService.SetReference(ProgressBarContainer); + } + + private void WindowEx_Closed(object sender, Microsoft.UI.Xaml.WindowEventArgs args) + { + _editorScope?.Dispose(); + + _notificationService.ClearReference(); + _progressService.ClearReference(); } } \ No newline at end of file diff --git a/Ghost.InternalEditor/View/Windows/LandingWindow.xaml b/Ghost.App/View/Windows/LandingWindow.xaml similarity index 99% rename from Ghost.InternalEditor/View/Windows/LandingWindow.xaml rename to Ghost.App/View/Windows/LandingWindow.xaml index 7e01ccf..09cdbcf 100644 --- a/Ghost.InternalEditor/View/Windows/LandingWindow.xaml +++ b/Ghost.App/View/Windows/LandingWindow.xaml @@ -71,7 +71,6 @@ - diff --git a/Ghost.InternalEditor/View/Windows/LandingWindow.xaml.cs b/Ghost.App/View/Windows/LandingWindow.xaml.cs similarity index 84% rename from Ghost.InternalEditor/View/Windows/LandingWindow.xaml.cs rename to Ghost.App/View/Windows/LandingWindow.xaml.cs index bfda58e..7c762b1 100644 --- a/Ghost.InternalEditor/View/Windows/LandingWindow.xaml.cs +++ b/Ghost.App/View/Windows/LandingWindow.xaml.cs @@ -1,6 +1,7 @@ using Ghost.App.Services; using Ghost.App.View.Pages.Landing; using Ghost.Data.Resources; +using Ghost.Editor.Services.Contracts; using Ghost.Engine.Resources; using Microsoft.Extensions.DependencyInjection; using Microsoft.UI.Xaml.Controls; @@ -13,10 +14,14 @@ internal sealed partial class LandingWindow : WindowEx { private IServiceScope? _landingScope; + private readonly NotificationService _notificationService; + private int _previousSelectedIndex; public LandingWindow() { + _notificationService = (NotificationService)GhostApplication.GetService(); + AppWindow.SetIcon(AssetsPath.s_appIconPath); Title = EngineData.ENGINE_NAME; @@ -32,13 +37,13 @@ internal sealed partial class LandingWindow : WindowEx { _landingScope?.Dispose(); _landingScope = GhostApplication.CreateScope(); - GhostApplication.GetService().SetReference(InfoBar, NotificationQueue); + _notificationService.SetReference(InfoBar, NotificationQueue); } private void WindowEx_Closed(object sender, Microsoft.UI.Xaml.WindowEventArgs args) { _landingScope?.Dispose(); - GhostApplication.GetService().ClearReference(); + _notificationService.ClearReference(); } private void SelectorBar_SelectionChanged(SelectorBar sender, SelectorBarSelectionChangedEventArgs e) diff --git a/Ghost.InternalEditor/ViewModels/Pages/EngineEditor/ConsoleViewModel.cs b/Ghost.App/ViewModels/Pages/EngineEditor/ConsoleViewModel.cs similarity index 100% rename from Ghost.InternalEditor/ViewModels/Pages/EngineEditor/ConsoleViewModel.cs rename to Ghost.App/ViewModels/Pages/EngineEditor/ConsoleViewModel.cs diff --git a/Ghost.App/ViewModels/Pages/EngineEditor/HierarchyViewModel.cs b/Ghost.App/ViewModels/Pages/EngineEditor/HierarchyViewModel.cs new file mode 100644 index 0000000..f472be7 --- /dev/null +++ b/Ghost.App/ViewModels/Pages/EngineEditor/HierarchyViewModel.cs @@ -0,0 +1,38 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using Ghost.Editor.SceneGraph; +using System; +using System.Collections.ObjectModel; + +namespace Ghost.Editor.ViewModels.Pages.EngineEditor; + +internal partial class HierarchyViewModel : ObservableObject, IDisposable +{ + [ObservableProperty] + public partial ObservableCollection SceneList + { + get; + private set; + } = new(EditorWorldManager.LoadedWorlds); + + public HierarchyViewModel() + { + EditorWorldManager.OnWorldLoaded += OnWorldLoaded; + EditorWorldManager.OnWorldUnloaded += OnWorldUnloaded; + } + + private void OnWorldLoaded(WorldNode node) + { + SceneList.Add(node); + } + + private void OnWorldUnloaded(WorldNode node) + { + SceneList.Remove(node); + } + + public void Dispose() + { + EditorWorldManager.OnWorldLoaded -= OnWorldLoaded; + EditorWorldManager.OnWorldUnloaded -= OnWorldUnloaded; + } +} \ No newline at end of file diff --git a/Ghost.InternalEditor/ViewModels/Pages/EngineEditor/ProjectViewModel.cs b/Ghost.App/ViewModels/Pages/EngineEditor/ProjectViewModel.cs similarity index 87% rename from Ghost.InternalEditor/ViewModels/Pages/EngineEditor/ProjectViewModel.cs rename to Ghost.App/ViewModels/Pages/EngineEditor/ProjectViewModel.cs index f3f9b95..cfa8947 100644 --- a/Ghost.InternalEditor/ViewModels/Pages/EngineEditor/ProjectViewModel.cs +++ b/Ghost.App/ViewModels/Pages/EngineEditor/ProjectViewModel.cs @@ -2,6 +2,7 @@ using Ghost.App; using Ghost.App.Models; using Ghost.Data.Services; +using Ghost.Editor.AssetHandle; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -51,9 +52,9 @@ internal partial class ProjectViewModel : ObservableObject SubDirectories.Add(assetsRootItem); } - private void LoadSubFolderRecursive(ref ExplorerItem parentItem) + private static void LoadSubFolderRecursive(ref ExplorerItem parentItem) { - foreach (var directory in Directory.EnumerateDirectories(parentItem.Path)) + foreach (var directory in Directory.EnumerateDirectories(parentItem.FullName)) { var item = new ExplorerItem(Path.GetFileName(directory), directory, true); LoadSubFolderRecursive(ref item); @@ -116,28 +117,35 @@ internal partial class ProjectViewModel : ObservableObject DirectoryAssets.Add(fileItem); } - SelectedDirectory = await FindNodeIterative(SubDirectories[0], x => x.Path == path); + SelectedDirectory = await FindNodeIterative(SubDirectories[0], x => x.FullName == path); }); } - public void NavigateToSelected() + public async Task OpenSelected() { - if (SelectedAsset == null || !SelectedAsset.IsDirectory) + if (SelectedAsset == null) { return; } - NavigateToDirectory(SelectedAsset.Path); + if (SelectedAsset.IsDirectory) + { + NavigateToDirectory(SelectedAsset.FullName); + } + else + { + await AssetDatabase.OpenAsset(SelectedAsset.FullName); + } } partial void OnSelectedDirectoryChanged(ExplorerItem? value) { - DirectoryAssets.Clear(); if (value == null) { return; } - NavigateToDirectory(value.Path); + DirectoryAssets.Clear(); + NavigateToDirectory(value.FullName); } } \ No newline at end of file diff --git a/Ghost.InternalEditor/ViewModels/Pages/Landing/CreateProjectViewModel.cs b/Ghost.App/ViewModels/Pages/Landing/CreateProjectViewModel.cs similarity index 87% rename from Ghost.InternalEditor/ViewModels/Pages/Landing/CreateProjectViewModel.cs rename to Ghost.App/ViewModels/Pages/Landing/CreateProjectViewModel.cs index b0af1b4..fef5e1b 100644 --- a/Ghost.InternalEditor/ViewModels/Pages/Landing/CreateProjectViewModel.cs +++ b/Ghost.App/ViewModels/Pages/Landing/CreateProjectViewModel.cs @@ -6,8 +6,8 @@ using Ghost.App.Services; using Ghost.App.Utilities; using Ghost.Data.Models; using Ghost.Data.Services; +using Ghost.Editor.Models; using Ghost.Engine.Resources; -using Microsoft.UI.Xaml.Controls; using System.Collections.ObjectModel; using System.IO; using System.Linq; @@ -15,7 +15,7 @@ using System.Threading.Tasks; namespace Ghost.Editor.ViewModels.Pages.Landing; -internal partial class CreateProjectViewModel(StackedNotificationService notificationService, ProjectService projectService, AppStateMachine stateService) : ObservableObject, INavigationAware +internal partial class CreateProjectViewModel(NotificationService notificationService, ProjectService projectService, AppStateMachine stateService) : ObservableObject, INavigationAware { public ObservableCollection templates = new(); @@ -72,14 +72,14 @@ internal partial class CreateProjectViewModel(StackedNotificationService notific || !Directory.Exists(ProjectLocation) || !SelectedTemplate.HasValue) { - notificationService.ShowNotification("Incorrect project info", InfoBarSeverity.Error); + notificationService.ShowNotification("Incorrect project info", MessageType.Error); return; } var result = await projectService.CreateProjectAsync(ProjectName, ProjectLocation, EngineData.s_engineVersion, SelectedTemplate.Value.directory); if (!result.success) { - notificationService.ShowNotification(result.message, InfoBarSeverity.Error); + notificationService.ShowNotification(result.message, MessageType.Error); return; } @@ -89,7 +89,7 @@ internal partial class CreateProjectViewModel(StackedNotificationService notific } catch (System.Exception e) { - notificationService.ShowNotification($"Failed to load project: {e.Message}", InfoBarSeverity.Error); + notificationService.ShowNotification($"Failed to load project: {e.Message}", MessageType.Error); } } } \ No newline at end of file diff --git a/Ghost.InternalEditor/ViewModels/Pages/Landing/OpenProjectViewModel.cs b/Ghost.App/ViewModels/Pages/Landing/OpenProjectViewModel.cs similarity index 90% rename from Ghost.InternalEditor/ViewModels/Pages/Landing/OpenProjectViewModel.cs rename to Ghost.App/ViewModels/Pages/Landing/OpenProjectViewModel.cs index 6c4a68e..6a84951 100644 --- a/Ghost.InternalEditor/ViewModels/Pages/Landing/OpenProjectViewModel.cs +++ b/Ghost.App/ViewModels/Pages/Landing/OpenProjectViewModel.cs @@ -1,11 +1,11 @@ using CommunityToolkit.Mvvm.ComponentModel; using Ghost.App.Contracts; using Ghost.App.Infrastructures.AppState; -using Ghost.App.Services; using Ghost.Data.Models; using Ghost.Data.Services; +using Ghost.Editor.Models; +using Ghost.Editor.Services.Contracts; using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; using System; using System.Collections.ObjectModel; using System.Linq; @@ -15,7 +15,7 @@ using Windows.Storage; namespace Ghost.Editor.ViewModels.Pages.Landing; -internal partial class OpenProjectViewModel(ProjectService projectService, StackedNotificationService _notificationService, AppStateMachine _stateService) : ObservableObject, INavigationAware +internal partial class OpenProjectViewModel(ProjectService projectService, INotificationService _notificationService, AppStateMachine _stateService) : ObservableObject, INavigationAware { public readonly ObservableCollection projects = new(); @@ -86,7 +86,7 @@ internal partial class OpenProjectViewModel(ProjectService projectService, Stack errorMessage = "Unsupported data format. Please drop a folder containing a project."; } - _notificationService.ShowNotification(errorMessage, InfoBarSeverity.Error); + _notificationService.ShowNotification(errorMessage, MessageType.Error); CloseDropPanel: DragVisibility = Visibility.Collapsed; @@ -104,7 +104,7 @@ internal partial class OpenProjectViewModel(ProjectService projectService, Stack } catch (Exception e) { - _notificationService.ShowNotification($"Failed to load project: {e.Message}", InfoBarSeverity.Error); + _notificationService.ShowNotification($"Failed to load project: {e.Message}", MessageType.Error); } } } \ No newline at end of file diff --git a/Ghost.InternalEditor/ViewModels/Windows/EngineEditorViewModel.cs b/Ghost.App/ViewModels/Windows/EngineEditorViewModel.cs similarity index 100% rename from Ghost.InternalEditor/ViewModels/Windows/EngineEditorViewModel.cs rename to Ghost.App/ViewModels/Windows/EngineEditorViewModel.cs diff --git a/Ghost.InternalEditor/app.manifest b/Ghost.App/app.manifest similarity index 100% rename from Ghost.InternalEditor/app.manifest rename to Ghost.App/app.manifest diff --git a/Ghost.ArchetypeEntities/AssemblyInfo.cs b/Ghost.ArchetypeEntities/AssemblyInfo.cs deleted file mode 100644 index 744263a..0000000 --- a/Ghost.ArchetypeEntities/AssemblyInfo.cs +++ /dev/null @@ -1,7 +0,0 @@ -global using EntityID = System.UInt32; -global using GenerationID = System.UInt16; -global using WorldID = System.UInt16; - -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("Ghost.Engine")] \ No newline at end of file diff --git a/Ghost.ArchetypeEntities/Chunk.cs b/Ghost.ArchetypeEntities/Chunk.cs deleted file mode 100644 index 69e3efb..0000000 --- a/Ghost.ArchetypeEntities/Chunk.cs +++ /dev/null @@ -1,213 +0,0 @@ -using Misaki.HighPerformance.Unsafe.Collections; -using Misaki.HighPerformance.Unsafe.Helpers; -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace Ghost.Entities; - -internal unsafe struct ChunkCollection : IDisposable -{ - private UnsafeArray _chunkStorage; - private int _count; - private int _capacity; - - public readonly int Count => _count; - public readonly int Capacity => _capacity; - - public readonly ref Chunk this[int index] => ref _chunkStorage[index]; - - public ChunkCollection(int capacity) - { - _chunkStorage = new(capacity, Allocator.Persistent); - _count = 0; - _capacity = capacity; - } - - public void Add(Chunk chunk) - { - _chunkStorage[_count] = chunk; - _count++; - } - - public void EnsureCapacity(int newCapacity) - { - if (newCapacity <= _capacity) - { - return; - } - - _chunkStorage.Resize(newCapacity); - } - - public void TrimExcess() - { - if (_count == _capacity) - { - return; - } - - _chunkStorage.Resize(_count); - } - - public void Clear() - { - for (var i = 0; i < _count; i++) - { - _chunkStorage[i].Clear(); - } - - _count = 0; - _capacity = 0; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly Span AsSpan() - { - return _chunkStorage.AsSpan(); - } - - public void Dispose() - { - for (var i = 0; i < _count; i++) - { - _chunkStorage[i].Dispose(); - } - - _chunkStorage.Dispose(); - _count = 0; - _capacity = 0; - } -} - -internal struct Chunk : IDisposable -{ - public UnsafeArray entities; - public UnsafeArray> components; - - // The component lookup array is used to quickly find the index of a component in the components array. - // Mapping component ID to component index in the components array. - private UnsafeArray _componentLookup; - - private int _count; - private readonly int _capacity; - private bool _isDisposed; - - public readonly int Count => _count; - public readonly int Capacity => _capacity; - - public Chunk(int capacity, Span data) : this(capacity, data, Component.ToLookupArray(data, Allocator.Persistent)) - { - } - - public Chunk(int capacity, Span data, UnsafeArray lookup) - { - _count = 0; - _capacity = capacity; - - entities = new((int)capacity, Allocator.Persistent); - components = new(data.Length, Allocator.Persistent); - - _componentLookup = lookup; - - for (var i = 0; i < data.Length; i++) - { - var component = data[i]; - components[component.id] = new UnsafeArray(capacity * (int)component.sizeInByte, Allocator.Persistent); - } - } - - public int Add(Entity entity) - { - var index = _count; - entities[index] = entity; - _count++; - - return index; - } - - public unsafe bool Remove(int index) - { - if (index < 0 || index >= _count) - { - return false; - } - - var lastIndex = _count--; - entities[index] = entities[lastIndex]; - - for (var i = 0; i < components.Count; i++) - { - var componentArray = UnsafeUtilities.ReadArrayElementUnsafe>(components.GetUnsafePtr(), i); - var componentSize = componentArray->Count / _capacity; - var removedComponent = UnsafeUtilities.ReadArrayElementUnsafe(componentArray->GetUnsafePtr(), index * componentSize); - var lastComponent = UnsafeUtilities.ReadArrayElementUnsafe(componentArray->GetUnsafePtr(), lastIndex * componentSize); - MemoryUtilities.MemCpy(removedComponent, lastComponent, (nuint)componentSize); - } - - return true; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private readonly int IndexOf() - where T : unmanaged, IComponent - { - var id = Component.data.id; - Debug.Assert(id != -1 && id < _componentLookup.Count, $"Index is out of bounds, component {typeof(T)} with id {id} does not exist in this chunk."); - return _componentLookup[id]; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly bool Has() - where T : unmanaged, IComponent - { - var id = Component.data.id; - return id < _componentLookup.Count && _componentLookup[id] != -1; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly unsafe UnsafeArray GetArrayOf() - where T : unmanaged, IComponent - { - var index = IndexOf(); - var componentArray = components[index]; - return UnsafeUtilities.CastArray(componentArray); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly unsafe ref T GetComponent(int index) - where T : unmanaged, IComponent - { - var componentArray = GetArrayOf(); - return ref componentArray[index]; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public readonly Entity GetEntity(int index) - { - return entities[index]; - } - - public void Clear() - { - _count = 0; - } - - public void Dispose() - { - if (_isDisposed) - { - return; - } - - entities.Dispose(); - _componentLookup.Dispose(); - - for (var i = 0; i < components.Count; i++) - { - components[i].Dispose(); - } - components.Dispose(); - - _isDisposed = true; - } -} \ No newline at end of file diff --git a/Ghost.ArchetypeEntities/Component.cs b/Ghost.ArchetypeEntities/Component.cs deleted file mode 100644 index df7e333..0000000 --- a/Ghost.ArchetypeEntities/Component.cs +++ /dev/null @@ -1,116 +0,0 @@ -using Ghost.Entities.Helpers; -using Ghost.Entities.Registries; -using Misaki.HighPerformance.Unsafe.Collections; -using Misaki.HighPerformance.Unsafe.Helpers; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace Ghost.Entities; - -public interface IComponent -{ - -} - -[SkipLocalsInit] -internal readonly record struct ComponentData -{ - public readonly int id; - public readonly int sizeInByte; - - public ComponentData(int id, int sizeInByte) - { - this.id = id; - this.sizeInByte = sizeInByte; - } -} - -internal static class Component -{ - internal static int GetTotalSize(in Span datas) - { - var size = 0; - foreach (var type in datas) - { - var typeSize = type.sizeInByte; - typeSize = typeSize != 1 ? typeSize : 0; // Ignore tag components - size += typeSize; - } - - return size; - } - - internal static unsafe UnsafeArray ToLookupArray(in Span datas, Allocator allocator) - { - var max = 0; - foreach (var data in datas) - { - var componentId = data.id; - if (componentId >= max) - { - max = componentId; - } - } - - // Create lookup table where the component ID points to the component index. - var array = new UnsafeArray(max + 1, allocator); - array.AsSpan().Fill(-1); - - for (var index = 0; index < datas.Length; index++) - { - ref var type = ref datas[index]; - var componentId = type.id; - array[componentId] = index; - } - - return array; - } - - internal static int GetHashCode(Span components) - { - // Search for the highest id to determine how much uints we need for the stack. - var highestId = 0; - foreach (ref var cmp in components) - { - if (cmp.id > highestId) - { - highestId = cmp.id; - } - } - - // Allocate the stack and set bits to replicate a bitset - var length = BitSet.RequiredLength(highestId + 1); - Span stack = stackalloc uint[length]; - var spanBitSet = new SpanBitSet(stack); - - foreach (ref var type in components) - { - var x = type.id; - spanBitSet.SetBit(x); - } - - return GetHashCode(stack); - } - - public static int GetHashCode(Span span) - { - var hashCode = new HashCode(); - hashCode.AddBytes(MemoryMarshal.AsBytes(span)); - - return hashCode.ToHashCode(); - } -} - -internal static class Component - where T : unmanaged, IComponent -{ - public static readonly ComponentData data; - - public static readonly Signature signature; - - static Component() - { - data = ComponentRegistry.GetOrAdd(); - signature = new Signature(data); - } -} diff --git a/Ghost.ArchetypeEntities/Core/Archetype.Edge.cs b/Ghost.ArchetypeEntities/Core/Archetype.Edge.cs deleted file mode 100644 index e1fdb64..0000000 --- a/Ghost.ArchetypeEntities/Core/Archetype.Edge.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Misaki.HighPerformance.Unsafe.Collections; - -namespace Ghost.Entities.Core; -internal partial struct Archetype : IEquatable -{ - public void AddInsertionEdge(Archetype archetype) - { - if (_insertionEdges.IsCreated) - { - _insertionEdges = new UnsafeHashSet(_BUCKET_SIZE, Allocator.Persistent); - } - _insertionEdges.Add(archetype); - } - - public readonly bool Equals(Archetype other) - { - return signature.Equals(other.signature); - } -} \ No newline at end of file diff --git a/Ghost.ArchetypeEntities/Core/Archetype.cs b/Ghost.ArchetypeEntities/Core/Archetype.cs deleted file mode 100644 index 1f59519..0000000 --- a/Ghost.ArchetypeEntities/Core/Archetype.cs +++ /dev/null @@ -1,76 +0,0 @@ -using Ghost.Entities.Helpers; -using Misaki.HighPerformance.Unsafe.Collections; -using Misaki.HighPerformance.Unsafe.Helpers; - -namespace Ghost.Entities.Core; - -internal partial struct Archetype : IDisposable -{ - private const int _BUCKET_SIZE = 16; - - // The component ID to array index lookup array. - private UnsafeArray _lookupArray; - - public readonly int sizeOfBaseChunk; - public readonly int sizeOfChunk; - - public readonly int entitiesPerChunk; - public int totalEntityCount; - - public Signature signature; - // For fast lookups - public BitSet bitSet; - public ChunkCollection chunks; - - - private UnsafeHashSet _insertionEdges; - private UnsafeHashSet _deletionEdges; - - public readonly UnsafeArray LookupArray => _lookupArray; - - internal Archetype(Signature signature, int sizeOfBaseChunk, int minimalEntityCountPerChunk) - { - this.signature = signature; - this.sizeOfBaseChunk = sizeOfBaseChunk; - - var sizeOfTotalData = Component.GetTotalSize(signature.componentDatas.AsSpan()); - sizeOfChunk = GetSizeOfChunk(sizeOfBaseChunk, minimalEntityCountPerChunk, sizeOfTotalData); - entitiesPerChunk = GetEntityCount(sizeOfChunk, sizeOfTotalData); - - _lookupArray = Component.ToLookupArray(signature.componentDatas.AsSpan(), Allocator.Persistent); - bitSet = new BitSet(); - for (var i = 0; i < signature.componentDatas.Count; i++) - { - bitSet.SetBit(signature.componentDatas[i].id); - } - - chunks = new ChunkCollection(1); - AddNewChunk(); - } - - private unsafe static int GetEntityCount(int sizeOfChunk, int sizeOfTotalData) - { - return sizeOfChunk / (sizeof(Entity) + sizeOfTotalData); - } - - private static unsafe int GetSizeOfChunk(int sizeOfBaseChunk, int entityCount, int sizeOfTotalData) - { - var entityBytes = (sizeof(Entity) + sizeOfTotalData) * entityCount; - return (int)Math.Ceiling((float)entityBytes / sizeOfBaseChunk) * sizeOfBaseChunk; // Calculates and rounds to a multiple of BaseSize to store the number of entities - } - - public ref Chunk AddNewChunk() - { - chunks.EnsureCapacity(chunks.Count + 1); - chunks.Add(new Chunk(entitiesPerChunk, signature.componentDatas.AsSpan(), _lookupArray)); - return ref chunks[^1]; - } - - public void Dispose() - { - _lookupArray.Dispose(); - signature.Dispose(); - bitSet.Dispose(); - chunks.Dispose(); - } -} diff --git a/Ghost.ArchetypeEntities/Core/Slot.cs b/Ghost.ArchetypeEntities/Core/Slot.cs deleted file mode 100644 index cfc2411..0000000 --- a/Ghost.ArchetypeEntities/Core/Slot.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace Ghost.Entities.Core; - -/// -/// The struct references an entry within an using a reference to its and its index. -/// -[SkipLocalsInit] -internal record struct Slot -{ - /// - /// The index of the in the . - /// - public int index; - - /// - /// The index of the in which the is located. - /// - public int chunkIndex; - - /// - /// Initializes a new instance of the struct. - /// - /// The index of the in the . - /// The index of the in which the is located. - public Slot(int index, int chunkIndex) - { - this.index = index; - this.chunkIndex = chunkIndex; - } - - /// - /// Adds a plus operator for easy calculation of new . Adds the positions of both s. - /// - /// The first . - /// The second . - /// The result . - public static Slot operator +(Slot first, Slot second) - { - return new Slot(first.index + second.index, first.chunkIndex + second.chunkIndex); - } - - /// - /// Adds a plus plus operator for easy calculation of new . Increases the index by one. - /// - /// The . - /// The with index increased by one.. - public static Slot operator ++(Slot slot) - { - slot.index++; - return slot; - } - - /// - /// Validates the , moves the if it is outside a to match it. - /// - /// - public void Wrap(int capacity) - { - // Result outside valid chunk, wrap into next one - if (index < capacity) - { - return; - } - - // Index outside of its chunk, so we calculate how many times a chunk fit into the index for adjusting the chunkindex to that position. - // Floor since we do not need a rounded value since the index is within that chunk and not the next one. - chunkIndex += (int)Math.Floor(index / (float)capacity); - - // After moving the chunk index we can simply take the rest and assign it as a index. - index %= capacity; - } - - /// - /// Moves or shifts this by one slot forward. - /// Ensures that the slots chunkindex updated properly once the end was reached. - /// - /// The to shift by one. - /// The capacity of the chunk the slot is in. - /// - public static Slot Shift(ref Slot source, int sourceCapacity) - { - source.index++; - source.Wrap(sourceCapacity); - return source; - } - - /// - /// Moves or shifts the source based on the destination and calculates its new position. - /// Used for copy operations to predict where the source will end up. - /// - /// The source , from which we want to calculate where it lands.. - /// The destination , a reference point at which the copy or shift operation starts. - /// The source . - /// The destination - public static Slot Shift(in Slot source, int sourceCapacity, in Slot destination, int destinationCapacity) - { - var freeSpot = destination; - var resultSlot = source + freeSpot; - resultSlot.index += source.chunkIndex * (sourceCapacity - destinationCapacity); - resultSlot.Wrap(destinationCapacity); - - return resultSlot; - } -} \ No newline at end of file diff --git a/Ghost.ArchetypeEntities/Entity.cs b/Ghost.ArchetypeEntities/Entity.cs deleted file mode 100644 index f111698..0000000 --- a/Ghost.ArchetypeEntities/Entity.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace Ghost.Entities; - -[SkipLocalsInit] -public struct Entity : IEquatable, IComparable -{ - private const EntityID _WORLD_INDEX_BITS = 4u; - private const EntityID _GENERATION_BITS = 8u; - private const EntityID _INDEX_BITS = sizeof(EntityID) * 8 - _WORLD_INDEX_BITS - _GENERATION_BITS; - - private const EntityID _WORLD_INDEX_MASK = (1u << (int)_WORLD_INDEX_BITS) - 1; - private const EntityID _GENERATION_MASK = (1u << (int)_GENERATION_BITS) - 1; - private const EntityID _INDEX_MASK = (1u << (int)_INDEX_BITS) - 1; - private const EntityID _ID_MASK = EntityID.MaxValue; - - private EntityID _id; - - public readonly bool IsValid - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => _id != _ID_MASK; - } - - public readonly EntityID Index - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => _id & _INDEX_MASK; - } - - public readonly GenerationID Generation - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => (GenerationID)(_id >> (int)_INDEX_BITS & _GENERATION_MASK); - } - - public readonly WorldID WorldIndex - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => (WorldID)(_id >> (int)(_INDEX_BITS + _GENERATION_BITS) & _WORLD_INDEX_MASK); - } - - public void IncrementGeneration() - { - var generation = Generation + 1u; - if (generation >= _GENERATION_MASK) - { - throw new InvalidOperationException("Generation overflow"); - } - - _id = _id & ~(_GENERATION_MASK << (int)_INDEX_BITS) | generation << (int)_INDEX_BITS; - } - - internal Entity(EntityID index, EntityID generation, EntityID worldIndex) - { - _id = worldIndex << (int)(_INDEX_BITS + _GENERATION_BITS) | generation << (int)_INDEX_BITS | index; - } - - public readonly bool Equals(Entity other) - { - return _id == other._id; - } - - public readonly int CompareTo(Entity other) - { - return _id.CompareTo(other._id); - } - - public override readonly bool Equals(object? obj) - { - return obj is Entity other && Equals(other); - } - - public override readonly int GetHashCode() - { - return _id.GetHashCode(); - } - - public static bool operator ==(Entity left, Entity right) - { - return left.Equals(right); - } - - public static bool operator !=(Entity left, Entity right) - { - return !(left == right); - } - - public override readonly string ToString() - { - return $"Entity {{ Index: {Index}, Generation: {Generation}, WorldIndex: {WorldIndex} }}"; - } -} \ No newline at end of file diff --git a/Ghost.ArchetypeEntities/Ghost.Entities.csproj b/Ghost.ArchetypeEntities/Ghost.Entities.csproj deleted file mode 100644 index f7d47f5..0000000 --- a/Ghost.ArchetypeEntities/Ghost.Entities.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - net9.0 - enable - enable - True - - - - True - - - - True - - - - - ..\..\Class\Misaki.HighPerformance\Misaki.HighPerformance.Unsafe\bin\Release\net9.0\Misaki.HighPerformance.Unsafe.dll - - - - diff --git a/Ghost.ArchetypeEntities/Helpers/BitSet.cs b/Ghost.ArchetypeEntities/Helpers/BitSet.cs deleted file mode 100644 index 0281228..0000000 --- a/Ghost.ArchetypeEntities/Helpers/BitSet.cs +++ /dev/null @@ -1,604 +0,0 @@ -// Code from https://github.com/genaray/Arch/blob/master/src/Arch/Core/Utils/BitSet.cs - -using Misaki.HighPerformance.Unsafe.Collections; -using Misaki.HighPerformance.Unsafe.Helpers; -using System.Numerics; -using System.Runtime.CompilerServices; -using System.Text; - -namespace Ghost.Entities.Helpers; - -// NOTE: Can this be replaced with `System.Collections.BitArray`? -// NOTE: If not, can it at least mirror that type's API? -/// -/// The class -/// represents a resizable collection of bits. -/// -public struct BitSet : IDisposable -{ - private const int _BIT_SIZE = (sizeof(uint) * 8) - 1; // 31 - private const int _INDEX_SIZE = 5; // log_2(BitSize + 1) - - private static readonly int _padding = Vector.Count; // The padding used for vectorisation, the amount of uints required for being vectorized basically - - /// - /// Determines the required length of an to hold the passed id or bit. - /// - /// The id or bit. - /// A size of required s for the bitset. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int RequiredLength(int id) - { - return (id >> 5) + int.Sign(id & _BIT_SIZE); - } - - /// - /// The bits from the bitset. - /// - private UnsafeArray _bits; - - /// TODO: Update on ClearBit, however clearbit is only used in tests so its fine for now. - /// - /// The highest bit set. - /// - private int _highestBit; - - /// TODO: Update on ClearBit, probably remove in favor? - /// - /// The maximum -index current in use. - /// - private int _max; - - /// - /// Initializes a new instance of the class. - /// - public BitSet() - { - _bits = new UnsafeArray(_padding, Allocator.Persistent); - } - - /// - /// Initializes a new instance of the class. - /// - public BitSet(params Span bits) - { - _bits = new UnsafeArray(bits.Length, Allocator.Persistent); - _bits.CopyFrom(bits); - } - - /// - /// The highest uint index in use inside the -array. - /// - public readonly int HighestIndex - { - get => _max; - } - - /// - /// The highest bit set. - /// - public readonly int HighestBit - { - get => _highestBit; - } - - /// - /// Returns the length of the bitset, how many int's it consists of. - /// - public readonly int Count - { - get => _bits.Count; - } - - /// - /// Checks whether a bit is set at the index. - /// - /// The index. - /// True if it is, otherwise false - public readonly bool IsSet(int index) - { - var b = index >> _INDEX_SIZE; - if (b >= _bits.Count) - { - return false; - } - - return (_bits[b] & (1 << (index & _BIT_SIZE))) != 0; - } - - /// - /// Sets a bit at the given index. - /// Resizes its internal array if necessary. - /// - /// The index. - public void SetBit(int index) - { - var b = index >> _INDEX_SIZE; - if (b >= _bits.Count) - { - _bits.Resize((b + _padding) / _padding * _padding); // Round up to a multiply of Padding - } - - // Track highest set bit - _highestBit = Math.Max(_highestBit, index); - _max = (_highestBit / (_BIT_SIZE + 1)) + 1; - _bits[b] |= 1u << (index & _BIT_SIZE); - } - - /// - /// Clears the bit at the given index. - /// - /// The index. - public readonly void ClearBit(int index) - { - var b = index >> _INDEX_SIZE; - if (b >= _bits.Count) - { - return; - } - - _bits[b] &= ~(1u << (index & _BIT_SIZE)); - } - - /// - /// Sets all bits. - /// - public void SetAll() - { - var count = _bits.Count; - for (var i = 0; i < count; i++) - { - _bits[i] = 0xffffffff; - } - - _highestBit = (_bits.Count * (_BIT_SIZE + 1)) - 1; - _max = (_highestBit / (_BIT_SIZE + 1)) + 1; - } - - /// - /// Clears all set bits. - /// - public readonly void ClearAll() - { - _bits.Clear(); - } - - /// - /// Checks if all bits from this instance match those of the other instance. - /// - /// The other . - /// True if they match, false if not. - [SkipLocalsInit] - public readonly bool All(BitSet other) - { - var min = Math.Min(Math.Min(Count, other.Count), _max); - if (!Vector.IsHardwareAccelerated || min < _padding) - { - // Bitwise and - for (var i = 0; i < min; i++) - { - var bit = _bits[i]; - if ((bit & other._bits[i]) != bit) - { - return false; - } - } - - // Handle extra bits on our side that might just be all zero. - for (var i = min; i < _max; i++) - { - if (_bits[i] != 0) - { - return false; - } - } - } - else - { - // Vectorized bitwise and - for (var i = 0; i < min; i += _padding) - { - var vector = new Vector(_bits.AsSpan()[i..]); - var otherVector = new Vector(other._bits.AsSpan()[i..]); - - var resultVector = Vector.BitwiseAnd(vector, otherVector); - if (!Vector.EqualsAll(resultVector, vector)) - { - return false; - } - } - - // Handle extra bits on our side that might just be all zero. - for (var i = min; i < _max; i += _padding) - { - var vector = new Vector(_bits.AsSpan()[i..]); - if (!Vector.EqualsAll(vector, Vector.Zero)) // Vectors are not zero bits[0] != 0 basically - { - return false; - } - } - } - - return true; - } - - /// - /// Checks if any bits from this instance match those of the other instance. - /// - /// The other . - /// True if they match, false if not. - public readonly bool Any(BitSet other) - { - var min = Math.Min(Math.Min(Count, other.Count), _max); - if (!Vector.IsHardwareAccelerated || min < _padding) - { - var bits = _bits.AsSpan(); - var otherBits = other._bits.AsSpan(); - - // Bitwise and, return true since any is met - for (var i = 0; i < min; i++) - { - var bit = bits[i]; - if ((bit & otherBits[i]) > 0) - { - return true; - } - } - - // Handle extra bits on our side that might just be all zero. - for (var i = min; i < _max; i++) - { - if (bits[i] > 0) - { - return false; - } - } - } - else - { - // Vectorized bitwise and, return true since any is met - for (var i = 0; i < min; i += _padding) - { - var vector = new Vector(_bits.AsSpan()[i..]); - var otherVector = new Vector(other._bits.AsSpan()[i..]); - - var resultVector = Vector.BitwiseAnd(vector, otherVector); - if (!Vector.EqualsAll(resultVector, Vector.Zero)) - { - return true; - } - } - - // Handle extra bits on our side that might just be all zero. - for (var i = min; i < _max; i += _padding) - { - var vector = new Vector(_bits.AsSpan()[i..]); - if (!Vector.EqualsAll(vector, Vector.Zero)) // Vectors are not zero bits[0] != 0 basically - { - return false; - } - } - } - - return _highestBit <= 0; - } - - /// - /// Checks if none bits from this instance match those of the other instance. - /// - /// The other . - /// True if none match, false if not. - public readonly bool None(BitSet other) - { - var min = Math.Min(Math.Min(Count, other.Count), _max); - if (!Vector.IsHardwareAccelerated || min < _padding) - { - var bits = _bits.AsSpan(); - var otherBits = other._bits.AsSpan(); - - // Bitwise and, return true since any is met - for (var i = 0; i < min; i++) - { - var bit = bits[i]; - if ((bit & otherBits[i]) != 0) - { - return false; - } - } - } - else - { - // Vectorized bitwise and, return true since any is met - for (var i = 0; i < min; i += _padding) - { - var vector = new Vector(_bits.AsSpan()[i..]); - var otherVector = new Vector(other._bits.AsSpan()[i..]); - - var resultVector = Vector.BitwiseAnd(vector, otherVector); - if (!Vector.EqualsAll(resultVector, Vector.Zero)) - { - return false; - } - } - } - - return true; - } - - /// - /// Checks if exactly all bits from this instance match those of the other instance. - /// - /// The other . - /// True if they match, false if not. - public readonly bool Exclusive(BitSet other) - { - var min = Math.Min(Math.Min(Count, other.Count), _max); - - if (!Vector.IsHardwareAccelerated || min < _padding) - { - var bits = _bits.AsSpan(); - var otherBits = other._bits.AsSpan(); - - // Bitwise xor, if both are not totally equal, return false - for (var i = 0; i < min; i++) - { - var bit = bits[i]; - if ((bit ^ otherBits[i]) != 0) - { - return false; - } - } - - // handle extra bits on our side that might just be all zero - for (var i = min; i < _max; i++) - { - if (bits[i] != 0) - { - return false; - } - } - } - else - { - // Vectorized bitwise xor, return true since any is met - for (var i = 0; i < min; i += _padding) - { - var vector = new Vector(_bits.AsSpan()[i..]); - var otherVector = new Vector(other._bits.AsSpan()[i..]); - - var resultVector = Vector.Xor(vector, otherVector); - if (!Vector.EqualsAll(resultVector, Vector.Zero)) - { - return false; - } - } - - // Handle extra bits on our side that might just be all zero. - for (var i = min; i < _max; i += _padding) - { - var vector = new Vector(_bits.AsSpan()[i..]); - if (!Vector.EqualsAll(vector, Vector.Zero)) // Vectors are not zero bits[0] != 0 basically - { - return false; - } - } - } - - return true; - } - - /// - /// Creates a to access the . - /// - /// The hash. - public readonly Span AsSpan() - { - var max = (_highestBit / (_BIT_SIZE + 1)) + 1; - return _bits.AsSpan()[0..max]; - } - - /// - /// Copies the bits into a and returns a slice containing the copied . - /// - /// The to copy into. - /// If true, it will zero the unused space from the . - /// The . - public readonly Span AsSpan(Span span, bool zero = true) - { - // Copy everything that's possible from one to another - var length = Math.Min(Count, span.Length); - for (var index = 0; index < length; index++) - { - span[index] = _bits[index]; - } - - // Zero the rest space which was not overriden due to the copy. - for (var index = length; zero && index < span.Length; index++) - { - span[index] = 0; - } - - return span[0..length]; - } - - /// - /// Calculates the hash, this is unique for the set bits. Two with the same set bits, result in the same hash. - /// - /// The hash. - public readonly override int GetHashCode() - { - return Component.GetHashCode(AsSpan()); - } - - /// - /// Prints the content of this instance. - /// - /// The string. - public readonly override string ToString() - { - // Convert uint to binary form for pretty printing - var binaryBuilder = new StringBuilder(); - foreach (var bit in _bits) - { - binaryBuilder.Append(Convert.ToString((uint)bit, 2).PadLeft(32, '0')).Append(','); - } - binaryBuilder.Length--; - - return $"{nameof(_bits)}: {binaryBuilder}, {nameof(Count)}: {Count}"; - } - - public void Dispose() - { - _bits.Dispose(); - } -} - -/// -/// The struct -/// represents a non resizable collection of bits. -/// Used to set, check and clear bits on a allocated or on the stack. -/// -public readonly ref struct SpanBitSet -{ - private const int _BIT_SIZE = (sizeof(uint) * 8) - 1; // 31 - // NOTE: Is a byte not 8 bits? - private const int _BYTE_SIZE = 5; // log_2(BitSize + 1) - - /// - /// The bits from the bitset. - /// - private readonly Span _bits; - - /// - /// Initializes a new instance of the class. - /// - public SpanBitSet(Span bits) - { - _bits = bits; - } - - /// - /// Checks whether a bit is set at the index. - /// - /// The index. - /// True if it is, otherwise false - public bool IsSet(int index) - { - var b = index >> _BYTE_SIZE; - if (b >= _bits.Length) - { - return false; - } - - return (_bits[b] & (1 << (index & _BIT_SIZE))) != 0; - } - - /// - /// Sets a bit at the given index. - /// Resizes its internal array if necessary. - /// - /// The index. - public void SetBit(int index) - { - var b = index >> _BYTE_SIZE; - if (b >= _bits.Length) - { - return; - } - - _bits[b] |= 1u << (index & _BIT_SIZE); - } - - /// - /// Clears the bit at the given index. - /// - /// The index. - public void ClearBit(int index) - { - var b = index >> _BYTE_SIZE; - if (b >= _bits.Length) - { - return; - } - - _bits[b] &= ~(1u << (index & _BIT_SIZE)); - } - - /// - /// Sets all bits. - /// - public void SetAll() - { - var count = _bits.Length; - for (var i = 0; i < count; i++) - { - _bits[i] = 0xffffffff; - } - } - - /// - /// Clears all set bits. - /// - public void ClearAll() - { - _bits.Clear(); - } - - /// - /// Creates a to access the . - /// - /// The hash. - public Span AsSpan() - { - return _bits; - } - - /// - /// Copies the bits into a and returns a slice containing the copied . - /// - /// - /// The hash. - public Span AsSpan(Span span, bool zero = true) - { - // Prevent exception because target array is to small for copy operation - var length = Math.Min(this._bits.Length, span.Length); - for (var index = 0; index < length; index++) - { - span[index] = _bits[index]; - } - - // Zero the rest space which was not overriden due to the copy. - for (var index = length; zero && index < span.Length; index++) - { - span[index] = 0; - } - - return span[.._bits.Length]; - } - - /// - /// Calculates the hash, this is unique for the set bits. Two with the same set bits, result in the same hash. - /// - /// The hash. - public override int GetHashCode() - { - return Component.GetHashCode(AsSpan()); - } - - /// - /// Prints the content of this instance. - /// - /// The string. - public override string ToString() - { - // Convert uint to binary form for pretty printing - var binaryBuilder = new StringBuilder(); - foreach (var bit in _bits) - { - binaryBuilder.Append(Convert.ToString((uint)bit, 2).PadLeft(32, '0')).Append(','); - } - binaryBuilder.Length--; - - return $"{nameof(_bits)}: {string.Join(",", binaryBuilder)}"; - } -} diff --git a/Ghost.ArchetypeEntities/Helpers/ThreadLocker.cs b/Ghost.ArchetypeEntities/Helpers/ThreadLocker.cs deleted file mode 100644 index 1128981..0000000 --- a/Ghost.ArchetypeEntities/Helpers/ThreadLocker.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Ghost.Entities.Helpers; - -internal static class ThreadLocker -{ - private static Lock? _worldLock; - public static Lock WorldLock => _worldLock ??= new(); -} \ No newline at end of file diff --git a/Ghost.ArchetypeEntities/Registries/ComponentRegistry.cs b/Ghost.ArchetypeEntities/Registries/ComponentRegistry.cs deleted file mode 100644 index 91ef809..0000000 --- a/Ghost.ArchetypeEntities/Registries/ComponentRegistry.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Ghost.Entities.Registries; - -internal static class ComponentRegistry -{ - private static readonly Dictionary _hashCodeToComponentMap = new(64); - - public static unsafe ComponentData GetOrAdd() - where T : unmanaged, IComponent - { - var type = typeof(T); - if (_hashCodeToComponentMap.TryGetValue(type, out var data)) - { - return data; - } - - var id = (ushort)_hashCodeToComponentMap.Count; - data = new ComponentData(id, sizeof(T)); - _hashCodeToComponentMap.Add(type, data); - - return data; - } -} \ No newline at end of file diff --git a/Ghost.ArchetypeEntities/Services/EntityChangeQueue.cs b/Ghost.ArchetypeEntities/Services/EntityChangeQueue.cs deleted file mode 100644 index 8782f84..0000000 --- a/Ghost.ArchetypeEntities/Services/EntityChangeQueue.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Ghost.Entities.Services; - -internal class EntityChangeQueue -{ - // TODO: This class is not implemented yet. -} \ No newline at end of file diff --git a/Ghost.ArchetypeEntities/Signature.cs b/Ghost.ArchetypeEntities/Signature.cs deleted file mode 100644 index c909e2d..0000000 --- a/Ghost.ArchetypeEntities/Signature.cs +++ /dev/null @@ -1,53 +0,0 @@ -using Misaki.HighPerformance.Unsafe.Collections; -using Misaki.HighPerformance.Unsafe.Helpers; - -namespace Ghost.Entities; - -internal struct Signature : IDisposable, IEquatable -{ - public UnsafeArray componentDatas; - private int _hashCode; - - public Signature(params Span components) - { - componentDatas = new UnsafeArray(components.Length, Allocator.Persistent); - componentDatas.CopyFrom(components); - - _hashCode = -1; - _hashCode = GetHashCode(); - } - - public bool Equals(Signature other) - { - return GetHashCode() == other.GetHashCode(); - } - - public override bool Equals(object? obj) - { - if (obj is Signature other) - { - return Equals(other); - } - - return false; - } - - public override int GetHashCode() - { - if (_hashCode != -1) - { - return _hashCode; - } - - unchecked - { - _hashCode = Component.GetHashCode(componentDatas.AsSpan()); - return _hashCode; - } - } - - public void Dispose() - { - componentDatas.Dispose(); - } -} diff --git a/Ghost.Data/Repository/AssetsRepository.cs b/Ghost.Data/Repository/AssetsRepository.cs new file mode 100644 index 0000000..18c3dc4 --- /dev/null +++ b/Ghost.Data/Repository/AssetsRepository.cs @@ -0,0 +1,6 @@ +namespace Ghost.Data.Repository; + +internal class AssetsRepository +{ + +} diff --git a/Ghost.Editor/AssetHandle/AssetDatabase.cs b/Ghost.Editor/AssetHandle/AssetDatabase.cs new file mode 100644 index 0000000..846a4b5 --- /dev/null +++ b/Ghost.Editor/AssetHandle/AssetDatabase.cs @@ -0,0 +1,83 @@ +using System.Diagnostics; +using System.Reflection; + +namespace Ghost.Editor.AssetHandle; + +public static class AssetDatabase +{ + private static readonly Dictionary> _assetOpenHandlers = new(StringComparer.OrdinalIgnoreCase); + private static readonly Dictionary> _asyncAssetOpenHandler = new(StringComparer.OrdinalIgnoreCase); + + static AssetDatabase() + { + RegisterAssetHandles(); + } + + private static void RegisterAssetHandles() + { + var methods = AppDomain.CurrentDomain.GetAssemblies() + .SelectMany(a => a.GetTypes()) + .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) + .Where(m => m.GetCustomAttribute() != null && + m.GetParameters().Length == 1 && + m.GetParameters()[0].ParameterType == typeof(string)); + + foreach (var method in methods) + { + var attr = method.GetCustomAttribute()!; + var del = (Action)Delegate.CreateDelegate(typeof(Action), method); + foreach (var ext in attr.Extensions) + { + if (_assetOpenHandlers.ContainsKey(ext)) + { + throw new InvalidOperationException($"Duplicate handler for extension '{ext}'"); + } + + _assetOpenHandlers[ext] = del; + } + } + + var asyncMethods = AppDomain.CurrentDomain.GetAssemblies() + .SelectMany(a => a.GetTypes()) + .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) + .Where(m => m.GetCustomAttribute() != null && + m.GetParameters().Length == 1 && + m.GetParameters()[0].ParameterType == typeof(string) && + m.ReturnType == typeof(Task)); + + foreach (var method in asyncMethods) + { + var attr = method.GetCustomAttribute()!; + var del = (Func)Delegate.CreateDelegate(typeof(Func), method); + foreach (var ext in attr.Extensions) + { + if (_asyncAssetOpenHandler.ContainsKey(ext)) + { + throw new InvalidOperationException($"Duplicate async handler for extension '{ext}'"); + } + _asyncAssetOpenHandler[ext] = del; + } + } + } + + public static async ValueTask OpenAsset(string path) + { + var extension = Path.GetExtension(path); + if (_assetOpenHandlers.TryGetValue(extension, out var handler)) + { + handler(path); + } + else if (_asyncAssetOpenHandler.TryGetValue(extension, out var asyncHandler)) + { + await asyncHandler(path); + } + else + { + Process.Start(new ProcessStartInfo(path) + { + UseShellExecute = true + }); + } + + } +} \ No newline at end of file diff --git a/Ghost.Editor/AssetHandle/AssetOpenHandlerAttribute .cs b/Ghost.Editor/AssetHandle/AssetOpenHandlerAttribute .cs new file mode 100644 index 0000000..084b565 --- /dev/null +++ b/Ghost.Editor/AssetHandle/AssetOpenHandlerAttribute .cs @@ -0,0 +1,29 @@ +namespace Ghost.Editor.AssetHandle; + +[AttributeUsage(AttributeTargets.Method)] +public class AssetOpenHandlerAttribute : Attribute +{ + public string[] Extensions + { + get; + } + + public AssetOpenHandlerAttribute(params string[] extensions) + { + Extensions = extensions.Select(e => e.StartsWith(".") ? e.ToLowerInvariant() : "." + e.ToLowerInvariant()).ToArray(); + } +} + +[AttributeUsage(AttributeTargets.Method)] +public class AsyncAssetOpenHandlerAttribute : Attribute +{ + public string[] Extensions + { + get; + } + + public AsyncAssetOpenHandlerAttribute(params string[] extensions) + { + Extensions = extensions.Select(e => e.StartsWith(".") ? e.ToLowerInvariant() : "." + e.ToLowerInvariant()).ToArray(); + } +} \ No newline at end of file diff --git a/Ghost.Editor/Contracts/IInspectable.cs b/Ghost.Editor/Contracts/IInspectable.cs new file mode 100644 index 0000000..87499fe --- /dev/null +++ b/Ghost.Editor/Contracts/IInspectable.cs @@ -0,0 +1,7 @@ +using Microsoft.UI.Xaml; + +namespace Ghost.Editor.Contracts; +internal interface IInspectable +{ + public UIElement OnInspectorDraw(); +} \ No newline at end of file diff --git a/Ghost.Editor/EditorApplication.cs b/Ghost.Editor/EditorApplication.cs new file mode 100644 index 0000000..54c8ca0 --- /dev/null +++ b/Ghost.Editor/EditorApplication.cs @@ -0,0 +1,29 @@ +namespace Ghost.Editor; + +public static class EditorApplication +{ + private static IServiceProvider? _serviceProvider; + + public static bool IsInitialized => _serviceProvider != null; + + internal static void Activate(object? parameters, IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + + + public static T GetService() where T : class + { + if (!IsInitialized) + { + throw new InvalidOperationException("EditorApplication is not initialized."); + } + + if (_serviceProvider!.GetService(typeof(T)) is not T service) + { + throw new ArgumentException($"{typeof(T)} needs to be registered in the service provider."); + } + + return service; + } +} \ No newline at end of file diff --git a/Ghost.Editor/Ghost.Editor.csproj b/Ghost.Editor/Ghost.Editor.csproj index 6187cec..a666739 100644 --- a/Ghost.Editor/Ghost.Editor.csproj +++ b/Ghost.Editor/Ghost.Editor.csproj @@ -1,24 +1,23 @@ - - + - net9.0 + net9.0-windows10.0.22621.0 + 10.0.17763.0 + Ghost.Editor + win-x86;win-x64;win-arm64 + true enable - enable preview + enable + 10.0.20348.0 - + + - + - - - - ..\..\Class\Misaki.HighPerformance\Misaki.HighPerformance.Unsafe\bin\Release\net9.0\Misaki.HighPerformance.Unsafe.dll - - - - + + \ No newline at end of file diff --git a/Ghost.Editor/Models/Asset.cs b/Ghost.Editor/Models/Asset.cs new file mode 100644 index 0000000..a49a2f6 --- /dev/null +++ b/Ghost.Editor/Models/Asset.cs @@ -0,0 +1,24 @@ +namespace Ghost.Editor.Models; + +public abstract class Asset +{ + /// + /// Get the Guid of the asset. + /// + public Guid GUID + { + get; + } = Guid.NewGuid(); + + /// + /// True if the asset is a folder, false if it is a file. + /// + public bool IsFolder + { + get; + } + + internal void GenerateMetadata() + { + } +} \ No newline at end of file diff --git a/Ghost.Editor/Models/MessageType.cs b/Ghost.Editor/Models/MessageType.cs new file mode 100644 index 0000000..c559200 --- /dev/null +++ b/Ghost.Editor/Models/MessageType.cs @@ -0,0 +1,9 @@ +namespace Ghost.Editor.Models; + +public enum MessageType +{ + Informational, + Success, + Warning, + Error +} \ No newline at end of file diff --git a/Ghost.Editor/Models/WorldAsset.cs b/Ghost.Editor/Models/WorldAsset.cs new file mode 100644 index 0000000..d601f04 --- /dev/null +++ b/Ghost.Editor/Models/WorldAsset.cs @@ -0,0 +1,14 @@ +using Ghost.Editor.AssetHandle; +using Ghost.Editor.Resources; +using Ghost.Editor.SceneGraph; + +namespace Ghost.Editor.Models; + +public class WorldAsset : Asset +{ + [AsyncAssetOpenHandler(FileExtensions.SCENE_FILE_EXTENSION)] + public static async Task Open(string path) + { + await EditorWorldManager.LoadWorld(path); + } +} \ No newline at end of file diff --git a/Ghost.Editor/Resources/FileExtensions.cs b/Ghost.Editor/Resources/FileExtensions.cs new file mode 100644 index 0000000..9b38981 --- /dev/null +++ b/Ghost.Editor/Resources/FileExtensions.cs @@ -0,0 +1,11 @@ +namespace Ghost.Editor.Resources; + +internal static class FileExtensions +{ + public const string PROJECT_FILE_EXTENSION = ".ghostproj"; + public const string TEMPLATE_FILE_EXTENSION = ".ghosttemplate"; + public const string SCENE_FILE_EXTENSION = ".ghostscene"; + public const string ASSET_FILE_EXTENSION = ".ghostasset"; + public const string SHADER_FILE_EXTENSION = ".ghostshader"; + public const string MATERIAL_FILE_EXTENSION = ".ghostmaterial"; +} \ No newline at end of file diff --git a/Ghost.Editor/SceneGraph/EditorWorldManager.cs b/Ghost.Editor/SceneGraph/EditorWorldManager.cs new file mode 100644 index 0000000..4941d72 --- /dev/null +++ b/Ghost.Editor/SceneGraph/EditorWorldManager.cs @@ -0,0 +1,53 @@ +using Ghost.Editor.Resources; +using Ghost.Editor.Services.Contracts; +using Ghost.Engine.Resources; +using System.Text.Json; + +namespace Ghost.Editor.SceneGraph; + +public enum OpenWorldMode +{ + Single, + Additive, + AdditiveWithoutLoading +} + +public static class EditorWorldManager +{ + // TODO: Use guid keys instead of string paths for better performance and uniqueness + private static readonly Dictionary _loadedWorlds = new(); + public static IEnumerable LoadedWorlds => _loadedWorlds.Values; + + public static event Action? OnWorldLoaded; + public static event Action? OnWorldUnloaded; + + public static async Task LoadWorld(string worldPath) + { + if (_loadedWorlds.ContainsKey(worldPath) + || !File.Exists(worldPath) + || Path.GetExtension(worldPath) != FileExtensions.SCENE_FILE_EXTENSION) + { + return; + } + + var progressService = EditorApplication.GetService(); + progressService.ShowIndeterminateProgress("Loading world..."); + + foreach (var world in _loadedWorlds) + { + world.Value.Unload(); + OnWorldUnloaded?.Invoke(world.Value); + } + + await using var readStream = new FileStream(worldPath, FileMode.Open, FileAccess.Read, FileShare.Read); + var deserializedScene = await JsonSerializer.DeserializeAsync(readStream, StaticResource.defaultSerializerOptions) ?? throw new Exception("Deserialization failed."); + + _loadedWorlds.Clear(); + + _loadedWorlds[worldPath] = deserializedScene; + await deserializedScene.LoadAsync(); + + progressService.HideProgress(); + OnWorldLoaded?.Invoke(deserializedScene); + } +} \ No newline at end of file diff --git a/Ghost.Editor/SceneGraph/WorldNode.cs b/Ghost.Editor/SceneGraph/WorldNode.cs index 0e1072a..d65697d 100644 --- a/Ghost.Editor/SceneGraph/WorldNode.cs +++ b/Ghost.Editor/SceneGraph/WorldNode.cs @@ -1,14 +1,16 @@ -using Ghost.Editor.Serializer; +using Ghost.Editor.Contracts; +using Ghost.Editor.Serializer; using Ghost.Engine.Components; using Ghost.Entities; +using Microsoft.UI.Xaml; using System.Text.Json.Serialization; namespace Ghost.Editor.SceneGraph; [JsonConverter(typeof(WorldNodeSerializer))] -public partial class WorldNode : SceneGraphNode +public partial class WorldNode : SceneGraphNode, IEquatable { - private readonly World _world; + private World _world; private Dictionary _entityNodeLookup = new(); public World World => _world; @@ -73,7 +75,6 @@ public partial class WorldNode : SceneGraphNode private EntityNode BuildNodeRecursive(Entity entity, World world) { - // TODO: Node serialization. if (!_entityNodeLookup.TryGetValue(entity, out var node)) { node = new EntityNode(entity, "New Entity"); @@ -105,8 +106,69 @@ public partial class WorldNode : SceneGraphNode } } - public void Load() + public Task LoadAsync() { - BuildGraph(); + return Task.Run(BuildGraph); + } + + public void Unload() + { + _world.Dispose(); + _world = null!; + + Children?.Clear(); + _entityNodeLookup.Clear(); + } + + public override string ToString() + { + return $"WorldNode: {Name} (World ID: {_world.ID})"; + } + + public override int GetHashCode() + { + return HashCode.Combine(_world, Name); + } + + public override bool Equals(object? obj) + { + return obj is WorldNode other && Equals(other); + } + + public bool Equals(WorldNode? other) + { + if (other is null) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return _world.Equals(other._world) && Name == other.Name; + } + + public static bool operator ==(WorldNode? left, WorldNode? right) + { + if (left is null) + { + return right is null; + } + return left.Equals(right); + } + + public static bool operator !=(WorldNode? left, WorldNode? right) + { + return !(left == right); + } +} + +public partial class WorldNode : IInspectable +{ + public UIElement OnInspectorDraw() + { + throw new NotImplementedException(); } } \ No newline at end of file diff --git a/Ghost.Editor/Services/Contracts/IInspectorService.cs b/Ghost.Editor/Services/Contracts/IInspectorService.cs new file mode 100644 index 0000000..ce02b28 --- /dev/null +++ b/Ghost.Editor/Services/Contracts/IInspectorService.cs @@ -0,0 +1,12 @@ +using Ghost.Editor.Contracts; + +namespace Ghost.Editor.Services.Contracts; + +internal interface IInspectorService +{ + public IInspectable? SelectedInspectable + { + get; + set; + } +} \ No newline at end of file diff --git a/Ghost.Editor/Services/Contracts/INotificationService.cs b/Ghost.Editor/Services/Contracts/INotificationService.cs new file mode 100644 index 0000000..cef71e7 --- /dev/null +++ b/Ghost.Editor/Services/Contracts/INotificationService.cs @@ -0,0 +1,8 @@ +using Ghost.Editor.Models; + +namespace Ghost.Editor.Services.Contracts; + +public interface INotificationService +{ + public void ShowNotification(string? message, MessageType type, int duration = 5, string? title = null); +} diff --git a/Ghost.Editor/Services/Contracts/IProgressService.cs b/Ghost.Editor/Services/Contracts/IProgressService.cs new file mode 100644 index 0000000..fce0331 --- /dev/null +++ b/Ghost.Editor/Services/Contracts/IProgressService.cs @@ -0,0 +1,9 @@ +namespace Ghost.Editor.Services.Contracts; + +public interface IProgressService +{ + public void ShowProgress(string message, double progress = 0.0); + public void ShowIndeterminateProgress(string message); + public void SetProgress(double progress); + public void HideProgress(); +} \ No newline at end of file diff --git a/Ghost.Engine/Models/LogMessage.cs b/Ghost.Engine/Models/LogMessage.cs index 0892764..948b153 100644 --- a/Ghost.Engine/Models/LogMessage.cs +++ b/Ghost.Engine/Models/LogMessage.cs @@ -1,6 +1,4 @@ -using System.Diagnostics; - -namespace Ghost.Engine.Models; +namespace Ghost.Engine.Models; public enum LogLevel { @@ -21,7 +19,7 @@ internal class LogMessage get; set; } - public StackTrace? StackTrace + public string? StackTrace { get; set; } @@ -31,7 +29,7 @@ internal class LogMessage get; set; } - public LogMessage(LogLevel level, string message, StackTrace? stackTrace = null) + public LogMessage(LogLevel level, string message, string? stackTrace = null) { Level = level; Message = message; diff --git a/Ghost.Engine/Resources/StaticResource.cs b/Ghost.Engine/Resources/StaticResource.cs new file mode 100644 index 0000000..a2af363 --- /dev/null +++ b/Ghost.Engine/Resources/StaticResource.cs @@ -0,0 +1,13 @@ +using System.Text.Json; + +namespace Ghost.Engine.Resources; + +public static class StaticResource +{ + public static JsonSerializerOptions defaultSerializerOptions = new() + { + WriteIndented = true, + IncludeFields = true, + IgnoreReadOnlyProperties = true, + }; +} \ No newline at end of file diff --git a/Ghost.Engine/Services/Logger.cs b/Ghost.Engine/Services/Logger.cs index 58fe559..d3ef227 100644 --- a/Ghost.Engine/Services/Logger.cs +++ b/Ghost.Engine/Services/Logger.cs @@ -16,7 +16,7 @@ public static class Logger private const int _MAX_LOGS = 4096; private static readonly List _logs = new(); - internal static List Logs => _logs; + internal static IReadOnlyList Logs => _logs; internal static event Action? OnLogsUpdate; @@ -39,7 +39,21 @@ public static class Logger stackTrace = new StackTrace(skipFrame, true); } - var logMessage = new LogMessage(level, message, stackTrace); + var logMessage = new LogMessage(level, message, stackTrace?.ToString()); + _logs.Add(logMessage); + + OnLogsUpdate?.Invoke(LogChangeType.LogAdded); + } + + private static void LogExceptionInternal(Exception ex) + { + if (_logs.Count >= _MAX_LOGS) + { + _logs.RemoveAt(0); + OnLogsUpdate?.Invoke(LogChangeType.LogRemoved); + } + + var logMessage = new LogMessage(LogLevel.Error, ex.Message, ex.StackTrace); _logs.Add(logMessage); OnLogsUpdate?.Invoke(LogChangeType.LogAdded); @@ -65,6 +79,11 @@ public static class Logger LogInternal(LogLevel.Error, message, 3); } + public static void LogError(Exception ex) + { + LogExceptionInternal(ex); + } + internal static void Clear() { _logs.Clear(); diff --git a/Ghost.Entities/AssemblyInfo.cs b/Ghost.Entities/AssemblyInfo.cs index c1b77b6..ef61a5e 100644 --- a/Ghost.Entities/AssemblyInfo.cs +++ b/Ghost.Entities/AssemblyInfo.cs @@ -7,4 +7,4 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Ghost.App")] [assembly: InternalsVisibleTo("Ghost.Engine")] [assembly: InternalsVisibleTo("Ghost.Editor")] -[assembly: InternalsVisibleTo("Ghost.Test")] \ No newline at end of file +[assembly: InternalsVisibleTo("Ghost.UnitTest")] \ No newline at end of file diff --git a/Ghost.Entities/Components/ComponentStorage.cs b/Ghost.Entities/Components/ComponentStorage.cs index a736640..8a87e7b 100644 --- a/Ghost.Entities/Components/ComponentStorage.cs +++ b/Ghost.Entities/Components/ComponentStorage.cs @@ -22,6 +22,7 @@ internal interface IComponentPool : IDisposable public bool Remove(Entity entity); public bool Has(Entity entity); public IComponentData Get(Entity entity); + public void Set(Entity entity, in IComponentData component); public IEnumerable<(Entity entity, IComponentData component)> Enumerate(); } @@ -30,6 +31,7 @@ internal interface IComponentPool : IComponentPool where T : IComponentData { public void Add(Entity entity, T Component); + public void Set(Entity entity, in T component); } internal class ComponentPool : IComponentPool @@ -151,17 +153,6 @@ internal class ComponentPool : IComponentPool return ref _components[index].data; } - public IEnumerable<(Entity entity, IComponentData component)> Enumerate() - { - for (var i = 0; i < _nextId; i++) - { - if (_components[i].owner.IsValid) - { - yield return (_components[i].owner, _components[i].data); - } - } - } - public bool Has(Entity entity) { if (entity.ID >= _lookup.Length) @@ -173,6 +164,15 @@ internal class ComponentPool : IComponentPool return index != Entity.INVALID_ID && _components[index].owner.Generation == entity.Generation; } + public void Set(Entity entity, in IComponentData component) + { + if (component is not T typedComponent) + { + throw new ArgumentException($"Component type mismatch. Expected {typeof(T)}, but got {component.GetType()}."); + } + Set(entity, typedComponent); + } + public void Set(Entity entity, in T component) { if (!entity.IsValid || entity.ID >= _lookup.Length || GetComponentIndex(entity) == Entity.INVALID_ID) @@ -185,6 +185,17 @@ internal class ComponentPool : IComponentPool _components[index].owner = entity; } + public IEnumerable<(Entity entity, IComponentData component)> Enumerate() + { + for (var i = 0; i < _nextId; i++) + { + if (_components[i].owner.IsValid) + { + yield return (_components[i].owner, _components[i].data); + } + } + } + public void Dispose() { _components = Array.Empty(); @@ -327,11 +338,37 @@ internal class ScriptComponentPool : IComponentPool return _scriptComponents?.ContainsKey(entity) ?? false; } + [Obsolete("Use GetAll instead of Get for ScriptComponentPool.")] public IComponentData Get(Entity entity) { throw new NotSupportedException("Use GetAll instead of Get for ScriptComponentPool."); } + public void Set(Entity entity, in IComponentData component) + { + if (component is not ScriptComponent scriptComponent) + { + throw new ArgumentException($"Component type mismatch. Expected {typeof(ScriptComponent)}, but got {component.GetType()}."); + } + Set(entity, scriptComponent); + } + + public void Set(Entity entity, in ScriptComponent component) + { + if (!Has(entity) + || !_scriptComponents!.TryGetValue(entity, out var scriptList) + || scriptList == null) + { + return; + } + var index = scriptList.IndexOf(component); + if (index >= 0) + { + scriptList[index] = component; + component.Owner = entity; + } + } + public IEnumerable<(Entity entity, IComponentData component)> Enumerate() { if (_scriptComponents == null) diff --git a/Ghost.Entities/Template/QueryEnumerable.cs b/Ghost.Entities/Template/QueryEnumerable.cs index 4ed5e12..035e117 100644 --- a/Ghost.Entities/Template/QueryEnumerable.cs +++ b/Ghost.Entities/Template/QueryEnumerable.cs @@ -25,12 +25,12 @@ public struct QueryEnumerable _pool0 = pool0; _count = count; - + _filters = new(); _filters._all.Add(TypeHandle.Get()); } - public readonly Enumerator GetEnumerator() => new (_world, _pool0, _count, _filters); + public readonly Enumerator GetEnumerator() => new(_world, _pool0, _count, _filters); public ref struct Enumerator { @@ -43,7 +43,7 @@ public struct QueryEnumerable private readonly int _count; private BitSet _filterMask; - + public QueryItem Current { get; @@ -78,101 +78,101 @@ public struct QueryEnumerable } } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } } public struct QueryEnumerable @@ -195,13 +195,13 @@ public struct QueryEnumerable _pool1 = pool1; _count = count; - + _filters = new(); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); } - public readonly Enumerator GetEnumerator() => new (_world, _pool0, _pool1, _count, _filters); + public readonly Enumerator GetEnumerator() => new(_world, _pool0, _pool1, _count, _filters); public ref struct Enumerator { @@ -215,7 +215,7 @@ public struct QueryEnumerable private readonly int _count; private BitSet _filterMask; - + public QueryItem Current { get; @@ -251,101 +251,101 @@ public struct QueryEnumerable } } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } } public struct QueryEnumerable @@ -370,14 +370,14 @@ public struct QueryEnumerable _pool2 = pool2; _count = count; - + _filters = new(); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); } - public readonly Enumerator GetEnumerator() => new (_world, _pool0, _pool1, _pool2, _count, _filters); + public readonly Enumerator GetEnumerator() => new(_world, _pool0, _pool1, _pool2, _count, _filters); public ref struct Enumerator { @@ -392,7 +392,7 @@ public struct QueryEnumerable private readonly int _count; private BitSet _filterMask; - + public QueryItem Current { get; @@ -429,101 +429,101 @@ public struct QueryEnumerable } } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } } public struct QueryEnumerable @@ -550,7 +550,7 @@ public struct QueryEnumerable _pool3 = pool3; _count = count; - + _filters = new(); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); @@ -558,7 +558,7 @@ public struct QueryEnumerable _filters._all.Add(TypeHandle.Get()); } - public readonly Enumerator GetEnumerator() => new (_world, _pool0, _pool1, _pool2, _pool3, _count, _filters); + public readonly Enumerator GetEnumerator() => new(_world, _pool0, _pool1, _pool2, _pool3, _count, _filters); public ref struct Enumerator { @@ -574,7 +574,7 @@ public struct QueryEnumerable private readonly int _count; private BitSet _filterMask; - + public QueryItem Current { get; @@ -612,101 +612,101 @@ public struct QueryEnumerable } } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } } public struct QueryEnumerable @@ -735,7 +735,7 @@ public struct QueryEnumerable _pool4 = pool4; _count = count; - + _filters = new(); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); @@ -744,7 +744,7 @@ public struct QueryEnumerable _filters._all.Add(TypeHandle.Get()); } - public readonly Enumerator GetEnumerator() => new (_world, _pool0, _pool1, _pool2, _pool3, _pool4, _count, _filters); + public readonly Enumerator GetEnumerator() => new(_world, _pool0, _pool1, _pool2, _pool3, _pool4, _count, _filters); public ref struct Enumerator { @@ -761,7 +761,7 @@ public struct QueryEnumerable private readonly int _count; private BitSet _filterMask; - + public QueryItem Current { get; @@ -800,101 +800,101 @@ public struct QueryEnumerable } } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } } public struct QueryEnumerable @@ -925,7 +925,7 @@ public struct QueryEnumerable _pool5 = pool5; _count = count; - + _filters = new(); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); @@ -935,7 +935,7 @@ public struct QueryEnumerable _filters._all.Add(TypeHandle.Get()); } - public readonly Enumerator GetEnumerator() => new (_world, _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _count, _filters); + public readonly Enumerator GetEnumerator() => new(_world, _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _count, _filters); public ref struct Enumerator { @@ -953,7 +953,7 @@ public struct QueryEnumerable private readonly int _count; private BitSet _filterMask; - + public QueryItem Current { get; @@ -993,101 +993,101 @@ public struct QueryEnumerable } } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } } public struct QueryEnumerable @@ -1120,7 +1120,7 @@ public struct QueryEnumerable _pool6 = pool6; _count = count; - + _filters = new(); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); @@ -1131,7 +1131,7 @@ public struct QueryEnumerable _filters._all.Add(TypeHandle.Get()); } - public readonly Enumerator GetEnumerator() => new (_world, _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _pool6, _count, _filters); + public readonly Enumerator GetEnumerator() => new(_world, _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _pool6, _count, _filters); public ref struct Enumerator { @@ -1150,7 +1150,7 @@ public struct QueryEnumerable private readonly int _count; private BitSet _filterMask; - + public QueryItem Current { get; @@ -1191,101 +1191,101 @@ public struct QueryEnumerable } } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } } public struct QueryEnumerable @@ -1320,7 +1320,7 @@ public struct QueryEnumerable _pool7 = pool7; _count = count; - + _filters = new(); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); @@ -1332,7 +1332,7 @@ public struct QueryEnumerable _filters._all.Add(TypeHandle.Get()); } - public readonly Enumerator GetEnumerator() => new (_world, _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _pool6, _pool7, _count, _filters); + public readonly Enumerator GetEnumerator() => new(_world, _pool0, _pool1, _pool2, _pool3, _pool4, _pool5, _pool6, _pool7, _count, _filters); public ref struct Enumerator { @@ -1352,7 +1352,7 @@ public struct QueryEnumerable private readonly int _count; private BitSet _filterMask; - + public QueryItem Current { get; @@ -1394,100 +1394,100 @@ public struct QueryEnumerable } } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData - { + where TComponent0 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } - public readonly QueryEnumerable WithAll() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + public readonly QueryEnumerable WithAll() + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); _filters._all.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAny() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); _filters._any.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithAbsent() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); _filters._absent.Add(TypeHandle.Get()); return this; - } + } public readonly QueryEnumerable WithDisabled() - where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData - { + where TComponent0 : struct, IComponentData where TComponent1 : struct, IComponentData where TComponent2 : struct, IComponentData + { _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); _filters._disabled.Add(TypeHandle.Get()); return this; - } + } } diff --git a/Ghost.Entities/Template/QueryItem.cs b/Ghost.Entities/Template/QueryItem.cs index c7a32e2..f21c4ca 100644 --- a/Ghost.Entities/Template/QueryItem.cs +++ b/Ghost.Entities/Template/QueryItem.cs @@ -25,7 +25,7 @@ public readonly struct QueryItem public void Deconstruct(out Entity entity, out Ref c0) { entity = _entity; - c0 = new (ref _pool0.GetRef(_entity)); + c0 = new(ref _pool0.GetRef(_entity)); } } @@ -52,7 +52,8 @@ public readonly struct QueryItem public void Deconstruct(out Entity entity, out Ref c0, out Ref c1) { entity = _entity; - c0 = new (ref _pool0.GetRef(_entity));c1 = new (ref _pool1.GetRef(_entity)); + c0 = new(ref _pool0.GetRef(_entity)); + c1 = new(ref _pool1.GetRef(_entity)); } } @@ -82,7 +83,9 @@ public readonly struct QueryItem public void Deconstruct(out Entity entity, out Ref c0, out Ref c1, out Ref c2) { entity = _entity; - c0 = new (ref _pool0.GetRef(_entity));c1 = new (ref _pool1.GetRef(_entity));c2 = new (ref _pool2.GetRef(_entity)); + c0 = new(ref _pool0.GetRef(_entity)); + c1 = new(ref _pool1.GetRef(_entity)); + c2 = new(ref _pool2.GetRef(_entity)); } } @@ -115,7 +118,10 @@ public readonly struct QueryItem public void Deconstruct(out Entity entity, out Ref c0, out Ref c1, out Ref c2, out Ref c3) { entity = _entity; - c0 = new (ref _pool0.GetRef(_entity));c1 = new (ref _pool1.GetRef(_entity));c2 = new (ref _pool2.GetRef(_entity));c3 = new (ref _pool3.GetRef(_entity)); + c0 = new(ref _pool0.GetRef(_entity)); + c1 = new(ref _pool1.GetRef(_entity)); + c2 = new(ref _pool2.GetRef(_entity)); + c3 = new(ref _pool3.GetRef(_entity)); } } @@ -151,7 +157,11 @@ public readonly struct QueryItem public void Deconstruct(out Entity entity, out Ref c0, out Ref c1, out Ref c2, out Ref c3, out Ref c4) { entity = _entity; - c0 = new (ref _pool0.GetRef(_entity));c1 = new (ref _pool1.GetRef(_entity));c2 = new (ref _pool2.GetRef(_entity));c3 = new (ref _pool3.GetRef(_entity));c4 = new (ref _pool4.GetRef(_entity)); + c0 = new(ref _pool0.GetRef(_entity)); + c1 = new(ref _pool1.GetRef(_entity)); + c2 = new(ref _pool2.GetRef(_entity)); + c3 = new(ref _pool3.GetRef(_entity)); + c4 = new(ref _pool4.GetRef(_entity)); } } @@ -190,7 +200,12 @@ public readonly struct QueryItem public void Deconstruct(out Entity entity, out Ref c0, out Ref c1, out Ref c2, out Ref c3, out Ref c4, out Ref c5) { entity = _entity; - c0 = new (ref _pool0.GetRef(_entity));c1 = new (ref _pool1.GetRef(_entity));c2 = new (ref _pool2.GetRef(_entity));c3 = new (ref _pool3.GetRef(_entity));c4 = new (ref _pool4.GetRef(_entity));c5 = new (ref _pool5.GetRef(_entity)); + c0 = new(ref _pool0.GetRef(_entity)); + c1 = new(ref _pool1.GetRef(_entity)); + c2 = new(ref _pool2.GetRef(_entity)); + c3 = new(ref _pool3.GetRef(_entity)); + c4 = new(ref _pool4.GetRef(_entity)); + c5 = new(ref _pool5.GetRef(_entity)); } } @@ -232,7 +247,13 @@ public readonly struct QueryItem public void Deconstruct(out Entity entity, out Ref c0, out Ref c1, out Ref c2, out Ref c3, out Ref c4, out Ref c5, out Ref c6) { entity = _entity; - c0 = new (ref _pool0.GetRef(_entity));c1 = new (ref _pool1.GetRef(_entity));c2 = new (ref _pool2.GetRef(_entity));c3 = new (ref _pool3.GetRef(_entity));c4 = new (ref _pool4.GetRef(_entity));c5 = new (ref _pool5.GetRef(_entity));c6 = new (ref _pool6.GetRef(_entity)); + c0 = new(ref _pool0.GetRef(_entity)); + c1 = new(ref _pool1.GetRef(_entity)); + c2 = new(ref _pool2.GetRef(_entity)); + c3 = new(ref _pool3.GetRef(_entity)); + c4 = new(ref _pool4.GetRef(_entity)); + c5 = new(ref _pool5.GetRef(_entity)); + c6 = new(ref _pool6.GetRef(_entity)); } } @@ -277,7 +298,14 @@ public readonly struct QueryItem public void Deconstruct(out Entity entity, out Ref c0, out Ref c1, out Ref c2, out Ref c3, out Ref c4, out Ref c5, out Ref c6, out Ref c7) { entity = _entity; - c0 = new (ref _pool0.GetRef(_entity));c1 = new (ref _pool1.GetRef(_entity));c2 = new (ref _pool2.GetRef(_entity));c3 = new (ref _pool3.GetRef(_entity));c4 = new (ref _pool4.GetRef(_entity));c5 = new (ref _pool5.GetRef(_entity));c6 = new (ref _pool6.GetRef(_entity));c7 = new (ref _pool7.GetRef(_entity)); + c0 = new(ref _pool0.GetRef(_entity)); + c1 = new(ref _pool1.GetRef(_entity)); + c2 = new(ref _pool2.GetRef(_entity)); + c3 = new(ref _pool3.GetRef(_entity)); + c4 = new(ref _pool4.GetRef(_entity)); + c5 = new(ref _pool5.GetRef(_entity)); + c6 = new(ref _pool6.GetRef(_entity)); + c7 = new(ref _pool7.GetRef(_entity)); } } diff --git a/Ghost.Entities/Template/QueryRefComponent.cs b/Ghost.Entities/Template/QueryRefComponent.cs index 2d50819..bbdb536 100644 --- a/Ghost.Entities/Template/QueryRefComponent.cs +++ b/Ghost.Entities/Template/QueryRefComponent.cs @@ -6,17 +6,17 @@ namespace Ghost.Entities; public delegate void QueryRefComponent(Entity entity, ref T0 t0Component) where T0 : struct, IComponentData; -public delegate void QueryRefComponent(Entity entity, ref T0 t0Component,ref T1 t1Component) +public delegate void QueryRefComponent(Entity entity, ref T0 t0Component, ref T1 t1Component) where T0 : struct, IComponentData where T1 : struct, IComponentData; -public delegate void QueryRefComponent(Entity entity, ref T0 t0Component,ref T1 t1Component,ref T2 t2Component) +public delegate void QueryRefComponent(Entity entity, ref T0 t0Component, ref T1 t1Component, ref T2 t2Component) where T0 : struct, IComponentData where T1 : struct, IComponentData where T2 : struct, IComponentData; -public delegate void QueryRefComponent(Entity entity, ref T0 t0Component,ref T1 t1Component,ref T2 t2Component,ref T3 t3Component) +public delegate void QueryRefComponent(Entity entity, ref T0 t0Component, ref T1 t1Component, ref T2 t2Component, ref T3 t3Component) where T0 : struct, IComponentData where T1 : struct, IComponentData where T2 : struct, IComponentData where T3 : struct, IComponentData; -public delegate void QueryRefComponent(Entity entity, ref T0 t0Component,ref T1 t1Component,ref T2 t2Component,ref T3 t3Component,ref T4 t4Component) +public delegate void QueryRefComponent(Entity entity, ref T0 t0Component, ref T1 t1Component, ref T2 t2Component, ref T3 t3Component, ref T4 t4Component) where T0 : struct, IComponentData where T1 : struct, IComponentData where T2 : struct, IComponentData where T3 : struct, IComponentData where T4 : struct, IComponentData; -public delegate void QueryRefComponent(Entity entity, ref T0 t0Component,ref T1 t1Component,ref T2 t2Component,ref T3 t3Component,ref T4 t4Component,ref T5 t5Component) +public delegate void QueryRefComponent(Entity entity, ref T0 t0Component, ref T1 t1Component, ref T2 t2Component, ref T3 t3Component, ref T4 t4Component, ref T5 t5Component) where T0 : struct, IComponentData where T1 : struct, IComponentData where T2 : struct, IComponentData where T3 : struct, IComponentData where T4 : struct, IComponentData where T5 : struct, IComponentData; -public delegate void QueryRefComponent(Entity entity, ref T0 t0Component,ref T1 t1Component,ref T2 t2Component,ref T3 t3Component,ref T4 t4Component,ref T5 t5Component,ref T6 t6Component) +public delegate void QueryRefComponent(Entity entity, ref T0 t0Component, ref T1 t1Component, ref T2 t2Component, ref T3 t3Component, ref T4 t4Component, ref T5 t5Component, ref T6 t6Component) where T0 : struct, IComponentData where T1 : struct, IComponentData where T2 : struct, IComponentData where T3 : struct, IComponentData where T4 : struct, IComponentData where T5 : struct, IComponentData where T6 : struct, IComponentData; -public delegate void QueryRefComponent(Entity entity, ref T0 t0Component,ref T1 t1Component,ref T2 t2Component,ref T3 t3Component,ref T4 t4Component,ref T5 t5Component,ref T6 t6Component,ref T7 t7Component) +public delegate void QueryRefComponent(Entity entity, ref T0 t0Component, ref T1 t1Component, ref T2 t2Component, ref T3 t3Component, ref T4 t4Component, ref T5 t5Component, ref T6 t6Component, ref T7 t7Component) where T0 : struct, IComponentData where T1 : struct, IComponentData where T2 : struct, IComponentData where T3 : struct, IComponentData where T4 : struct, IComponentData where T5 : struct, IComponentData where T6 : struct, IComponentData where T7 : struct, IComponentData; diff --git a/Ghost.Entities/World.cs b/Ghost.Entities/World.cs index 84fdd24..dcd6e58 100644 --- a/Ghost.Entities/World.cs +++ b/Ghost.Entities/World.cs @@ -44,7 +44,7 @@ public partial class World } } -public partial class World : IDisposable +public partial class World : IDisposable, IEquatable { private readonly WorldID _id; private readonly EntityManager _entityManager; @@ -92,4 +92,34 @@ public partial class World : IDisposable s_freeWorldSlots.Enqueue(_id); } + + public bool Equals(World? other) + { + if (other is null) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return _id == other._id; + } + + public override int GetHashCode() + { + return _id.GetHashCode(); + } + + public static bool operator ==(World? left, World? right) + { + return left?.Equals(right) ?? right is null; + } + + public static bool operator !=(World? left, World? right) + { + return !(left == right); + } } \ No newline at end of file diff --git a/Ghost.InternalEditor/Contracts/INotificationService.cs b/Ghost.InternalEditor/Contracts/INotificationService.cs deleted file mode 100644 index 9bb2338..0000000 --- a/Ghost.InternalEditor/Contracts/INotificationService.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.UI.Xaml.Controls; - -namespace Ghost.App.Contracts; - -internal interface INotificationService -{ - public void ShowNotification(string? message, InfoBarSeverity severity, int duration = 5, string? title = null); -} - -internal interface INotificationService : INotificationService -{ - public void Initialize(T notificationQueue); - public void ClearQueueReference(); -} \ No newline at end of file diff --git a/Ghost.InternalEditor/ViewModels/Pages/EngineEditor/HierarchyViewModel.cs b/Ghost.InternalEditor/ViewModels/Pages/EngineEditor/HierarchyViewModel.cs deleted file mode 100644 index 7b2d583..0000000 --- a/Ghost.InternalEditor/ViewModels/Pages/EngineEditor/HierarchyViewModel.cs +++ /dev/null @@ -1,38 +0,0 @@ -using CommunityToolkit.Mvvm.ComponentModel; -using Ghost.Editor.SceneGraph; -using Ghost.Entities; -using System.Collections.ObjectModel; - -namespace Ghost.Editor.ViewModels.Pages.EngineEditor; - -internal partial class HierarchyViewModel : ObservableObject -{ - [ObservableProperty] - public partial ObservableCollection SceneList - { - get; - private set; - } = new(); - - public HierarchyViewModel() - { - // Test only - var testWorld = World.Create(); - var entity1 = SceneGraphHelpers.CreateEntityNode(testWorld, "entity 1"); - var entity2 = SceneGraphHelpers.CreateEntityNode(testWorld, "entity 3"); - var entity3 = SceneGraphHelpers.CreateEntityNode(testWorld, "entity 4"); - var entity4 = SceneGraphHelpers.CreateEntityNode(testWorld, "entity 5"); - var entity5 = SceneGraphHelpers.CreateEntityNode(testWorld, "entity 2"); - - var testScene = new WorldNode(testWorld, "Test Scene"); - - SceneGraphHelpers.AttachChild(testScene, entity1, entity2); - SceneGraphHelpers.AttachChild(testScene, entity1, entity3); - SceneGraphHelpers.AttachChild(testScene, entity2, entity4); - - testScene.AddChild(entity1); - testScene.AddChild(entity5); - - SceneList.Add(testScene); - } -} \ No newline at end of file diff --git a/Ghost.Test/Ghost.Test.csproj b/Ghost.Test/Ghost.Test.csproj deleted file mode 100644 index d62e017..0000000 --- a/Ghost.Test/Ghost.Test.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - Exe - net9.0 - enable - enable - - - - - - - - - - - - ..\..\Class\Misaki.HighPerformance\Misaki.HighPerformance.Unsafe\bin\Release\net9.0\Misaki.HighPerformance.Unsafe.dll - - - - diff --git a/Ghost.Test/Program.cs b/Ghost.Test/Program.cs deleted file mode 100644 index e34df80..0000000 --- a/Ghost.Test/Program.cs +++ /dev/null @@ -1,4 +0,0 @@ -using Ghost.Test; -using Ghost.Test.TestFramework; - -TestRunner.Run(); diff --git a/Ghost.UnitTest/Assets/LockScreenLogo.scale-200.png b/Ghost.UnitTest/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 0000000..7440f0d Binary files /dev/null and b/Ghost.UnitTest/Assets/LockScreenLogo.scale-200.png differ diff --git a/Ghost.UnitTest/Assets/SplashScreen.scale-200.png b/Ghost.UnitTest/Assets/SplashScreen.scale-200.png new file mode 100644 index 0000000..32f486a Binary files /dev/null and b/Ghost.UnitTest/Assets/SplashScreen.scale-200.png differ diff --git a/Ghost.UnitTest/Assets/Square150x150Logo.scale-200.png b/Ghost.UnitTest/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 0000000..53ee377 Binary files /dev/null and b/Ghost.UnitTest/Assets/Square150x150Logo.scale-200.png differ diff --git a/Ghost.UnitTest/Assets/Square44x44Logo.scale-200.png b/Ghost.UnitTest/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 0000000..f713bba Binary files /dev/null and b/Ghost.UnitTest/Assets/Square44x44Logo.scale-200.png differ diff --git a/Ghost.UnitTest/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/Ghost.UnitTest/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 0000000..dc9f5be Binary files /dev/null and b/Ghost.UnitTest/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/Ghost.UnitTest/Assets/StoreLogo.png b/Ghost.UnitTest/Assets/StoreLogo.png new file mode 100644 index 0000000..a4586f2 Binary files /dev/null and b/Ghost.UnitTest/Assets/StoreLogo.png differ diff --git a/Ghost.UnitTest/Assets/Wide310x150Logo.scale-200.png b/Ghost.UnitTest/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 0000000..8b4a5d0 Binary files /dev/null and b/Ghost.UnitTest/Assets/Wide310x150Logo.scale-200.png differ diff --git a/Ghost.UnitTest/Ghost.UnitTest.csproj b/Ghost.UnitTest/Ghost.UnitTest.csproj new file mode 100644 index 0000000..ff9737f --- /dev/null +++ b/Ghost.UnitTest/Ghost.UnitTest.csproj @@ -0,0 +1,80 @@ + + + WinExe + net9.0-windows10.0.22621.0 + 10.0.17763.0 + Ghost.UnitTest + app.manifest + x86;x64;ARM64 + win-x86;win-x64;win-arm64 + win-$(Platform).pubxml + true + true + enable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ..\..\Class\Misaki.HighPerformance\Misaki.HighPerformance.Unsafe\bin\Release\net9.0\Misaki.HighPerformance.Unsafe.dll + + + + + + true + + + + + False + True + False + 10.0.20348.0 + enable + + diff --git a/Ghost.UnitTest/Package.appxmanifest b/Ghost.UnitTest/Package.appxmanifest new file mode 100644 index 0000000..36cf5a3 --- /dev/null +++ b/Ghost.UnitTest/Package.appxmanifest @@ -0,0 +1,51 @@ + + + + + + + + + + Ghost.UnitTest + Misaki + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ghost.UnitTest/Properties/launchSettings.json b/Ghost.UnitTest/Properties/launchSettings.json new file mode 100644 index 0000000..04171d2 --- /dev/null +++ b/Ghost.UnitTest/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "Ghost.UnitTest (Package)": { + "commandName": "MsixPackage" + }, + "Ghost.UnitTest (Unpackaged)": { + "commandName": "Project" + } + } +} \ No newline at end of file diff --git a/Ghost.Test/EntityTest.cs b/Ghost.UnitTest/Test/EntityTest.cs similarity index 99% rename from Ghost.Test/EntityTest.cs rename to Ghost.UnitTest/Test/EntityTest.cs index 7a759d3..d6048a3 100644 --- a/Ghost.Test/EntityTest.cs +++ b/Ghost.UnitTest/Test/EntityTest.cs @@ -47,6 +47,7 @@ public partial class EntityTest : ITest world.SystemStorage.AddSystem(); world.SystemStorage.AddSystem(); + world.SystemStorage.CreateSystems(); world.SystemStorage.UpdateSystems(); diff --git a/Ghost.Test/SerializationTest.cs b/Ghost.UnitTest/Test/SerializationTest.cs similarity index 97% rename from Ghost.Test/SerializationTest.cs rename to Ghost.UnitTest/Test/SerializationTest.cs index f8edf12..6dd453f 100644 --- a/Ghost.Test/SerializationTest.cs +++ b/Ghost.UnitTest/Test/SerializationTest.cs @@ -46,6 +46,6 @@ internal class SerializationTest : ITest var readStream = new FileStream(_TEST_FILE_PATH, FileMode.Open, FileAccess.Read, FileShare.Read); var deserializedScene = JsonSerializer.Deserialize(readStream, options) ?? throw new Exception("Deserialization failed."); - deserializedScene.Load(); + deserializedScene.LoadAsync(); } } \ No newline at end of file diff --git a/Ghost.Test/TestFramework/ITest.cs b/Ghost.UnitTest/TestFramework/ITest.cs similarity index 100% rename from Ghost.Test/TestFramework/ITest.cs rename to Ghost.UnitTest/TestFramework/ITest.cs diff --git a/Ghost.Test/TestFramework/TestRunner.cs b/Ghost.UnitTest/TestFramework/TestRunner.cs similarity index 100% rename from Ghost.Test/TestFramework/TestRunner.cs rename to Ghost.UnitTest/TestFramework/TestRunner.cs diff --git a/Ghost.UnitTest/UnitTestApp.xaml b/Ghost.UnitTest/UnitTestApp.xaml new file mode 100644 index 0000000..2b53ec9 --- /dev/null +++ b/Ghost.UnitTest/UnitTestApp.xaml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/Ghost.UnitTest/UnitTestApp.xaml.cs b/Ghost.UnitTest/UnitTestApp.xaml.cs new file mode 100644 index 0000000..4211086 --- /dev/null +++ b/Ghost.UnitTest/UnitTestApp.xaml.cs @@ -0,0 +1,55 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using Microsoft.UI.Xaml.Shapes; +using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.ApplicationModel; +using Windows.ApplicationModel.Activation; +using Windows.Foundation; +using Windows.Foundation.Collections; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace Ghost.UnitTest; +/// +/// Provides application-specific behavior to supplement the default Application class. +/// +public partial class UnitTestApp : Application +{ + private Window? _window; + + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public UnitTestApp() + { + InitializeComponent(); + } + + /// + /// Invoked when the application is launched. + /// + /// Details about the launch request and process. + protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args) + { + Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI(); + + _window = new UnitTestAppWindow(); + _window.Activate(); + + UITestMethodAttribute.DispatcherQueue = _window.DispatcherQueue; + + Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(Environment.CommandLine); + } +} diff --git a/Ghost.UnitTest/UnitTestAppWindow.xaml b/Ghost.UnitTest/UnitTestAppWindow.xaml new file mode 100644 index 0000000..c3c3bdc --- /dev/null +++ b/Ghost.UnitTest/UnitTestAppWindow.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + diff --git a/Ghost.UnitTest/UnitTestAppWindow.xaml.cs b/Ghost.UnitTest/UnitTestAppWindow.xaml.cs new file mode 100644 index 0000000..67bbc8f --- /dev/null +++ b/Ghost.UnitTest/UnitTestAppWindow.xaml.cs @@ -0,0 +1,26 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace Ghost.UnitTest; +public sealed partial class UnitTestAppWindow : Window +{ + public UnitTestAppWindow() + { + InitializeComponent(); + } +} diff --git a/Ghost.UnitTest/UnitTests.cs b/Ghost.UnitTest/UnitTests.cs new file mode 100644 index 0000000..ddda339 --- /dev/null +++ b/Ghost.UnitTest/UnitTests.cs @@ -0,0 +1,25 @@ +using Microsoft.UI.Xaml.Controls; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Ghost.UnitTest; +[TestClass] +public partial class UnitTest1 +{ + [TestMethod] + public void TestMethod1() + { + Assert.AreEqual(0, 0); + } + + // Use the UITestMethod attribute for tests that need to run on the UI thread. + [UITestMethod] + public void TestMethod2() + { + var grid = new Grid(); + Assert.AreEqual(0, grid.MinWidth); + } +} diff --git a/Ghost.UnitTest/app.manifest b/Ghost.UnitTest/app.manifest new file mode 100644 index 0000000..ebf5da1 --- /dev/null +++ b/Ghost.UnitTest/app.manifest @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + PerMonitorV2 + + + \ No newline at end of file diff --git a/GhostEngine.sln b/GhostEngine.sln index 387e2f4..d71f4ce 100644 --- a/GhostEngine.sln +++ b/GhostEngine.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.14.35906.104 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.App", "Ghost.InternalEditor\Ghost.App.csproj", "{15AFE3A1-0CAF-4B36-8835-121C4D683BBF}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.App", "Ghost.App\Ghost.App.csproj", "{15AFE3A1-0CAF-4B36-8835-121C4D683BBF}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Engine", "Ghost.Engine\Ghost.Engine.csproj", "{1ED62E09-8F36-4671-896B-16C1C1530202}" EndProject @@ -11,13 +11,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Data", "Ghost.Data\Gh EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Entities", "Ghost.Entities\Ghost.Entities.csproj", "{8A1C494B-2888-4D0D-8325-9F5C8D1D1955}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Test", "Ghost.Test\Ghost.Test.csproj", "{276D09BD-7C8B-4D59-803D-96CCD83D41B0}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Graphics", "Ghost.Graphics\Ghost.Graphics.csproj", "{9B0B2CA8-B200-4F19-9D09-A7B99F98BB44}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Generator", "Ghost.Generator\Ghost.Generator.csproj", "{996ABECC-1C5A-4F07-B8AC-D063F91962CB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Editor", "Ghost.Editor\Ghost.Editor.csproj", "{E0BD59AD-0DB3-45CA-A906-0BDC0A26DD63}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.Editor", "Ghost.Editor\Ghost.Editor.csproj", "{CC6E1FCB-A80E-4F6C-B519-C8CADB6D5650}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghost.UnitTest", "Ghost.UnitTest\Ghost.UnitTest.csproj", "{4179873E-8174-4D17-9584-8C223BA71366}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -83,18 +83,6 @@ Global {8A1C494B-2888-4D0D-8325-9F5C8D1D1955}.Release|x64.Build.0 = Release|Any CPU {8A1C494B-2888-4D0D-8325-9F5C8D1D1955}.Release|x86.ActiveCfg = Release|Any CPU {8A1C494B-2888-4D0D-8325-9F5C8D1D1955}.Release|x86.Build.0 = Release|Any CPU - {276D09BD-7C8B-4D59-803D-96CCD83D41B0}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {276D09BD-7C8B-4D59-803D-96CCD83D41B0}.Debug|ARM64.Build.0 = Debug|Any CPU - {276D09BD-7C8B-4D59-803D-96CCD83D41B0}.Debug|x64.ActiveCfg = Debug|Any CPU - {276D09BD-7C8B-4D59-803D-96CCD83D41B0}.Debug|x64.Build.0 = Debug|Any CPU - {276D09BD-7C8B-4D59-803D-96CCD83D41B0}.Debug|x86.ActiveCfg = Debug|Any CPU - {276D09BD-7C8B-4D59-803D-96CCD83D41B0}.Debug|x86.Build.0 = Debug|Any CPU - {276D09BD-7C8B-4D59-803D-96CCD83D41B0}.Release|ARM64.ActiveCfg = Release|Any CPU - {276D09BD-7C8B-4D59-803D-96CCD83D41B0}.Release|ARM64.Build.0 = Release|Any CPU - {276D09BD-7C8B-4D59-803D-96CCD83D41B0}.Release|x64.ActiveCfg = Release|Any CPU - {276D09BD-7C8B-4D59-803D-96CCD83D41B0}.Release|x64.Build.0 = Release|Any CPU - {276D09BD-7C8B-4D59-803D-96CCD83D41B0}.Release|x86.ActiveCfg = Release|Any CPU - {276D09BD-7C8B-4D59-803D-96CCD83D41B0}.Release|x86.Build.0 = Release|Any CPU {9B0B2CA8-B200-4F19-9D09-A7B99F98BB44}.Debug|ARM64.ActiveCfg = Debug|Any CPU {9B0B2CA8-B200-4F19-9D09-A7B99F98BB44}.Debug|ARM64.Build.0 = Debug|Any CPU {9B0B2CA8-B200-4F19-9D09-A7B99F98BB44}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -119,18 +107,36 @@ Global {996ABECC-1C5A-4F07-B8AC-D063F91962CB}.Release|x64.Build.0 = Release|Any CPU {996ABECC-1C5A-4F07-B8AC-D063F91962CB}.Release|x86.ActiveCfg = Release|Any CPU {996ABECC-1C5A-4F07-B8AC-D063F91962CB}.Release|x86.Build.0 = Release|Any CPU - {E0BD59AD-0DB3-45CA-A906-0BDC0A26DD63}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {E0BD59AD-0DB3-45CA-A906-0BDC0A26DD63}.Debug|ARM64.Build.0 = Debug|Any CPU - {E0BD59AD-0DB3-45CA-A906-0BDC0A26DD63}.Debug|x64.ActiveCfg = Debug|Any CPU - {E0BD59AD-0DB3-45CA-A906-0BDC0A26DD63}.Debug|x64.Build.0 = Debug|Any CPU - {E0BD59AD-0DB3-45CA-A906-0BDC0A26DD63}.Debug|x86.ActiveCfg = Debug|Any CPU - {E0BD59AD-0DB3-45CA-A906-0BDC0A26DD63}.Debug|x86.Build.0 = Debug|Any CPU - {E0BD59AD-0DB3-45CA-A906-0BDC0A26DD63}.Release|ARM64.ActiveCfg = Release|Any CPU - {E0BD59AD-0DB3-45CA-A906-0BDC0A26DD63}.Release|ARM64.Build.0 = Release|Any CPU - {E0BD59AD-0DB3-45CA-A906-0BDC0A26DD63}.Release|x64.ActiveCfg = Release|Any CPU - {E0BD59AD-0DB3-45CA-A906-0BDC0A26DD63}.Release|x64.Build.0 = Release|Any CPU - {E0BD59AD-0DB3-45CA-A906-0BDC0A26DD63}.Release|x86.ActiveCfg = Release|Any CPU - {E0BD59AD-0DB3-45CA-A906-0BDC0A26DD63}.Release|x86.Build.0 = Release|Any CPU + {CC6E1FCB-A80E-4F6C-B519-C8CADB6D5650}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {CC6E1FCB-A80E-4F6C-B519-C8CADB6D5650}.Debug|ARM64.Build.0 = Debug|Any CPU + {CC6E1FCB-A80E-4F6C-B519-C8CADB6D5650}.Debug|x64.ActiveCfg = Debug|Any CPU + {CC6E1FCB-A80E-4F6C-B519-C8CADB6D5650}.Debug|x64.Build.0 = Debug|Any CPU + {CC6E1FCB-A80E-4F6C-B519-C8CADB6D5650}.Debug|x86.ActiveCfg = Debug|Any CPU + {CC6E1FCB-A80E-4F6C-B519-C8CADB6D5650}.Debug|x86.Build.0 = Debug|Any CPU + {CC6E1FCB-A80E-4F6C-B519-C8CADB6D5650}.Release|ARM64.ActiveCfg = Release|Any CPU + {CC6E1FCB-A80E-4F6C-B519-C8CADB6D5650}.Release|ARM64.Build.0 = Release|Any CPU + {CC6E1FCB-A80E-4F6C-B519-C8CADB6D5650}.Release|x64.ActiveCfg = Release|Any CPU + {CC6E1FCB-A80E-4F6C-B519-C8CADB6D5650}.Release|x64.Build.0 = Release|Any CPU + {CC6E1FCB-A80E-4F6C-B519-C8CADB6D5650}.Release|x86.ActiveCfg = Release|Any CPU + {CC6E1FCB-A80E-4F6C-B519-C8CADB6D5650}.Release|x86.Build.0 = Release|Any CPU + {4179873E-8174-4D17-9584-8C223BA71366}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {4179873E-8174-4D17-9584-8C223BA71366}.Debug|ARM64.Build.0 = Debug|ARM64 + {4179873E-8174-4D17-9584-8C223BA71366}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {4179873E-8174-4D17-9584-8C223BA71366}.Debug|x64.ActiveCfg = Debug|x64 + {4179873E-8174-4D17-9584-8C223BA71366}.Debug|x64.Build.0 = Debug|x64 + {4179873E-8174-4D17-9584-8C223BA71366}.Debug|x64.Deploy.0 = Debug|x64 + {4179873E-8174-4D17-9584-8C223BA71366}.Debug|x86.ActiveCfg = Debug|x86 + {4179873E-8174-4D17-9584-8C223BA71366}.Debug|x86.Build.0 = Debug|x86 + {4179873E-8174-4D17-9584-8C223BA71366}.Debug|x86.Deploy.0 = Debug|x86 + {4179873E-8174-4D17-9584-8C223BA71366}.Release|ARM64.ActiveCfg = Release|ARM64 + {4179873E-8174-4D17-9584-8C223BA71366}.Release|ARM64.Build.0 = Release|ARM64 + {4179873E-8174-4D17-9584-8C223BA71366}.Release|ARM64.Deploy.0 = Release|ARM64 + {4179873E-8174-4D17-9584-8C223BA71366}.Release|x64.ActiveCfg = Release|x64 + {4179873E-8174-4D17-9584-8C223BA71366}.Release|x64.Build.0 = Release|x64 + {4179873E-8174-4D17-9584-8C223BA71366}.Release|x64.Deploy.0 = Release|x64 + {4179873E-8174-4D17-9584-8C223BA71366}.Release|x86.ActiveCfg = Release|x86 + {4179873E-8174-4D17-9584-8C223BA71366}.Release|x86.Build.0 = Release|x86 + {4179873E-8174-4D17-9584-8C223BA71366}.Release|x86.Deploy.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE