From 5c6e3031d597ed6fc6b871033a29848eb45a3e7a Mon Sep 17 00:00:00 2001 From: hzhang Date: Wed, 10 Jul 2024 07:02:11 +0100 Subject: [PATCH] source generator --- Nocturnis.csproj | 1 + src/Attributes/DirectAsset.cs | 6 ++++++ src/Attributes/UniqueInheritance.cs | 6 ++++++ src/Creatures/Characters/IBaseCharacter.cs | 8 -------- src/Creatures/Characters/INonPlayerCharacter.cs | 9 +++++++++ src/Creatures/Characters/IPlayerCharacter.cs | 10 ++++++++++ .../CreatureActions/ICreatureAction.cs | 2 ++ src/Creatures/IBaseCharacter.cs | 6 ++++++ src/ENodeInterface.cs | 11 +++++++++++ src/Enigmos/Boards/IBaseBoard.cs | 5 +++++ src/Enigmos/Boards/IPrimaryBoard.cs | 8 ++++++++ src/Enigmos/ModuleManuals/IModuleManualTab.cs | 2 +- src/Enigmos/Modules/IBaseModule.cs | 3 ++- src/Enigmos/Modules/ICompositeModule.cs | 2 +- .../Modules/IComputationalCompositeModule.cs | 8 -------- src/Enigmos/Modules/IEngineModule.cs | 6 ++++++ .../Modules/IEnumerableProcessingModule.cs | 9 +++++++++ .../Modules/IInternalComputationalModule.cs | 11 +++++++++++ src/Enigmos/Modules/IOptimizationModule.cs | 4 ++-- src/Enigmos/Modules/IProgrammableModule.cs | 2 +- src/Enigmos/Modules/ITerminalModule.cs | 1 + .../Ports/DataPorts/Directions/IDataInPort.cs | 1 - .../Ports/DataPorts/Directions/IDataOutPort.cs | 2 -- src/Enigmos/Ports/IBasePort.cs | 1 + .../Controls/CreatureControl.cs | 2 +- src/GlobalManagement/Controls/EnigmosControl.cs | 4 ++++ .../Providers/GlobalProvider.cs | 17 +++++++++++++++++ .../Providers/ISceneProvider.cs | 6 ++---- .../Providers/ITextureProvider.cs | 11 +++++++++++ src/IDirectAsset.cs | 8 ++++++++ src/INodeInterface.cs | 8 ++++++++ src/ISceneConcept.cs | 6 ++++++ src/Inventories/Items/IBaseItem.cs | 11 ++++++++--- src/UIElements/IPanelViewer.cs | 4 ++++ src/UIElements/ISimpleLabel.cs | 2 +- 35 files changed, 169 insertions(+), 34 deletions(-) create mode 100644 src/Attributes/DirectAsset.cs create mode 100644 src/Attributes/UniqueInheritance.cs delete mode 100644 src/Creatures/Characters/IBaseCharacter.cs create mode 100644 src/Creatures/Characters/INonPlayerCharacter.cs create mode 100644 src/Creatures/Characters/IPlayerCharacter.cs create mode 100644 src/Creatures/IBaseCharacter.cs create mode 100644 src/ENodeInterface.cs create mode 100644 src/Enigmos/Boards/IPrimaryBoard.cs delete mode 100644 src/Enigmos/Modules/IComputationalCompositeModule.cs create mode 100644 src/Enigmos/Modules/IEngineModule.cs create mode 100644 src/Enigmos/Modules/IEnumerableProcessingModule.cs create mode 100644 src/Enigmos/Modules/IInternalComputationalModule.cs create mode 100644 src/GlobalManagement/Providers/ITextureProvider.cs create mode 100644 src/IDirectAsset.cs create mode 100644 src/INodeInterface.cs create mode 100644 src/ISceneConcept.cs diff --git a/Nocturnis.csproj b/Nocturnis.csproj index 45dacd6..a8d5f6b 100644 --- a/Nocturnis.csproj +++ b/Nocturnis.csproj @@ -15,6 +15,7 @@ + diff --git a/src/Attributes/DirectAsset.cs b/src/Attributes/DirectAsset.cs new file mode 100644 index 0000000..bc18f7d --- /dev/null +++ b/src/Attributes/DirectAsset.cs @@ -0,0 +1,6 @@ +namespace Nocturnis.Attributes; +[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class)] +public class DirectAsset : Attribute +{ + +} \ No newline at end of file diff --git a/src/Attributes/UniqueInheritance.cs b/src/Attributes/UniqueInheritance.cs new file mode 100644 index 0000000..e17e149 --- /dev/null +++ b/src/Attributes/UniqueInheritance.cs @@ -0,0 +1,6 @@ +namespace Nocturnis.Attributes; +[AttributeUsage(AttributeTargets.Class)] +public class UniqueInheritance : Attribute +{ + +} \ No newline at end of file diff --git a/src/Creatures/Characters/IBaseCharacter.cs b/src/Creatures/Characters/IBaseCharacter.cs deleted file mode 100644 index ca69e29..0000000 --- a/src/Creatures/Characters/IBaseCharacter.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Nocturnis.UIElements; - -namespace Nocturnis.Creatures.Characters; - -public interface IBaseCharacter : IBaseCreature -{ - IDashboardTab DashboardTab { get; set; } -} \ No newline at end of file diff --git a/src/Creatures/Characters/INonPlayerCharacter.cs b/src/Creatures/Characters/INonPlayerCharacter.cs new file mode 100644 index 0000000..049260d --- /dev/null +++ b/src/Creatures/Characters/INonPlayerCharacter.cs @@ -0,0 +1,9 @@ +using Nocturnis.Enigmos.Boards; +using Nocturnis.UIElements; + +namespace Nocturnis.Creatures.Characters; + +public interface INonPlayerCharacter : IBaseCreature +{ + +} \ No newline at end of file diff --git a/src/Creatures/Characters/IPlayerCharacter.cs b/src/Creatures/Characters/IPlayerCharacter.cs new file mode 100644 index 0000000..2b12ca1 --- /dev/null +++ b/src/Creatures/Characters/IPlayerCharacter.cs @@ -0,0 +1,10 @@ +using Nocturnis.Enigmos.Boards; +using Nocturnis.UIElements; + +namespace Nocturnis.Creatures.Characters; + +public interface IPlayerCharacter : IBaseCharacter +{ + IDashboardTab DashboardTab { get; set; } + IPrimaryBoard MotherBoard { get; set; } +} \ No newline at end of file diff --git a/src/Creatures/CreatureActions/ICreatureAction.cs b/src/Creatures/CreatureActions/ICreatureAction.cs index 5623694..52f0732 100644 --- a/src/Creatures/CreatureActions/ICreatureAction.cs +++ b/src/Creatures/CreatureActions/ICreatureAction.cs @@ -1,3 +1,4 @@ +using Nocturnis.Inventories.Items; using Skeleton.Algebra; using Skeleton.Algebra.DimensionProviders; @@ -7,4 +8,5 @@ public interface ICreatureAction { void Move(R2 dir); void Attack(R2 dir); + void Drop(IBaseItem item); } \ No newline at end of file diff --git a/src/Creatures/IBaseCharacter.cs b/src/Creatures/IBaseCharacter.cs new file mode 100644 index 0000000..6e02afa --- /dev/null +++ b/src/Creatures/IBaseCharacter.cs @@ -0,0 +1,6 @@ +namespace Nocturnis.Creatures; + +public interface IBaseCharacter : IBaseCreature +{ + +} \ No newline at end of file diff --git a/src/ENodeInterface.cs b/src/ENodeInterface.cs new file mode 100644 index 0000000..d7afdc0 --- /dev/null +++ b/src/ENodeInterface.cs @@ -0,0 +1,11 @@ +using Godot; + +namespace Nocturnis; + +public static class ENodeInterface +{ + public static Node AsNode(this INodeInterface n) + { + return n as Node; + } +} \ No newline at end of file diff --git a/src/Enigmos/Boards/IBaseBoard.cs b/src/Enigmos/Boards/IBaseBoard.cs index 21df7a6..045d207 100644 --- a/src/Enigmos/Boards/IBaseBoard.cs +++ b/src/Enigmos/Boards/IBaseBoard.cs @@ -1,11 +1,14 @@ using Nocturnis.Enigmos.Cables; using Nocturnis.Enigmos.Ports; +using Nocturnis.UIElements; using Nocturnis.UIElements.Layers; namespace Nocturnis.Enigmos.Boards; public interface IBaseBoard { + IPanelViewer? PanelViewer { get; set; } + IEnumerable OnBoardPorts { get; } IBasePort? ConnectPending { get; set; } Dictionary CablePairing { get; set; } void AddCable(IBaseCable cable); @@ -15,4 +18,6 @@ public interface IBaseBoard IModuleManualLayer? ModuleManualLayer { get; set; } IModuleMovingLayer? ModuleMovingLayer { get; set; } void Reset(); + void SetCableVisualMode(bool mode); + void SetLabelVisualMode(bool mode); } \ No newline at end of file diff --git a/src/Enigmos/Boards/IPrimaryBoard.cs b/src/Enigmos/Boards/IPrimaryBoard.cs new file mode 100644 index 0000000..156f90e --- /dev/null +++ b/src/Enigmos/Boards/IPrimaryBoard.cs @@ -0,0 +1,8 @@ +using Nocturnis.Enigmos.Modules; + +namespace Nocturnis.Enigmos.Boards; + +public interface IPrimaryBoard : IBaseBoard +{ + IEngineModule Engine { get; set; } +} \ No newline at end of file diff --git a/src/Enigmos/ModuleManuals/IModuleManualTab.cs b/src/Enigmos/ModuleManuals/IModuleManualTab.cs index a91bd3b..450b67d 100644 --- a/src/Enigmos/ModuleManuals/IModuleManualTab.cs +++ b/src/Enigmos/ModuleManuals/IModuleManualTab.cs @@ -1,6 +1,6 @@ namespace Nocturnis.Enigmos.ModuleManuals; -public interface IModuleManualTab +public interface IModuleManualTab : INodeInterface { string FullName(); } \ No newline at end of file diff --git a/src/Enigmos/Modules/IBaseModule.cs b/src/Enigmos/Modules/IBaseModule.cs index d9c32aa..7203d15 100644 --- a/src/Enigmos/Modules/IBaseModule.cs +++ b/src/Enigmos/Modules/IBaseModule.cs @@ -7,6 +7,7 @@ namespace Nocturnis.Enigmos.Modules; public interface IBaseModule { + Texture2D? PreviewTexture { get; } IEnumerable Ports { get; } IBaseBoard? Board { get; set; } Vector2 PositionToBoard { get; } @@ -14,7 +15,7 @@ public interface IBaseModule double MaintenanceAlpha { get; } double MaintenanceBeta { get; } string GetDescription { get; } - ISimpleLabel? Label { get; } + Label? Label { get; } Node AsNode { get; } Vector2 Position { get; set; } string LabelString { get; set; } diff --git a/src/Enigmos/Modules/ICompositeModule.cs b/src/Enigmos/Modules/ICompositeModule.cs index 76610af..b0bdda4 100644 --- a/src/Enigmos/Modules/ICompositeModule.cs +++ b/src/Enigmos/Modules/ICompositeModule.cs @@ -1,6 +1,6 @@ namespace Nocturnis.Enigmos.Modules; -public interface ICompositeModule +public interface ICompositeModule : IBaseModule { IBaseModule[] SubModules { get; } } diff --git a/src/Enigmos/Modules/IComputationalCompositeModule.cs b/src/Enigmos/Modules/IComputationalCompositeModule.cs deleted file mode 100644 index 0cc4be7..0000000 --- a/src/Enigmos/Modules/IComputationalCompositeModule.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Godot; - -namespace Nocturnis.Enigmos.Modules; - -public interface IComputationalCompositeModule : ICompositeModule -{ - Vector2 PositionToBoard { get; } -} diff --git a/src/Enigmos/Modules/IEngineModule.cs b/src/Enigmos/Modules/IEngineModule.cs new file mode 100644 index 0000000..c033584 --- /dev/null +++ b/src/Enigmos/Modules/IEngineModule.cs @@ -0,0 +1,6 @@ +namespace Nocturnis.Enigmos.Modules; + +public interface IEngineModule : ITerminalModule +{ + +} \ No newline at end of file diff --git a/src/Enigmos/Modules/IEnumerableProcessingModule.cs b/src/Enigmos/Modules/IEnumerableProcessingModule.cs new file mode 100644 index 0000000..a59a4e9 --- /dev/null +++ b/src/Enigmos/Modules/IEnumerableProcessingModule.cs @@ -0,0 +1,9 @@ +using Nocturnis.DataStructures; + +namespace Nocturnis.Enigmos.Modules; + +public interface IEnumerableProcessingModule : ICompositeModule +{ + IData[] CachedInputArray { get; set; } + int ProcessingIndex { get; set; } +} diff --git a/src/Enigmos/Modules/IInternalComputationalModule.cs b/src/Enigmos/Modules/IInternalComputationalModule.cs new file mode 100644 index 0000000..b93e793 --- /dev/null +++ b/src/Enigmos/Modules/IInternalComputationalModule.cs @@ -0,0 +1,11 @@ +using Nocturnis.DataStructures; + +namespace Nocturnis.Enigmos.Modules; + +public interface IInternalComputationalModule : ICompositeModule +{ + IData? CachedResult { get; set; } + void Compute(); + bool ComputationFinished { get; set; } + bool ComputationStarted { get; set; } +} \ No newline at end of file diff --git a/src/Enigmos/Modules/IOptimizationModule.cs b/src/Enigmos/Modules/IOptimizationModule.cs index 4605aa7..15f1d9c 100644 --- a/src/Enigmos/Modules/IOptimizationModule.cs +++ b/src/Enigmos/Modules/IOptimizationModule.cs @@ -5,7 +5,7 @@ namespace Nocturnis.Enigmos.Modules; public interface IOptimizationModule : IProgrammableModule { IData CachedResult { get; set; } - bool OptimizationStarted { get; set; } - bool OptimizationFinished { get; set; } + bool ComputationStarted { get; set; } + bool ComputationFinished { get; set; } void Optimize(); } diff --git a/src/Enigmos/Modules/IProgrammableModule.cs b/src/Enigmos/Modules/IProgrammableModule.cs index 1a026e5..6e18574 100644 --- a/src/Enigmos/Modules/IProgrammableModule.cs +++ b/src/Enigmos/Modules/IProgrammableModule.cs @@ -1,5 +1,5 @@ namespace Nocturnis.Enigmos.Modules; -public interface IProgrammableModule : IBaseModule +public interface IProgrammableModule : ICompositeModule { } \ No newline at end of file diff --git a/src/Enigmos/Modules/ITerminalModule.cs b/src/Enigmos/Modules/ITerminalModule.cs index 57d59d7..9b979d2 100644 --- a/src/Enigmos/Modules/ITerminalModule.cs +++ b/src/Enigmos/Modules/ITerminalModule.cs @@ -3,5 +3,6 @@ namespace Nocturnis.Enigmos.Modules; public interface ITerminalModule : IParameterModule { void Drain(); + bool Finished { get; set; } } diff --git a/src/Enigmos/Ports/DataPorts/Directions/IDataInPort.cs b/src/Enigmos/Ports/DataPorts/Directions/IDataInPort.cs index 68fc5ea..53df0cd 100644 --- a/src/Enigmos/Ports/DataPorts/Directions/IDataInPort.cs +++ b/src/Enigmos/Ports/DataPorts/Directions/IDataInPort.cs @@ -1,5 +1,4 @@ using Nocturnis.DataStructures; -using Skeleton.DataStructure; namespace Nocturnis.Enigmos.Ports.DataPorts.Directions; diff --git a/src/Enigmos/Ports/DataPorts/Directions/IDataOutPort.cs b/src/Enigmos/Ports/DataPorts/Directions/IDataOutPort.cs index a7aa145..967a66c 100644 --- a/src/Enigmos/Ports/DataPorts/Directions/IDataOutPort.cs +++ b/src/Enigmos/Ports/DataPorts/Directions/IDataOutPort.cs @@ -1,7 +1,5 @@ using Nocturnis.DataStructures; -using Nocturnis.Enigmos.Modules; using Nocturnis.Enigmos.Modules.ComputationalModules; -using Skeleton.DataStructure; namespace Nocturnis.Enigmos.Ports.DataPorts.Directions; diff --git a/src/Enigmos/Ports/IBasePort.cs b/src/Enigmos/Ports/IBasePort.cs index 14f082f..a52cce4 100644 --- a/src/Enigmos/Ports/IBasePort.cs +++ b/src/Enigmos/Ports/IBasePort.cs @@ -6,6 +6,7 @@ namespace Nocturnis.Enigmos.Ports; public interface IBasePort { + Vector2 PositionToBoard { get; } bool Connected { get; } IBaseModule? Module { get; set; } bool IsMatch(IBasePort oth); diff --git a/src/GlobalManagement/Controls/CreatureControl.cs b/src/GlobalManagement/Controls/CreatureControl.cs index f489ba2..79bff96 100644 --- a/src/GlobalManagement/Controls/CreatureControl.cs +++ b/src/GlobalManagement/Controls/CreatureControl.cs @@ -19,5 +19,5 @@ public class CreatureControl { } - public IBaseCharacter? CurrentCharacter { get; set; } + public IPlayerCharacter? CurrentCharacter { get; set; } } \ No newline at end of file diff --git a/src/GlobalManagement/Controls/EnigmosControl.cs b/src/GlobalManagement/Controls/EnigmosControl.cs index 5fd7a24..d96d510 100644 --- a/src/GlobalManagement/Controls/EnigmosControl.cs +++ b/src/GlobalManagement/Controls/EnigmosControl.cs @@ -1,4 +1,5 @@ using Nocturnis.Enigmos.Modules; +using Nocturnis.GlobalManagement.Providers; namespace Nocturnis.GlobalManagement.Controls; @@ -23,11 +24,14 @@ public class EnigmosControl public void ShutDownEngine() { + EngineUp = false; } public void PowerUpEngine() { + EngineUp = true; } public double Energy { get; set; } = 0d; + public bool EngineUp { get; private set; } } diff --git a/src/GlobalManagement/Providers/GlobalProvider.cs b/src/GlobalManagement/Providers/GlobalProvider.cs index 67f4434..4ff9119 100644 --- a/src/GlobalManagement/Providers/GlobalProvider.cs +++ b/src/GlobalManagement/Providers/GlobalProvider.cs @@ -1,3 +1,5 @@ +using Godot; + namespace Nocturnis.GlobalManagement.Providers; public static class GlobalProvider @@ -8,4 +10,19 @@ public static class GlobalProvider public static ISceneProvider? SceneProvider { get; set; } public static IPolymorphismProvider? PolymorphismProvider { get; set; } public static IDataPackageTypeProvider? DataPackageTypeProvider { get; set; } + public static ITextureProvider? TextureProvider { get; set; } + + public static readonly Dictionary AssetNameMapper = new(); + + public static class ItemIconMapper + { + public static Texture2D? Texture { get; set; } + } + + public static class AssetMapper + { + public static PackedScene Scene { get; set; } + } + + public static Font Font { get; set; } } diff --git a/src/GlobalManagement/Providers/ISceneProvider.cs b/src/GlobalManagement/Providers/ISceneProvider.cs index 2775c80..98e97bd 100644 --- a/src/GlobalManagement/Providers/ISceneProvider.cs +++ b/src/GlobalManagement/Providers/ISceneProvider.cs @@ -1,10 +1,8 @@ -using Godot; using Nocturnis.Scenes; namespace Nocturnis.GlobalManagement.Providers; public interface ISceneProvider { - IRootScene RootScene { get; set; } - PackedScene AssetMapper(); -} \ No newline at end of file + IRootScene? RootScene { get; set; } +} diff --git a/src/GlobalManagement/Providers/ITextureProvider.cs b/src/GlobalManagement/Providers/ITextureProvider.cs new file mode 100644 index 0000000..19676f8 --- /dev/null +++ b/src/GlobalManagement/Providers/ITextureProvider.cs @@ -0,0 +1,11 @@ +using Godot; +using Nocturnis.Enigmos.Modules; +using Nocturnis.Inventories.Items; + +namespace Nocturnis.GlobalManagement.Providers; + +public interface ITextureProvider +{ + Texture2D ModuleTextureMapper(IBaseModule module); + Texture2D ItemTextureMapper(IBaseItem item); +} \ No newline at end of file diff --git a/src/IDirectAsset.cs b/src/IDirectAsset.cs new file mode 100644 index 0000000..41441a4 --- /dev/null +++ b/src/IDirectAsset.cs @@ -0,0 +1,8 @@ +using Nocturnis.Attributes; + +namespace Nocturnis; +[DirectAsset] +public interface IDirectAsset +{ + +} \ No newline at end of file diff --git a/src/INodeInterface.cs b/src/INodeInterface.cs new file mode 100644 index 0000000..3bdbea9 --- /dev/null +++ b/src/INodeInterface.cs @@ -0,0 +1,8 @@ +using Godot; + +namespace Nocturnis; + +public interface INodeInterface +{ + +} \ No newline at end of file diff --git a/src/ISceneConcept.cs b/src/ISceneConcept.cs new file mode 100644 index 0000000..a58f19d --- /dev/null +++ b/src/ISceneConcept.cs @@ -0,0 +1,6 @@ +namespace Nocturnis; + +public interface ISceneConcept +{ + +} \ No newline at end of file diff --git a/src/Inventories/Items/IBaseItem.cs b/src/Inventories/Items/IBaseItem.cs index 2294f39..2c9776f 100644 --- a/src/Inventories/Items/IBaseItem.cs +++ b/src/Inventories/Items/IBaseItem.cs @@ -1,6 +1,11 @@ -namespace Nocturnis.Inventories.Items; +using Godot; +using Skeleton.Algebra; +using Skeleton.Algebra.DimensionProviders; -public interface IBaseItem +namespace Nocturnis.Inventories.Items; +using R2 = CategoryOf.OnField.FVector; +public interface IBaseItem : INodeInterface { - + StringName Status { get; set; } + R2 ItemPosition { get; set; } } \ No newline at end of file diff --git a/src/UIElements/IPanelViewer.cs b/src/UIElements/IPanelViewer.cs index 59877db..e9535be 100644 --- a/src/UIElements/IPanelViewer.cs +++ b/src/UIElements/IPanelViewer.cs @@ -1,6 +1,10 @@ +using Godot; + namespace Nocturnis.UIElements; public interface IPanelViewer { + Camera2D? PanelViewerCamera { get; set; } + void BackToCenter(); } \ No newline at end of file diff --git a/src/UIElements/ISimpleLabel.cs b/src/UIElements/ISimpleLabel.cs index ca3f1d0..1b6bb17 100644 --- a/src/UIElements/ISimpleLabel.cs +++ b/src/UIElements/ISimpleLabel.cs @@ -2,7 +2,7 @@ using Godot; namespace Nocturnis.UIElements; -public interface ISimpleLabel +public interface ISimpleLabel : ISceneConcept { Vector2 Position { get; set; } Vector2 Size { get; set; }