增加 log 信息(4): lock 状态;sign occupied 状态; PropHud inspect prop; prop enable/disable
This commit is contained in:
parent
8d0ee06247
commit
3b1822810f
@ -155,6 +155,7 @@ func get_prop_hud() -> PropHud:
|
|||||||
func toggle_hud_display(display_hud: bool) -> void:
|
func toggle_hud_display(display_hud: bool) -> void:
|
||||||
var prop_hud = get_prop_hud() as PropHud
|
var prop_hud = get_prop_hud() as PropHud
|
||||||
if prop_hud:
|
if prop_hud:
|
||||||
|
print("[hud] toggle_hud_display:", display_hud)
|
||||||
if display_hud:
|
if display_hud:
|
||||||
prop_hud.display_hud()
|
prop_hud.display_hud()
|
||||||
else:
|
else:
|
||||||
@ -189,6 +190,7 @@ func has_prop(prop_key: String) -> bool:
|
|||||||
func enable_prop_item_silently(prop_key: String) -> void:
|
func enable_prop_item_silently(prop_key: String) -> void:
|
||||||
var prop_hud = get_prop_hud()
|
var prop_hud = get_prop_hud()
|
||||||
if prop_hud:
|
if prop_hud:
|
||||||
|
print("[prop] enable_prop_item_silently prop:", prop_key)
|
||||||
prop_hud.enable_prop_item(prop_key, false)
|
prop_hud.enable_prop_item(prop_key, false)
|
||||||
else:
|
else:
|
||||||
printerr("enable_prop_item_silently: PropHud node not found")
|
printerr("enable_prop_item_silently: PropHud node not found")
|
||||||
@ -197,6 +199,7 @@ func enable_prop_item_silently(prop_key: String) -> void:
|
|||||||
func enable_prop_item(prop_key: String) -> void:
|
func enable_prop_item(prop_key: String) -> void:
|
||||||
var prop_hud = get_prop_hud()
|
var prop_hud = get_prop_hud()
|
||||||
if prop_hud:
|
if prop_hud:
|
||||||
|
print("[prop] enable_prop_item prop:", prop_key)
|
||||||
prop_hud.enable_prop_item(prop_key)
|
prop_hud.enable_prop_item(prop_key)
|
||||||
else:
|
else:
|
||||||
printerr("enable_prop_item PropHud node not found")
|
printerr("enable_prop_item PropHud node not found")
|
||||||
@ -206,6 +209,7 @@ func enable_prop_item(prop_key: String) -> void:
|
|||||||
func enable_important_item(prop_key: String, display_inspector = true) -> void:
|
func enable_important_item(prop_key: String, display_inspector = true) -> void:
|
||||||
var prop_hud = get_prop_hud()
|
var prop_hud = get_prop_hud()
|
||||||
if prop_hud:
|
if prop_hud:
|
||||||
|
print("[prop] enable_important_item prop:", prop_key)
|
||||||
prop_hud.enable_important_item(prop_key, display_inspector)
|
prop_hud.enable_important_item(prop_key, display_inspector)
|
||||||
else:
|
else:
|
||||||
printerr("enable_important_item PropHud node not found")
|
printerr("enable_important_item PropHud node not found")
|
||||||
@ -214,6 +218,7 @@ func enable_important_item(prop_key: String, display_inspector = true) -> void:
|
|||||||
func disable_prop_item(prop_key: String) -> void:
|
func disable_prop_item(prop_key: String) -> void:
|
||||||
var prop_hud = get_prop_hud()
|
var prop_hud = get_prop_hud()
|
||||||
if prop_hud:
|
if prop_hud:
|
||||||
|
print("[prop] disable_prop_item prop:", prop_key)
|
||||||
prop_hud.disable_prop_item(prop_key)
|
prop_hud.disable_prop_item(prop_key)
|
||||||
else:
|
else:
|
||||||
printerr("disable_prop_item PropHud node not found")
|
printerr("disable_prop_item PropHud node not found")
|
||||||
|
@ -57,8 +57,8 @@ func freeze(duration := 0.0) -> void:
|
|||||||
_freeze_requests += 1
|
_freeze_requests += 1
|
||||||
var f_requests = _freeze_requests
|
var f_requests = _freeze_requests
|
||||||
_request_mutex.unlock()
|
_request_mutex.unlock()
|
||||||
if GlobalConfig.DEBUG:
|
|
||||||
print("[Lock] Freeze applied: ", _freeze_requests)
|
print("[Lock] Freeze applied: ", _freeze_requests)
|
||||||
|
if GlobalConfig.DEBUG:
|
||||||
print("freeze from: ", _get_stack_info())
|
print("freeze from: ", _get_stack_info())
|
||||||
freeze_changed.emit(f_requests, true)
|
freeze_changed.emit(f_requests, true)
|
||||||
|
|
||||||
@ -77,8 +77,8 @@ func release() -> void:
|
|||||||
_freeze_requests = 0
|
_freeze_requests = 0
|
||||||
var f_requests = _freeze_requests
|
var f_requests = _freeze_requests
|
||||||
_request_mutex.unlock()
|
_request_mutex.unlock()
|
||||||
if GlobalConfig.DEBUG:
|
|
||||||
print("[Lock] Release applied: ", _freeze_requests)
|
print("[Lock] Release applied: ", _freeze_requests)
|
||||||
|
if GlobalConfig.DEBUG:
|
||||||
print("release from: ", _get_stack_info())
|
print("release from: ", _get_stack_info())
|
||||||
freeze_changed.emit(f_requests, false)
|
freeze_changed.emit(f_requests, false)
|
||||||
|
|
||||||
@ -90,8 +90,8 @@ func hold(duration := 0.0) -> void:
|
|||||||
_request_mutex.lock()
|
_request_mutex.lock()
|
||||||
_hold_requests += 1
|
_hold_requests += 1
|
||||||
_request_mutex.unlock()
|
_request_mutex.unlock()
|
||||||
if GlobalConfig.DEBUG:
|
|
||||||
print("[Lock] Hold applied: ", _hold_requests)
|
print("[Lock] Hold applied: ", _hold_requests)
|
||||||
|
if GlobalConfig.DEBUG:
|
||||||
print("hold from: ", _get_stack_info())
|
print("hold from: ", _get_stack_info())
|
||||||
hold_changed.emit(_hold_requests, true)
|
hold_changed.emit(_hold_requests, true)
|
||||||
|
|
||||||
@ -110,8 +110,8 @@ func unhold() -> void:
|
|||||||
_hold_requests = 0
|
_hold_requests = 0
|
||||||
var h_requests = _hold_requests
|
var h_requests = _hold_requests
|
||||||
_request_mutex.unlock()
|
_request_mutex.unlock()
|
||||||
if GlobalConfig.DEBUG:
|
|
||||||
print("[Lock] Unhold applied: ", _hold_requests)
|
print("[Lock] Unhold applied: ", _hold_requests)
|
||||||
|
if GlobalConfig.DEBUG:
|
||||||
print("unhold from: ", _get_stack_info())
|
print("unhold from: ", _get_stack_info())
|
||||||
hold_changed.emit(h_requests, true)
|
hold_changed.emit(h_requests, true)
|
||||||
|
|
||||||
@ -143,8 +143,8 @@ func lock_all(duration := 0.0) -> void:
|
|||||||
var h_requests = _hold_requests
|
var h_requests = _hold_requests
|
||||||
var f_requests = _freeze_requests
|
var f_requests = _freeze_requests
|
||||||
_request_mutex.unlock()
|
_request_mutex.unlock()
|
||||||
if GlobalConfig.DEBUG:
|
|
||||||
prints("[Lock] LockAll applied (hold, freeze): ", _hold_requests, _freeze_requests)
|
prints("[Lock] LockAll applied (hold, freeze): ", _hold_requests, _freeze_requests)
|
||||||
|
if GlobalConfig.DEBUG:
|
||||||
print("lock_all from: ", _get_stack_info())
|
print("lock_all from: ", _get_stack_info())
|
||||||
hold_changed.emit(h_requests, true)
|
hold_changed.emit(h_requests, true)
|
||||||
freeze_changed.emit(f_requests, true)
|
freeze_changed.emit(f_requests, true)
|
||||||
@ -177,8 +177,8 @@ func unlock_all() -> void:
|
|||||||
_request_mutex.unlock()
|
_request_mutex.unlock()
|
||||||
hold_changed.emit(h_requests, false)
|
hold_changed.emit(h_requests, false)
|
||||||
freeze_changed.emit(f_requests, false)
|
freeze_changed.emit(f_requests, false)
|
||||||
if GlobalConfig.DEBUG:
|
|
||||||
prints("[Lock] UnlockAll applied (hold, freeze): ", _hold_requests, _freeze_requests)
|
prints("[Lock] UnlockAll applied (hold, freeze): ", _hold_requests, _freeze_requests)
|
||||||
|
if GlobalConfig.DEBUG:
|
||||||
print("unlock_all from: ", _get_stack_info())
|
print("unlock_all from: ", _get_stack_info())
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,7 +34,10 @@ 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 时需要先锁定,操作完成后解锁
|
||||||
@ -142,9 +145,9 @@ func align_activation() -> bool:
|
|||||||
activated,
|
activated,
|
||||||
"[/color]",
|
"[/color]",
|
||||||
" occupied:[color=khaki]",
|
" occupied:[color=khaki]",
|
||||||
_get_name_from_path(occupied),
|
Sign.get_name_from_path(occupied),
|
||||||
"[/color] touching:[color=coral]",
|
"[/color] touching:[color=coral]",
|
||||||
_get_name_from_paths(_touching_sign_arr),
|
Sign.get_name_from_paths(_touching_sign_arr),
|
||||||
"[/color]"
|
"[/color]"
|
||||||
)
|
)
|
||||||
return activated
|
return activated
|
||||||
@ -193,7 +196,7 @@ func _try_activate() -> bool:
|
|||||||
return activated
|
return activated
|
||||||
|
|
||||||
|
|
||||||
func _get_name_from_path(path: NodePath) -> String:
|
static func get_name_from_path(path: NodePath) -> String:
|
||||||
if not path:
|
if not path:
|
||||||
return ""
|
return ""
|
||||||
# return -2 idx
|
# return -2 idx
|
||||||
@ -206,12 +209,12 @@ func _get_name_from_path(path: NodePath) -> String:
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
func _get_name_from_paths(paths: Array[NodePath]) -> String:
|
static func get_name_from_paths(paths: Array[NodePath]) -> String:
|
||||||
if len(paths) == 0:
|
if len(paths) == 0:
|
||||||
return ""
|
return ""
|
||||||
var names = []
|
var names = []
|
||||||
for path in paths:
|
for path in paths:
|
||||||
names.append(_get_name_from_path(path))
|
names.append(Sign.get_name_from_path(path))
|
||||||
return ", ".join(names)
|
return ", ".join(names)
|
||||||
|
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ func _update_prop_display_with_texture():
|
|||||||
var player = SceneManager.get_player()
|
var player = SceneManager.get_player()
|
||||||
if player:
|
if player:
|
||||||
player.set_catty_light(key == "prop_小猫玩具完整")
|
player.set_catty_light(key == "prop_小猫玩具完整")
|
||||||
|
print("[PropHud] current display prop:", key)
|
||||||
# 选中标记 select_mark; 如果被 free 掉,则重新创建
|
# 选中标记 select_mark; 如果被 free 掉,则重新创建
|
||||||
if select_mark and is_instance_valid(select_mark):
|
if select_mark and is_instance_valid(select_mark):
|
||||||
var parent = select_mark.get_parent()
|
var parent = select_mark.get_parent()
|
||||||
@ -334,6 +334,7 @@ func _on_prop_inspected(id := 0) -> void:
|
|||||||
prop_key = inventory.current_item_key()
|
prop_key = inventory.current_item_key()
|
||||||
if prop_key:
|
if prop_key:
|
||||||
sfx_inspect.play()
|
sfx_inspect.play()
|
||||||
|
print("[PropHud] inspect prop:", prop_key)
|
||||||
inspect_item(prop_key, false)
|
inspect_item(prop_key, false)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user