Files
shenandClaude Sonnet 5 47baf6c0c6 Metin2 game client (P0–P11) + mobile asset pipeline
Networked client on the existing Godot 4.7 + libgr2 renderer:
- net: m2dev wire protocol (libsodium KX + XChaCha20), auth/select/game
  phases, EntityStore world model, ~all GC/CG headers. char create/delete,
  private shop / mall / cube, SHOP_GC_START_EX, guild, party (+ CG_PARTY_SET_STATE),
  quests, dragon soul, refine, safebox, exchange.
- UI: in-game windows migrated 1:1 from the reference uiscript/root .py —
  char status (/stat), inventory+equipment, select-item ([SELECT_ITEM] quest
  token), system-option + game-option + ESC system menu, private-shop 39-grid,
  party info board, shop tabs, atlas, minimap, quickbar, chat, …
- EterGrnLib polish: GR2 material blend/two-sided, LOD crossfade, motion-event
  dispatch, contact shadow, ray-AABB picking, weapon grip pre-transform.

Portable asset IO (A1) — all extension/libgr2/formats/mtproto reads routed
through godot::FileAccess (res:// PCK works on iOS/Android); standalone-lib
*_path() kept for the non-Godot CTests. AssetResolver + PropertyRegistry
switched to a baked index (bake_asset_index.gd) instead of std::filesystem.

Mobile builds: build-{android,ios}.sh, export-android.sh, pack-assets.sh,
gen-debug-keystore.sh. Assets ship as a zip mounted at runtime by
project/asset_pack.gd (adb push now; HTTP download is a drop-in later).

ctest 10/10, 34 GDScript suites, macOS/iOS/Android all build.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013EJxkHiNKS4kybHS3XKyAJ
2026-08-31 20:02:12 +09:00

48 lines
2.0 KiB
GDScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AssetRoot —— Metin2 资源根目录的唯一解析点。
#
# 资源(`.gr2` / `.dds` / `locale` / `OutdoorA1` / `uiscript` …)不进版本库。
# 解析顺序:
# 1. 环境变量 MT_ASSETS(绝对路径)
# 2. res://../assets —— 开发树(仓库根的 assets/)
# 3. <可执行文件>/../Resources/assets —— 打包进 .app 内
# 4. <.app 同级>/assets —— .app 旁边放一份
# 都没有就返回 res://../assets(调用方自行 warn)。
#
# var root := AssetRoot.path()
# var il := AssetRoot.sub("locale/locale/common/item_list.txt")
# if AssetRoot.available(): ...
class_name AssetRoot
extends RefCounted
static func _candidates() -> Array:
var out: Array = []
var env := OS.get_environment("MT_ASSETS")
if env != "":
out.append(env)
# 挂载的 assets.zipAssetPack)把资源放到 res://assets —— 移动端主路径。
# 用 asset_index.txt 作为「pack 已挂载」信号(空的 project/assets/ 占位目录不算)。
if FileAccess.file_exists("res://assets/asset_index.txt"):
out.append("res://assets")
out.append(ProjectSettings.globalize_path("res://../assets"))
var exe := OS.get_executable_path()
if exe != "":
var exe_dir := exe.get_base_dir() # .../mtgodot-poc.app/Contents/MacOS
out.append(exe_dir.path_join("../Resources/assets").simplify_path())
out.append(exe_dir.path_join("../../../assets").simplify_path()) # 与 .app 同级
out.append(exe_dir.path_join("assets")) # 与裸可执行文件同级
return out
static func path() -> String:
for c in _candidates():
if DirAccess.dir_exists_absolute(c):
return c
return ProjectSettings.globalize_path("res://../assets")
# 资源根下的子路径(用 path_join,跨平台)。
static func sub(rel: String) -> String:
return path().path_join(rel)
# 资源目录是否真的存在(缺资源的测试据此跳过)。
static func available() -> bool:
return DirAccess.dir_exists_absolute(path())