mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
新增 `IInputTranslator` 接口用于解耦原始输入与游戏事件的转换逻辑。 在 `InputSystem` 中增加注册、注销和处理原始输入的方法,支持优先级控制。 重构 `GodotInputBridge`,移除原有硬编码翻译逻辑,改为通过 `HandleRaw` 调用转换器处理。 新增 `GodotInputTranslator` 实现 `IInputTranslator`,负责将 Godot 输入事件翻译为游戏事件。 模块初始化时自动注册该转换器至输入系统。
31 lines
767 B
C#
31 lines
767 B
C#
using GFramework.Game.input;
|
||
using Godot;
|
||
|
||
namespace GFramework.Godot.input;
|
||
|
||
/// <summary>
|
||
/// Godot输入桥接类,用于将Godot的输入事件转换为游戏框架的输入事件
|
||
/// </summary>
|
||
public partial class GodotInputBridge : Node
|
||
{
|
||
private InputSystem _inputSystem = null!;
|
||
|
||
/// <summary>
|
||
/// 绑定输入系统
|
||
/// </summary>
|
||
/// <param name="inputSystem">要绑定的输入系统实例</param>
|
||
public void Bind(InputSystem inputSystem)
|
||
{
|
||
_inputSystem = inputSystem;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 处理输入事件的回调方法
|
||
/// </summary>
|
||
/// <param name="event">Godot输入事件</param>
|
||
public override void _Input(InputEvent @event)
|
||
{
|
||
_inputSystem.HandleRaw(@event);
|
||
}
|
||
}
|