mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-24 20:34:29 +08:00
refactor(godot): 重构Godot相关扩展并迁移至新项目结构
- 将NodeExtensions和UnRegisterExtension迁移至GFramework.Core.Godot项目 - 更新命名空间以匹配新的项目结构 - 为扩展方法参数添加可空注解以提高安全性 - 移除旧的条件编译指令#if GODOT和#endif - 创建新的GFramework.Core.Godot.csproj项目文件 - 在解决方案中注册新的GFramework.Core.Godot项目 - 更新主项目文件以排除新项目中的文件冲突 - 添加GodotSharpEditor包引用以支持Godot编辑器功能 - 链接新项目的扩展文件到原有路径以保持兼容性
This commit is contained in:
parent
4a947a40b1
commit
fdc51e23b7
18
GFramework.Core.Godot/GFramework.Core.Godot.csproj
Normal file
18
GFramework.Core.Godot/GFramework.Core.Godot.csproj
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<Product>GeWuYou.GFramework.Core.Godot</Product>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="GodotSharpEditor" Version="4.5.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\GFramework.Core\GFramework.Core.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@ -1,7 +1,5 @@
|
|||||||
#if GODOT
|
using Godot;
|
||||||
using System.Threading.Tasks;
|
namespace GFramework.Core.Godot.godot.extensions;
|
||||||
using Godot;
|
|
||||||
namespace GFramework.framework.godot;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 节点扩展方法类,提供对Godot节点的扩展功能
|
/// 节点扩展方法类,提供对Godot节点的扩展功能
|
||||||
@ -12,7 +10,7 @@ public static class NodeExtensions
|
|||||||
/// 安全地将节点加入删除队列,在下一帧开始时释放节点资源
|
/// 安全地将节点加入删除队列,在下一帧开始时释放节点资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="node">要释放的节点实例</param>
|
/// <param name="node">要释放的节点实例</param>
|
||||||
public static void QueueFreeX(this Node node)
|
public static void QueueFreeX(this Node? node)
|
||||||
{
|
{
|
||||||
// 检查节点是否为空
|
// 检查节点是否为空
|
||||||
if (node is null)
|
if (node is null)
|
||||||
@ -40,7 +38,7 @@ public static class NodeExtensions
|
|||||||
/// 立即释放节点资源,不等待下一帧
|
/// 立即释放节点资源,不等待下一帧
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="node">要立即释放的节点实例</param>
|
/// <param name="node">要立即释放的节点实例</param>
|
||||||
public static void FreeX(this Node node)
|
public static void FreeX(this Node? node)
|
||||||
{
|
{
|
||||||
// 检查节点是否为空
|
// 检查节点是否为空
|
||||||
if (node is null)
|
if (node is null)
|
||||||
@ -82,7 +80,7 @@ public static class NodeExtensions
|
|||||||
/// 2. Godot 实例仍然存在(未被释放)
|
/// 2. Godot 实例仍然存在(未被释放)
|
||||||
/// 3. 已经加入 SceneTree
|
/// 3. 已经加入 SceneTree
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool IsValidNode(this Node node)
|
public static bool IsValidNode(this Node? node)
|
||||||
{
|
{
|
||||||
return node is not null &&
|
return node is not null &&
|
||||||
GodotObject.IsInstanceValid(node) &&
|
GodotObject.IsInstanceValid(node) &&
|
||||||
@ -97,11 +95,10 @@ public static class NodeExtensions
|
|||||||
///
|
///
|
||||||
/// 返回 true 表示该节点不可用。
|
/// 返回 true 表示该节点不可用。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool IsInvalidNode(this Node node)
|
public static bool IsInvalidNode(this Node? node)
|
||||||
{
|
{
|
||||||
return node is null ||
|
return node is null ||
|
||||||
!GodotObject.IsInstanceValid(node) ||
|
!GodotObject.IsInstanceValid(node) ||
|
||||||
!node.IsInsideTree();
|
!node.IsInsideTree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
@ -1,8 +1,7 @@
|
|||||||
#if GODOT
|
using GFramework.Core.events;
|
||||||
using Godot;
|
using Godot;
|
||||||
using GWFramework.framework.events;
|
|
||||||
|
|
||||||
namespace GWFramework.framework.extensions;
|
namespace GFramework.Core.Godot.godot.extensions;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 提供取消注册扩展方法的静态类
|
/// 提供取消注册扩展方法的静态类
|
||||||
@ -21,6 +20,4 @@ public static class UnRegisterExtension
|
|||||||
node.TreeExiting += unRegister.UnRegister;
|
node.TreeExiting += unRegister.UnRegister;
|
||||||
return unRegister;
|
return unRegister;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -38,6 +38,18 @@
|
|||||||
<EmbeddedResource Remove="GFramework.Generator\**" />
|
<EmbeddedResource Remove="GFramework.Generator\**" />
|
||||||
<EmbeddedResource Remove="GFramework.Generator.Attributes\**" />
|
<EmbeddedResource Remove="GFramework.Generator.Attributes\**" />
|
||||||
<EmbeddedResource Remove="GFramework.Core\**" />
|
<EmbeddedResource Remove="GFramework.Core\**" />
|
||||||
|
<Compile Remove="GFramework.Godot\**" />
|
||||||
|
<EmbeddedResource Remove="GFramework.Godot\**" />
|
||||||
|
<None Remove="GFramework.Godot\**" />
|
||||||
|
<Compile Update="GFramework.Core.Godot\godot\extensions\NodeExtensions.cs">
|
||||||
|
<Link>GFramework.Godot\godot\extensions\NodeExtensions.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="GFramework.Core.Godot\godot\extensions\UnRegisterExtension.cs">
|
||||||
|
<Link>GFramework.Godot\godot\extensions\UnRegisterExtension.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Remove="GFramework.Core.Godot\**" />
|
||||||
|
<EmbeddedResource Remove="GFramework.Core.Godot\**" />
|
||||||
|
<None Remove="GFramework.Core.Godot\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- 作为 Analyzer 引入本地 SourceGenerator -->
|
<!-- 作为 Analyzer 引入本地 SourceGenerator -->
|
||||||
|
|||||||
@ -8,6 +8,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Generator.Attrib
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Core", "GFramework.Core\GFramework.Core.csproj", "{A6D5854D-79EA-487A-9ED9-396E6A1F8031}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Core", "GFramework.Core\GFramework.Core.csproj", "{A6D5854D-79EA-487A-9ED9-396E6A1F8031}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Core.Godot", "GFramework.Core.Godot\GFramework.Core.Godot.csproj", "{FC56D81A-3A3B-4B49-B318-363DFA0D8206}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -30,5 +32,9 @@ Global
|
|||||||
{A6D5854D-79EA-487A-9ED9-396E6A1F8031}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{A6D5854D-79EA-487A-9ED9-396E6A1F8031}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A6D5854D-79EA-487A-9ED9-396E6A1F8031}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{A6D5854D-79EA-487A-9ED9-396E6A1F8031}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{A6D5854D-79EA-487A-9ED9-396E6A1F8031}.Release|Any CPU.Build.0 = Release|Any CPU
|
{A6D5854D-79EA-487A-9ED9-396E6A1F8031}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{FC56D81A-3A3B-4B49-B318-363DFA0D8206}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FC56D81A-3A3B-4B49-B318-363DFA0D8206}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FC56D81A-3A3B-4B49-B318-363DFA0D8206}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FC56D81A-3A3B-4B49-B318-363DFA0D8206}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user