debug和修复
This commit is contained in:
@@ -150,6 +150,9 @@ func _rebuild_stamp() -> void:
|
||||
## 在 pos 处盖一个印章。越界像素直接跳过,所以画到边上也不会出错。
|
||||
func _stamp_at(pos: Vector2) -> void:
|
||||
var d := _stamp_d
|
||||
# d 恒为偶数(上方是按 r * 2 算出来的),这里的整除不会丢精度。
|
||||
# 所以只抑制警告、不改算法 —— 换成浮点反而会引入半像素偏移。
|
||||
@warning_ignore("integer_division")
|
||||
var r := d / 2
|
||||
var cx := int(round(pos.x)) - r
|
||||
var cy := int(round(pos.y)) - r
|
||||
|
||||
@@ -187,9 +187,9 @@ func save_drawing_as_expression(display_name: String) -> Dictionary:
|
||||
return {}
|
||||
|
||||
var rows := _read_library_index()
|
||||
var name := display_name.strip_edges()
|
||||
if name.is_empty():
|
||||
name = "我的表情 %d" % (rows.size() + 1)
|
||||
var entry_name := display_name.strip_edges()
|
||||
if entry_name.is_empty():
|
||||
entry_name = "我的表情 %d" % (rows.size() + 1)
|
||||
var id := "user:%d" % Time.get_ticks_usec()
|
||||
var filename := id.replace(":", "_") + ".png"
|
||||
var file := FileAccess.open("%s/%s" % [LIBRARY_DIR, filename], FileAccess.WRITE)
|
||||
@@ -199,13 +199,13 @@ func save_drawing_as_expression(display_name: String) -> Dictionary:
|
||||
file.store_buffer(painter.to_png_bytes())
|
||||
file.close()
|
||||
|
||||
rows.append({"id": id, "name": name, "file": filename})
|
||||
rows.append({"id": id, "name": entry_name, "file": filename})
|
||||
if not _write_library_index(rows):
|
||||
return {}
|
||||
if not select_expression(id):
|
||||
return {}
|
||||
save()
|
||||
return {"id": id, "name": name}
|
||||
return {"id": id, "name": entry_name}
|
||||
|
||||
|
||||
func _read_library_index() -> Array:
|
||||
|
||||
@@ -16,6 +16,8 @@ extends CharacterBody3D
|
||||
@onready var camera: Camera3D = $CameraRig/Camera
|
||||
## 准心(挂在 CameraRig/HUD 下)。远端玩家的 HUD 会随 camera_rig 一起被释放。
|
||||
@onready var crosshair: Crosshair = $CameraRig/HUD/Crosshair
|
||||
## 右上角调试面板。同样挂在 HUD 下,所以远端玩家不会显示它。
|
||||
@onready var debug_panel: DebugPanel = $CameraRig/HUD/DebugPanel
|
||||
@onready var animation_player: PlayerAnimator = $AnimationPlayer
|
||||
@onready var look: PlayerLook = $Look
|
||||
@onready var motor: PlayerMotor = $Motor
|
||||
@@ -56,6 +58,8 @@ func _ready() -> void:
|
||||
)
|
||||
# 准心接线:拾取组件一发现交互状态变化,就通知准心换外观(点 / 手 / 抓)。
|
||||
pickup.interact_state_changed.connect(_on_pickup_interact_state_changed)
|
||||
# 调试面板接线:把要读的组件注入进去,面板自己不 get_node。
|
||||
debug_panel.setup(self, motor, pickup, camera)
|
||||
set_mouse_captured(true)
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
[ext_resource type="AnimationLibrary" uid="uid://ddnmtmswkjx6g" path="res://character/player/assets/animations/fall.glb" id="4_hr31g"]
|
||||
[ext_resource type="Texture2D" uid="uid://c67qe66m2aft4" path="res://character/assets/grab.png" id="4_ywhvj"]
|
||||
[ext_resource type="AnimationLibrary" uid="uid://ddkl5cqdd5usx" path="res://character/player/assets/animations/idle.glb" id="5_lqp71"]
|
||||
[ext_resource type="Script" uid="uid://d2rmc8p4g4dt6" path="res://ui/debug_panel.gd" id="5_ywhvj"]
|
||||
[ext_resource type="AnimationLibrary" uid="uid://esw60hwb2cty" path="res://character/player/assets/animations/jump.glb" id="6_vuhga"]
|
||||
[ext_resource type="AnimationLibrary" uid="uid://rqhclfyiingo" path="res://character/player/assets/animations/run.glb" id="7_muf2e"]
|
||||
[ext_resource type="AnimationLibrary" uid="uid://dy8a178vlbsof" path="res://character/player/assets/animations/sneak.glb" id="8_jo6ux"]
|
||||
@@ -61,6 +62,13 @@ script = ExtResource("2_vuhga")
|
||||
hover_texture = ExtResource("3_i6sc0")
|
||||
hold_texture = ExtResource("4_ywhvj")
|
||||
|
||||
[node name="DebugPanel" type="Control" parent="CameraRig/HUD" unique_id=1328176640]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource("5_ywhvj")
|
||||
|
||||
[node name="Body" type="Node3D" parent="." unique_id=394283421]
|
||||
|
||||
[node name="mouse" parent="Body" unique_id=1995806863 instance=ExtResource("2_wu8e1")]
|
||||
|
||||
@@ -140,3 +140,8 @@ func _throw() -> void:
|
||||
## 当前是否抓着东西。调试用,也方便以后加「搬运时不能开枪」这类规则。
|
||||
func has_object() -> bool:
|
||||
return is_instance_valid(_current)
|
||||
|
||||
|
||||
## 当前准心是否指着可拖拽的刚体(还没抓)。调试用。
|
||||
func is_hovering() -> bool:
|
||||
return _hovering
|
||||
|
||||
@@ -7,12 +7,9 @@ properties/0/replication_mode = 1
|
||||
properties/1/path = NodePath("Body:rotation")
|
||||
properties/1/spawn = true
|
||||
properties/1/replication_mode = 1
|
||||
properties/2/path = NodePath(".:health")
|
||||
properties/2/path = NodePath("AnimationPlayer:anim_state")
|
||||
properties/2/spawn = true
|
||||
properties/2/replication_mode = 1
|
||||
properties/3/path = NodePath("AnimationPlayer:anim_state")
|
||||
properties/3/path = NodePath("AnimationPlayer:anim_speed")
|
||||
properties/3/spawn = true
|
||||
properties/3/replication_mode = 1
|
||||
properties/4/path = NodePath("AnimationPlayer:anim_speed")
|
||||
properties/4/spawn = true
|
||||
properties/4/replication_mode = 1
|
||||
|
||||
Reference in New Issue
Block a user