using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace MyBackpackAlert_Chinese;
[BepInPlugin("my.pahsiv.MyBackpackAlert.Chinese", "MyBackpackAlert 中文汉化补丁", "1.0.9")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
private static Harmony _harmony;
private void Awake()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Expected O, but got Unknown
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"MyBackpackAlert 中文汉化补丁正在加载...");
try
{
_harmony = new Harmony("my.pahsiv.MyBackpackAlert.Chinese");
Assembly assembly = null;
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly2 in assemblies)
{
if (assembly2.GetName().Name == "my.pahsiv.MyBackpackAlert")
{
assembly = assembly2;
break;
}
}
if (assembly == null)
{
Log.LogWarning((object)"未找到 MyBackpackAlert 原模组程序集,汉化补丁将不生效。请确保已安装 MyBackpackAlert。");
return;
}
Type type = assembly.GetType("MyBackpackAlert.Plugin");
if (type == null)
{
Log.LogError((object)"未找到 MyBackpackAlert.Plugin 类型");
return;
}
MethodInfo methodInfo = type.GetMethod("Notification", BindingFlags.Static | BindingFlags.Public, null, new Type[3]
{
typeof(string),
typeof(string),
typeof(bool)
}, null);
if (methodInfo == null)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public);
MethodInfo[] array = methods;
foreach (MethodInfo methodInfo2 in array)
{
if (methodInfo2.Name == "Notification")
{
methodInfo = methodInfo2;
break;
}
}
}
if (methodInfo == null)
{
Log.LogError((object)"未找到 Notification 方法");
return;
}
Log.LogInfo((object)("已定位 Notification 方法: " + methodInfo.ToString()));
MethodInfo method = typeof(NotificationPatch).GetMethod("Prefix", BindingFlags.Static | BindingFlags.NonPublic);
_harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
MethodInfo methodInfo3 = type.GetMethod("GetItemName", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(ushort) }, null);
if (methodInfo3 == null)
{
MethodInfo[] methods2 = type.GetMethods(BindingFlags.Static | BindingFlags.Public);
MethodInfo[] array2 = methods2;
foreach (MethodInfo methodInfo4 in array2)
{
if (methodInfo4.Name == "GetItemName")
{
methodInfo3 = methodInfo4;
break;
}
}
}
if (methodInfo3 != null)
{
Log.LogInfo((object)("已定位 GetItemName 方法: " + methodInfo3.ToString()));
MethodInfo method2 = typeof(GetItemNamePatch).GetMethod("Postfix", BindingFlags.Static | BindingFlags.NonPublic);
_harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
else
{
Log.LogWarning((object)"未找到 GetItemName 方法,物品名翻译将不生效");
}
Log.LogInfo((object)"MyBackpackAlert 中文汉化补丁加载完成!");
}
catch (Exception ex)
{
Log.LogError((object)("汉化补丁加载失败: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
internal static class NotificationPatch
{
private static bool Prefix(ref string __0, ref string __1, ref bool __2)
{
if (!string.IsNullOrEmpty(__0))
{
__0 = Translator.Translate(__0);
}
return true;
}
}
internal static class Translator
{
private static readonly Dictionary<string, string> FullTranslations = new Dictionary<string, string>(StringComparer.Ordinal)
{
{ "Add Item : [Slot {0}] {1} | {2}", "添加物品:[槽位 {0}] {1} | {2}" },
{ "Remove Item : [Slot {0}] {1} | {2}", "移除物品:[槽位 {0}] {1} | {2}" },
{ "Character Ownership Request (209) | ViewID: {0}, Owner: {1}, Requester: {2}", "角色所有权请求 (209) | ViewID: {0}, 所有者: {1}, 请求者: {2}" },
{ "Character Ownership Theft (210) | ViewID: {0}, Sender: {1}, NewOwner: {2}", "角色所有权窃取 (210) | ViewID: {0}, 发送者: {1}, 新所有者: {2}" },
{ "Character Destroy Request (204) | ViewID: {0}, Attacker: {1}", "角色破坏请求 (204) | ViewID: {0}, 攻击者: {1}" },
{ "Player Destroy Request (204) | ViewID: {0}, Attacker: {1}", "玩家破坏请求 (204) | ViewID: {0}, 攻击者: {1}" },
{ "New RPC_Explode Record : {0} | {1}", "新的爆炸记录:{0} | {1}" },
{ "Dangerous instantiation: {0} | {1}", "危险实例化:{0} | {1}" },
{ "Position: {0}", "位置:{0}" },
{ "Actor {0}", "角色 {0}" }
};
private static readonly List<KeyValuePair<string, string>> PartialTranslations = BuildPartialTranslations();
private static List<KeyValuePair<string, string>> BuildPartialTranslations()
{
List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
list.Add(new KeyValuePair<string, string>("from your backpack!", "从你的背包中!"));
list.Add(new KeyValuePair<string, string>("from your fannypack!", "从你的腰包中!"));
list.Add(new KeyValuePair<string, string>("has taken the ", "拿走了"));
list.Add(new KeyValuePair<string, string>("[Dart Shot] Shooter: ", "[吹箭射击] 射手:"));
list.Add(new KeyValuePair<string, string>("[Dart Shot]", "[吹箭射击]"));
list.Add(new KeyValuePair<string, string>("[Near Miss] Character: ", "[险些命中] 角色:"));
list.Add(new KeyValuePair<string, string>("[Near Miss]", "[险些命中]"));
list.Add(new KeyValuePair<string, string>("Shooter: ", "射手:"));
list.Add(new KeyValuePair<string, string>("Character: ", "角色:"));
list.Add(new KeyValuePair<string, string>(" | Distance: ", " | 距离:"));
list.Add(new KeyValuePair<string, string>(" | Hit: ", " | 命中:"));
list.Add(new KeyValuePair<string, string>("{0:F2}m", "{0:F2}米"));
list.Add(new KeyValuePair<string, string>("[EXPLODE] Blacklisted player ", "[爆炸] 已拉黑玩家 "));
list.Add(new KeyValuePair<string, string>("[EXPLODE]", "[爆炸]"));
list.Add(new KeyValuePair<string, string>("attempted to spawn explosion!", "试图生成爆炸!"));
list.Add(new KeyValuePair<string, string>("-> RPC_Explode (SPAM DETECTED - BLACKLISTED)", "-> RPC_Explode(检测到刷屏 - 已拉黑)"));
list.Add(new KeyValuePair<string, string>("[BEE SWARM]", "[蜂群]"));
list.Add(new KeyValuePair<string, string>("attempted to force a bee swarm!", "试图强制召唤蜂群!"));
list.Add(new KeyValuePair<string, string>("[OWNERSHIP REQUEST (204)]", "[所有权请求 (204)]"));
list.Add(new KeyValuePair<string, string>("[OWNERSHIP THEFT (210)]", "[所有权窃取 (210)]"));
list.Add(new KeyValuePair<string, string>("requested ownership of ", "请求了…的所有权"));
list.Add(new KeyValuePair<string, string>("tried to steal ownership of ", "试图窃取…的所有权"));
list.Add(new KeyValuePair<string, string>("'s player object!", "的玩家对象!"));
list.Add(new KeyValuePair<string, string>("[CHARACTER DESTROY (204)]", "[角色破坏 (204)]"));
list.Add(new KeyValuePair<string, string>("[PLAYER DESTROY (204)]", "[玩家破坏 (204)]"));
list.Add(new KeyValuePair<string, string>("tried to destroy ", "试图破坏"));
list.Add(new KeyValuePair<string, string>("'s character!", "的角色!"));
list.Add(new KeyValuePair<string, string>("[FORCE DESTROY ITEM]", "[强制销毁物品]"));
list.Add(new KeyValuePair<string, string>("[FORCE REMOVE ITEM]", "[强制移除物品]"));
list.Add(new KeyValuePair<string, string>("[FORCE DROP ITEM]", "[强制丢弃物品]"));
list.Add(new KeyValuePair<string, string>("[FORCE UNPASS OUT]", "[强制苏醒]"));
list.Add(new KeyValuePair<string, string>("[FORCE PASS OUT]", "[强制晕倒]"));
list.Add(new KeyValuePair<string, string>("[FORCE END GAME]", "[强制结束游戏]"));
list.Add(new KeyValuePair<string, string>("[FORCE CROUCH]", "[强制蹲下]"));
list.Add(new KeyValuePair<string, string>("[FORCE EMOTE]", "[强制表情]"));
list.Add(new KeyValuePair<string, string>("[FORCE JUMP]", "[强制跳跃]"));
list.Add(new KeyValuePair<string, string>("attempted to destroy item held by ", "试图销毁…持有的物品"));
list.Add(new KeyValuePair<string, string>("attempted to remove item from ", "试图从…移除物品"));
list.Add(new KeyValuePair<string, string>("attempted to drop item from ", "试图从…丢弃物品"));
list.Add(new KeyValuePair<string, string>("attempted to render PassedOut on ", "试图在…上渲染晕倒状态"));
list.Add(new KeyValuePair<string, string>("attempted to play emote ", "试图播放表情"));
list.Add(new KeyValuePair<string, string>("attempted to force the game to end!", "试图强制结束游戏!"));
list.Add(new KeyValuePair<string, string>("attempted to make ", "试图让"));
list.Add(new KeyValuePair<string, string>("crouch!", "蹲下!"));
list.Add(new KeyValuePair<string, string>("unpass out!", "苏醒!"));
list.Add(new KeyValuePair<string, string>("pass out!", "晕倒!"));
list.Add(new KeyValuePair<string, string>("jump!", "跳跃!"));
list.Add(new KeyValuePair<string, string>("-> CharacterPassedOut -> ", "-> 角色晕倒 -> "));
list.Add(new KeyValuePair<string, string>("-> DestroyHeldItemRpc -> ", "-> 销毁手持物品RPC -> "));
list.Add(new KeyValuePair<string, string>("-> DropItemFromSlotRPC -> ", "-> 从槽位丢弃物品RPC -> "));
list.Add(new KeyValuePair<string, string>("-> JumpRpc -> ", "-> 跳跃RPC -> "));
list.Add(new KeyValuePair<string, string>("-> RPCA_PassOut -> ", "-> RPCA_晕倒 -> "));
list.Add(new KeyValuePair<string, string>("-> RPCA_PlayRemove -> ", "-> RPCA_播放移除 -> "));
list.Add(new KeyValuePair<string, string>("-> RPCA_SetCrouch -> ", "-> RPCA_设置蹲下 -> "));
list.Add(new KeyValuePair<string, string>("-> RPCA_UnPassOut -> ", "-> RPCA_苏醒 -> "));
list.Add(new KeyValuePair<string, string>("-> RPCEndGame_ForceWin", "-> 强制结束游戏_强制胜利"));
list.Add(new KeyValuePair<string, string>("-> RPCRemoveItemFromSlot -> ", "-> 从槽位移除物品RPC -> "));
list.Add(new KeyValuePair<string, string>("-> SetBeesAngryRPC", "-> 设置蜜蜂愤怒RPC"));
list.Add(new KeyValuePair<string, string>("[Instantiate] ", "[实例化] "));
list.Add(new KeyValuePair<string, string>("[RitualDagger] ", "[仪式匕首] "));
list.Add(new KeyValuePair<string, string>("[RitualDagger]", "[仪式匕首]"));
list.Add(new KeyValuePair<string, string>("Player: ", "玩家:"));
list.Add(new KeyValuePair<string, string>(" on ", " 在…上 "));
return list;
}
public static string Translate(string input)
{
if (string.IsNullOrEmpty(input))
{
return input;
}
string key = RemoveColorTags(input);
if (FullTranslations.TryGetValue(key, out var value))
{
return RestoreColorTags(input, value);
}
string text = input;
foreach (KeyValuePair<string, string> partialTranslation in PartialTranslations)
{
if (text.Contains(partialTranslation.Key))
{
text = text.Replace(partialTranslation.Key, partialTranslation.Value);
}
}
return TranslateColoredItemNames(text);
}
private static string TranslateColoredItemNames(string text)
{
int startIndex = 0;
while (true)
{
int num = text.IndexOf("<color=", startIndex, StringComparison.OrdinalIgnoreCase);
if (num < 0)
{
break;
}
int num2 = text.IndexOf('>', num);
if (num2 < 0)
{
break;
}
int num3 = text.IndexOf("</color>", num2 + 1, StringComparison.OrdinalIgnoreCase);
if (num3 < 0)
{
break;
}
string text2 = text.Substring(num2 + 1, num3 - num2 - 1);
string text3 = ItemTranslator.TranslateItemName(text2);
if (text3 != text2)
{
text = text.Substring(0, num2 + 1) + text3 + text.Substring(num3);
startIndex = num2 + 1 + text3.Length;
}
else
{
startIndex = num3 + 8;
}
}
return text;
}
private static string RemoveColorTags(string text)
{
int num;
while ((num = text.IndexOf("<color=", StringComparison.OrdinalIgnoreCase)) >= 0)
{
int num2 = text.IndexOf('>', num);
if (num2 < 0)
{
break;
}
text = text.Remove(num, num2 - num + 1);
}
text = text.Replace("</color>", "").Replace("</COLOR>", "");
return text;
}
private static string RestoreColorTags(string original, string translated)
{
string text = original.Trim();
if (text.StartsWith("<color=", StringComparison.OrdinalIgnoreCase) && text.EndsWith("</color>", StringComparison.OrdinalIgnoreCase))
{
int num = text.IndexOf('>');
if (num > 0)
{
string text2 = text.Substring(0, num + 1);
return text2 + translated + "</color>";
}
}
return translated;
}
}
internal static class GetItemNamePatch
{
private static void Postfix(ref string __result)
{
if (!string.IsNullOrEmpty(__result))
{
__result = ItemTranslator.TranslateItemName(__result);
}
}
}
internal static class ItemTranslator
{
private static readonly Dictionary<string, string> ItemDict = BuildItemDict();
private static readonly Dictionary<string, string> WordDict = BuildWordDict();
private static Dictionary<string, string> BuildItemDict()
{
Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
dictionary["Airline Food"] = "飞机餐";
dictionary["Airplane Food"] = "飞机餐";
dictionary["Scout Cookies"] = "童军饼干";
dictionary["ScoutCookies"] = "童军饼干";
dictionary["ScoutCookies_Vanilla"] = "童军饼干";
dictionary["Trail Mix"] = "混合坚果";
dictionary["TrailMix"] = "混合坚果";
dictionary["Granola Bar"] = "燕麦棒";
dictionary["Energy Drink"] = "能量饮料";
dictionary["Sports Drink"] = "运动饮料";
dictionary["Marshmallow"] = "棉花糖";
dictionary["Big Lollipop"] = "大棒棒糖";
dictionary["Lollipop"] = "大棒棒糖";
dictionary["Lollipop_Prop"] = "大棒棒糖";
dictionary["Fortified Milk"] = "奶白金";
dictionary["FortifiedMilk"] = "奶白金";
dictionary["Hot Dog"] = "热狗肠";
dictionary["Glizzy"] = "热狗肠";
dictionary["Glizzy_CattailVariant"] = "热狗肠";
dictionary["Egg"] = "煎蛋";
dictionary["EggTurkey"] = "煎蛋";
dictionary["EggRaven"] = "煎蛋";
dictionary["Cooked Bird"] = "\"鸟\"";
dictionary["NestEgg"] = "好大蛋";
dictionary["NestEgg_Raven"] = "好大蛋";
dictionary["Emergency Survival Ration"] = "紧急生存口粮";
dictionary["Base Camp Coffee"] = "大本营咖啡";
dictionary["Pure Glacier Water"] = "纯净冰川水";
dictionary["Protein Recovery Shake"] = "蛋白恢复奶昔";
dictionary["Traditional Sherpa Stew"] = "传统夏尔巴炖菜";
dictionary["Altitude Adjustment Tea"] = "高原适应茶";
dictionary["Bugfix"] = "蜱虫";
dictionary["Red Crispberry"] = "红脆莓";
dictionary["Apple Berry Red"] = "红脆莓";
dictionary["Yellow Crispberry"] = "黄脆莓";
dictionary["Apple Berry Yellow"] = "黄脆莓";
dictionary["Green Crispberry"] = "绿脆莓";
dictionary["Apple Berry Green"] = "绿脆莓";
dictionary["Purple Kingberry"] = "紫荔莓";
dictionary["Kingberry Purple"] = "紫荔莓";
dictionary["Yellow Kingberry"] = "黄荔莓";
dictionary["Kingberry Yellow"] = "黄荔莓";
dictionary["Green Kingberry"] = "青荔莓";
dictionary["Kingberry Green"] = "青荔莓";
dictionary["Red Clusterberry"] = "红葚莓";
dictionary["Clusterberry Red"] = "红葚莓";
dictionary["Yellow Clusterberry"] = "黄葚莓";
dictionary["Clusterberry Yellow"] = "黄葚莓";
dictionary["Black Clusterberry"] = "黑葚莓";
dictionary["Clusterberry Black"] = "黑葚莓";
dictionary["Green Clusterberry"] = "绿葚莓";
dictionary["Clusterberry_UNUSED"] = "绿葚莓";
dictionary["Orange Winterberry"] = "橙雪莓";
dictionary["Winterberry Orange"] = "橙雪莓";
dictionary["Yellow Winterberry"] = "黄雪莓";
dictionary["Winterberry Yellow"] = "黄雪莓";
dictionary["Red Prickleberry"] = "红刺莓";
dictionary["Prickleberry_Red"] = "红刺莓";
dictionary["Gold Prickleberry"] = "金刺莓";
dictionary["Golden Prickleberry"] = "金刺莓";
dictionary["Prickleberry_Gold"] = "金刺莓";
dictionary["Scorchberry"] = "火烧莓";
dictionary["Pepper Berry"] = "火烧莓";
dictionary["Napberry"] = "晚安莓";
dictionary["Pink Berrynana"] = "粉莓蕉";
dictionary["Berrynana Pink"] = "粉莓蕉";
dictionary["Yellow Berrynana"] = "黄莓蕉";
dictionary["Berrynana Yellow"] = "黄莓蕉";
dictionary["Blue Berrynana"] = "蓝莓蕉";
dictionary["Berrynana Blue"] = "蓝莓蕉";
dictionary["Brown Berrynana"] = "棕莓蕉";
dictionary["Berrynana Brown"] = "棕莓蕉";
dictionary["Berrynana"] = "莓蕉";
dictionary["Berrynana Peel"] = "莓蕉皮";
dictionary["Coconut"] = "椰子";
dictionary["Item_Coconut"] = "椰子";
dictionary["Half-Coconut"] = "半边椰子";
dictionary["Coconut Half"] = "半边椰子";
dictionary["Item_Coconut_half"] = "半边椰子";
dictionary["Honeycomb"] = "蜂巢蜜";
dictionary["Item_Honeycomb"] = "蜂巢蜜";
dictionary["Beehive"] = "蜂巢";
dictionary["Big Egg"] = "好大蛋";
dictionary["Small Egg"] = "小小蛋";
dictionary["Blue Shroomberry"] = "蓝菇莓";
dictionary["Shroomberry_Blue"] = "蓝菇莓";
dictionary["Green Shroomberry"] = "绿菇莓";
dictionary["Shroomberry_Green"] = "绿菇莓";
dictionary["Purple Shroomberry"] = "紫菇莓";
dictionary["Shroomberry_Purple"] = "紫菇莓";
dictionary["Red Shroomberry"] = "红菇莓";
dictionary["Shroomberry_Red"] = "红菇莓";
dictionary["Yellow Shroomberry"] = "黄菇莓";
dictionary["Shroomberry_Yellow"] = "黄菇莓";
dictionary["Chubby Mushroom"] = "梨鲍菇";
dictionary["Chubby Shroom"] = "梨鲍菇";
dictionary["Mushroom Chubby"] = "梨鲍菇";
dictionary["Poisonous Cluster Mushroom"] = "银针菇";
dictionary["Cluster Mushroom"] = "银针菇";
dictionary["Cluster Shroom"] = "银针菇";
dictionary["Mushroom Cluster"] = "银针菇";
dictionary["Mushroom Cluster Poison"] = "银针菇";
dictionary["Bugle Shroom"] = "喇叭菇";
dictionary["Mushroom Lace"] = "喇叭菇";
dictionary["Mushroom Lace Poison"] = "喇叭菇";
dictionary["Button Shroom"] = "馒头菇";
dictionary["Mushroom Normie"] = "馒头菇";
dictionary["Mushroom Normie Poison"] = "馒头菇";
dictionary["Shelf Shroom"] = "踏板菇";
dictionary["Shelf Fungus"] = "踏板菇";
dictionary["ShelfShroom"] = "踏板菇";
dictionary["Remedy Fungus"] = "灵药菇";
dictionary["HealingPuffShroom"] = "灵药菇";
dictionary["Cloud Fungus"] = "云雾菇";
dictionary["CloudFungus"] = "云雾菇";
dictionary["Bounce Fungus"] = "弹力菇";
dictionary["BounceShroom"] = "弹力菇";
dictionary["Warp Fungus"] = "曲迁菇";
dictionary["WarpFungus"] = "曲迁菇";
dictionary["Mushroom Glow"] = "发光菇";
dictionary["Medicinal Root"] = "药用根茎";
dictionary["MedicinalRoot"] = "药用根茎";
dictionary["Aloe Vera"] = "芦荟";
dictionary["AloeVera"] = "芦荟";
dictionary["Scorpion"] = "蝎子";
dictionary["Tick"] = "蜱虫";
dictionary["Mandrake"] = "曼德拉草";
dictionary["Mandragora"] = "曼德拉草";
dictionary["Mandrake_Hidden"] = "曼德拉草";
dictionary["Magic Bean"] = "魔豆";
dictionary["MagicBean"] = "魔豆";
dictionary["Frog"] = "青蛙";
dictionary["Frog Legs"] = "田鸡腿";
dictionary["FrogLegs"] = "田鸡腿";
dictionary["Early Bird"] = "早起虫儿";
dictionary["Early Worm"] = "早起虫儿";
dictionary["EarlyWorm"] = "早起虫儿";
dictionary["Conch"] = "海螺";
dictionary["Seashell"] = "海螺";
dictionary["Snowball"] = "雪球";
dictionary["Cactus"] = "仙人球";
dictionary["Stone"] = "石头";
dictionary["FireWood"] = "木柴";
dictionary["ClimbingChalk"] = "攀岩粉";
dictionary["Professional Climbing Rope"] = "专业登山绳";
dictionary["Titanium Ice Axe"] = "钛合金冰镐";
dictionary["Advanced Climbing Harness"] = "高级登山安全带";
dictionary["High Altitude Expedition Tent"] = "高海拔探险帐篷";
dictionary["GPS Navigation Device"] = "GPS导航设备";
dictionary["Insulated Sleeping Bag"] = "保温睡袋";
dictionary["Mountaineering Boots"] = "登山靴";
dictionary["Satellite Communication Device"] = "卫星通讯设备";
dictionary["Climbing Piton"] = "岩钉";
dictionary["StackablePiton"] = "岩钉";
dictionary["Piton"] = "岩钉";
dictionary["ClimbingSpike"] = "岩钉";
dictionary["Rope"] = "绳索";
dictionary["Rope Spool"] = "绳索";
dictionary["RopeSpool"] = "绳索";
dictionary["Anti-Rope Spool"] = "反重绳索";
dictionary["Anti-Gravity Rope Spool"] = "反重绳索";
dictionary["Rope Cannon"] = "绳索炮";
dictionary["Rope Shooter"] = "绳索炮";
dictionary["RopeShooter"] = "绳索炮";
dictionary["Anti-Rope Cannon"] = "反重绳索炮";
dictionary["Rope Shooter Anti"] = "反重绳索炮";
dictionary["RopeShooterAnti"] = "反重绳索炮";
dictionary["AntiZooka"] = "反重绳索炮";
dictionary["Chain Cannon"] = "锁链发射器";
dictionary["Chain Launcher"] = "锁链发射器";
dictionary["ChainShooter"] = "锁链发射器";
dictionary["Rescue Claw"] = "救援抓钩";
dictionary["RescueHook"] = "救援抓钩";
dictionary["RescueHook_Infinite"] = "救援抓钩";
dictionary["Checkpoint Flag"] = "检查点旗标";
dictionary["Flag_Plantable_Checkpoint"] = "检查点旗标";
dictionary["Book of Bones"] = "骸骨之书";
dictionary["The Book of Bones"] = "骸骨之书";
dictionary["BookOfBones"] = "骸骨之书";
dictionary["Parasol"] = "太阳伞";
dictionary["Parasol_Roots Variant"] = "太阳伞";
dictionary["Glider"] = "滑翔伞";
dictionary["Bandages"] = "绷带";
dictionary["Medkit"] = "急救箱";
dictionary["First Aid Kit"] = "急救箱";
dictionary["FirstAidKit"] = "急救箱";
dictionary["Antidote"] = "解毒剂";
dictionary["Cure-All"] = "万灵药";
dictionary["Heat Pack"] = "暖宝宝";
dictionary["Faerie Lantern"] = "仙子提灯";
dictionary["Lantern_Faerie"] = "仙子提灯";
dictionary["Sunscreen"] = "防晒喷雾";
dictionary["HealingDart Variant"] = "治疗飞镖";
dictionary["Compass"] = "罗盘";
dictionary["Pirate's Compass"] = "海盗罗盘";
dictionary["Pirate Compass"] = "海盗罗盘";
dictionary["Warp Compass"] = "曲迁罗盘";
dictionary["Cheat Compass"] = "作弊罗盘";
dictionary["Cheat Compass 1"] = "作弊罗盘";
dictionary["Lantern"] = "提灯";
dictionary["Torch"] = "火炬";
dictionary["Flare"] = "照明棒";
dictionary["Bugle"] = "喇叭";
dictionary["Bugle of Friendship"] = "友谊喇叭";
dictionary["Petal Bugle"] = "友谊喇叭";
dictionary["Bugle_Magic"] = "友谊喇叭";
dictionary["Scoutmaster's Bugle"] = "童军领队的喇叭";
dictionary["Bugle_Scoutmaster Variant"] = "童军领队的喇叭";
dictionary["Bugle_Prop Variant"] = "喇叭";
dictionary["Binoculars"] = "望远镜";
dictionary["Telescope"] = "望远镜";
dictionary["Binoculars_Prop"] = "望远镜";
dictionary["Megaphone"] = "扩音器";
dictionary["Candle"] = "烛台";
dictionary["Blowgun"] = "吹箭筒";
dictionary["Dynamite"] = "炸药";
dictionary["Ritual Dagger"] = "仪式匕首";
dictionary["RitualDagger"] = "仪式匕首";
dictionary["Portable Stove"] = "便携火炉";
dictionary["PortableStovetopItem"] = "便携火炉";
dictionary["Scout Cannon"] = "童子军大炮";
dictionary["ScoutCannonItem"] = "童子军大炮";
dictionary["Pandora's Lunchbox"] = "潘多拉餐盒";
dictionary["PandorasBox"] = "潘多拉餐盒";
dictionary["Cursed Skull"] = "诅咒头骨";
dictionary["Skull"] = "头骨";
dictionary["Ancient Effigy"] = "古老玩偶";
dictionary["Ancient Idol"] = "古老玩偶";
dictionary["AncientIdol"] = "古老玩偶";
dictionary["Scout Effigy"] = "童军雕像";
dictionary["ScoutEffigy"] = "童军雕像";
dictionary["Bing Bong Plush"] = "宾邦";
dictionary["Bing Bong Airways Mascot"] = "宾邦";
dictionary["Bing Bong"] = "宾邦";
dictionary["BingBong_Prop Variant"] = "宾邦";
dictionary["Passport"] = "护照";
dictionary["Frisbee"] = "飞盘";
dictionary["Flying Disc"] = "飞盘";
dictionary["Basketball"] = "篮球";
dictionary["Warpsketball"] = "曲迁篮球";
dictionary["Wilderness Handbook"] = "旅行指南";
dictionary["Guidebook"] = "旅行指南";
dictionary["Travel Guide"] = "旅行指南";
dictionary["GuidebookPage"] = "撕下的书页";
dictionary["GuidebookPage_13_FirstTeams"] = "撕下的书页";
dictionary["Scroll"] = "卷轴";
dictionary["Torn Page"] = "撕下的书页";
dictionary["Strange Crystal"] = "奇怪水晶";
dictionary["Strange Gem"] = "奇怪水晶";
dictionary["ScoutmasterSoul"] = "童军领队之魂";
dictionary["Climbing Balloons"] = "一束气球";
dictionary["Balloon Bunch"] = "一束气球";
dictionary["BalloonBunch"] = "一束气球";
dictionary["Balloons"] = "气球";
dictionary["Balloon"] = "气球";
dictionary["Jetpack"] = "喷气背包";
dictionary["Rocket Backpack"] = "火箭背包";
dictionary["Rocketpack"] = "火箭背包";
dictionary["Clown Backpack"] = "滑稽背包";
dictionary["Backpack"] = "背包";
dictionary["Fannypack"] = "腰包";
dictionary["Auto Parachute"] = "自动降落伞";
dictionary["Parachute"] = "自动降落伞";
dictionary["Amulet_SuperJump"] = "童军的进取";
dictionary["Amulet_InfiniteStamina"] = "童军的野心";
dictionary["Amulet_Clone"] = "童军的盛情";
dictionary["Amulet_Healing"] = "童军的毅力";
dictionary["Scout's Generosity"] = "童军的盛情";
dictionary["Scout's Hospitality"] = "童军的盛情";
dictionary["Amulet_Clone"] = "童军的盛情";
dictionary["Scout's Tenacity"] = "童军的坚毅";
dictionary["Scout's Perseverance"] = "童军的毅力";
dictionary["Amulet_Healing"] = "童军的毅力";
dictionary["Scout's Ambition"] = "童军的野心";
dictionary["Amulet_InfiniteStamina"] = "童军的野心";
dictionary["Scout's Initiative"] = "童军的进取";
dictionary["Amulet_SuperJump"] = "童军的进取";
dictionary["Scout's Honor"] = "童军的荣耀";
dictionary["Scout's Glory"] = "童军的荣耀";
dictionary["ScoutsHonor"] = "童军的荣耀";
dictionary["King"] = "国王";
dictionary["Queen"] = "皇后";
dictionary["Knight"] = "骑士";
dictionary["Rook"] = "战车";
dictionary["Bishop"] = "主教";
dictionary["Pawn"] = "兵卒";
dictionary["C_King"] = "国王";
dictionary["C_Queen"] = "皇后";
dictionary["C_Knight"] = "骑士";
dictionary["C_Rook_m"] = "战车";
dictionary["C_Rook_f"] = "战车";
dictionary["C_Bishop_m"] = "主教";
dictionary["C_Bishop_f"] = "主教";
dictionary["C_Pawn_m"] = "兵卒";
dictionary["C_Pawn_f"] = "兵卒";
dictionary["Banana Peel"] = "香蕉皮";
dictionary["Candelabra"] = "烛台";
dictionary["Bird"] = "\"鸟\"";
List<string> list = new List<string>(dictionary.Keys);
foreach (string item in list)
{
string text = ToPascalCase(item);
if (!dictionary.ContainsKey(text))
{
dictionary[text] = dictionary[item];
}
if (text.StartsWith("The", StringComparison.OrdinalIgnoreCase) && text.Length > 3)
{
string key = text.Substring(3);
if (!dictionary.ContainsKey(key))
{
dictionary[key] = dictionary[item];
}
}
}
return dictionary;
}
private static string ToPascalCase(string name)
{
string[] array = name.Split(new char[4] { ' ', '-', '\'', '_' }, StringSplitOptions.RemoveEmptyEntries);
StringBuilder stringBuilder = new StringBuilder();
string[] array2 = array;
foreach (string text in array2)
{
if (text.Length > 0)
{
stringBuilder.Append(char.ToUpperInvariant(text[0]));
if (text.Length > 1)
{
stringBuilder.Append(text.Substring(1));
}
}
}
return stringBuilder.ToString();
}
private static Dictionary<string, string> BuildWordDict()
{
Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
dictionary["food"] = "食物";
dictionary["drink"] = "饮料";
dictionary["bar"] = "棒";
dictionary["mix"] = "混合";
dictionary["cookie"] = "曲奇";
dictionary["cookies"] = "曲奇";
dictionary["candy"] = "糖";
dictionary["lollipop"] = "棒棒糖";
dictionary["mushroom"] = "蘑菇";
dictionary["shroom"] = "蘑菇";
dictionary["berry"] = "莓";
dictionary["berries"] = "莓";
dictionary["fruit"] = "水果";
dictionary["meat"] = "肉";
dictionary["stew"] = "炖菜";
dictionary["soup"] = "汤";
dictionary["tea"] = "茶";
dictionary["coffee"] = "咖啡";
dictionary["water"] = "水";
dictionary["shake"] = "奶昔";
dictionary["ration"] = "口粮";
dictionary["meal"] = "餐";
dictionary["snack"] = "零食";
dictionary["chocolate"] = "巧克力";
dictionary["nut"] = "坚果";
dictionary["nuts"] = "坚果";
dictionary["seed"] = "种子";
dictionary["seeds"] = "种子";
dictionary["marshmallow"] = "棉花糖";
dictionary["lunchbox"] = "午餐盒";
dictionary["stove"] = "炉";
dictionary["red"] = "红";
dictionary["blue"] = "蓝";
dictionary["green"] = "绿";
dictionary["yellow"] = "黄";
dictionary["black"] = "黑";
dictionary["white"] = "白";
dictionary["pink"] = "粉";
dictionary["purple"] = "紫";
dictionary["orange"] = "橙";
dictionary["brown"] = "棕";
dictionary["golden"] = "金";
dictionary["gold"] = "金";
dictionary["big"] = "大";
dictionary["small"] = "小";
dictionary["large"] = "大";
dictionary["giant"] = "巨";
dictionary["magic"] = "魔法";
dictionary["magical"] = "魔法";
dictionary["ancient"] = "古老";
dictionary["cursed"] = "诅咒";
dictionary["legendary"] = "传奇";
dictionary["rare"] = "稀有";
dictionary["common"] = "普通";
dictionary["uncommon"] = "罕见";
dictionary["poisonous"] = "有毒";
dictionary["medicinal"] = "药用";
dictionary["healing"] = "治疗";
dictionary["emergency"] = "紧急";
dictionary["portable"] = "便携";
dictionary["pure"] = "纯净";
dictionary["high-energy"] = "高能";
dictionary["protein"] = "蛋白";
dictionary["recovery"] = "恢复";
dictionary["survival"] = "生存";
dictionary["traditional"] = "传统";
dictionary["anti-rope"] = "反重力绳";
dictionary["anti"] = "反";
dictionary["rope"] = "绳";
dictionary["cannon"] = "炮";
dictionary["spool"] = "轴";
dictionary["chain"] = "链";
dictionary["piton"] = "岩钉";
dictionary["compass"] = "指南针";
dictionary["lantern"] = "提灯";
dictionary["flare"] = "信号弹";
dictionary["bandages"] = "绷带";
dictionary["bandage"] = "绷带";
dictionary["medkit"] = "医疗包";
dictionary["antidote"] = "解毒剂";
dictionary["effigy"] = "雕像";
dictionary["idol"] = "神像";
dictionary["skull"] = "骷髅";
dictionary["plush"] = "玩偶";
dictionary["peel"] = "皮";
dictionary["bean"] = "豆";
dictionary["bugle"] = "号角";
dictionary["blowgun"] = "吹箭";
dictionary["friendship"] = "友谊";
dictionary["scout"] = "童子军";
dictionary["scoutmaster"] = "童子军";
dictionary["airline"] = "航空";
dictionary["airplane"] = "飞机";
dictionary["trail"] = "小径";
dictionary["mountain"] = "山地";
dictionary["granola"] = "燕麦";
dictionary["energy"] = "能量";
dictionary["sports"] = "运动";
dictionary["base"] = "基地";
dictionary["camp"] = "营地";
dictionary["glacier"] = "冰川";
dictionary["sherpa"] = "夏尔巴";
dictionary["altitude"] = "高原";
dictionary["adjustment"] = "适应";
dictionary["crispberry"] = "脆莓";
dictionary["kingberry"] = "王莓";
dictionary["clusterberry"] = "簇莓";
dictionary["winterberry"] = "冬青果";
dictionary["prickleberry"] = "刺莓";
dictionary["scorchberry"] = "灼莓";
dictionary["napberry"] = "睡眠莓";
dictionary["berrynana"] = "香蕉莓";
dictionary["coconut"] = "椰子";
dictionary["half"] = "半颗";
dictionary["chubby"] = "胖";
dictionary["cluster"] = "簇生";
dictionary["button"] = "纽扣";
dictionary["shelf"] = "架子";
dictionary["remedy"] = "治疗";
dictionary["fungus"] = "真菌";
dictionary["root"] = "根";
dictionary["aloe"] = "芦荟";
dictionary["vera"] = "芦荟";
dictionary["scorpion"] = "蝎子";
dictionary["Tick"] = "蜱虫";
dictionary["pandora"] = "潘多拉";
dictionary["cure-all"] = "万能药";
dictionary["cure"] = "治愈";
dictionary["all"] = "全";
dictionary["bing"] = "冰";
dictionary["bong"] = "棒";
dictionary["banana"] = "香蕉";
dictionary["pirate"] = "海盗";
dictionary["faerie"] = "精灵";
dictionary["fairy"] = "精灵";
dictionary["heat"] = "热";
dictionary["pack"] = "包";
dictionary["heat pack"] = "暖宝宝";
return dictionary;
}
public static string TranslateItemName(string name)
{
if (string.IsNullOrEmpty(name))
{
return name;
}
if (ItemDict.TryGetValue(name, out var value))
{
return value;
}
string text = name.Trim();
if (text != name && ItemDict.TryGetValue(text, out value))
{
return value;
}
return TranslateByWords(name);
}
private static string TranslateByWords(string name)
{
string[] array = name.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (array.Length == 0)
{
return name;
}
List<string> list = new List<string>();
bool flag = false;
foreach (string text in array)
{
string text2 = text.TrimEnd('.', ',', '!', '?', ':', ';');
string text3 = text.Substring(text2.Length);
if (WordDict.TryGetValue(text2, out var value))
{
list.Add(value + text3);
flag = true;
}
else if (WordDict.TryGetValue(text2.ToLowerInvariant(), out value))
{
list.Add(value + text3);
flag = true;
}
else
{
list.Add(text);
}
}
if (!flag)
{
return name;
}
return string.Join("", list);
}
}