Files
mtgodot-poc/project/player_motion_test.gd
T

59 lines
2.1 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:
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)
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")
_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")
pv.queue_free()
audio.queue_free()