Decompiled source of ConfigurableSouldboundCatalyst v1.0.0

ConfigurableSoulboundCatalyst.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExamplePlugin;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;

[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("ConfigurableSoulboundCatalyst")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ConfigurableSoulboundCatalyst")]
[assembly: AssemblyTitle("ConfigurableSoulboundCatalyst")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ExamplePlugin
{
	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);
		}
	}
}
namespace SoulboundCatalystBaseBuff
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("VVitchh.SoulboundCatalystBaseBuff", "SoulboundCatalystBaseBuff", "1.0.0")]
	public class ConfigurableSoulboundCatalyst : BaseUnityPlugin
	{
		public const string PluginGUID = "VVitchh.SoulboundCatalystBaseBuff";

		public const string PluginAuthor = "VVitchh";

		public const string PluginName = "SoulboundCatalystBaseBuff";

		public const string PluginVersion = "1.0.0";

		private static ConfigEntry<float> BaseBuffValue;

		public static ConfigEntry<float> ScalingValue { get; set; }

		public void Awake()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Applying IL Hook to oncharacterDeath");
			BaseBuffValue = ((BaseUnityPlugin)this).Config.Bind<float>("Base buff value", "Starting value", 4f, "Starting value for cooldown reduction. The normal calc it runs is 2+2x with x being the number of copies you have, This sets it to 4 so the calc becomes 4+2x, so it still scales by 2 seconds per copy, but starts with 6s cooldown reduction instead of 4");
			ScalingValue = ((BaseUnityPlugin)this).Config.Bind<float>("Scaling value", "scaling value", 2f, "Changes how many seconds reduced per each copy of the item. Default value is 2");
			GlobalEventManager.OnCharacterDeath += new Manipulator(doubleTalismanEffect);
		}

		public static void doubleTalismanEffect(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[5]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdloc(i, 17),
				(Instruction i) => ILPatternMatchingExt.MatchLdcR4(i, 2f),
				(Instruction i) => ILPatternMatchingExt.MatchLdloc(i, 48),
				(Instruction i) => ILPatternMatchingExt.MatchConvR4(i),
				(Instruction i) => ILPatternMatchingExt.MatchLdcR4(i, 2f)
			}))
			{
				int index = val.Index;
				val.Index = index + 1;
				val.Remove();
				val.Emit(OpCodes.Ldc_R4, BaseBuffValue.Value);
				val.Index += 2;
				val.Remove();
				val.Emit(OpCodes.Ldc_R4, ScalingValue.Value);
			}
		}
	}
}