Decompiled source of ThatFrogIHate v1.0.0

BepInEx/plugins/ThatFrogIHate.dll

Decompiled 2 days 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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ThatFrogIHate")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+965ee0e6b4285e94418dd747b37fcb1bf5df4d6a")]
[assembly: AssemblyProduct("ThatFrogIHate")]
[assembly: AssemblyTitle("ThatFrogIHate")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/coderCleric/ThatFrogIHate")]
[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.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace ThatFrogIHate
{
	[HarmonyPatch]
	public static class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(BattleWave), "WaveStarted")]
		public static void KillThatFrog(BattleWave __instance)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.children.Count != 0 && ((Object)__instance.children[0].gameObject).name.Equals("Swamp Shaman"))
			{
				ThatFrogIHatePlugin.DebugLog("Groal detected");
				ThatFrogIHatePlugin.StartKillTimer(__instance.children[0].hm);
			}
		}
	}
	[BepInPlugin("io.github.codercleric.thatfrogihate", "ThatFrogIHate", "1.0.0")]
	public class ThatFrogIHatePlugin : BaseUnityPlugin
	{
		private HealthManager savedManager;

		private GameObject gunInst;

		private float progress = -1f;

		private float killDelay = 10f;

		private float startFadeInDelay = 7f;

		private float startFadeOutDelay = 12f;

		private float fadeDuration = 2f;

		private bool frogShot;

		public const string Id = "io.github.codercleric.thatfrogihate";

		public static ThatFrogIHatePlugin Instance { get; private set; }

		public AssetBundle gunBundle { get; private set; }

		public GameObject gunObj { get; private set; }

		public static string Name => "ThatFrogIHate";

		public static string Version => "1.0.0";

		private void Awake()
		{
			Instance = this;
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "bundles", "groal_gun");
			gunBundle = AssetBundle.LoadFromFile(text);
			gunObj = gunBundle.LoadAsset<GameObject>("Assets/Gun.prefab");
			DebugLog("Bundle loaded");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Let's get that frog!");
		}

		public static void StartKillTimer(HealthManager healthManager)
		{
			if (!(Instance.progress >= 0f))
			{
				DebugLog("Starting the kill timer");
				Instance.progress = 0f;
				Instance.savedManager = healthManager;
				Instance.SpawnGun();
				Instance.frogShot = false;
			}
		}

		private void Update()
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)gunInst == (Object)null)
			{
				progress = -1f;
			}
			if (progress >= 0f)
			{
				progress += Time.deltaTime;
				float num = 0f;
				if (progress >= startFadeInDelay && progress < startFadeOutDelay)
				{
					num = progress - startFadeInDelay;
					num /= fadeDuration;
				}
				else if (progress >= startFadeOutDelay)
				{
					num = progress - startFadeOutDelay;
					num /= fadeDuration;
					num = 1f - num;
				}
				num = Mathf.Clamp01(num);
				((Renderer)gunInst.GetComponent<SpriteRenderer>()).sharedMaterial.color = new Color(1f, 1f, 1f, num);
				if (progress >= killDelay && !frogShot)
				{
					savedManager.ApplyExtraDamage(10000);
					gunInst.GetComponent<AudioSource>().Play();
					frogShot = true;
				}
				if (progress > startFadeOutDelay + fadeDuration + 1f)
				{
					progress = -1f;
				}
			}
		}

		public void SpawnGun()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			gunInst = Object.Instantiate<GameObject>(gunObj);
			gunInst.transform.position = new Vector3(65.6145f, 19.1443f, 0.05f);
			Material material = ((Renderer)((Component)savedManager).GetComponent<MeshRenderer>()).material;
			material.color = new Color(1f, 1f, 1f, 0f);
			((Renderer)gunInst.GetComponent<SpriteRenderer>()).sharedMaterial = material;
		}

		public static void DebugLog(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)msg);
		}
	}
}