Decompiled source of HarderSong v1.0.2

HarderSong.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[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("HarderSong")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("HarderSong")]
[assembly: AssemblyTitle("HarderSong")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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.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;
		}
	}
	[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 HarderSong
{
	[BepInPlugin("cuckson.hardersong", "HarderSong", "1.0.1")]
	public class HarderSong : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(HeroController), "BindCompleted")]
		private class Patch_HeroController_BindCompleted
		{
			[CompilerGenerated]
			private sealed class <DelayedDamage>d__1 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <DelayedDamage>d__1(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_0026: Unknown result type (might be due to invalid IL or missing references)
					//IL_0030: Expected O, but got Unknown
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<>2__current = (object)new WaitForSeconds(0.05f);
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						GameManager.instance.hero_ctrl.TakeHealth(1);
						GameManager.instance.hero_ctrl.CancelAttack();
						GameManager.instance.hero_ctrl.RegainControl();
						GameManager.instance.hero_ctrl.StartAnimationControl();
						return false;
					}
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			private static void Postfix()
			{
				if (_currentHealth == GameManager.instance.hero_ctrl.playerData.maxHealth - 3 || _currentHealth == GameManager.instance.hero_ctrl.playerData.CurrentMaxHealth - 3)
				{
					((MonoBehaviour)instance).StartCoroutine(DelayedDamage());
				}
				else if (GameManager.instance.hero_ctrl.playerData.health < GameManager.instance.hero_ctrl.playerData.maxHealth && GameManager.instance.hero_ctrl.playerData.health < GameManager.instance.hero_ctrl.playerData.CurrentMaxHealth)
				{
					((MonoBehaviour)instance).StartCoroutine(DelayedDamage());
				}
			}

			[IteratorStateMachine(typeof(<DelayedDamage>d__1))]
			private static IEnumerator DelayedDamage()
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <DelayedDamage>d__1(0);
			}
		}

		[HarmonyPatch(typeof(PlayerData), "AddHealth")]
		private class Patch_PlayerData_AddHealth
		{
			private static void Prefix()
			{
				_currentHealth = GameManager.instance.hero_ctrl.playerData.health;
			}
		}

		private static HarderSong instance;

		private static int _currentHealth;

		internal static ConfigEntry<int> HealthMult;

		private void Awake()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			instance = this;
			HealthMult = ((BaseUnityPlugin)this).Config.Bind<int>("Extra", "Health Mult", 2, "Multiply Boss Health by amount.");
			Harmony val = new Harmony("cuckson.hardersong");
			val.PatchAll();
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private static IEnumerable<GameObject> GetAllGameObjectsInScene(Scene scene)
		{
			GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
			List<GameObject> list = new List<GameObject>();
			GameObject[] array = rootGameObjects;
			foreach (GameObject val in array)
			{
				list.Add(val);
				list.AddRange(from t in val.GetComponentsInChildren<Transform>(true)
					select ((Component)t).gameObject);
			}
			return list;
		}

		private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			foreach (GameObject item in GetAllGameObjectsInScene(scene))
			{
				if (((Object)item).name.Equals("Boss Scene"))
				{
					BeefyEnemies(scene);
					break;
				}
			}
		}

		private static void BeefyEnemies(Scene scene)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			foreach (GameObject item in GetAllGameObjectsInScene(scene))
			{
				HealthManager component = item.GetComponent<HealthManager>();
				if ((Object)(object)component != (Object)null)
				{
					component.hp *= HealthMult.Value;
				}
			}
		}

		private static void DumpAllHealthManagers()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			HealthManager[] array = Object.FindObjectsOfType<HealthManager>(true);
			ManualLogSource logger = ((BaseUnityPlugin)instance).Logger;
			object arg = array.Length;
			Scene activeScene = SceneManager.GetActiveScene();
			logger.LogInfo((object)$"Found {arg} HealthManager(s) in scene {((Scene)(ref activeScene)).name}");
			HealthManager[] array2 = array;
			foreach (HealthManager val in array2)
			{
				GameObject gameObject = ((Component)val).gameObject;
				((BaseUnityPlugin)instance).Logger.LogInfo((object)$"HealthManager on GameObject: {((Object)gameObject).name}, Position: {gameObject.transform.position}");
			}
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "cuckson.hardersong";

		public const string PLUGIN_NAME = "HarderSong";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}