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():