Decompiled source of LaserCycloneTennis v1.0.0

plugins/LaserCycloneTennis/LaserCycloneTennisPlugin.dll

Decompiled 3 hours ago
using System;
using System.Diagnostics;
using System.IO;
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 EntityStates;
using EntityStates.Huntress.HuntressWeapon;
using IL.EntityStates.Huntress.HuntressWeapon;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates.Huntress.HuntressWeapon;
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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LaserCycloneTennisPlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LaserCycloneTennisPlugin")]
[assembly: AssemblyTitle("LaserCycloneTennisPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 LaserCycloneTennis
{
	[BepInPlugin("ShandoIsBad.LaserCycloneTennis", "LaserCycloneTennis", "1.0.0")]
	public class LaserCycloneTennis : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__StockGraceWindow;

			public static hook_FireLaserCyclone <1>__RefundSecondary;
		}

		public const string PluginGUID = "ShandoIsBad.LaserCycloneTennis";

		public const string PluginAuthor = "ShandoVK";

		public const string PluginName = "LaserCycloneTennis";

		public const string PluginVersion = "1.0.0";

		private const int comboCap = 20;

		private static ConfigEntry<bool> uncapCombo;

		public void Awake()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			uncapCombo = ((BaseUnityPlugin)this).Config.Bind<bool>("No Chocolate", "Uncap combo", false, $"If true, removes the {20} combo restriction back to vanilla behavior. Vanilla has no upper limit so this may make the skill quite unbalanced if spammed.");
			object obj = <>O.<0>__StockGraceWindow;
			if (obj == null)
			{
				Manipulator val = StockGraceWindow;
				<>O.<0>__StockGraceWindow = val;
				obj = (object)val;
			}
			CatchCyclone.FixedUpdate += (Manipulator)obj;
			object obj2 = <>O.<1>__RefundSecondary;
			if (obj2 == null)
			{
				hook_FireLaserCyclone val2 = RefundSecondary;
				<>O.<1>__RefundSecondary = val2;
				obj2 = (object)val2;
			}
			ThrowCycloneKickable.FireLaserCyclone += (hook_FireLaserCyclone)obj2;
		}

		private static void StockGraceWindow(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 num = 0;
			while (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<GenericSkill>(x, "get_stock")
			}))
			{
				int index = val.Index;
				val.Index = index + 1;
				val.EmitDelegate<Func<int, int>>((Func<int, int>)((int stock) => Mathf.Max(stock, 1)));
				num++;
			}
		}

		private static void RefundSecondary(orig_FireLaserCyclone orig, ThrowCycloneKickable self)
		{
			GenericSkill val = (Object.op_Implicit((Object)(object)((EntityState)self).skillLocator) ? ((EntityState)self).skillLocator.secondary : null);
			int num = (Object.op_Implicit((Object)(object)val) ? val.stock : 0);
			byte comboCounter = self.comboCounter;
			if (!uncapCombo.Value && comboCounter > 20)
			{
				self.comboCounter = 20;
			}
			orig.Invoke(self);
			self.comboCounter = comboCounter;
			if (((EntityState)self).isAuthority && self.isKick && Object.op_Implicit((Object)(object)val) && val.stock < num)
			{
				val.AddOneStock();
			}
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

		private static string Format(object data, string file, int line)
		{
			string fileName = Path.GetFileName(file);
			return $"[{fileName}:{line}] {data}";
		}

		internal static void Debug(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogDebug((object)Format(data, file, line));
		}

		internal static void Error(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogError((object)Format(data, file, line));
		}

		internal static void Fatal(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogFatal((object)Format(data, file, line));
		}

		internal static void Info(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogInfo((object)Format(data, file, line));
		}

		internal static void Message(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogMessage((object)Format(data, file, line));
		}

		internal static void Warning(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogWarning((object)Format(data, file, line));
		}
	}
}