diff --git a/GFramework.Game.Abstractions/Directory.Build.props b/GFramework.Game.Abstractions/Directory.Build.props new file mode 100644 index 0000000..1e6c3bf --- /dev/null +++ b/GFramework.Game.Abstractions/Directory.Build.props @@ -0,0 +1,24 @@ + + + + netstandard2.0 + true + true + + preview + + + + all + runtime; build; native; contentfiles; analyzers + + + all + runtime; build; native; contentfiles; analyzers + + + diff --git a/GFramework.Game.Abstractions/GFramework.Game.Abstractions.csproj b/GFramework.Game.Abstractions/GFramework.Game.Abstractions.csproj new file mode 100644 index 0000000..fc12664 --- /dev/null +++ b/GFramework.Game.Abstractions/GFramework.Game.Abstractions.csproj @@ -0,0 +1,20 @@ + + + + + false + true + T:System.Diagnostics.CodeAnalysis.NotNullWhenAttribute + enable + + + + + + + + + diff --git a/GFramework.Game.Abstractions/assets/AssetCatalog.cs b/GFramework.Game.Abstractions/assets/AssetCatalog.cs new file mode 100644 index 0000000..3425829 --- /dev/null +++ b/GFramework.Game.Abstractions/assets/AssetCatalog.cs @@ -0,0 +1,52 @@ +namespace System.Runtime.CompilerServices +{ + // 这个类用于支持C# 9.0中的init访问器和记录类型功能 + internal static class IsExternalInit; +} + +namespace GFramework.Game.Abstractions.assets +{ + /// + /// 资源目录类,用于定义和管理游戏中的场景和资源标识符 + /// + public static class AssetCatalog + { + /// + /// 资源标识符接口,定义了资源路径的访问接口 + /// + public interface IAssetId + { + /// + /// 获取资源的路径 + /// + string Path { get; } + } + + /// + /// 资源目录映射结构体,用于存储资源目录的键值对映射关系 + /// + /// 资源目录的键 + /// 资源标识符 + public readonly record struct AssetCatalogMapping(string Key, IAssetId Id); + + + /// + /// 场景页面资源标识符结构体,用于标识场景页面资源 + /// + /// 场景页面资源路径 + public readonly record struct ScenePageId(string Path) : IAssetId; + + + /// + /// 场景单元资源标识符结构体,用于标识场景单元资源 + /// + /// 场景单元资源路径 + public readonly record struct SceneUnitId(string Path) : IAssetId; + + /// + /// 通用资源标识符结构体,实现IAssetId接口 + /// + /// 资源路径 + public readonly record struct AssetId(string Path) : IAssetId; + } +} \ No newline at end of file diff --git a/GFramework.Game/assets/IAssetCatalogSystem.cs b/GFramework.Game.Abstractions/assets/IAssetCatalogSystem.cs similarity index 98% rename from GFramework.Game/assets/IAssetCatalogSystem.cs rename to GFramework.Game.Abstractions/assets/IAssetCatalogSystem.cs index 5a0f57b..cab53ee 100644 --- a/GFramework.Game/assets/IAssetCatalogSystem.cs +++ b/GFramework.Game.Abstractions/assets/IAssetCatalogSystem.cs @@ -1,6 +1,6 @@ using GFramework.Core.Abstractions.system; -namespace GFramework.Game.assets; +namespace GFramework.Game.Abstractions.assets; /// /// 资源目录系统接口,用于管理场景和资源的获取与查询 diff --git a/GFramework.Game/assets/IResourceFactorySystem.cs b/GFramework.Game.Abstractions/assets/IResourceFactorySystem.cs similarity index 89% rename from GFramework.Game/assets/IResourceFactorySystem.cs rename to GFramework.Game.Abstractions/assets/IResourceFactorySystem.cs index e35de48..fff1989 100644 --- a/GFramework.Game/assets/IResourceFactorySystem.cs +++ b/GFramework.Game.Abstractions/assets/IResourceFactorySystem.cs @@ -1,6 +1,7 @@ -using GFramework.Core.Abstractions.system; +using System; +using GFramework.Core.Abstractions.system; -namespace GFramework.Game.assets; +namespace GFramework.Game.Abstractions.assets; /// /// 资源工厂系统接口,用于获取指定类型的资源创建函数 diff --git a/GFramework.Game/assets/ResourceFactory.cs b/GFramework.Game.Abstractions/assets/ResourceFactory.cs similarity index 97% rename from GFramework.Game/assets/ResourceFactory.cs rename to GFramework.Game.Abstractions/assets/ResourceFactory.cs index d85babd..40176be 100644 --- a/GFramework.Game/assets/ResourceFactory.cs +++ b/GFramework.Game.Abstractions/assets/ResourceFactory.cs @@ -1,4 +1,8 @@ -namespace GFramework.Game.assets; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace GFramework.Game.Abstractions.assets; /// /// 资源工厂类,用于注册和解析各种资源的创建工厂 diff --git a/GFramework.Game/GFramework.Game.csproj b/GFramework.Game/GFramework.Game.csproj index 629ae18..c5189f3 100644 --- a/GFramework.Game/GFramework.Game.csproj +++ b/GFramework.Game/GFramework.Game.csproj @@ -8,5 +8,6 @@ + diff --git a/GFramework.Game/assets/AbstractAssetCatalogSystem.cs b/GFramework.Game/assets/AbstractAssetCatalogSystem.cs index bac333d..894464d 100644 --- a/GFramework.Game/assets/AbstractAssetCatalogSystem.cs +++ b/GFramework.Game/assets/AbstractAssetCatalogSystem.cs @@ -1,4 +1,5 @@ using GFramework.Core.system; +using GFramework.Game.Abstractions.assets; namespace GFramework.Game.assets; diff --git a/GFramework.Game/assets/AssetCatalog.cs b/GFramework.Game/assets/AssetCatalog.cs deleted file mode 100644 index f1abd49..0000000 --- a/GFramework.Game/assets/AssetCatalog.cs +++ /dev/null @@ -1,45 +0,0 @@ -namespace GFramework.Game.assets; - -/// -/// 资源目录类,用于定义和管理游戏中的场景和资源标识符 -/// -public static class AssetCatalog -{ - /// - /// 资源标识符接口,定义了资源路径的访问接口 - /// - public interface IAssetId - { - /// - /// 获取资源的路径 - /// - string Path { get; } - } - - /// - /// 资源目录映射结构体,用于存储资源目录的键值对映射关系 - /// - /// 资源目录的键 - /// 资源标识符 - public readonly record struct AssetCatalogMapping(string Key, IAssetId Id); - - - /// - /// 场景页面资源标识符结构体,用于标识场景页面资源 - /// - /// 场景页面资源路径 - public readonly record struct ScenePageId(string Path) : IAssetId; - - - /// - /// 场景单元资源标识符结构体,用于标识场景单元资源 - /// - /// 场景单元资源路径 - public readonly record struct SceneUnitId(string Path) : IAssetId; - - /// - /// 通用资源标识符结构体,实现IAssetId接口 - /// - /// 资源路径 - public readonly record struct AssetId(string Path) : IAssetId; -} \ No newline at end of file diff --git a/GFramework.Godot.Abstractions/GFramework.Godot.Abstractions.csproj b/GFramework.Godot.Abstractions/GFramework.Godot.Abstractions.csproj index bedec62..12bbbed 100644 --- a/GFramework.Godot.Abstractions/GFramework.Godot.Abstractions.csproj +++ b/GFramework.Godot.Abstractions/GFramework.Godot.Abstractions.csproj @@ -16,6 +16,7 @@ + diff --git a/GFramework.Godot.Abstractions/assets/IResourceLoadSystem.cs b/GFramework.Godot.Abstractions/assets/IResourceLoadSystem.cs index 3070391..50a2e6e 100644 --- a/GFramework.Godot.Abstractions/assets/IResourceLoadSystem.cs +++ b/GFramework.Godot.Abstractions/assets/IResourceLoadSystem.cs @@ -1,4 +1,7 @@ -using GFramework.Core.Abstractions.system; +using System; +using System.Collections.Generic; +using GFramework.Core.Abstractions.system; +using GFramework.Game.Abstractions.assets; namespace GFramework.Godot.Abstractions.assets; diff --git a/GFramework.Godot/GFramework.Godot.csproj b/GFramework.Godot/GFramework.Godot.csproj index fbeda6a..de3a586 100644 --- a/GFramework.Godot/GFramework.Godot.csproj +++ b/GFramework.Godot/GFramework.Godot.csproj @@ -14,6 +14,7 @@ + diff --git a/GFramework.Godot/architecture/AbstractArchitecture.cs b/GFramework.Godot/architecture/AbstractArchitecture.cs index 49943ab..6403e60 100644 --- a/GFramework.Godot/architecture/AbstractArchitecture.cs +++ b/GFramework.Godot/architecture/AbstractArchitecture.cs @@ -1,5 +1,6 @@ using GFramework.Core.architecture; using GFramework.Core.constants; +using GFramework.Godot.Abstractions.architecture; using GFramework.Godot.extensions; using Godot; diff --git a/GFramework.Godot/architecture/AbstractGodotModule.cs b/GFramework.Godot/architecture/AbstractGodotModule.cs index 79f821b..13bd4ce 100644 --- a/GFramework.Godot/architecture/AbstractGodotModule.cs +++ b/GFramework.Godot/architecture/AbstractGodotModule.cs @@ -1,5 +1,6 @@ using GFramework.Core.Abstractions.architecture; using GFramework.Core.architecture; +using GFramework.Godot.Abstractions.architecture; using Godot; namespace GFramework.Godot.architecture; @@ -9,6 +10,11 @@ namespace GFramework.Godot.architecture; /// public abstract class AbstractGodotModule : IGodotModule { + /// + /// 获取模块关联的Godot节点 + /// + public abstract Node Node { get; } + /// /// 当架构阶段发生变化时调用此方法 /// @@ -33,9 +39,11 @@ public abstract class AbstractGodotModule : IGodotModule public abstract void Install(IArchitecture architecture); /// - /// 获取模块关联的Godot节点 + /// 当模块从架构中分离时调用此方法 /// - public abstract Node Node { get; } + public virtual void OnDetach() + { + } /// /// 当模块被附加到架构时调用此方法 @@ -44,11 +52,4 @@ public abstract class AbstractGodotModule : IGodotModule public virtual void OnAttach(Architecture architecture) { } - - /// - /// 当模块从架构中分离时调用此方法 - /// - public virtual void OnDetach() - { - } } \ No newline at end of file diff --git a/GFramework.Godot/assets/ResourceLoadSystem.cs b/GFramework.Godot/assets/ResourceLoadSystem.cs index 426ce77..eb541a6 100644 --- a/GFramework.Godot/assets/ResourceLoadSystem.cs +++ b/GFramework.Godot/assets/ResourceLoadSystem.cs @@ -1,9 +1,9 @@ using GFramework.Core.system; -using GFramework.Game.assets; +using GFramework.Game.Abstractions.assets; using GFramework.Godot.Abstractions.assets; using Godot; -namespace GFramework.Godot.system; +namespace GFramework.Godot.assets; /// /// 资源加载系统,用于统一管理和缓存Godot资源(如场景、纹理等)的加载与实例化。 diff --git a/GFramework.csproj b/GFramework.csproj index f8b9dd3..f737276 100644 --- a/GFramework.csproj +++ b/GFramework.csproj @@ -44,6 +44,8 @@ + + @@ -71,6 +73,8 @@ + + @@ -84,9 +88,8 @@ - - - + + diff --git a/GFramework.sln b/GFramework.sln index cf67b9b..7953d3f 100644 --- a/GFramework.sln +++ b/GFramework.sln @@ -24,6 +24,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Core.Abstraction EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Godot.Abstractions", "GFramework.Godot.Abstractions\GFramework.Godot.Abstractions.csproj", "{EFE2EF31-CEAC-4BFD-851B-5E00FEBC945D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Game.Abstractions", "GFramework.Game.Abstractions\GFramework.Game.Abstractions.csproj", "{E20DBA4C-CEB9-4184-B614-5A99A9AE4472}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -78,5 +80,9 @@ Global {EFE2EF31-CEAC-4BFD-851B-5E00FEBC945D}.Debug|Any CPU.Build.0 = Debug|Any CPU {EFE2EF31-CEAC-4BFD-851B-5E00FEBC945D}.Release|Any CPU.ActiveCfg = Release|Any CPU {EFE2EF31-CEAC-4BFD-851B-5E00FEBC945D}.Release|Any CPU.Build.0 = Release|Any CPU + {E20DBA4C-CEB9-4184-B614-5A99A9AE4472}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E20DBA4C-CEB9-4184-B614-5A99A9AE4472}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E20DBA4C-CEB9-4184-B614-5A99A9AE4472}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E20DBA4C-CEB9-4184-B614-5A99A9AE4472}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal