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:
@@ -0,0 +1,92 @@
|
||||
# DeathUI (P4) —— 主角死亡 → 灰屏 + 复活窗。
|
||||
#
|
||||
# var d := preload("res://ui/death_ui.gd").new()
|
||||
# add_child(d)
|
||||
# d.setup(m2client, canvas_parent)
|
||||
#
|
||||
# 触发:M2Client.entity_dead(main_vid) 或 phase_changed("dead")。
|
||||
# 复活走服务器 quest 命令(同客户端):/restart_here · /restart_town(CG_CHAT)。
|
||||
# 复活成功服务器发 GC_PLAYER_POINTS(hp>0) / 相位回 game -> 自动关。
|
||||
extends Node
|
||||
|
||||
var client: Node
|
||||
var _root: Control
|
||||
var _shown := false
|
||||
|
||||
func setup(m2client: Node, parent: Node) -> void:
|
||||
client = m2client
|
||||
_build(parent)
|
||||
if client.has_signal("entity_dead"):
|
||||
client.entity_dead.connect(_on_dead)
|
||||
if client.has_signal("phase_changed"):
|
||||
client.phase_changed.connect(func(p): if p == "dead": show_dialog())
|
||||
if client.has_signal("vitals_changed"):
|
||||
client.vitals_changed.connect(_on_vitals)
|
||||
|
||||
func _on_dead(vid: int) -> void:
|
||||
if client.has_method("get_main_vid") and vid == client.get_main_vid():
|
||||
show_dialog()
|
||||
|
||||
func _on_vitals(vid: int) -> void:
|
||||
if not _shown:
|
||||
return
|
||||
if client.has_method("get_main_vid") and vid == client.get_main_vid():
|
||||
var e: Dictionary = client.get_entity(vid)
|
||||
if int(e.get("hp", 0)) > 0 and not e.get("dead", false):
|
||||
hide_dialog()
|
||||
|
||||
func show_dialog() -> void:
|
||||
if _shown:
|
||||
return
|
||||
_shown = true
|
||||
_root.visible = true
|
||||
|
||||
func hide_dialog() -> void:
|
||||
_shown = false
|
||||
_root.visible = false
|
||||
|
||||
func _build(parent: Node) -> void:
|
||||
_root = Control.new()
|
||||
_root.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
_root.visible = false
|
||||
_root.mouse_filter = Control.MOUSE_FILTER_STOP
|
||||
parent.add_child(_root)
|
||||
|
||||
var dim := ColorRect.new()
|
||||
dim.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
dim.color = Color(0.1, 0.0, 0.0, 0.55)
|
||||
_root.add_child(dim)
|
||||
|
||||
var panel := Panel.new()
|
||||
panel.set_anchors_preset(Control.PRESET_CENTER)
|
||||
panel.position = Vector2(-150, -70)
|
||||
panel.size = Vector2(300, 140)
|
||||
var sb := StyleBoxFlat.new()
|
||||
sb.bg_color = Color(0.12, 0.1, 0.1, 0.97)
|
||||
sb.border_color = Color(0.5, 0.2, 0.2)
|
||||
sb.set_border_width_all(1)
|
||||
sb.set_corner_radius_all(4)
|
||||
panel.add_theme_stylebox_override("panel", sb)
|
||||
_root.add_child(panel)
|
||||
|
||||
var title := Label.new()
|
||||
title.text = "你已阵亡"
|
||||
title.position = Vector2(0, 16)
|
||||
title.size = Vector2(300, 0)
|
||||
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
panel.add_child(title)
|
||||
|
||||
_btn(panel, "在此复活", 24, 60, func(): _restart("/restart_here"))
|
||||
_btn(panel, "回城复活", 158, 60, func(): _restart("/restart_town"))
|
||||
|
||||
func _btn(parent: Control, text: String, x: int, y: int, cb: Callable) -> void:
|
||||
var b := Button.new()
|
||||
b.text = text
|
||||
b.position = Vector2(x, y)
|
||||
b.size = Vector2(118, 30)
|
||||
b.pressed.connect(cb)
|
||||
parent.add_child(b)
|
||||
|
||||
func _restart(cmd: String) -> void:
|
||||
if client and client.has_method("say"):
|
||||
client.say(0, cmd) # CHAT_TYPE_TALKING
|
||||
Reference in New Issue
Block a user