# client_main —— 打包客户端的入口场景根(main_scene = res://client_main.tscn)。 # # 走 40250 原生 port 路径:40250 system.py 在内嵌解释器里跑,界面画在 # python_ui_surface.gd、RenderGame 的 3D 绘制画在 python_3d_surface.gd。 # 方向键/鼠标点地走动走 40250 原路径(2V3);app.Exit() 退出进程。 # 资源目录由 AssetRoot 决定:40250 Client/pack 资源包。 extends Node func _ready() -> void: if OS.get_environment("MT_TEST_MODE") == "particle_exit": add_child(preload("res://particle_exit_test.gd").new()) return # MT_TEST_MODE=python:在 app 进程里起内嵌解释器跑 system.py(PORT-PLAN 批次 2P step 4)。 # 导出模板不接受 --script,这是在真机 APK/IPA 里跑这条检查的唯一入口。 if OS.get_environment("MT_TEST_MODE") == "python": AssetPack.ensure() var fail: int = preload("res://python_host_check.gd").new().run() if fail == 0: print("PASS: python_host_check (app 进程内 system.py)") else: printerr("%d check(s) failed" % fail) get_tree().quit(1 if fail else 0) return # 原生 port 路径:40250 system.py 的界面直接画在 Godot Canvas 上(PORT-PLAN 2V0-f), # Logo → 登录 → 选人 → 进游戏,RenderGame 的 3D 绘制由 python_3d_surface.gd 画出(2V2-e), # 方向键/鼠标点地走动走 40250 原路径(2V3);app.Exit() 退出进程。 if OS.has_environment("MT_PORT_PATH") and OS.get_environment("MT_PORT_PATH") == "legacy": push_warning("[client] MT_PORT_PATH=legacy 已废弃并移除,40250 原生 port 路径已接管主循环") _start_port_route() # 启动 40250 原生 port 路径 func _start_port_route() -> void: AssetPack.ensure() if not (ClassDB.class_exists("Metin2PythonHost") and AssetRoot.pack_ready()): printerr("[client] port 路由缺少 Metin2PythonHost 或 40250 Client/pack(%s)" % AssetRoot.client_path()) get_tree().quit(1) return var surface: Control = preload("res://python_ui_surface.gd").new() surface.name = "PythonUISurface" add_child(surface) # The UI surface runs CPythonApplication::Process in its _process; the 3D surface reads that # frame's draws after it, so it comes second in the tree. var world: Node3D = preload("res://python_3d_surface.gd").new() world.name = "Python3DSurface" add_child(world) var err: String = surface.run_app() if err != "": printerr("port: " + err) get_tree().quit(1)