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
This commit is contained in:
shen
2026-08-31 20:02:12 +09:00
co-authored by Claude Sonnet 5
parent f4917a2b3b
commit 47baf6c0c6
414 changed files with 69568 additions and 385 deletions
+60
View File
@@ -0,0 +1,60 @@
# AssetPack —— 把 Metin2 资源(assets/ + bgm/ + asset_index.txt 打成的 assets.zip
# 挂载到 res://,供 AssetRoot / C++ 的 FileAccess 读取。
#
# 桌面开发:仓库旁的散 assets/ 直接可用 -> ensure() 什么都不做。
# 移动端:APK/IPA 里没有资源;assets.zip 由外部提供:
# Android —— adb push build/export/assets.zip /sdcard/Android/data/<pkg>/files/
# iOS —— ios-deploy --upload assets.zip --to Documents/
# 找到就 ProjectSettings.load_resource_pack() 挂到 res://。
#
# 候选路径:MT_ASSETS_ZIP 环境变量 -> user://assets.zip ->
# <可执行文件目录>/assets.zip -> res://../assets.zip(开发)
#
# FUTURE(下载版):_find_local_zip() 失败时,改为 HTTPRequest 从 ASSET_PACK_URL
# 下载到 user://assets.zip(断点续传 + sha256 校验 + 进度 UI),再走同一个 mount。
class_name AssetPack
extends RefCounted
const ZIP_NAME := "assets.zip"
# const ASSET_PACK_URL := "" # FUTURE: 下载版填这里
static var mounted := false
static var last_source := ""
# 返回 true = 资源可用(散文件 或 已挂载 zip)。同步;本地文件场景不阻塞。
# force_zip=true:即使散 assets/ 可用也去挂 zip(测试 / 验证移动端路径用)。
static func ensure(force_zip := false) -> bool:
if mounted:
return true
if not force_zip and AssetRoot.available(): # 散 assets/(桌面开发)
return true
var zip := _find_local_zip()
if zip == "":
# FUTURE: 这里改成下载 ASSET_PACK_URL -> user://assets.zip -> 继续
push_warning("[AssetPack] 找不到 %sAndroid: adb push 到 files/iOS: 上传到 Documents/" % ZIP_NAME)
return false
if ProjectSettings.load_resource_pack(zip, false):
mounted = true
last_source = zip
print("[AssetPack] mounted ", zip)
return true
push_warning("[AssetPack] load_resource_pack 失败: " + zip)
return false
static func _find_local_zip() -> String:
var cands: Array[String] = []
var env := OS.get_environment("MT_ASSETS_ZIP")
if env != "":
cands.append(env)
cands.append("user://" + ZIP_NAME)
var data_dir := OS.get_user_data_dir()
if data_dir != "":
cands.append(data_dir.path_join(ZIP_NAME))
var exe := OS.get_executable_path()
if exe != "":
cands.append(exe.get_base_dir().path_join(ZIP_NAME))
cands.append("res://../" + ZIP_NAME) # 开发:仓库根旁
for c in cands:
if FileAccess.file_exists(c):
return c
return ""