Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Trunks Chinese Package v1.1.0
TrunksChinesePackage.dll
Decompiled 3 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using R2API; using RoR2; using RoR2.Skills; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NormalAIPeople.TrunksChinesePackage { [BepInPlugin("normalaipeople.trunks.chinese.package", "Trunks Chinese Package", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class TrunksChinesePackagePlugin : BaseUnityPlugin { private sealed class Translation { public readonly string Name; public readonly string Description; public Translation(string name, string description) { Name = name; Description = description; } } public const string PluginGuid = "normalaipeople.trunks.chinese.package"; public const string PluginName = "Trunks Chinese Package"; public const string PluginVersion = "1.1.0"; private const string TokenPrefix = "NORMALAIPEOPLE_TRUNKS_"; private readonly HashSet<string> registeredTokens = new HashSet<string>(); private bool translationsApplied; private static readonly Dictionary<string, string> UiText = new Dictionary<string, string>(StringComparer.Ordinal) { { "Transformations", "变身" }, { "Transformation", "变身形态" }, { "TRANSFORMATION", "变身形态" }, { "Overview", "概览" }, { "SKILL", "技能" }, { "LOADOUT", "装配" }, { "Power Level: ", "战斗力:" }, { "Total Mastery Levels Required: ", "所需总精通等级:" }, { "Ki Drain: ", "气消耗:" }, { " Per Second", "/秒" }, { "Charge Power: ", "蓄力威力:" }, { "Ultimate Skill", "终极技能" }, { "REMOVE", "移除" }, { "TOGGLE EXTRA", "切换额外形态" }, { "Damage", "伤害" }, { "Armor", "护甲" }, { "Attack Speed", "攻击速度" }, { "Movement Speed", "移动速度" }, { "Base Form", "常态" }, { "Super Saiyan", "超级赛亚人" }, { "Ascended Super Saiyan", "超越超级赛亚人" }, { "Ultra Super Saiyan", "超级赛亚人第三阶" }, { "Super Saiyan 2", "超级赛亚人2" }, { "Super Saiyan 3", "超级赛亚人3" }, { "Super Saiyan God", "超级赛亚人之神" }, { "Super Saiyan God 3", "超级赛亚人之神3" }, { "Super Saiyan Blue", "超级赛亚人蓝" }, { "Super Saiyan Blue 3", "超级赛亚人蓝3" }, { "Super Saiyan Rage", "超级赛亚人之怒" }, { "Kaioken None", "未启用界王拳" }, { "None", "无" }, { "All Forms unlocked", "全部形态已解锁" }, { "Mastered", "已精通" }, { " until next unlock", "后解锁下一形态" }, { " Mastery level", "级精通等级" }, { "Saiyan Blood", "赛亚人血统" }, { "Main Transformation", "主变身" }, { "Power down", "解除变身" }, { "Fly", "飞行" }, { "Jump", "跳跃" }, { "Ki", "气" }, { "All skills have no cooldowns; A ", "所有技能均无冷却时间;改为使用" }, { " resource is used instead!.\nPerform a ", "资源。\n轻按" }, { " (View Transformations Tab for more info).\n", "(更多信息请见“变身”页)。\n" }, { " by tapping ", "以" }, { " by holding ", "以" }, { "Free movement, but does not Auto-Move.", "可自由移动,但不会自动前进。" }, { "\nDash towards a target and rapidly unleash a barrage of sword strikes! \nDealing ", "\n冲向目标并快速施展剑击连段!每一击造成" }, { " for each one!\n", "伤害!\n" }, { "Holding this skill drains ", "按住技能会每秒消耗" }, { "% Ki ", "%气" }, { "per second.", "。" }, { "\nOnce released, unleash an additional energy blast, dealing ", "\n松开后额外释放一道能量波,造成" }, { "\nPerform a series of rapid arm movements, firing a flaming explosive ball of energy! \nExplodes on hit, Dealing ", "\n快速结印并发射燃烧的爆炸能量球!命中时爆炸,造成" }, { "\nVanish at light speed and swiftly strike nearby enemies in front dealing ", "\n以光速消失并迅速攻击前方附近敌人,造成" }, { "Additional Damage is dealt when the same target is hit more than once.", "同一目标被多次命中时会受到额外伤害。" }, { "Duration can be extended at the cost of ", "可消耗" }, { " Ki", "气" }, { " per second!", "每秒以延长持续时间!" }, { "The number of strikes scales off attack speed.", "攻击次数会随攻击速度提高。" }, { "\nQuickly fire a large explosion! \nDamaging all enemies in front, Dealing ", "\n快速发射大型爆炸!对前方所有敌人造成" }, { "\nGenerate immense power to fire an energy wave upwards, dealing ", "\n积蓄庞大能量并向上发射能量波,造成" }, { " per second whilst the blast is active!\nBurn nearby enemies while charging, dealing ", "每秒伤害。蓄力时灼烧附近敌人,造成" }, { " per second!\nConsume additional Ki and increase damage by ", "每秒伤害!消耗额外气,并使伤害每秒提高" }, { " and size per second of charging!\n", "及范围!\n" }, { "Ki consumption gradually increases the longer you charge!", "蓄力越久,气的消耗越高!" }, { "\nUnleash the signature Masenko, Dealing ", "\n释放招牌魔闪光,造成" }, { "\nChannel your Saiyan strength, gaining ", "\n引导赛亚人力量,获得" }, { "% Damage", "%伤害" }, { " and ", "以及" }, { "% Health Regen", "%生命回复" }, { " for ", ",持续" }, { " seconds!", "秒!" }, { "\nWith an unwavering spirit, summon the Sword of Hope\nGranting a bonus ", "\n以坚定意志召唤希望之剑,获得额外" }, { "% Critical Strike Chance", "%暴击率" }, { " while active.\n", ",持续期间生效。\n" }, { "This skill requires ", "此技能需要" }, { "Light Charge ", "光之充能" }, { "to be full and consumes it over time", "充满,并会随时间消耗。" } }; private static readonly Dictionary<string, Translation> Translations = new Dictionary<string, Translation>(StringComparer.Ordinal) { { "Sword Strike", new Translation("剑击", "使用长剑进行近战连击。") }, { "Sword Strike Alternate", new Translation("剑击(替代)", "使用长剑攻击;可自由移动,但不会自动前进。") }, { "Ki Charge", new Translation("气力充能", "凝聚气以补充资源。") }, { "Shining Sword Attack", new Translation("闪耀剑击", "冲向目标并施展快速剑击连段;松开后释放额外能量波。") }, { "Burning Attack", new Translation("燃烧攻击", "快速结印并发射爆炸性火焰能量球。") }, { "Swift Massacre", new Translation("极速屠戮", "高速消失并攻击附近敌人;可消耗气延长持续时间。") }, { "Change The Future", new Translation("改变未来", "快速发射大型爆炸,伤害前方所有敌人。") }, { "Heat Dome Attack", new Translation("热穹攻击", "蓄力后向上发射巨大能量波;蓄力时会灼烧附近敌人。") }, { "Inexperienced Power Up", new Translation("不成熟的强化", "引导赛亚人力量,暂时提高伤害与生命回复。") }, { "Masenko", new Translation("魔闪光", "释放招牌魔闪光,对路径上的敌人造成持续伤害。") }, { "Sword Of Hope", new Translation("希望之剑", "召唤希望之剑,提高伤害和暴击率;需要光之充能充满。") }, { "Saiyan Blood", new Translation("赛亚人血统", "所有技能无冷却时间,改为消耗气;可进行变身、解除变身与飞行。") } }; private void Start() { InstallUiPatches(); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ApplyTranslationsOnce)); } private void OnDestroy() { RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(ApplyTranslationsOnce)); } private void ApplyTranslationsOnce() { if (!translationsApplied) { translationsApplied = true; ApplyTranslations(); } } private void InstallUiPatches() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown Harmony harmony = new Harmony("normalaipeople.trunks.chinese.package"); string[] array = new string[9] { "NS_KingModUtilities.TrainingMenuUI|OnCharacterSelected", "NS_KingModUtilities.UI_TransformationsMenu|OnExtraTransformationButtonClicked", "NS_KingModUtilities.UI_TransformationDisplay|DrawElement", "NS_KingModUtilities.UI_TransformationDisplay|CreateTransformationInfoText", "NS_KingModUtilities.UI_TransformationDisplay|CreateMasteryText", "NS_KingModUtilities.BONUS_STAT_NAMES|ConvertStatNameToDisplayName", "NS_KingModUtilities.TransformationHandler|CheckTransformationsAvailable", "NS_Trunks.TrunksTransformationData|GetTransformationSkillName", "NS_Trunks.TrunksTransformationHandler|OnTransformedFirstTime" }; for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { '|' }); Patch(harmony, array2[0], array2[1]); } array = new string[10] { "TSuperSaiyan", "TAscendedSuperSaiyan", "TUltraSuperSaiyan", "TSuperSaiyan2", "TSuperSaiyan3", "TSuperSaiyanGod", "TSuperSaiyanGod3", "TSuperSaiyanBlue", "TSuperSaiyanBlue3", "TSuperSaiyanRage" }; foreach (string text in array) { Patch(harmony, "NS_KingModUtilities." + text, "InitTransformation"); } } private static void Patch(Harmony harmony, string typeName, string methodName) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown Type type = AccessTools.TypeByName(typeName); if (type == null) { return; } MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name == methodName) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(TrunksChinesePackagePlugin), "LocalizeStringLiterals", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null); } } } private static IEnumerable<CodeInstruction> LocalizeStringLiterals(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldstr && instruction.operand is string && UiText.TryGetValue((string)instruction.operand, out var value)) { instruction.operand = value; } yield return instruction; } } private void ApplyTranslations() { SkillDef[] array = Resources.FindObjectsOfTypeAll<SkillDef>(); foreach (SkillDef val in array) { if (!((Object)(object)val == (Object)null) && !string.IsNullOrEmpty(val.skillName) && Translations.TryGetValue(val.skillName, out var value)) { string text = "NORMALAIPEOPLE_TRUNKS_" + ToTokenSegment(val.skillName); AddToken(text + "_NAME", value.Name); AddToken(text + "_DESCRIPTION", value.Description); val.skillNameToken = text + "_NAME"; val.skillDescriptionToken = text + "_DESCRIPTION"; } } } private void AddToken(string token, string chinese) { if (registeredTokens.Add(token)) { LanguageAPI.Add(token, chinese, "zh-CN"); } } private static string ToTokenSegment(string value) { char[] array = new char[value.Length]; for (int i = 0; i < value.Length; i++) { array[i] = (char.IsLetterOrDigit(value[i]) ? char.ToUpperInvariant(value[i]) : '_'); } return new string(array); } } }