using GFramework.Core.Abstractions.Pause; using Godot; namespace GFramework.Godot.Pause; /// /// Godot 引擎的暂停处理器 /// 响应暂停栈状态变化,控制 SceneTree.Paused /// public class GodotPauseHandler : IPauseHandler { private readonly SceneTree _tree; /// /// 创建 Godot 暂停处理器 /// /// 场景树 public GodotPauseHandler(SceneTree tree) { _tree = tree ?? throw new ArgumentNullException(nameof(tree)); } /// /// 处理器优先级 /// public int Priority => 0; /// /// 当暂停状态变化时调用 /// /// 暂停组 /// 是否暂停 public void OnPauseStateChanged(PauseGroup group, bool isPaused) { // 只有 Global 组影响 Godot 的全局暂停 if (group == PauseGroup.Global) { _tree.Paused = isPaused; GD.Print($"[GodotPauseHandler] SceneTree.Paused = {isPaused}"); } } }