using System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using R2API; using RoR2.Skills; using UnityEngine; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace NormalAIPeople.GokuChinesePackage; [BepInPlugin("normalaipeople.goku.chinese.package", "Goku Chinese Package", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class GokuChinesePackagePlugin : 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.goku.chinese.package"; public const string PluginName = "Goku Chinese Package"; public const string PluginVersion = "1.0.0"; private const string TokenPrefix = "NORMALAIPEOPLE_GOKU_"; private readonly HashSet registeredTokens = new HashSet(); private int refreshFrames = 900; private static readonly Dictionary Translations = new Dictionary(StringComparer.Ordinal) { { "Melee Strike", new Translation("近战打击", "以近战连击攻击敌人。激活界王拳时会改为瞬间移动攻击。") }, { "Triple Kick (Legacy)", new Translation("三重踢(旧版)", "连续踢击三次,每次造成伤害并回复气。") }, { "Instant Transmission", new Translation("瞬间移动", "锁定目标后瞬间移动至其附近;没有目标时移动距离受限。") }, { "Ki Charge", new Translation("气力充能", "凝聚气以补充气,并缓解负担以延长界王拳的持续时间。") }, { "Kamehameha", new Translation("龟派气功", "蓄力后释放龟派气功。持续蓄力会消耗更多气并提高伤害。") }, { "Spirit Bomb", new Translation("元气弹", "蓄力后释放元气弹,对范围内敌人造成伤害。蓄力会提高威力并消耗更多气;静止时获得护甲,移动时无法蓄力。") }, { "Angry Kamehameha", new Translation("愤怒龟派气功", "释放愤怒龟派气功,对路径上的敌人造成持续伤害。") }, { "Ki Blast Barrage", new Translation("气弹连射", "释放大量气弹,每发造成伤害。") }, { "Dragon Fist", new Translation("龙拳", "以强力的龙形一击突进并粉碎敌人。") }, { "God Bind", new Translation("神之束缚", "运用赛亚人之神的力量束缚并眩晕敌人。可消耗气延长持续时间。") }, { "Godly Display", new Translation("神之制裁", "快速瞬间移动并打击附近敌人,最后以强力咆哮收尾;攻击次数受攻击速度影响。") }, { "Kamehameha x10", new Translation("十倍龟派气功", "蓄力后释放强力十倍龟派气功。蓄力会提高伤害并消耗更多气。") }, { "Black Kamehameha", new Translation("黑色龟派气功", "蓄力后释放神圣的黑色龟派气功;蓄力会提高伤害并消耗更多气。") }, { "White Dragon Fist", new Translation("白龙拳", "以白龙之力发动强力近战终结一击。") } }; private void Start() { ApplyTranslations(); } private void Update() { if (refreshFrames-- > 0) { ApplyTranslations(); } } private void ApplyTranslations() { SkillDef[] array = Resources.FindObjectsOfTypeAll(); 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_GOKU_" + 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++) { char c = value[i]; array[i] = (char.IsLetterOrDigit(c) ? char.ToUpperInvariant(c) : '_'); } return new string(array); } }