Decompiled source of VoidFiendConciseText v1.0.0

VoidFiendConciseText.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using HarmonyLib;
using RoR2;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace VoidFiendConciseText;

[BepInPlugin("binma.voidfiend.concisetext", "Void Fiend Concise Text", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
	public const string Guid = "binma.voidfiend.concisetext";

	private static readonly HashSet<string> Tokens = new HashSet<string> { "VOIDSURVIVOR_PASSIVE_DESCRIPTION", "VOIDSURVIVOR_SECONDARY_DESCRIPTION", "VOIDSURVIVOR_UTILITY_DESCRIPTION", "VOIDSURVIVOR_UTILITY_UPRADE_TOOLTIP" };

	private static readonly string[][] Replacements = new string[16][]
	{
		new string[2] { "\n\n<style=cIsVoid>Unstable Touch", "\n<style=cIsVoid>Unstable Touch" },
		new string[2] { "\n\n<style=cIsVoid>Transformation Pulse", "\n<style=cIsVoid>Transformation Pulse" },
		new string[2] { "\n\n<style=cIsVoid>Faster Flood", "\n<style=cIsVoid>Faster Flood" },
		new string[2] { "\n\n<style=cIsVoid>Void Follow-through", "\n<style=cIsVoid>Void Follow-through" },
		new string[2] { "<style=cIsVoid>Transformation Pulse</style>", "<style=cIsVoid>Pulse</style>" },
		new string[2] { "<style=cIsVoid>Void Follow-through</style>", "<style=cIsVoid>Follow-through</style>" },
		new string[2] { "Hits have a <style=cIsDamage>", "<style=cIsDamage>" },
		new string[2] { "%</style> chance to inflict <style=cIsVoid>Collapse</style> in normal form, or <style=cIsDamage>", "%</style> chance to <style=cIsVoid>Collapse</style>, <style=cIsDamage>" },
		new string[2] { "%</style> while corrupted. Chance scales with the attack's proc coefficient. Collapse cannot trigger itself.", "%</style> when corrupted." },
		new string[2] { "Entering corrupted mode inflicts <style=cIsVoid>1 Collapse stack</style> on each enemy within <style=cIsUtility>", "Corrupting <style=cIsVoid>Collapses</style> enemies within <style=cIsUtility>" },
		new string[2] { "m</style>. Occurs once per transformation.", "m</style>." },
		new string[2] { "Normal-form Flood charges <style=cIsUtility>", "Charges <style=cIsUtility>" },
		new string[2] { "% faster</style>, in addition to attack speed.", "% faster</style>." },
		new string[2] { "After completing Trespass in either form, your next successful hit within <style=cIsUtility>", "Next hit within <style=cIsUtility>" },
		new string[2] { "s</style> has a <style=cIsDamage>", "s</style>: <style=cIsDamage>" },
		new string[2] { "% chance</style> to inflict <style=cIsVoid>1 Collapse stack</style>. Consumed on success or failure. Requires a positive proc coefficient; chance uses normal luck and is not scaled by that coefficient. Damage-over-time cannot consume it. Refreshes instead of stacking; replaces the passive roll on that hit.", "%</style> chance to <style=cIsVoid>Collapse</style>." }
	};

	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Expected O, but got Unknown
		Harmony val = new Harmony("binma.voidfiend.concisetext");
		MethodInfo methodInfo = AccessTools.Method(typeof(Language), "GetLocalizedStringByToken", new Type[1] { typeof(string) }, (Type[])null);
		HarmonyMethod val2 = new HarmonyMethod(typeof(Plugin), "Postfix", (Type[])null);
		val2.priority = 0;
		HarmonyMethod val3 = val2;
		MethodInfo methodInfo2 = methodInfo;
		val2 = val3;
		val.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	private static void Postfix(string __0, ref string __result)
	{
		if (__result != null && __0 != null && Tokens.Contains(__0))
		{
			string text = __result;
			string[][] replacements = Replacements;
			foreach (string[] array in replacements)
			{
				text = text.Replace(array[0], array[1]);
			}
			__result = text;
		}
	}
}