refactor: HUD 节点改用唯一名称引用,场景识别改用分组

- TopBarHUD 用 @onready + % 唯一名称替代硬编码路径
- TimeSystem 用 game_scene 分组替代场景名字符串比较
This commit is contained in:
2026-08-03 22:33:40 +08:00
parent 476834176c
commit b6c76d83d7
4 changed files with 19 additions and 13 deletions
+1
View File
@@ -4,6 +4,7 @@
[ext_resource type="PackedScene" uid="uid://dl0tb68vsw3c6" path="res://src/UI/HUD/TopBarHUD.tscn" id="1_g6xmk"]
[node name="MainGame" type="Node" unique_id=2053561265]
groups = ["game_scene"]
script = ExtResource("1_8bu23")
[node name="TopBarHud" parent="." unique_id=1115394694 instance=ExtResource("1_g6xmk")]
+2 -1
View File
@@ -51,9 +51,10 @@ func _process(delta: float) -> void:
## 判断当前场景是否为游戏世界场景(主菜单/存档界面不推进时间)。
## 通过 "game_scene" 分组识别,而非场景名。
func _is_in_game() -> bool:
var scene := get_tree().current_scene
return scene != null and scene.name == "MainGame"
return scene != null and scene.is_in_group("game_scene")
## 推进一日并广播对应信号,跨月/跨年时补发 month_passed / year_passed。