Decompiled source of Vegeta Chinese Package v1.0.0

VegetaChinesePackage.dll

Decompiled a day ago
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.VegetaChinesePackage;

[BepInPlugin("normalaipeople.vegeta.chinese.package", "Vegeta Chinese Package", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class VegetaChinesePackagePlugin : 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.vegeta.chinese.package";

	public const string PluginName = "Vegeta Chinese Package";

	public const string PluginVersion = "1.0.0";

	private const string TokenPrefix = "NORMALAIPEOPLE_VEGETA_";

	private readonly HashSet<string> registeredTokens = new HashSet<string>();

	private int refreshFrames = 900;

	private static readonly Dictionary<string, Translation> Translations = new Dictionary<string, Translation>(StringComparer.Ordinal)
	{
		{
			"Melee Strike",
			new Translation("近战打击", "以近战连击攻击敌人。")
		},
		{
			"Continuous Energy Blast",
			new Translation("连续能量弹", "凝聚并快速发射气弹,每发造成伤害。按住技能会持续消耗<style=cIsHealing>气</style>。")
		},
		{
			"Rising Sledgehammer",
			new Translation("升龙重锤", "上挑并击飞敌人;按住按钮可接续下砸,将敌人击倒。")
		},
		{
			"Empowered Ki Charge",
			new Translation("强化气力充能", "凝聚<style=cIsHealing>气</style>并获得强化状态。")
		},
		{
			"Galick Gun",
			new Translation("伽力克炮", "蓄力后释放伽力克炮。持续蓄力会消耗更多<style=cIsHealing>气</style>并提高伤害。")
		},
		{
			"Galaxy Breaker",
			new Translation("银河破坏者", "积蓄庞大能量后向上发射能量波。蓄力会提高伤害和范围,并持续消耗<style=cIsHealing>气</style>。")
		},
		{
			"Final Flash",
			new Translation("终极闪光", "蓄力后释放毁灭性的终极闪光,对路径上的敌人造成持续伤害。")
		},
		{
			"Prominence Flash",
			new Translation("闪耀冲击", "蓄力后释放神级闪耀冲击,对路径上的敌人造成持续伤害。")
		},
		{
			"Final Shine Attack",
			new Translation("终极闪光炮", "释放强力终极闪光炮,对路径上的敌人造成持续伤害。")
		}
	};

	private void Start()
	{
		ApplyTranslations();
	}

	private void Update()
	{
		if (refreshFrames-- > 0)
		{
			ApplyTranslations();
		}
	}

	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_VEGETA_" + 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);
	}
}