From 7cbda7b3dd36f5a1c0647c7cbc197ed8e6259295 Mon Sep 17 00:00:00 2001 From: shen <> Date: Sat, 19 Sep 2026 18:58:10 -0700 Subject: [PATCH] feat(locale): add Locale fallback for monster names in net_play._entity_name --- project/net_play.gd | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/project/net_play.gd b/project/net_play.gd index 14378430..5b408b04 100644 --- a/project/net_play.gd +++ b/project/net_play.gd @@ -663,12 +663,24 @@ func _entity_kind(e: Dictionary) -> int: return explicit_kind return 0 -# 实体显示名:玩家 / NPC 走 GC_CHAR_ADD_INFO 的 name;怪没有名字包 -> 查 mob_proto。 +var _locale_ref: RefCounted = null + +# 实体显示名:玩家 / NPC 走 GC_CHAR_ADD_INFO 的 name;怪没有名字包 -> 查 mob_proto / Locale。 func _entity_name(e: Dictionary) -> String: var nm := String(e.get("name", "")) if nm != "": return nm var race := int(e.get("race", 0)) + if race >= 1: + if _locale_ref == null and ResourceLoader.exists("res://locale.gd"): + var LocaleScript = load("res://locale.gd") + if LocaleScript: + _locale_ref = LocaleScript.new() + _locale_ref.setup(AssetRoot.path() if ResourceLoader.exists("res://asset_root.gd") else "") + if _locale_ref and _locale_ref.has_method("mob_name"): + var zh_name: String = _locale_ref.mob_name(race) + if not zh_name.begins_with("怪物 #") and not zh_name.is_empty(): + return zh_name if race >= 1 and proto and proto.has_method("mob"): var m: Dictionary = proto.mob(race) if not m.is_empty():