增加pause_counter_arr、sign interact/cancel、各类entity等日志记录点
This commit is contained in:
parent
3b1822810f
commit
a29f0fca79
@ -332,7 +332,9 @@ func _jump_back_to_index_and_quit_main() -> void:
|
|||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
get_tree().change_scene_to_packed(packed_index_page)
|
get_tree().change_scene_to_packed(packed_index_page)
|
||||||
# 防止游戏卡死 reset pause counter
|
# 防止游戏卡死 reset pause counter
|
||||||
pause_counter = 0
|
if pause_counter_arr.size() > 0:
|
||||||
|
printerr("checkout_index_page: pause_counter_arr is not empty, resetting pause counter")
|
||||||
|
pause_counter_arr.clear()
|
||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
|
|
||||||
|
|
||||||
@ -344,7 +346,9 @@ func enter_main_scene() -> void:
|
|||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
get_tree().change_scene_to_packed.call_deferred(main_scene)
|
get_tree().change_scene_to_packed.call_deferred(main_scene)
|
||||||
# get_tree().change_scene_to_file.call_deferred("uid://dygvcmykn02n8")
|
# get_tree().change_scene_to_file.call_deferred("uid://dygvcmykn02n8")
|
||||||
pause_counter = 0
|
if pause_counter_arr.size() > 0:
|
||||||
|
printerr("enter_main_scene: pause_counter_arr is not empty, resetting pause counter")
|
||||||
|
pause_counter_arr.clear()
|
||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
|
|
||||||
|
|
||||||
@ -386,16 +390,20 @@ func show_settings() -> void:
|
|||||||
|
|
||||||
|
|
||||||
#### 游戏场景树暂停计数器,设置、memory、bag 等菜单都会导致 pause
|
#### 游戏场景树暂停计数器,设置、memory、bag 等菜单都会导致 pause
|
||||||
var pause_counter := 0
|
## 目前有(5类): settings, panel, bag, note, memory
|
||||||
|
var pause_counter_arr: Array[String] = []
|
||||||
var pause_counter_mutex := Mutex.new()
|
var pause_counter_mutex := Mutex.new()
|
||||||
|
|
||||||
|
|
||||||
func toggle_pause_counter(plus := true) -> void:
|
func toggle_pause_counter(plus := true, from := "") -> void:
|
||||||
# 若不 lock,会导致快速切换菜单时出现并发问题(pause_counter 成为负数)
|
# 若不 lock,会导致快速切换菜单时出现并发问题(pause_counter 成为负数)
|
||||||
pause_counter_mutex.lock()
|
pause_counter_mutex.lock()
|
||||||
pause_counter += 1 if plus else -1
|
if plus:
|
||||||
print("SceneTree pause_counter: ", pause_counter)
|
pause_counter_arr.append(from)
|
||||||
get_tree().paused = pause_counter > 0
|
else:
|
||||||
|
pause_counter_arr.erase(from)
|
||||||
|
print("SceneTree pause_counter_arr: ", pause_counter_arr)
|
||||||
|
get_tree().paused = len(pause_counter_arr) > 0
|
||||||
pause_counter_mutex.unlock()
|
pause_counter_mutex.unlock()
|
||||||
|
|
||||||
|
|
||||||
|
@ -279,7 +279,6 @@ func _on_freeze_changed(count: int, is_add: bool):
|
|||||||
|
|
||||||
# 非首次 freeze 不改变动画状态,因为在动画演出中可能多次 freeze 与 release
|
# 非首次 freeze 不改变动画状态,因为在动画演出中可能多次 freeze 与 release
|
||||||
func _on_first_frozen() -> void:
|
func _on_first_frozen() -> void:
|
||||||
if GlobalConfig.DEBUG:
|
|
||||||
print("player _on_first_frozen. current_status=", current_status)
|
print("player _on_first_frozen. current_status=", current_status)
|
||||||
# reset status to idle or stay
|
# reset status to idle or stay
|
||||||
velocity = Vector2.ZERO
|
velocity = Vector2.ZERO
|
||||||
@ -372,8 +371,7 @@ func walk_to_x(global_pos_x: float) -> Tween:
|
|||||||
func walk_to(global_pos: Vector2) -> Tween:
|
func walk_to(global_pos: Vector2) -> Tween:
|
||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
velocity = Vector2.ZERO
|
velocity = Vector2.ZERO
|
||||||
if GlobalConfig.DEBUG:
|
print("player walk_to:", global_pos, " from:", global_position)
|
||||||
print("walk_to:", global_pos, " from:", global_position)
|
|
||||||
# 不同距离下,行走时长略做自适应
|
# 不同距离下,行走时长略做自适应
|
||||||
var time_cost = absf(global_pos.distance_to(global_position) / 50.0)
|
var time_cost = absf(global_pos.distance_to(global_position) / 50.0)
|
||||||
# 忽略过小的位移
|
# 忽略过小的位移
|
||||||
@ -406,8 +404,7 @@ func toggle_pause_state(pause := true) -> void:
|
|||||||
func _after_walk_to() -> void:
|
func _after_walk_to() -> void:
|
||||||
current_status = PlayerAnimationConfig.MOVEMENT_IDLE
|
current_status = PlayerAnimationConfig.MOVEMENT_IDLE
|
||||||
_play_animation()
|
_play_animation()
|
||||||
if GlobalConfig.DEBUG:
|
print("player walk_to end. unlock player")
|
||||||
print("walk_to end. unlock player")
|
|
||||||
SceneManager.unlock_player()
|
SceneManager.unlock_player()
|
||||||
|
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ func apply_dialogue_line() -> void:
|
|||||||
if audio_stream_player.playing:
|
if audio_stream_player.playing:
|
||||||
audio_stream_player.stop()
|
audio_stream_player.stop()
|
||||||
if GlobalConfig.DEBUG:
|
if GlobalConfig.DEBUG:
|
||||||
printerr("Dialogue no audio found! audio_path = %s audio_import_path = %s" % [audio_path, audio_import_path])
|
print_rich("[color=orange]Dialogue no audio found! audio_path = %s audio_import_path = %s" % [audio_path, audio_import_path])
|
||||||
|
|
||||||
# if dialogue_label.is_typing:
|
# if dialogue_label.is_typing:
|
||||||
# await dialogue_label.finished_typing
|
# await dialogue_label.finished_typing
|
||||||
|
@ -33,7 +33,7 @@ func display() -> void:
|
|||||||
if current_child.has_signal("exit"):
|
if current_child.has_signal("exit"):
|
||||||
current_child.connect("exit", _exit)
|
current_child.connect("exit", _exit)
|
||||||
elif GlobalConfig.DEBUG:
|
elif GlobalConfig.DEBUG:
|
||||||
print("[特写界面] no exit signal, packed_scene:", packed_scene)
|
print_rich("[color=orange][特写界面] no exit signal, packed_scene:", packed_scene)
|
||||||
|
|
||||||
|
|
||||||
func _exit(arg = null):
|
func _exit(arg = null):
|
||||||
|
@ -121,8 +121,7 @@ func _interacted():
|
|||||||
else:
|
else:
|
||||||
SceneManager.enable_prop_item(prop_key)
|
SceneManager.enable_prop_item(prop_key)
|
||||||
triggered.emit()
|
triggered.emit()
|
||||||
if GlobalConfig.DEBUG:
|
print("pickable triggered! prop_key=", prop_key, ",as_important_item=", as_important_item)
|
||||||
print("pickable triggered! name=", name)
|
|
||||||
_check_display()
|
_check_display()
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +95,6 @@ func _ready() -> void:
|
|||||||
ground_archive = ArchiveManager.archive.ground_archive()
|
ground_archive = ArchiveManager.archive.ground_archive()
|
||||||
icount = ground_archive.get_value(name, "icount", 0)
|
icount = ground_archive.get_value(name, "icount", 0)
|
||||||
status = ground_archive.get_value(name, "status", status)
|
status = ground_archive.get_value(name, "status", status)
|
||||||
if GlobalConfig.DEBUG:
|
|
||||||
print("Portal read status [", name, "] status=", status)
|
print("Portal read status [", name, "] status=", status)
|
||||||
_check_sign_mark_and_texture()
|
_check_sign_mark_and_texture()
|
||||||
area2d.body_entered.connect(_reset)
|
area2d.body_entered.connect(_reset)
|
||||||
@ -198,8 +197,7 @@ func _on_interacted() -> void:
|
|||||||
before_pre_transport_wait.emit()
|
before_pre_transport_wait.emit()
|
||||||
if pre_transport_wait_time > 0.0:
|
if pre_transport_wait_time > 0.0:
|
||||||
await get_tree().create_timer(pre_transport_wait_time).timeout
|
await get_tree().create_timer(pre_transport_wait_time).timeout
|
||||||
if GlobalConfig.DEBUG:
|
prints("[portal] transition to scene:", target_scene, target_portal, "immediately=", immediately)
|
||||||
print("传送前往", target_scene, target_portal, " immediately=", immediately)
|
|
||||||
var ground_loader = SceneManager.get_ground_loader() as GroundLoader
|
var ground_loader = SceneManager.get_ground_loader() as GroundLoader
|
||||||
if ground_loader:
|
if ground_loader:
|
||||||
if immediately:
|
if immediately:
|
||||||
|
@ -34,10 +34,7 @@ var pass_unhandled_input = false
|
|||||||
# var shadow_texture = preload("res://asset/art/ui/action_mark/探索空心ui.png") as Texture2D
|
# var shadow_texture = preload("res://asset/art/ui/action_mark/探索空心ui.png") as Texture2D
|
||||||
|
|
||||||
# 同时只能有一个物品被激活交互态,其他物品进入等待队列
|
# 同时只能有一个物品被激活交互态,其他物品进入等待队列
|
||||||
static var occupied: NodePath:
|
static var occupied: NodePath
|
||||||
set(val):
|
|
||||||
occupied = val
|
|
||||||
print("[Sign] occupied:", Sign.get_name_from_path(occupied))
|
|
||||||
# touching 状态改变时就要擦除
|
# touching 状态改变时就要擦除
|
||||||
static var _touching_sign_arr: Array[NodePath] = []
|
static var _touching_sign_arr: Array[NodePath] = []
|
||||||
# 使用互斥锁保证线程安全。在操作 occupied 或 _touching_sign_arr 时需要先锁定,操作完成后解锁
|
# 使用互斥锁保证线程安全。在操作 occupied 或 _touching_sign_arr 时需要先锁定,操作完成后解锁
|
||||||
@ -228,7 +225,6 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
if activated:
|
if activated:
|
||||||
if event.is_action_pressed("interact"):
|
if event.is_action_pressed("interact"):
|
||||||
get_viewport().set_input_as_handled()
|
get_viewport().set_input_as_handled()
|
||||||
if GlobalConfig.DEBUG:
|
|
||||||
print("Sign interacted:", get_parent().name)
|
print("Sign interacted:", get_parent().name)
|
||||||
interacted.emit()
|
interacted.emit()
|
||||||
if is_inside_tree():
|
if is_inside_tree():
|
||||||
@ -238,7 +234,6 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
grab_focus()
|
grab_focus()
|
||||||
elif event.is_action_pressed("cancel"):
|
elif event.is_action_pressed("cancel"):
|
||||||
get_viewport().set_input_as_handled()
|
get_viewport().set_input_as_handled()
|
||||||
if GlobalConfig.DEBUG:
|
|
||||||
print("Sign cancel:", get_parent().name)
|
print("Sign cancel:", get_parent().name)
|
||||||
cancel.emit()
|
cancel.emit()
|
||||||
release_focus()
|
release_focus()
|
||||||
|
@ -180,8 +180,7 @@ func move_player_to_portal(portal_name: String) -> void:
|
|||||||
elif portal_name == "right":
|
elif portal_name == "right":
|
||||||
mov_player.set_facing_direction(Vector2.LEFT)
|
mov_player.set_facing_direction(Vector2.LEFT)
|
||||||
reset_player_y()
|
reset_player_y()
|
||||||
if GlobalConfig.DEBUG:
|
print("[ground] move player to portal:", portal_name, portal_node.global_position)
|
||||||
print("move player to portal:", portal_name, portal_node.global_position)
|
|
||||||
elif mov_player:
|
elif mov_player:
|
||||||
printerr(scene_name, " portal not found: ", node_path)
|
printerr(scene_name, " portal not found: ", node_path)
|
||||||
else:
|
else:
|
||||||
|
@ -122,7 +122,6 @@ func transition_to_scene(scene_name: String, portal: String, wait_time := 1.4) -
|
|||||||
# 先发送,再暂停,允许 sfx 等节点执行 ease out
|
# 先发送,再暂停,允许 sfx 等节点执行 ease out
|
||||||
SceneManager.ground_transition_pre_paused.emit()
|
SceneManager.ground_transition_pre_paused.emit()
|
||||||
ground.process_mode = Node.PROCESS_MODE_DISABLED
|
ground.process_mode = Node.PROCESS_MODE_DISABLED
|
||||||
if GlobalConfig.DEBUG:
|
|
||||||
# print reenter lock status
|
# print reenter lock status
|
||||||
print("GroundLoader transition_to_scene: reenter lock status: ", ground.reenter_lock)
|
print("GroundLoader transition_to_scene: reenter lock status: ", ground.reenter_lock)
|
||||||
var scene_path = GROUND_SCENE_PATH_DICT.get(scene_name)
|
var scene_path = GROUND_SCENE_PATH_DICT.get(scene_name)
|
||||||
@ -208,14 +207,13 @@ func _add_ground():
|
|||||||
else:
|
else:
|
||||||
# move player to portal
|
# move player to portal
|
||||||
ground.move_player_to_portal(entrance_portal)
|
ground.move_player_to_portal(entrance_portal)
|
||||||
if GlobalConfig.DEBUG:
|
add_child(ground)
|
||||||
print(
|
print(
|
||||||
"GroundLoader add_ground finished:",
|
"GroundLoader add_ground finished:",
|
||||||
ground.scene_name,
|
ground.scene_name,
|
||||||
" player.pos=",
|
" player.pos=",
|
||||||
ground.get_player().global_position
|
ground.get_player().global_position
|
||||||
)
|
)
|
||||||
add_child(ground)
|
|
||||||
# ready 后,再整体重置 camera 位置
|
# ready 后,再整体重置 camera 位置
|
||||||
if not Engine.is_editor_hint():
|
if not Engine.is_editor_hint():
|
||||||
ground.get_camera().reset_position_immediately()
|
ground.get_camera().reset_position_immediately()
|
||||||
|
@ -11,7 +11,6 @@ extends Control
|
|||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
if GlobalConfig.DEBUG:
|
|
||||||
print("Index Page Ready")
|
print("Index Page Ready")
|
||||||
newgame_btn.pressed.connect(_on_newgame_pressed)
|
newgame_btn.pressed.connect(_on_newgame_pressed)
|
||||||
resume_btn.pressed.connect(_on_resume_pressed)
|
resume_btn.pressed.connect(_on_resume_pressed)
|
||||||
@ -37,8 +36,7 @@ func _on_newgame_pressed():
|
|||||||
func _on_resume_pressed():
|
func _on_resume_pressed():
|
||||||
sfx_click.global_play()
|
sfx_click.global_play()
|
||||||
# 继续一号存档
|
# 继续一号存档
|
||||||
if GlobalConfig.DEBUG:
|
print("Resume Game")
|
||||||
print("Resume")
|
|
||||||
if ArchiveManager.archives.has(1):
|
if ArchiveManager.archives.has(1):
|
||||||
# 设置 current_selected_archive_id 后,存档会自动加载
|
# 设置 current_selected_archive_id 后,存档会自动加载
|
||||||
GlobalConfigManager.config.current_selected_archive_id = 1
|
GlobalConfigManager.config.current_selected_archive_id = 1
|
||||||
|
@ -91,7 +91,7 @@ func _ready():
|
|||||||
# navigation
|
# navigation
|
||||||
return_btn.pressed.connect(_on_return_btn_pressed)
|
return_btn.pressed.connect(_on_return_btn_pressed)
|
||||||
return_btn.grab_focus()
|
return_btn.grab_focus()
|
||||||
SceneManager.toggle_pause_counter(true)
|
SceneManager.toggle_pause_counter(true, "settings")
|
||||||
# open
|
# open
|
||||||
$"Sfx打开".play()
|
$"Sfx打开".play()
|
||||||
# # resize
|
# # resize
|
||||||
@ -192,5 +192,5 @@ func _unhandled_key_input(event: InputEvent) -> void:
|
|||||||
|
|
||||||
func exit_settings() -> void:
|
func exit_settings() -> void:
|
||||||
$"Sfx关闭".global_play()
|
$"Sfx关闭".global_play()
|
||||||
SceneManager.toggle_pause_counter(false)
|
SceneManager.toggle_pause_counter(false, "settings")
|
||||||
queue_free()
|
queue_free()
|
||||||
|
@ -8,7 +8,7 @@ extends CanvasLayer
|
|||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
layer = GlobalConfig.CANVAS_LAYER_UX_PANEL
|
layer = GlobalConfig.CANVAS_LAYER_UX_PANEL
|
||||||
SceneManager.toggle_pause_counter(true)
|
SceneManager.toggle_pause_counter(true, "bag")
|
||||||
_load_item_buttons()
|
_load_item_buttons()
|
||||||
# fisplay first item
|
# fisplay first item
|
||||||
var hud = SceneManager.get_prop_hud()
|
var hud = SceneManager.get_prop_hud()
|
||||||
@ -76,5 +76,5 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func quit() -> void:
|
func quit() -> void:
|
||||||
SceneManager.toggle_pause_counter(false)
|
SceneManager.toggle_pause_counter(false, "bag")
|
||||||
queue_free()
|
queue_free()
|
||||||
|
@ -3,7 +3,7 @@ class_name Memory extends CanvasLayer
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
layer = GlobalConfig.CANVAS_LAYER_UX_PANEL
|
layer = GlobalConfig.CANVAS_LAYER_UX_PANEL
|
||||||
SceneManager.toggle_pause_counter(true)
|
SceneManager.toggle_pause_counter(true, "memory")
|
||||||
update_display()
|
update_display()
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func quit() -> void:
|
func quit() -> void:
|
||||||
SceneManager.toggle_pause_counter(false)
|
SceneManager.toggle_pause_counter(false, "memory")
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ extends CanvasLayer
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
layer = GlobalConfig.CANVAS_LAYER_UX_PANEL
|
layer = GlobalConfig.CANVAS_LAYER_UX_PANEL
|
||||||
SceneManager.toggle_pause_counter(true)
|
SceneManager.toggle_pause_counter(true, "note")
|
||||||
|
|
||||||
|
|
||||||
func _unhandled_input(event: InputEvent) -> void:
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
@ -18,5 +18,5 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func quit() -> void:
|
func quit() -> void:
|
||||||
SceneManager.toggle_pause_counter(false)
|
SceneManager.toggle_pause_counter(false, "note")
|
||||||
queue_free()
|
queue_free()
|
||||||
|
@ -11,7 +11,7 @@ extends CanvasLayer
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$SfxOpen.play()
|
$SfxOpen.play()
|
||||||
layer = GlobalConfig.CANVAS_LAYER_UX_PANEL
|
layer = GlobalConfig.CANVAS_LAYER_UX_PANEL
|
||||||
SceneManager.toggle_pause_counter(true)
|
SceneManager.toggle_pause_counter(true, "panel")
|
||||||
continue_btn.pressed.connect(_continue)
|
continue_btn.pressed.connect(_continue)
|
||||||
note_btn.pressed.connect(SceneManager.show_note)
|
note_btn.pressed.connect(SceneManager.show_note)
|
||||||
settings_btn.pressed.connect(SceneManager.show_settings)
|
settings_btn.pressed.connect(SceneManager.show_settings)
|
||||||
@ -27,7 +27,7 @@ func _quit_game() -> void:
|
|||||||
|
|
||||||
func _continue():
|
func _continue():
|
||||||
$SfxClose.global_play()
|
$SfxClose.global_play()
|
||||||
SceneManager.toggle_pause_counter(false)
|
SceneManager.toggle_pause_counter(false, "panel")
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user