- item_tooltip_view.gd: 新增 avoid_rect 属性,tooltip 与装备窗口重叠时自动推到左侧 - inventory_ui.gd: 悬停装备时传入窗口矩形作为避让区域 - 包含其他累积的功能开发和测试文件
105 lines
4.4 KiB
GDScript
105 lines
4.4 KiB
GDScript
# player_motion_test —— 40250 GC_MOTION / ServerCommand emotion clip mapping。
|
|
# godot --headless --path project --script player_motion_test.gd
|
|
extends SceneTree
|
|
|
|
const PlayerView = preload("res://ui/player_view.gd")
|
|
const Audio = preload("res://audio.gd")
|
|
|
|
var _fail := 0
|
|
|
|
func _ck(ok: bool, msg: String) -> void:
|
|
if not ok:
|
|
_fail += 1
|
|
printerr("FAIL: " + msg)
|
|
|
|
func _init() -> void:
|
|
await _run()
|
|
if _fail == 0:
|
|
print("PASS: player_motion_test")
|
|
quit(0)
|
|
else:
|
|
printerr("%d check(s) failed" % _fail)
|
|
quit(1)
|
|
|
|
func _run() -> void:
|
|
if not ClassDB.class_exists("Metin2Model") or not ClassDB.class_exists("Metin2AnimPlayer"):
|
|
print(" (skip: animation extension not registered)")
|
|
return
|
|
var assets := AssetRoot.path()
|
|
if not DirAccess.dir_exists_absolute(assets.path_join("PC/ymir work/pc/warrior")):
|
|
print(" (skip: PC assets unavailable)")
|
|
return
|
|
var pv: Node = PlayerView.new()
|
|
get_root().add_child(pv)
|
|
_ck(pv.build(assets, 0), "warrior PlayerView builds")
|
|
if pv.anim == null:
|
|
pv.free()
|
|
await process_frame
|
|
return
|
|
await process_frame
|
|
var body_mesh := pv.model.get_node_or_null("MeshInstance3D") as MeshInstance3D
|
|
var body_layer := body_mesh.get_layer_mask() if body_mesh != null else 0
|
|
_ck(body_mesh != null and body_layer == 2,
|
|
"character mesh is assigned to the character light layer (got %d)" % body_layer)
|
|
# 40250 __SetMotion -> __ShowEvent: a later valid motion request restores
|
|
# visibility, including a request for the same loop motion.
|
|
pv.set_motion_hidden(true)
|
|
pv.set_anim_state("wait")
|
|
_ck(not pv.is_motion_hidden() and pv.model.visible,
|
|
"same-state motion request restores visibility after CHARACTER_HIDE")
|
|
pv.set_motion_hidden(true)
|
|
pv.set_anim_state("run")
|
|
_ck(not pv.is_motion_hidden() and pv.model.visible,
|
|
"new motion request restores visibility after CHARACTER_HIDE")
|
|
var audio: Node = Audio.new()
|
|
get_root().add_child(audio)
|
|
audio.setup(assets)
|
|
pv.set_audio(audio)
|
|
pv.set_anim_state("run")
|
|
_ck(pv._sound_instances.size() == 3, "PlayerView run motion loads paired .mss instances")
|
|
pv.set_motion_mode(3) # MODE_TWOHAND_SWORD
|
|
_ck(String(pv.anim.get("anim_path")).contains("/twohand_sword/run.msa"),
|
|
"two-handed mode rebinds current run loop")
|
|
pv.set_anim_state("wait")
|
|
var twohand_wait := String(pv.anim.get("anim_path"))
|
|
_ck(twohand_wait.contains("/twohand_sword/") and
|
|
twohand_wait.get_file().get_basename() in ["wait", "wait_1"],
|
|
"two-handed wait uses a registered two-hand grip pose")
|
|
# 40250 GetMotionKey(HORSE_ONEHAND_SWORD, WAIT/WALK) falls back to HORSE,
|
|
# not GENERAL, because horse weapon modes only register combat motions.
|
|
pv._motion_mode = 10
|
|
var horse_wait := String(pv._motion_file("wait"))
|
|
_ck(horse_wait.contains("/horse/") and
|
|
horse_wait.get_file().get_basename() in ["wait", "wait_1", "wait_2"],
|
|
"horse one-hand wait falls back to HORSE motion mode and preserves weighted variants")
|
|
_ck(String(pv._motion_file("walk")).contains("/horse/walk.msa"),
|
|
"horse one-hand walk falls back to HORSE motion mode")
|
|
_ck(pv._motion_file("standup") == "",
|
|
"horse one-hand does not fall through to GENERAL for an unregistered motion")
|
|
pv._motion_mode = 3
|
|
pv.play_attack_motion(3, 14, 1.0)
|
|
_ck(String(pv.anim.get("anim_path")).contains("/twohand_sword/combo_01.msa"),
|
|
"two-handed first swing uses combo_01")
|
|
pv.set_motion_mode(1)
|
|
_ck(pv.set_motion_id(305), "clap motion resolves")
|
|
_ck(String(pv.anim.get("anim_path")).ends_with("action/clap.msa"),
|
|
"clap -> action/clap.msa")
|
|
_ck(pv.set_motion_id(308, 3), "kiss motion resolves with target job")
|
|
_ck(String(pv.anim.get("anim_path")).ends_with("action/kiss_with_shaman.msa"),
|
|
"kiss start + shaman target -> kiss_with_shaman.msa")
|
|
_ck(pv.set_motion_id(320), "slap hurt motion resolves")
|
|
_ck(String(pv.anim.get("anim_path")).ends_with("action/slap_hurt.msa"),
|
|
"slap hurt -> action/slap_hurt.msa")
|
|
# Release the test nodes synchronously. The native model/animation wrappers
|
|
# are owned by PlayerView and must be destroyed before SceneTree.quit().
|
|
pv.free()
|
|
audio.free()
|
|
# The production module keeps decoded GR2/MSA/material resources in bounded
|
|
# process caches. Clear them for this short-lived test so ObjectDB teardown
|
|
# can verify the actual node ownership rather than cache lifetime.
|
|
if ClassDB.class_exists("Metin2Model"):
|
|
Metin2Model.clear_texture_cache()
|
|
if ClassDB.class_exists("Metin2AnimPlayer"):
|
|
Metin2AnimPlayer.clear_clip_cache()
|
|
await process_frame
|