diff --git a/GFramework.Game/input/InputContextStack.cs b/GFramework.Game/input/InputContextStack.cs
index 358dde4..5c6663a 100644
--- a/GFramework.Game/input/InputContextStack.cs
+++ b/GFramework.Game/input/InputContextStack.cs
@@ -14,20 +14,41 @@ public class InputContextStack
public void Push(IInputContext context) => _stack.Push(context);
///
- /// 弹出堆栈顶部的输入上下文
+ /// 弹出堆栈顶部的元素
///
public void Pop() => _stack.Pop();
-
+
///
- /// 处理游戏输入事件,遍历堆栈中的所有上下文直到找到能够处理该事件的上下文
+ /// 弹出堆栈顶部的输入上下文
+ ///
+ /// 要弹出的输入上下文对象
+ /// 如果成功弹出返回true,否则返回false
+ public bool Pop(IInputContext ctx)
+ {
+ // 检查堆栈顶部元素是否与指定上下文匹配,如果不匹配则返回false
+ if (!_stack.TryPeek(out var top) || top != ctx) return false;
+ _stack.Pop();
+ return true;
+ }
+
+
+ ///
+ /// 获取堆栈顶部的输入上下文但不移除它
+ ///
+ /// 堆栈顶部的输入上下文
+ public IInputContext Peek() => _stack.Peek();
+
+
+ ///
+ /// 处理游戏输入事件
///
/// 要处理的游戏输入事件
- /// 如果堆栈中任意一个上下文成功处理了输入事件则返回true,否则返回false
+ /// 如果任何一个输入上下文成功处理了输入事件则返回true,否则返回false
public bool Handle(IGameInputEvent input)
{
- // 遍历堆栈中的所有上下文,调用其Handle方法处理输入事件
- // Any方法会在第一个返回true的上下文处停止遍历
+ // 从堆栈顶部开始遍历输入上下文,尝试处理输入事件
return _stack.Any(ctx => ctx.Handle(input));
}
+
}
diff --git a/GFramework.Game/input/InputSystem.cs b/GFramework.Game/input/InputSystem.cs
index 3de55d4..38bbf6a 100644
--- a/GFramework.Game/input/InputSystem.cs
+++ b/GFramework.Game/input/InputSystem.cs
@@ -80,7 +80,6 @@ public class InputSystem : AbstractSystem
{
if (!t.TryTranslate(rawInput, out var gameEvent)) continue;
Handle(gameEvent);
- return;
}
}
diff --git a/GFramework.Godot/input/AbstractGodotInputModule.cs b/GFramework.Godot/input/AbstractGodotInputModule.cs
index 4c14c9e..ac7ae7c 100644
--- a/GFramework.Godot/input/AbstractGodotInputModule.cs
+++ b/GFramework.Godot/input/AbstractGodotInputModule.cs
@@ -25,7 +25,7 @@ public abstract class AbstractGodotInputModule : AbstractGodotModule
/// 架构锚点节点的唯一标识名称
/// 用于在Godot场景树中创建和查找架构锚点节点
///
- private const string GodotInputBridgeName = $"__${GFrameworkConstants.FrameworkName}__GodotInputBridge__";
+ private const string GodotInputBridgeName = $"__{GFrameworkConstants.FrameworkName}__GodotInputBridge__";
///
/// 获取模块对应的节点对象