Decompiled source of LookingGlassTooltipChinese v1.0.0

BepInEx/plugins/LookingGlassTooltipCN/LookingGlassTooltipCN.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace LookingGlassTooltipCN;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("r2cn.lookingglass.tooltipchinese", "LookingGlass Tooltip Chinese", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource LoggerRef;

	private void Awake()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		LoggerRef = ((BaseUnityPlugin)this).Logger;
		try
		{
			Harmony val = new Harmony("r2cn.lookingglass.tooltipchinese");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Loaded. " + Translations.Map.Count + " translations, 2 methods patched."));
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Patch failed: " + ex));
		}
	}

	internal static void Log(string msg)
	{
		if (LoggerRef != null)
		{
			LoggerRef.LogInfo((object)msg);
		}
	}
}
internal static class PluginInfo
{
	public const string GUID = "r2cn.lookingglass.tooltipchinese";

	public const string NAME = "LookingGlass Tooltip Chinese";

	public const string VERSION = "1.0.0";
}
internal static class Translations
{
	public static readonly Dictionary<string, string> Map = new Dictionary<string, string>
	{
		{ "Block Chance: ", "格挡几率:" },
		{ "Max Buffs: ", "最大增益数:" },
		{ "Max Movement Speed: ", "最大移动速度:" },
		{ "Orb Interval: ", "法球间隔:" },
		{ "Bonus Damage: ", "额外伤害:" },
		{ "Skill Charges: ", "技能充能:" },
		{ "Flat Health: ", "固定生命值:" },
		{ "Health Increase as %: ", "生命值提升百分比:" },
		{ "Attack Speed per nearby: ", "每邻近单位攻速:" },
		{ "Max Attack Speed: ", "最大攻击速度:" },
		{ "Max Buff Count: ", "最大增益数量:" },
		{ "Fireworks: ", "烟花:" },
		{ "Proc Coefficient: ", "触发系数:" },
		{ "Healing: ", "治疗:" },
		{ "Radius: ", "半径:" },
		{ "Base Regen: ", "基础再生:" },
		{ "Damage per Kill: ", "每次击杀伤害:" },
		{ "Max Damage Increase: ", "最大伤害提升:" },
		{ "Max Stacks: ", "最大层数:" },
		{ "Sprint Bonus: ", "冲刺加成:" },
		{ "Actual Movement Speed: ", "实际移动速度:" },
		{ "Total Damage: ", "总伤害:" },
		{ "Burn Duration: ", "燃烧持续时间:" },
		{ "Crit Chance: ", "暴击几率:" },
		{ "Attack Speed: ", "攻击速度:" },
		{ "Movement Speed: ", "移动速度:" },
		{ "Bonus Armor: ", "额外护甲:" },
		{ "Shield Strength: ", "护盾强度:" },
		{ "Charges: ", "充能:" },
		{ "Damage Reduction: ", "伤害减免:" },
		{ "Gold Gained: ", "获得金币:" },
		{ "Bomb Chance: ", "炸弹几率:" },
		{ "Explosion Radius: ", "爆炸半径:" },
		{ "Stun Chance: ", "眩晕几率:" },
		{ "Barrier On-Kill: ", "击杀获得护盾:" },
		{ "Bleed Chance: ", "流血几率:" },
		{ "Effect Radius: ", "效果半径:" },
		{ "Damage Instances: ", "伤害次数:" },
		{ "Recharge Time: ", "充能时间:" },
		{ "Barrier per cooldown: ", "每次冷却护盾:" },
		{ "Max Crit Chance & Damage: ", "最大暴击几率与伤害:" },
		{ "Proc Chance: ", "触发几率:" },
		{ "Drop Chance: ", "掉落几率:" },
		{ "Buff Duration: ", "增益持续时间:" },
		{ "Upgrade Chance: ", "升级几率:" },
		{ "Slow Duration: ", "减速持续时间:" },
		{ "Mark Duration: ", "标记持续时间:" },
		{ "Extra Charges: ", "额外充能:" },
		{ "Cooldown Reduction: ", "冷却缩减:" },
		{ "Gold Worth: ", "金币价值:" },
		{ "Healing On-Hit: ", "命中治疗:" },
		{ "Extra Jumps: ", "额外跳跃:" },
		{ "Health On-Kill: ", "击杀回血:" },
		{ "Infusion Cap: ", "注入上限:" },
		{ "Healing Novas: ", "治疗新星:" },
		{ "Max Charges: ", "最大充能:" },
		{ "Secondary Cooldown Reduction: ", "副技能冷却缩减:" },
		{ "Transfer Count: ", "转移次数:" },
		{ "Range: ", "范围:" },
		{ "Threshold: ", "阈值:" },
		{ "Percent Stored per Buff: ", "每层增益存储百分比:" },
		{ "Currently stored: ", "当前存储:" },
		{ "Targets: ", "目标数:" },
		{ "Speed Bonus: ", "速度加成:" },
		{ "Armor: ", "护甲:" },
		{ "2 Items Chance: ", "2件物品几率:" },
		{ "3 Items Chance: ", "3件物品几率:" },
		{ "4 Items Chance: ", "4件物品几率:" },
		{ "5 Items Chance: ", "5件物品几率:" },
		{ "Common Chance: ", "普通品质几率:" },
		{ "Uncommon Chance: ", "稀有品质几率:" },
		{ "Legendary Chance: ", "传奇品质几率:" },
		{ "Damage: ", "伤害:" },
		{ "Max Shurikens: ", "最大手里剑:" },
		{ "Shuriken Cooldown: ", "手里剑冷却:" },
		{ "Max Targets: ", "最大目标数:" },
		{ "Chain Distance: ", "连锁距离:" },
		{ "Max Launch Count: ", "最大发射数:" },
		{ "Max Damage Bonus: ", "最大伤害加成:" },
		{ "Remaining Uses On Stage: ", "本关剩余次数:" },
		{ "Barrier On Activation: ", "激活时护盾:" },
		{ "Jump Boost: ", "跳跃提升:" },
		{ "Pillar Damage: ", "柱伤害:" },
		{ "Explosion Damage: ", "爆炸伤害:" },
		{ "Explosion max Radius: ", "爆炸最大半径:" },
		{ "Shield Explosion Damage: ", "护盾爆炸伤害:" },
		{ "Max Bonus Stats: ", "最大额外属性:" },
		{ "Luck: ", "幸运:" },
		{ "Healing Converted: ", "治疗转化:" },
		{ "Debuffs Ignored: ", "忽略减益:" },
		{ "Random Effects: ", "随机效果:" },
		{ "Frenzy Duration: ", "狂乱持续时间:" },
		{ "Dagger Damage: ", "匕首伤害:" },
		{ "Projectiles Blocked: ", "阻挡弹数:" },
		{ "Cooldown: ", "冷却:" },
		{ "Revives: ", "复活次数:" },
		{ "Max Radius: ", "最大半径:" },
		{ "Spawn Chance: ", "生成几率:" },
		{ "Ghost Duration: ", "幽灵持续时间:" },
		{ "Utility Cooldown Reduction: ", "实用技能冷却缩减:" },
		{ "Healing Radius: ", "治疗半径:" },
		{ "Bonus Crit Damage: ", "额外暴击伤害:" },
		{ "Healing Stored: ", "存储治疗:" },
		{ "Base Damage: ", "基础伤害:" },
		{ "Current Damage: ", "当前伤害:" },
		{ "Bonus Missile Damage: ", "额外导弹伤害:" },
		{ "Bonus Healing: ", "额外治疗:" },
		{ "Piercing Damage: ", "穿透伤害:" },
		{ "Extra Proc Chance: ", "额外触发几率:" },
		{ "Extra Damage: ", "额外伤害:" },
		{ "Hook Chance: ", "钩中几率:" },
		{ "Hook Damage: ", "钩伤害:" },
		{ "Debuff Duration: ", "减益持续时间:" },
		{ "Buildup Duration: ", "积累持续时间:" },
		{ "Large Monster Drop Chance: ", "大型怪物掉落几率:" },
		{ "Elite Drop Chance: ", "精英掉落几率:" },
		{ "Drone Attack Speed & Cooldown Reduction: ", "无人机攻速与冷却缩减:" },
		{ "Armor Reduced On-Hit: ", "命中降低护甲:" },
		{ "Max Health Damage: ", "最大生命伤害:" },
		{ "Max Missiles: ", "最大导弹:" },
		{ "Gold per Extra Missile: ", "每额外导弹金币:" },
		{ "Increased Temporary Item Duration: ", "临时物品持续时间增加:" },
		{ "Friend Bonus Damage: ", "友方额外伤害:" },
		{ "Respawn Cooldown: ", "复活冷却:" },
		{ "Max Infections: ", "最大感染数:" },
		{ "Networked Damage: ", "网络伤害:" },
		{ "Max Constructs: ", "最大构造体:" },
		{ "Damage per Ally: ", "每队友伤害:" },
		{ "Current Damage Bonus: ", "当前伤害加成:" },
		{ "Aurelionite Damage: ", "奥利昂伤害:" },
		{ "Aurelionite Health: ", "奥利昂生命:" },
		{ "All Stats: ", "全属性:" },
		{ "Wisp Damage: ", "鬼火伤害:" },
		{ "Wisp Cooldown: ", "鬼火冷却:" },
		{ "Tethers: ", "链接数:" },
		{ "Health Bonus: ", "生命加成:" },
		{ "Beetle Guards: ", "甲虫守卫:" },
		{ "Explosion Base Damage: ", "爆炸基础伤害:" },
		{ "Explosion Scaling: ", "爆炸成长:" },
		{ "Bonus Health: ", "额外生命:" },
		{ "Extra Equipment: ", "额外装备:" },
		{ "Base Armor Increase: ", "基础护甲提升:" },
		{ "Full Damage: ", "完整伤害:" },
		{ "Stacks Upgraded: ", "升级层数:" },
		{ "Nothings Done: ", "无事发生:" },
		{ "Gold Lost: ", "损失金币:" },
		{ "Healing Cap: ", "治疗上限:" },
		{ "Monster Credits: ", "怪物积分:" },
		{ "Monster Credits Scaled: ", "怪物积分成长:" },
		{ "Orb Cooldown: ", "法球冷却:" },
		{ "Max Orbs: ", "最大法球:" },
		{ "Ruin Duration: ", "废墟持续时间:" },
		{ "Lunar Item Chance: ", "月神物品几率:" },
		{ "Charging Time: ", "充能时间:" },
		{ "Zone Size: ", "区域大小:" },
		{ "Root Duration: ", "定身持续时间:" },
		{ "Attack Speed Multiplier: ", "攻击速度倍率:" },
		{ "Ward Radius: ", "守护半径:" },
		{ "Damage Multiplier: ", "伤害倍率:" },
		{ "Health Multiplier: ", "生命倍率:" },
		{ "Movement Speed Multiplier: ", "移动速度倍率:" },
		{ "Skill Duration: ", "技能持续时间:" },
		{ "Free Unlocks per Level: ", "每级免费解锁:" },
		{ "Cost of next Level: ", "下一级花费:" },
		{ "Increased Gold Price: ", "金币价格增加:" },
		{ "Instakill Chance: ", "秒杀几率:" },
		{ "Special Cooldown Reduction: ", "特殊技能冷却缩减:" },
		{ "Collapse Chance: ", "坍塌几率:" },
		{ "Max Allies: ", "最大队友:" },
		{ "Total Hits: ", "总命中:" },
		{ "Root Chance: ", "定身几率:" },
		{ "Sprint Healing: ", "冲刺治疗:" },
		{ "Damage Lost: ", "伤害损失:" },
		{ "Healing Drunk: ", "醉酒治疗:" },
		{ "Bonus Non-Level Health: ", "非等级额外生命:" },
		{ "Bonus Non-Level Regen: ", "非等级额外再生:" },
		{ "Base Damage Increase: ", "基础伤害提升:" },
		{ "Damage Increase as %: ", "伤害提升百分比:" },
		{ "Total Damage per second: ", "每秒总伤害:" },
		{ "Blight Amount: ", "枯萎量:" },
		{ "Blight Cooldown: ", "枯萎冷却:" },
		{ "Growth Rate: ", "成长率:" },
		{ "Duration: ", "持续时间:" },
		{ "Chance: ", "几率:" },
		{ "Lifesteal: ", "生命偷取:" },
		{ "Max Blades: ", "最大刀刃:" },
		{ "Gold Radius: ", "金币半径:" },
		{ "Bonus Gold: ", "额外金币:" },
		{ "Restoration Chance: ", "恢复几率:" },
		{ "Max Extra Jumps: ", "最大额外跳跃:" },
		{ "Cooldown per Jump: ", "每次跳跃冷却:" },
		{ "Armor at max Jumps: ", "满跳护甲:" },
		{ "Bleed Healing: ", "流血治疗:" },
		{ "Meters per charge: ", "每充能米数:" },
		{ "Max Speed Stacks: ", "最大速度层数:" },
		{ "Spirits: ", "灵魂:" },
		{ "Tendril Damage: ", "触须伤害:" },
		{ "Tendril Radius: ", "触须半径:" },
		{ "Barrier: ", "护盾:" },
		{ "Vision Distance: ", "视野距离:" },
		{ "Curse: ", "诅咒:" },
		{ "Maximum Poltergeists: ", "最大骚灵:" },
		{ "Extra Shrine of the Mountain Stacks: ", "额外山之神殿层数:" },
		{ "Difficulty Increase: ", "难度提升:" },
		{ "Healing Multiplier: ", "治疗倍率:" },
		{ "Mimic Bonus Stats: ", "拟态额外属性:" },
		{ "Stacking Multiplier: ", "叠加倍率:" },
		{ "Debuffs: ", "减益:" },
		{ "Items Disabled: ", "禁用物品:" },
		{ "Items Shared: ", "共享物品:" },
		{ "Acceleration Multiplier: ", "加速倍率:" },
		{ "Restoration Duration: ", "恢复持续时间:" },
		{ "Affliction Chance: ", "折磨几率:" },
		{ "\nWith this item, you will have:", "\n拥有此道具后,你将获得:" },
		{ "\nWith another stack, you will have:", "\n再叠加一层后,你将获得:" }
	};
}
internal static class Patcher
{
	internal static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions)
	{
		int replaced = 0;
		foreach (CodeInstruction ins in instructions)
		{
			if (ins.opcode == OpCodes.Ldstr && ins.operand != null && ins.operand is string key && Translations.Map.ContainsKey(key))
			{
				ins.operand = Translations.Map[key];
				replaced++;
			}
			yield return ins;
		}
		if (replaced > 0)
		{
			Plugin.Log("transpiler replaced " + replaced + " ldstr");
		}
	}
}
[HarmonyPatch]
internal static class PatchRegisterAll
{
	private static MethodBase TargetMethod()
	{
		return AccessTools.Method("LookingGlass.ItemStatsNameSpace.ItemDefinitions:RegisterAll", (Type[])null, (Type[])null);
	}

	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> ins)
	{
		return Patcher.Transpile(ins);
	}
}
[HarmonyPatch]
internal static class PatchGetItemDescription
{
	private static MethodBase TargetMethod()
	{
		return AccessTools.Method("LookingGlass.ItemStatsNameSpace.ItemStats:GetItemDescription", (Type[])null, (Type[])null);
	}

	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> ins)
	{
		return Patcher.Transpile(ins);
	}
}