fix(locale): resolve Chinese monster and NPC names via Locale.mob_names and early-bind name resolver

This commit is contained in:
shen
2026-09-19 19:19:55 -07:00
parent 7cbda7b3dd
commit 1637b500e5
4 changed files with 143 additions and 22 deletions
+11 -2
View File
@@ -246,6 +246,13 @@ func setup(m2client: Node, assets_root: String,
pc.ground_clicked.connect(_on_ground_clicked)
if _assets != "":
net_play.set_asset_root(_assets) # §3.5:加载 playersettingmodule.py 连击段表
var _early_loc: RefCounted = load("res://locale.gd").new()
_early_loc.setup(_assets, cur_lang)
net_play.locale = _early_loc
if net_world and "name_resolver" in net_world:
net_world.name_resolver = net_play._entity_name # 早期绑定:确保最先刷出的实体即显示中文名
if net_world and "kind_resolver" in net_world:
net_world.kind_resolver = net_play._entity_kind
# 主角必须先于后续的 proto/UI/远端实体重活建立。实网一次可收到近 200 个
# GC_CHARACTER_ADD;若等整个 setup() 尾部才订阅,怪物模型同步加载会把本地角色
@@ -485,8 +492,10 @@ func setup(m2client: Node, assets_root: String,
net_world.kind_resolver = net_play._entity_kind # §8.8 名字色分类:怪 / NPC 走 mob_proto bType
if net_world and "title_name_resolver" in net_world and assets_root != "":
# §8.8 称号名:introloading.__RegisterTitleName -> localeInfo.PVP_LEVEL<grade>
var _tt_loc: RefCounted = load("res://locale.gd").new()
_tt_loc.setup(assets_root, cur_lang)
var _tt_loc: RefCounted = net_play.locale if net_play.locale != null else load("res://locale.gd").new()
if net_play.locale == null:
_tt_loc.setup(assets_root, cur_lang)
net_play.locale = _tt_loc
net_world.title_name_resolver = func(g: int) -> String:
var k := "PVP_LEVEL%d" % g
return _tt_loc.t(k) if _tt_loc.has(k) else ""