Decompiled source of MorePearlStats v1.0.1

MoreStatsPlus.dll

Decompiled 19 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using MoreStats;
using R2API;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MoreStatsPlus")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreStatsPlus")]
[assembly: AssemblyTitle("MoreStatsPlus")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MoreStatsPlus;

[BepInPlugin("com.RiskOfBrainrot.MoreStatsPlus", "MoreStatsPlus", "1.0.0")]
public class MSPlusPlugin : BaseUnityPlugin
{
	public const string guid = "com.RiskOfBrainrot.MoreStatsPlus";

	public const string teamName = "RiskOfBrainrot";

	public const string modName = "MoreStatsPlus";

	public const string version = "1.0.0";

	public static ConfigFile CustomConfigFile;

	public static ConfigEntry<bool> enablePearlChanges;

	public static ConfigEntry<bool> enableTonicChanges;

	public static ConfigEntry<bool> enableAfflictionChanges;

	public static PluginInfo PInfo { get; private set; }

	private void Awake()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Expected O, but got Unknown
		CustomConfigFile = new ConfigFile(Paths.ConfigPath + "\\MoreStatsPlus.cfg", true);
		enablePearlChanges = CustomConfigFile.Bind<bool>("MoreStatsPlus", "Enable Pearl Rework", true, "Set to true to use morestats pearl, set to false for vanilla pearl.");
		enableTonicChanges = CustomConfigFile.Bind<bool>("MoreStatsPlus", "Enable Tonic Rework", true, "Set to true to use morestats tonic, set to false for vanilla tonic.");
		enableAfflictionChanges = CustomConfigFile.Bind<bool>("MoreStatsPlus", "Enable Affliction Rework", true, "Set to true to use morestats affliction, set to false for vanilla affliction.");
		StatHooks.GetMoreStatCoefficients += new MoreStatHookEventHandler(MoreAfflictionStats);
		LanguageAPI.Add("EQUIPMENT_TONIC_DESC", "Drink the Tonic, gaining a boost for 20 seconds. Increases <style=cIsDamage>damage</style> by <style=cIsDamage>+100%</style>. Increases <style=cIsDamage>attack speed</style> by <style=cIsDamage>+70%</style>. Increases <style=cIsDamage>armor</style> by <style=cIsDamage>+20</style>. Increases <style=cIsHealing>maximum health</style> by <style=cIsHealing>+50%</style>. Increases <style=cIsHealing>passive health regeneration</style> by <style=cIsHealing>+300%</style>. Increases <style=cIsHealing>healing</style> by <style=cIsHealing>+70%</style>.Increases <style=cIsUtility>movespeed</style> by <style=cIsUtility>+30%</style>.Increases <style=cIsUtility>Luck</style> by <style=cIsUtility>+0.5</style>.Increases <style=cIsUtility>jumps</style> by <style=cIsUtility>1</style>.Reduces <style=cIsUtility>shield regeneration delay</style> by <style=cIsUtility>-2 seconds</style>.Reduces <style=cIsUtility>barrier decay</style> by <style=cIsUtility>-50%</style>.\n\nWhen the Tonic wears off, you have a <style=cIsHealth>20%</style> chance to gain a <style=cIsHealth>Tonic Affliction, reducing all of your stats</style> by <style=cIsHealth>-5%</style> <style=cStack>(-5% per stack)</style>.");
	}

	private void MoreStatsPlusStats(CharacterBody sender, MoreStatHookEventArgs args)
	{
		Inventory inventory = sender.inventory;
		if ((Object)(object)inventory != (Object)null)
		{
			int itemCount = inventory.GetItemCount(Items.ShinyPearl);
			if (itemCount > 0 && enablePearlChanges.Value)
			{
				float num = MathF.Pow(1.1f, itemCount);
				args.luckAdd += 0.1f * (float)itemCount;
				args.healingPercentIncreaseMult *= num;
				args.barrierDecayRatePercentDecreaseDiv *= num;
				args.shieldDelayPercentDecreaseDiv *= num;
			}
			int itemCount2 = inventory.GetItemCount(Items.TonicAffliction);
			if (itemCount2 > 0 && enableAfflictionChanges.Value)
			{
				float num2 = MathF.Pow(0.95f, itemCount2);
				args.luckAdd -= 0.05f * (float)itemCount2;
				args.healingPercentIncreaseMult *= num2;
				args.barrierDecayRatePercentDecreaseDiv *= num2;
				args.shieldDelayPercentDecreaseDiv *= num2;
			}
		}
		if (sender.HasBuff(Buffs.TonicBuff) && enableTonicChanges.Value)
		{
			args.luckAdd += 0.5f;
			args.healingPercentIncreaseMult *= 1.7f;
			args.shieldDelaySecondsIncreaseAddPreMult -= 2f;
			args.barrierDecayRatePercentDecreaseDiv *= 2f;
			args.jumpCountAdd++;
		}
	}

	private void MoreAfflictionStats(CharacterBody sender, MoreStatHookEventArgs args)
	{
		Inventory inventory = sender.inventory;
		if ((Object)(object)inventory != (Object)null)
		{
			int itemCount = inventory.GetItemCount(Items.TonicAffliction);
			if (itemCount > 0)
			{
				float num = MathF.Pow(0.95f, itemCount);
				args.luckAdd -= 0.05f * (float)itemCount;
				args.healingPercentIncreaseMult *= num;
				args.barrierDecayRatePercentDecreaseDiv *= num;
				args.shieldDelayPercentDecreaseDiv *= num;
			}
		}
	}

	private void MoreTonicStats(CharacterBody sender, MoreStatHookEventArgs args)
	{
		if (sender.HasBuff(Buffs.TonicBuff))
		{
			args.luckAdd += 0.5f;
			args.healingPercentIncreaseMult *= 1.7f;
			args.shieldDelaySecondsIncreaseAddPreMult -= 2f;
			args.barrierDecayRatePercentDecreaseDiv += 2f;
			args.jumpCountAdd++;
		}
	}

	private void MorePearlStats(CharacterBody sender, MoreStatHookEventArgs args)
	{
		Inventory inventory = sender.inventory;
		if ((Object)(object)inventory != (Object)null)
		{
			int itemCount = inventory.GetItemCount(Items.ShinyPearl);
			if (itemCount > 0)
			{
				float num = MathF.Pow(1.1f, itemCount);
				args.luckAdd += 0.1f * (float)itemCount;
				args.healingPercentIncreaseMult *= num;
				args.barrierDecayRatePercentDecreaseDiv *= num;
				args.shieldDelayPercentDecreaseDiv *= num;
			}
		}
	}
}