Decompiled source of Good bye Style Go Round v0.0.4

StyleGoRound.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("StyleGoRound")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Idea directly copied from DmC")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1+2787b35e06280b30e0538fc89e1169e3106ddff4")]
[assembly: AssemblyProduct("StyleGoRound")]
[assembly: AssemblyTitle("StyleGoRound")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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;
		}
	}
}
internal static class LogHelper
{
	internal static ManualLogSource log { get; set; }

	public static void LogInfo(object data, [CallerFilePath] string filePath = "")
	{
		ManualLogSource obj = log;
		if (obj != null)
		{
			obj.LogInfo((object)$"[{GetClassName(filePath)}] {data}");
		}
	}

	public static void LogWarning(object data, [CallerFilePath] string filePath = "")
	{
		ManualLogSource obj = log;
		if (obj != null)
		{
			obj.LogWarning((object)$"[{GetClassName(filePath)}] {data}");
		}
	}

	public static void LogError(object data, [CallerFilePath] string filePath = "")
	{
		ManualLogSource obj = log;
		if (obj != null)
		{
			obj.LogError((object)$"[{GetClassName(filePath)}] {data}");
		}
	}

	public static void LogDebug(object data, [CallerFilePath] string filePath = "")
	{
		ManualLogSource obj = log;
		if (obj != null)
		{
			obj.LogDebug((object)$"[{GetClassName(filePath)}] {data}");
		}
	}

	private static string GetClassName(string path)
	{
		return Path.GetFileNameWithoutExtension(path);
	}
}
namespace StyleGoRound
{
	public static class ILHelper
	{
		public static IEnumerable<CodeInstruction> Insert(IEnumerable<CodeInstruction> instructions, ILGenerator il)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, il);
			FieldInfo fieldInfo = AccessTools.Field(typeof(Enemy), "health");
			MethodInfo methodInfo = AccessTools.Method(typeof(GetHurtChecker), "DamageCheck", (Type[])null, (Type[])null);
			while (true)
			{
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((OpCode?)OpCodes.Sub, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Stfld, (object)fieldInfo, (string)null)
				});
				if (val.IsInvalid)
				{
					break;
				}
				Label label = il.DefineLabel();
				val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[5]
				{
					new CodeInstruction(OpCodes.Dup, (object)null),
					new CodeInstruction(OpCodes.Call, (object)methodInfo),
					new CodeInstruction(OpCodes.Brtrue_S, (object)label),
					new CodeInstruction(OpCodes.Pop, (object)null),
					new CodeInstruction(OpCodes.Ldc_R4, (object)0f)
				});
				val.AddLabels((IEnumerable<Label>)new Label[1] { label });
				val.Advance(2);
			}
			return val.InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(Enemy))]
	public static class EnemyPatch
	{
		private static MethodInfo methodChecker = AccessTools.Method(typeof(GetHurtChecker), "DamageCheck", (Type[])null, (Type[])null);

		[HarmonyTranspiler]
		[HarmonyPatch("GetHurt")]
		public static IEnumerable<CodeInstruction> GetHurtTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator il)
		{
			return ILHelper.Insert(instructions, il);
		}

		[HarmonyTranspiler]
		[HarmonyPatch("HandleParrying")]
		public static IEnumerable<CodeInstruction> HandleParryingTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator il)
		{
			return ILHelper.Insert(instructions, il);
		}
	}
	[HarmonyPatch(typeof(EnemyIdentifier))]
	public static class EnemyIdentifierPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Explode")]
		public static bool ExplosionPrefix()
		{
			StackTrace stackTrace = new StackTrace();
			MethodBase method = stackTrace.GetFrame(2).GetMethod();
			string name = method.DeclaringType.Name;
			LogHelper.LogDebug("Explosion triggered by: " + name, "H:\\C#Project\\StyleGoRound\\src\\Patch\\GetHurtPatch.cs");
			if (name == "DeathZone")
			{
				return true;
			}
			if (!GetHurtChecker.IsEnoughRank())
			{
				return false;
			}
			LogHelper.LogDebug("explosion prevented due to low rank.", "H:\\C#Project\\StyleGoRound\\src\\Patch\\GetHurtPatch.cs");
			return true;
		}
	}
	[BepInPlugin("greycsont.ultrakill.StyleGoRound", "StyleGoRound", "0.0.4")]
	[BepInProcess("ULTRAKILL.exe")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony harmony;

		private void Awake()
		{
			LogHelper.log = ((BaseUnityPlugin)this).Logger;
			LoadMainModule();
			LoadOptionalModule();
			PatchHarmony();
			LogHelper.LogInfo("Plugin greycsont.ultrakill.StyleGoRound is loaded!", "H:\\C#Project\\StyleGoRound\\src\\Plugin.cs");
		}

		private void LoadMainModule()
		{
		}

		private void LoadOptionalModule()
		{
		}

		private void PatchHarmony()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			harmony = new Harmony("greycsont.ultrakill.StyleGoRound.harmony");
			harmony.PatchAll();
		}
	}
	internal static class PluginInfo
	{
		public const string PLUGIN_GUID = "greycsont.ultrakill.StyleGoRound";

		public const string PLUGIN_NAME = "StyleGoRound";

		public const string PLUGIN_VERSION = "0.0.4";
	}
	public static class GetHurtChecker
	{
		public static bool IsEnoughRank()
		{
			try
			{
				return MonoSingleton<StyleHUD>.Instance.rankIndex > 3;
			}
			catch (Exception ex)
			{
				LogHelper.LogError("Error checking rank: " + ex.Message, "H:\\C#Project\\StyleGoRound\\src\\RankChecker.cs");
				return true;
			}
		}

		public static bool IsDamageOverLimit(float damage)
		{
			return damage > 500f;
		}

		public static bool DamageCheck(float damage)
		{
			LogHelper.LogInfo($"Enough rank: {IsEnoughRank()}, Damage over limit: {IsDamageOverLimit(damage)}", "H:\\C#Project\\StyleGoRound\\src\\RankChecker.cs");
			return IsEnoughRank() || IsDamageOverLimit(damage);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}