Decompiled source of ItemsRebalanced v0.0.1

plugins/ItemsRebalanced/ItemsRebalanced.dll

Decompiled 4 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 BepInEx.Logging;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ItemsRebalanced")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+755ae00b551178fff70f5cb804d45c7901f22d8e")]
[assembly: AssemblyProduct("ItemsRebalanced")]
[assembly: AssemblyTitle("ItemsRebalanced")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 ItemsRebalanced
{
	public static class DescColors
	{
		public enum Color
		{
			cStack,
			cIsDamage,
			cIsHealth,
			cIsUtility,
			cIsHealing,
			cIsVoid
		}

		public static string Style(this string self, Color style)
		{
			return "<style=" + style.ToString() + ">" + self + "</style>";
		}
	}
	public class DescSetter
	{
		public static string BisonSteakName = "FLATHEALTH";

		public static string StunGrenadeName = "STUNCHANCEONHIT";

		public static void SetDesc()
		{
			string text = "ITEM_";
			string text2 = "_PICKUP";
			string text3 = "_DESC";
			if (ItemsRebalancedConfig.EnableBisonSteakRework.Value == 1)
			{
				string text4 = "While above " + "90% health ".Style(DescColors.Color.cIsHealth) + ", increase " + "movement speed ".Style(DescColors.Color.cIsUtility) + "by " + "28% ".Style(DescColors.Color.cIsUtility) + "(+28% per stack)".Style(DescColors.Color.cStack) + ".";
				LanguageAPI.Add(text + BisonSteakName + text2, text4);
				LanguageAPI.Add(text + BisonSteakName + text3, text4);
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Egglectro.ItemsRebalanced", "ItemsRebalanced", "0.0.1")]
	public class ItemsRebalanced : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<Instruction, bool> <>9__4_1;

			public static Func<Instruction, bool> <>9__4_2;

			public static Func<Instruction, bool> <>9__4_3;

			public static Func<Instruction, bool> <>9__4_4;

			public static Manipulator <>9__4_0;

			internal void <Awake>b__4_0(ILContext il)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				ILCursor val = new ILCursor(il);
				int num3 = default(int);
				int num2 = default(int);
				float num = default(float);
				val.TryGotoNext(new Func<Instruction, bool>[4]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num3),
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num2),
					(Instruction x) => ILPatternMatchingExt.MatchConvR4(x),
					(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num)
				});
				val.Index += 3;
				val.Next.Operand = 0f;
			}

			internal bool <Awake>b__4_1(Instruction x)
			{
				int num = default(int);
				return ILPatternMatchingExt.MatchLdloc(x, ref num);
			}

			internal bool <Awake>b__4_2(Instruction x)
			{
				int num = default(int);
				return ILPatternMatchingExt.MatchLdloc(x, ref num);
			}

			internal bool <Awake>b__4_3(Instruction x)
			{
				return ILPatternMatchingExt.MatchConvR4(x);
			}

			internal bool <Awake>b__4_4(Instruction x)
			{
				float num = default(float);
				return ILPatternMatchingExt.MatchLdcR4(x, ref num);
			}
		}

		public const string PluginGUID = "Egglectro.ItemsRebalanced";

		public const string PluginAuthor = "Egglectro";

		public const string PluginName = "ItemsRebalanced";

		public const string PluginVersion = "0.0.1";

		public void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			ItemsRebalancedConfig.SetUpConfigs((BaseUnityPlugin)(object)this);
			DescSetter.SetDesc();
			HealthComponent.TakeDamage += new hook_TakeDamage(OnTakeDamage);
			HealthComponent.Heal += new hook_Heal(OnCharacterHeal);
			if (ItemsRebalancedConfig.EnableBisonSteakRework.Value != 1)
			{
				return;
			}
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				Manipulator val = delegate(ILContext il)
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Expected O, but got Unknown
					ILCursor val2 = new ILCursor(il);
					int num3 = default(int);
					int num2 = default(int);
					float num = default(float);
					val2.TryGotoNext(new Func<Instruction, bool>[4]
					{
						(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num3),
						(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num2),
						(Instruction x) => ILPatternMatchingExt.MatchConvR4(x),
						(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num)
					});
					val2.Index += 3;
					val2.Next.Operand = 0f;
				};
				<>c.<>9__4_0 = val;
				obj = (object)val;
			}
			CharacterBody.RecalculateStats += (Manipulator)obj;
			CharacterBody.RecalculateStats += new hook_RecalculateStats(ReworkBisonSteak);
		}

		private void OnTakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			orig.Invoke(self, damageInfo);
			if (Object.op_Implicit((Object)(object)self.body))
			{
				self.body.RecalculateStats();
			}
		}

		private float OnCharacterHeal(orig_Heal orig, HealthComponent self, float healAmount, ProcChainMask procChainMask, bool nonRegen)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			float result = orig.Invoke(self, healAmount, procChainMask, nonRegen);
			if (Object.op_Implicit((Object)(object)self.body))
			{
				self.body.RecalculateStats();
			}
			return result;
		}

		private void ReworkBisonSteak(orig_RecalculateStats orig, CharacterBody self)
		{
			orig.Invoke(self);
			if (!NetworkServer.active)
			{
				return;
			}
			if ((Object)(object)self.healthComponent != (Object)null)
			{
				int num = (Object.op_Implicit((Object)(object)self.inventory) ? self.inventory.GetItemCount(Items.FlatHealth) : 0);
				if (num > 0)
				{
					float num2 = self.healthComponent.health / self.healthComponent.fullHealth;
					float num3 = ((num2 >= 0.9f) ? (0.28f * (float)num) : 0f);
					float num4 = self.baseMoveSpeed * num3;
					self.moveSpeed += num4;
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Bison Steak rework activated. Item count: {num}, Percent health: {num2}, MoveSpeed: {self.moveSpeed}");
				}
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"HealthComponent is null, cannot apply Bison Steak rework.");
			}
		}
	}
	public static class ItemsRebalancedConfig
	{
		public static ConfigEntry<int> EnableStunGrenadeRework { get; set; }

		public static ConfigEntry<int> EnableBisonSteakRework { get; set; }

		public static ConfigEntry<int> EnableLeechingSeedRework { get; set; }

		public static ConfigEntry<int> EnableAegisRework { get; set; }

		public static ConfigEntry<int> EnableTitanicKnurlRework { get; set; }

		public static ConfigEntry<int> EnableLostSeersLensesRework { get; set; }

		public static void SetUpConfigs(BaseUnityPlugin plugin)
		{
			CommonConfig(plugin);
		}

		public static void CommonConfig(BaseUnityPlugin plugin)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			EnableBisonSteakRework = plugin.Config.Bind<int>("Bison Steak", "Toggle Rework", 1, new ConfigDescription("[ 0 = Disabled | 1 = Enabled ]", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1), Array.Empty<object>()));
		}

		public static void UncommonConfig(BaseUnityPlugin plugin)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			EnableLeechingSeedRework = plugin.Config.Bind<int>("Leeching Seed", "Toggle Rework", 1, new ConfigDescription("[ 0 = Disabled | 1 = Enabled ]", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1), Array.Empty<object>()));
		}

		public static void LegendaryConfig(BaseUnityPlugin plugin)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			EnableAegisRework = plugin.Config.Bind<int>("Aegis", "Toggle Rework", 1, new ConfigDescription("[ 0 = Disabled | 1 = Enabled ]", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1), Array.Empty<object>()));
		}

		public static void BossConfig(BaseUnityPlugin plugin)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			EnableTitanicKnurlRework = plugin.Config.Bind<int>("TitanicKnurl", "Toggle Rework", 1, new ConfigDescription("[ 0 = Disabled | 1 = Enabled ]", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1), Array.Empty<object>()));
		}

		public static void VoidConfig(BaseUnityPlugin plugin)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			EnableLostSeersLensesRework = plugin.Config.Bind<int>("Lost Seer's Lenses", "Toggle Rework", 1, new ConfigDescription("[ 0 = Disabled | 1 = Enabled ]", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1), Array.Empty<object>()));
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}