mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
refactor(godot): 将Godot抽象接口移动到独立项目
- 将IGodotModule接口从GFramework.Godot移动到GFramework.Godot.Abstractions - 将IResourceLoadSystem接口从GFramework.Godot移动到GFramework.Godot.Abstractions - 将IAudioManagerSystem接口从GFramework.Godot移动到GFramework.Godot.Abstractions - 在相关系统类中添加对GFramework.Godot.Abstractions的引用 - 在解决方案文件中添加GFramework.Godot.Abstractions项目引用 - 创建Directory.Build.props和项目配置文件支持抽象层构建
This commit is contained in:
parent
a191228d85
commit
1a13809bae
24
GFramework.Godot.Abstractions/Directory.Build.props
Normal file
24
GFramework.Godot.Abstractions/Directory.Build.props
Normal file
@ -0,0 +1,24 @@
|
||||
<Project>
|
||||
<!-- import parent: https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build -->
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
|
||||
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||
<!--
|
||||
we use a higher version than supported by the target framework to have nullable types and other nice features
|
||||
(a lot of features get polyfilled by Meziantou.Polyfill)
|
||||
however we need to be careful with the available features!
|
||||
-->
|
||||
<LangVersion>preview</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Meziantou.Analyzer" Version="2.0.264">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Meziantou.Polyfill" Version="1.0.71">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!--
|
||||
配置项目构建属性
|
||||
设置项目不可打包、生成文档文件,并包含特定的Polyfill
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<IsPackable>false</IsPackable>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<MeziantouPolyfill_IncludedPolyfills>T:System.Diagnostics.CodeAnalysis.NotNullWhenAttribute</MeziantouPolyfill_IncludedPolyfills>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Godot.SourceGenerators" Version="4.5.1" PrivateAssets="all"/>
|
||||
<PackageReference Include="GodotSharpEditor" Version="4.5.1" PrivateAssets="all"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GFramework.Core.Abstractions\GFramework.Core.Abstractions.csproj" PrivateAssets="all"/>
|
||||
</ItemGroup>
|
||||
<!-- 引入必要的命名空间 -->
|
||||
<ItemGroup>
|
||||
<Using Include="GFramework.Godot.Abstractions"/>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -1,8 +1,6 @@
|
||||
using GFramework.Core.Abstractions.architecture;
|
||||
using GFramework.Core.architecture;
|
||||
using Godot;
|
||||
|
||||
namespace GFramework.Godot.architecture;
|
||||
namespace GFramework.Godot.Abstractions.architecture;
|
||||
|
||||
/// <summary>
|
||||
/// Godot模块接口,定义了Godot引擎中模块的基本行为和属性
|
||||
@ -1,8 +1,6 @@
|
||||
using GFramework.Core.Abstractions.system;
|
||||
using GFramework.Game.assets;
|
||||
using Godot;
|
||||
|
||||
namespace GFramework.Godot.assets;
|
||||
namespace GFramework.Godot.Abstractions.assets;
|
||||
|
||||
/// <summary>
|
||||
/// 资源加载系统接口,提供资源和场景的加载、实例化、预加载等功能
|
||||
@ -1,7 +1,6 @@
|
||||
using GFramework.Core.Abstractions.system;
|
||||
using Godot;
|
||||
|
||||
namespace GFramework.Godot.system;
|
||||
namespace GFramework.Godot.Abstractions.system;
|
||||
|
||||
/// <summary>
|
||||
/// 音频管理器系统接口,用于统一管理背景音乐和音效的播放
|
||||
@ -15,8 +15,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GFramework.Game\GFramework.Game.csproj"/>
|
||||
<ProjectReference Include="..\GFramework.Godot.Abstractions\GFramework.Godot.Abstractions.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="extensions\ControlExtensions.cs"/>
|
||||
</ItemGroup>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using GFramework.Core.Abstractions.architecture;
|
||||
using GFramework.Core.system;
|
||||
using GFramework.Game.assets;
|
||||
using GFramework.Godot.Abstractions.assets;
|
||||
using Godot;
|
||||
|
||||
namespace GFramework.Godot.assets;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using GFramework.Core.system;
|
||||
using GFramework.Game.assets;
|
||||
using GFramework.Godot.assets;
|
||||
using GFramework.Godot.Abstractions.assets;
|
||||
using Godot;
|
||||
|
||||
namespace GFramework.Godot.system;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using GFramework.Core.system;
|
||||
using GFramework.Game.assets;
|
||||
using GFramework.Godot.assets;
|
||||
using GFramework.Godot.Abstractions.assets;
|
||||
using GFramework.Godot.Abstractions.system;
|
||||
using Godot;
|
||||
|
||||
namespace GFramework.Godot.system;
|
||||
@ -195,26 +196,6 @@ public abstract class AbstractAudioManagerSystem : AbstractSystem, IAudioManager
|
||||
player.Play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 播放3D音效
|
||||
/// </summary>
|
||||
/// <param name="audioPath">音频文件路径</param>
|
||||
/// <param name="position">3D空间中的位置</param>
|
||||
/// <param name="volume">音量大小,范围0-1</param>
|
||||
public virtual void PlaySound3D(string audioPath, Vector3 position, float volume = 1.0f)
|
||||
{
|
||||
if (AvailableSound3DPlayers.Count == 0) return;
|
||||
|
||||
var audioStream = ResourceLoadSystem?.LoadResource<AudioStream>(audioPath);
|
||||
if (audioStream == null) return;
|
||||
|
||||
var player = AvailableSound3DPlayers.Dequeue();
|
||||
player.Stream = audioStream;
|
||||
player.VolumeDb = LinearToDb(volume * SoundVolume * MasterVolume);
|
||||
player.Position = position;
|
||||
player.Play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止背景音乐
|
||||
/// </summary>
|
||||
@ -425,6 +406,26 @@ public abstract class AbstractAudioManagerSystem : AbstractSystem, IAudioManager
|
||||
// 可以通过AudioEffectReverb实现
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 播放3D音效
|
||||
/// </summary>
|
||||
/// <param name="audioPath">音频文件路径</param>
|
||||
/// <param name="position">3D空间中的位置</param>
|
||||
/// <param name="volume">音量大小,范围0-1</param>
|
||||
public virtual void PlaySound3D(string audioPath, Vector3 position, float volume = 1.0f)
|
||||
{
|
||||
if (AvailableSound3DPlayers.Count == 0) return;
|
||||
|
||||
var audioStream = ResourceLoadSystem?.LoadResource<AudioStream>(audioPath);
|
||||
if (audioStream == null) return;
|
||||
|
||||
var player = AvailableSound3DPlayers.Dequeue();
|
||||
player.Stream = audioStream;
|
||||
player.VolumeDb = LinearToDb(volume * SoundVolume * MasterVolume);
|
||||
player.Position = position;
|
||||
player.Play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 系统初始化方法
|
||||
/// </summary>
|
||||
|
||||
@ -22,6 +22,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.SourceGenerators
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Core.Abstractions", "GFramework.Core.Abstractions\GFramework.Core.Abstractions.csproj", "{31BA9F62-153A-4943-A8A0-7571FC7D5FEE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Godot.Abstractions", "GFramework.Godot.Abstractions\GFramework.Godot.Abstractions.csproj", "{EFE2EF31-CEAC-4BFD-851B-5E00FEBC945D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -72,5 +74,9 @@ Global
|
||||
{31BA9F62-153A-4943-A8A0-7571FC7D5FEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{31BA9F62-153A-4943-A8A0-7571FC7D5FEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{31BA9F62-153A-4943-A8A0-7571FC7D5FEE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EFE2EF31-CEAC-4BFD-851B-5E00FEBC945D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{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
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user